// error_reporting(E_ALL); // ini_set('display_errors', 1); exit; require_once("connect.php"); $id = $_GET["id"]; $pid = $_GET["pid"]; $tid = $_GET["tid"]; if (isset($_POST["ieteikt"])){ // Additional headers $to = $kamemails = $_POST["kamemails"]; $subject = $_POST["kamvards"] . ' - Tavs draugs iesaka ...'; $message = addslashes($_POST["teksts"]); $headers = 'From: editor@ploome.com' . "\r\n" . 'Bcc: editor@ploome.com' . "\r\n"; // Mail it @mail($to, $subject, $message, $headers); //echo "
mail($to, $subject, $message, $headers);";
header ("Location: ". $_POST["cels"]);
}else if (isset($_POST["ierakstiit"])) {
//echo $cels;
$vards = addslashes(strip_tags($_POST["vards"]));
$komentars = addslashes(strip_tags($_POST["komentars"]));
$komentars = str_replace("\r\n","
", $komentars);
$komentars = str_replace("
","
", $komentars);
$id = intval($id);
$skaits = 0;
// parbaudam uz skaitu, lai nav dublikaatu
$ieraksti = mysql_query("SELECT count(*) FROM `komentari` WHERE docid = '$id' and `user` = '$vards' and `comment` = '$komentars'");
if ($ieraksti){
while ($kategorija = mysql_fetch_row($ieraksti)){
$skaits = $kategorija[0];
}
}
$cik = intval($skaits);
// all good, insert in
if ($cik == 0 && strlen($vards) >= 1 and strlen($komentars) >= 10){
$sql = "INSERT INTO `komentari` (`id`, `docid`, `when`, `user`, `comment`) VALUES ('', '$id', NOW(), '$vards', '$komentars');";
mysql_query($sql);
}
echo '';
die();
//header ("Location: ". $_POST["cels"]);
}
else
{
if ($pid != 0){
$code = "";
$code .= "";
echo "document.write ('$code'); ";
}
//echo "function show () { alert(this.document.location); document.write (' $code $code $code '); }";
//$saraksts = komentusaraksts($id);
//echo "function showKomentari () { return '
$saraksts '; }";
echo "function showKomentari () { return ''; }";
echo "function showIesakidraugam() { return '" . iesakidraugam() . "'; }";
}
function komentuskaits($id){
$id = intval($id);
$ieraksti = mysql_query("SELECT count(*) FROM `komentari` WHERE docid = '$id'");
while ($kategorija = mysql_fetch_row($ieraksti)){
$skaits = $kategorija[0];
}
$cik = intval($skaits);
if ($cik == 1 ) { $k = "komentārs"; } else { $k = "komentāri"; }
return "$cik $k";
}
/// funkcija kas sagatavo komentaaru sarakstu JS formaataa
function komentusaraksts($id){
$id = intval($id);
$saraksts = "";
/////////// with charset being set
$ieraksti = mysql_query("SELECT `when`, `user`, `comment` FROM `komentari` WHERE docid = '$id' ORDER by `when`");
while ($kategorija = mysql_fetch_row($ieraksti)){
$laiks = $kategorija[0];
//$laiks = substr($laiks, 0, 4) . "-" . substr($laiks, 4, 2) . "-" . substr($laiks, 6, 2) . " " . substr($laiks, 8, 2) . ":" . substr($laiks, 10, 2);
$saraksts .= "
" . addslashes($kategorija[1]) . " / " . $laiks . "
" . addslashes($kategorija[2]);
}
return $saraksts;
}
/// funkcija kas izveido formu
function iesakidraugam(){
$code = "| Drauga vārds | |
| Drauga epasts | |
| Jūsu teksts | |