http://www.fsf.org/ or write * to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, * MA 02111-1307, USA. * */ // This is to handle external variables (POST, GET, COOKIES) in cmsdam style require ("plugins/guestbook/external.php"); // This is to parse media requests, media serializer will be used!! if (($media != "") && (strlen($media) > 0)) { // A media was requested!! // Clean PHP output buffer to serialize a clean media and not HTML!! // I have to turn off output buffering because of a PHP bug in ob_clean()! ob_end_clean(); // Media serializer!! require ("plugins/mediaserializer/index.php"); $mediaserializer = new CmsDam_MediaSerializer; // Check for requested media in plugins/guestbook! if (file_exists("plugins/guestbook/" . $media)) // Feed the media serializer with the media request and print the result echo $mediaserializer->CmsDam_MediaSerializer_stream("plugins/guestbook/" . $media); // We finished to serialize requested media, so we say to you Good Bye!! exit(); } // END of media parsing // Begin of guestbook $proctime_start = microtime(); # Configuration and functions inclusion ################################################################################################# require ("plugins/guestbook/config.php"); $url_to_start = $cms->sections->section_uri($section, 1); // Guestbook starting address $lang_dir = "plugins/guestbook/languages"; // Language directory $loc_dir = "plugins/guestbook/locations"; // Locations directory $image_dir = $cms->sections->section_uri($section) . "&media=images"; // Image URL, we need MediaSerializer for this! $limit = array($limit_min_words, $limit_max_words); // Message limits require ("plugins/guestbook/functions.php"); if (strstr (getenv('HTTP_USER_AGENT'), 'MSIE')) { $in_field_size = "50"; $text_field_size = "31"; } else { $in_field_size = "30"; $text_field_size = "24"; } # DB Connection ################################################################################################# if (!$cms->dbms->DB_connect()) echo "DEBUG: Guestbook: DB NOT connected"; # Process ################################################################################################# if (($smiliehelp_ != "") && (strlen($smiliehelp_) > 0)) { // Smilies help was requested echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; $cms->dbms->dbquery("SELECT * FROM " . $smilies_tablename) or died("Query error"); while ($db = $cms->dbms->dbfetch_array()) { echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; } $cms->dbms->stack_pop(); echo "
\n"; echo "Codice\n"; echo "
\n"; echo "Nome\n"; echo "
$db[code]
  
$db[name]
\n"; } if ($urlcodehelp_ != "") { // URL code help readfile("plugins/guestbook/urlcodehelp.html"); } if ($action == "submit") { // Add an action if (!$in && !$delid && !$delcommentid && !$commentid) { header("Location: " . $cms->sections->section_uri($section, 1)); exit; } elseif ($delid && $admin == $adminpass) { $query = "DELETE FROM " . $guestbook_tablename ." WHERE id='$delid'"; $cms->dbms->dbquery($query) or died("Query error"); header("Location: " . $cms->sections->section_uri($section, 1) . "&offset=$offset&poffset=$poffset&admin=$admin"); exit; } elseif ($delcommentid && $admin == $adminpass) { $query = "UPDATE " . $guestbook_tablename . " SET comment='' where id='$delcommentid'"; $cms->dbms->dbquery($query) or died("Query error"); header("Location: " . $cms->sections->section_uri($section, 1) . "&offset=$offset&poffset=$poffset&admin=$admin"); exit; } elseif ($commentid && $admin == $adminpass) { //echo "DEBUG: comment: " . $comment; if(isset($comment)) { $action = changed; $query = "UPDATE " . $guestbook_tablename . " SET comment='".encode_msg($comment, $smilies_tablename)."' where id='$commentid'"; $cms->dbms->dbquery($query) or died("Query error"); } else { $action=""; } header("Location: " . $cms->sections->section_uri($section, 1) . "&commentid=$commentid&action=$action&offset=$offset&poffset=$poffset&admin=$admin"); exit; } else { if (isbanned($bannedips_tablename)) { header("Location: " . $cms->sections->section_uri($section, 1)); exit; } $add_date = time(); $cms->dbms->dbquery("SELECT * FROM " . $guestbook_tablename . " WHERE ip='$client_ip' AND timestamp>($add_date-(60*$timelimit))") or died("Query error"); //$result = $cms->dbms->result; $query = $cms->dbms->dbfetch_array(); if ($query) { header("Location: " . $cms->sections->section_uri($section, 1)); exit; } $cms->dbms->stack_pop(); $in = strip_array($in); $in['message'] = encode_msg($in['message'], $smilies_tablename); $in['http'] = str_replace("http://", "", $in['http']); if ($in['name'] == "") { died("
$name_empty
Indietro
"); } if ($in['icq'] != "" && ($in['icq'] < 1000 || $in['icq'] > 999999999)) { died("
$icq_wrong
"); } if(!eregi("^[0-9a-z]([-_.]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\\.[a-z]{2,3}$",$in['email']) && $in['email'] != "") { died("
$non_valid_email
"); } if (strlen($in['message']) < $limit["0"] || strlen($in['message']) > $limit["1"]) { died("
$message_incorrect $limit[0] $and $limit[1] $characters.
Indietro
"); } if ($in['email'] == "") { $in['email'] = "none"; } if ($in['icq'] == "") { $in['icq'] = 0; } if ($in['http'] == "") { $in['http'] = "none"; } if ($in['location'] == "0") { $in['location'] = "none"; } $in['browser'] = $HTTP_USER_AGENT; $cms->dbms->dbquery("INSERT INTO " . $guestbook_tablename . " (name, email, http, icq, message, timestamp, ip, location, browser) VALUES('$in[name]', '$in[email]','$in[http]','$in[icq]','$in[message]','$add_date', '$client_ip','$in[location]','$in[browser]')") or died("Query error"); $cms->dbms->stack_pop(); if ($gb_notify) { @mail("$gb_notify","$gb_notifysubj","$notify_text $in[name]\n\n".censor_msg($in[message], $badwords_tablename),"From: $gb_notify"); } if ($timelimit) { setcookie("cmsdamguestflood","$guestbook_head", time()+(60*$timelimit),"/"); } if ($admin) { $adminlink = "&admin=$admin"; } header("Location: " . $cms->sections->section_uri($section, 1) . $adminlink); exit; } } else { // View messages ##################### # Page body ################################################################################################# echo" \n"; echo" \n"; echo" \n"; echo" \n"; echo" \n"; echo" \n"; echo" \n"; echo"
\n"; echo" \n"; echo" \n"; echo" \n"; echo" \n"; echo"
\n"; if ($action == "add") { echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo "
\n"; echo "
$guestbook_head
\n"; echo "
\n"; echo "
$gb_link1head
\n"; echo "
\n"; echo "
\n"; echo "
\n"; echo " \n"; echo ""; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; if ($location_text) { echo " \n"; } else { echo " \n"; } echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo "
$gbadd_name
$gbadd_location
$gbadd_email
$gbadd_icq
$gbadd_url

"; echo "\n"; echo "
\n"; echo "
\n"; } elseif ($action == "admin" && $admin == $adminpass) { echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo "
\n"; echo "
$guestbook_head
\n"; echo "
\n"; echo " \n"; echo "
\n"; echo " \n"; } elseif ($action == "badwords" && $admin == $adminpass) { echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo "
\n"; echo "
$guestbook_head
\n"; echo "
\n"; echo " \n"; echo "
\n"; $count = 0; // FROM HERE $cms->dbms->dbquery("select * from " . $badwords_tablename) or die("Query error"); echo "
\n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo "
\n"; echo " "; echo " \n"; echo " \n"; echo "
\n"; while ($db = $cms->dbms->dbfetch_array()) { echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo "
\n"; echo "
$db[badword]
"; echo "
\n"; echo " \n"; echo "
\n"; $count++; } $cms->dbms->stack_pop(); echo "

$count $gb_link4stat

\n"; } elseif ($action == "edit_badword" || $action == "new_badword" && $admin == $adminpass) { echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo "
\n"; echo "
$guestbook_head
\n"; echo "
\n"; echo " \n"; echo "
\n"; echo "\n"; if ($action == "edit_badword") { echo "\n"; } else { echo "\n"; } echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "
$gb_link3text
\n"; echo "

\n"; } elseif ($action == "save_edit_badword" && $admin == $adminpass) { $cms->dbms->dbquery("UPDATE " . $badwords_tablename . " SET badword='$newvalue' WHERE badword='$value'") or die("Query error"); $cms->dbms->stack_pop(); echo "\n"; } elseif ($action == "save_new_badword" && $admin == $adminpass) { $cms->dbms->dbquery("INSERT INTO " . $badwords_tablename . " (badword) VALUES('$newvalue')") or die("Query error"); $cms->dbms->stack_pop(); echo "\n"; } elseif ($action == "delete_badword" && $admin == $adminpass) { $cms->dbms->dbquery("DELETE FROM " . $badwords_tablename . " WHERE badword='$value'") or die("Query error"); $cms->dbms->stack_pop(); echo "\n"; } elseif ($action == "banned_ips" && $admin == $adminpass) { echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo "
\n"; echo "
$guestbook_head
\n"; echo "
\n"; echo " \n"; echo "
\n"; $count = 0; $cms->dbms->dbquery("select * from " . $bannedips_tablename) or die("Query error"); echo "
\n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo "
\n"; echo " "; echo " \n"; echo " \n"; echo "
\n"; while ($db = $cms->dbms->dbfetch_array()) { echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo "
\n"; echo "
$db[0]
"; echo "
\n"; echo " \n"; echo "
\n"; $count++; } $cms->dbms->stack_pop(); echo "

$count $gb_link4stat

\n"; } elseif ($action == "edit_banned_ip" || $action == "new_banned_ip") { echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo "
\n"; echo "
$guestbook_head
\n"; echo "
\n"; echo " \n"; echo "
\n"; echo "\n"; if ($action == "edit_banned_ip") { echo "\n"; } else { echo "\n"; } echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "
$gb_link4text
\n"; echo "

\n"; } elseif ($action == "save_edit_banned_ip" && $admin == $adminpass) { $cms->dbms->dbquery("UPDATE " . $bannedips_tablename . " SET banned_ip='$newvalue' WHERE banned_ip='$value'") or die("Query error"); $cms->dbms->stack_pop(); echo "\n"; } elseif ($action == "save_new_banned_ip" && $admin == $adminpass) { $cms->dbms->dbquery("INSERT INTO " . $bannedips_tablename . " (banned_ip) VALUES('$newvalue')") or die("Query error"); $cms->dbms->stack_pop(); echo "\n"; } elseif ($action == "delete_banned_ip" && $admin == $adminpass) { $cms->dbms->dbquery("DELETE FROM " . $bannedips_tablename . " WHERE banned_ip='$value'") or die("Query error"); $cms->dbms->stack_pop(); echo "\n"; } else { if ($admin) { $adminlink="&admin=$admin"; } echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo "
\n"; echo "
$guestbook_head
\n"; echo "
\n"; echo " \n"; echo "
\n"; echo "
\n"; # Begin to visualize ################################################################################################# echo "\n"; echo "\n"; # Number of page calculation ################################################################################################# if (empty($perpage)) $perpage = 1; if (empty($pperpage)) $pperpage = 9; //!!! Solamente 5,7,9,11,13 !!!! if (empty($sort)) $sort = "desc"; if (empty($offset)) $offset = 0; if (empty($poffset)) $poffset = 0; $cms->dbms->dbquery("SELECT count(*) FROM " . $guestbook_tablename); $amount_array = $cms->dbms->dbfetch_array(); $cms->dbms->stack_pop(); $pages = ceil($amount_array["0"] / $perpage); $actpage = ($offset+$perpage)/$perpage; $maxoffset = ($pages-1)*$perpage; $maxpoffset = $pages-$pperpage; $middlepage=($pperpage-1)/2; if ($maxpoffset<0) {$maxpoffset=0;} echo "\n"; echo "
\n"; echo "$gb_desc
\n"; echo "
\n"; if ($pages) { // stampa solo quando pages > 0 echo "$ad_pages\n"; if ($offset) { $noffset = $offset-$perpage; $npoffset = $noffset/$perpage-$middlepage; if ($npoffset<0) { $npoffset=0; } if ($npoffset>$maxpoffset) { $npoffset = $maxpoffset; } echo "[sections->section_uri($section, 1)."&ffset=0&poffset=0$adminlink\"><<] "; echo "[sections->section_uri($section, 1)."&offset=$noffset&poffset=$npoffset$adminlink\"><] "; } for($i = $poffset; $i< $poffset+$pperpage && $i < $pages; $i++) { $noffset = $i * $perpage; $npoffset = $noffset/$perpage-$middlepage; if ($npoffset<0) { $npoffset = 0; } if ($npoffset>$maxpoffset) { $npoffset = $maxpoffset; } $actual = $i + 1; if ($actual == $actpage) { echo "($actual) "; } else { echo "[sections->section_uri($section, 1)."&offset=$noffset&poffset=$npoffset$adminlink\">$actual] "; } } if ($offset+$perpage<$amount_array["0"]) { $noffset=$offset+$perpage; $npoffset = $noffset/$perpage-$middlepage; if ($npoffset<0) { $npoffset=0; } if ($npoffset>$maxpoffset) { $npoffset = $maxpoffset; } echo "[sections->section_uri($section, 1)."&offset=$noffset&poffset=$npoffset$adminlink\">>] "; echo "[sections->section_uri($section, 1)."&offset=$maxoffset&poffset=$maxpoffset$adminlink\">>>] "; } } echo "
\n"; # Start of page ################################################################################################# echo "\n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; # Catch the action ################################################################################################# $cms->dbms->dbquery("SELECT * FROM " . $guestbook_tablename . " ORDER by id $sort LIMIT $offset, $perpage"); while ($db = $cms->dbms->dbfetch_array()) { if ($dateformat=="eu") { $when = strftime("%d.%m.%Y %H:%M", $db["timestamp"]); } else { $when = strftime("%m/%d/%Y %I:%M %p", $db["timestamp"]); } if ($db[email] != "none") { $email = ""; } else { $email = ""; } if ($db[icq]!= 0) { $icq = ""; } else { $icq = ""; } if ($db[http] != "none") { $http = ""; } else { $http = ""; } if ($db[ip] != "none") { if ($admin == $adminpass) { $ip = ""; } else { $ip = ""; } } else { $ip = ""; } if ($db[location] != "none") { $location = "$gb_location
$db[location]
"; } else { $location = "

"; } if ($db[browser] != "") { $browser = ""; } else { $browser = ""; } echo " \n"; echo " \n"; echo " \n \n"; } $cms->dbms->stack_pop(); # End of the page ###################################################################################### echo"
$gb_name$gb_comments
\n"; echo "
$db[name]

\n"; echo "
$location
\n"; echo "
$icq $http $email $ip $browser\n"; echo "

".censor_msg($db[message],$badwords_tablename,($admin==$adminpass))."
\n"; if($commentid == $db[id] && $action != "changed" && $admin == $adminpass) { echo "   \n"; echo ""; echo " \n"; echo " \n"; echo "
\n
"; echo "   sections->section_uri($section, 1)."&smiliehelp_=1\">$smiley_help
\n"; } elseif(!empty($db[comment])) { echo "   
".$gb_modcomment.$db[comment]."
\n"; } echo "
\n"; echo"
\n"; } echo"
\n"; echo"
\n"; echo"
\n"; if ($show_sysinfo) { list($usec, $sec) = explode(" ",$proctime_start); $proctime_start = $usec+$sec; list($usec, $sec) = explode(" ",microtime()); $proctime_end = $usec+$sec; $proctime = $proctime_end-$proctime_start; $cms->dbms->dbquery("SELECT id FROM " . $guestbook_tablename); $countall=$cms->dbms->dbnum_rows(); echo"
Processingtime: ".substr($proctime,0,7)." sec., Entries: $countall, PHP Ver. ".phpversion()."
\n"; } echo"
\n"; } # Closing DB connection ################################################################################################# $cms->dbms->DB_close(); ?>