/*
CMSimple Guestbook plugin
© 2006 - Joachim Barthel - www.qualifire.de/cmsimple/en
---------------------------------------------------------------------
Disclaimer: No warranties at all, use on your own risk !
---------------------------------------------------------------------
Requirements: - CMSimple 2.5 is installed and running.
- The plugin loader from cmsimpleplugins.svarrer.dk
is installed and working !
---------------------------------------------------------------------
Feedback to: jbarthel@qualifire.de
---------------------------------------------------------------------
Version 0.1 beta 0 (23. Feb. 2006)
Version 0.1 beta 1 (26. Feb. 2006)
- Support for multilingual use
- Enhancements of display
- Support of CrLf in message
- Storing of IP address
Version 0.1 beta 2 (14. March 2006)
- No double entries on refresh
- Text-Captcha for spam protections
- Using CSS for displaying the entries
Version 0.1 beta 3 (19. March 2006)
- Display of EMAIL and WEBSITE switchable
- Option for removing HTML and SCRIPT elements
- Full CSS support for colors
- Splitting into pages
Version 0.1 beta 4 (24. March 2006)
- support of french language (thanx to Gerd)
- constant width of name column
- Info-Mail for new entries
- ignores empty lines
Version 0.1 beta 5a (18. April 2006)
- support of apostrophe (' and ")
- checking of mandatory field (incl. white spaces)
- beautified info email
- enhanced Captcha
- thanks email
- switching on/off
- support for php w/o bcmath
Version 0.1 beta 5b (19. April 2006)
- enhanced header() for MS IIS
Version 0.1 beta 5c (20. April 2006)
- display of PHP errors (=white page problem)
Version 0.1 beta 5d (30. April 2006)
- enhanced handling of title field
*/
function gblist() {
GLOBAL $su, $sl, $plugin_cf, $plugin_tx, $pth, $plugin;
$t = "";
if(eregi("true",$plugin_cf['gbook']['captcha'])) {
$gbcc = isset($_POST['gbcc']) ? $_POST['gbcc'] : $_GET['gbcc'];
} else {
$gbcc = CreateTextCaptcha();
}
$gbname = isset($_POST['gbname']) ? $_POST['gbname'] : $_GET['gbname'];
$gbemail = isset($_POST['gbemail']) ? $_POST['gbemail'] : $_GET['gbemail'];
$gbwebsite = isset($_POST['gbwebsite']) ? $_POST['gbwebsite'] : $_GET['gbwebsite'];
$gbtitle = isset($_POST['gbtitle']) ? $_POST['gbtitle'] : $_GET['gbtitle'];
$gbmessage = isset($_POST['gbmessage']) ? $_POST['gbmessage'] : $_GET['gbmessage'];
$gbpage = isset($_POST['page']) ? $_POST['page'] : $_GET['page'];
error_reporting(E_ALL);
$plugin = basename(dirname(__FILE__),"/");
$gbfile = $pth['folder']['plugins'].$plugin."/content/guestbook_".$sl.".txt";
$imgpath = $pth['folder']['plugins']."gbook/";
if($gbname && $gbmessage) {
if ($gbcc == CreateTextCaptcha()) {
$gbwebsite = eregi_replace("http://","",$gbwebsite);
$gbname = RemoveHtml($gbname);
$gbemail = RemoveHtml($gbemail);
$gbwebsite = RemoveHtml($gbwebsite);
$gbtitle = str_replace(";",",", $gbtitle);
$gbtitle = RemoveHtml($gbtitle);
if(eregi("true",$plugin_cf['gbook']['remove_html'])) {
$gbmessage = RemoveHtml($gbmessage);
}
$gbmessage = str_replace(chr(13).chr(10),"
",$gbmessage);
$gbmessage = str_replace(chr(13),"
",$gbmessage);
$gbmessage = str_replace(chr(10),"
",$gbmessage);
$gbmessage = str_replace(";",",",$gbmessage);
if (!$fp = fopen($gbfile, 'a')) {
$t .= "
\n";
$t .= "\n";
if(eregi("true",$plugin_cf['gbook']['new_entries'])) {
$t .= "
";
} else {
$t .= $plugin_tx['gbook']['txt_offline_hint'];
}
if (file_exists($pth['folder']['plugins']."sfilter/index.php")){
// $t .= "
--- SFilter installed ---
";
}
$t .= "
";
$t .= "";
$t .= "
";
$t .= "
";
if(is_file($gbfile)){
$fp = fopen($gbfile, "r");
$tl = "";
$lineCount = 0;
$gbNameArray = array();
$gbEmailArray = array();
$gbWebsiteArray = array();
$gbTimeArray = array();
$gbDateArray = array();
$gbTitleArray = array();
$gbMessageArray = array();
$gbIpaddrArray = array();
$asrctxt = array (chr(92).chr(34),
chr(92).chr(39),
chr(10).chr(13),
chr(13),
chr(10));
$areptxt = array (chr(34),
chr(39),
"",
"",
"");
while (!feof($fp)) {
$line = fgets($fp, 4096);
@list($gbname,$gbemail,$gbwebsite,$gbtime,$gbdate,$gbtitle,$gbmessage,$gbipaddr) = split(";", $line);
if (($gbtitle=="") && ($gbmessage=="")) {
} else {
array_push($gbNameArray, str_replace($asrctxt, $areptxt, $gbname));
array_push($gbEmailArray, str_replace($asrctxt, $areptxt, $gbemail));
array_push($gbWebsiteArray, $gbwebsite);
array_push($gbTimeArray, $gbtime);
array_push($gbDateArray, $gbdate);
array_push($gbTitleArray, str_replace($asrctxt, $areptxt, $gbtitle));
array_push($gbMessageArray, str_replace($asrctxt, $areptxt, $gbmessage));
array_push($gbIpaddrArray, str_replace($asrctxt, $areptxt, $gbipaddr));
$lineCount++;
}
}
$lineCount--;
fclose($fp);
}
$startNum = $lineCount - intval($gbpage) * intval($plugin_cf['gbook']['items_per_page']);
$endNum = $startNum - intval($plugin_cf['gbook']['items_per_page']) + 1.0;
if ($endNum < 0) $endNum = 0;
for ($i = $startNum; $i >= $endNum; $i--) {
if (myModulo($i,2) == 0) {
$lineClass = "gblightline";
} else {
$lineClass = "gbdarkline";
}
$tm = "";
$tm .= "
";
$tm .= "
";
$tl .= $tm;
}
$t .= $tl;
$lineCount++;
$maxPages = myDiv($lineCount, intval($plugin_cf['gbook']['items_per_page']));
if (myModulo($lineCount, intval($plugin_cf['gbook']['items_per_page'])) > 0) $maxPages++;
$t .= "
";
$t .= "
";
$t .= "
Guestbook-plugin by QualiFIRE";
$t .= "
";
$t .= "
";
$t .= "\n\n";
return $t;
}
function CreateTextCaptcha() {
$t = "";
$gbLastIP = $_SERVER["REMOTE_ADDR"];
$gbLastIP = intval(substr($gbLastIP,strrpos($gbLastIP,".")+1));
$t .= MakeCaptChar(date("d")*$gbLastIP);
$t .= MakeCaptChar(date("m")*$gbLastIP);
$t .= MakeCaptChar(date("z")*$gbLastIP);
$t .= MakeCaptChar((date("w")+11)*$gbLastIP);
$t .= MakeCaptChar(date("W")*$gbLastIP);
$t .= MakeCaptChar($gbLastIP);
return $t;
}
function MakeCaptChar($nVal){
$nSmlVal = myModulo($nVal,35);
if ($nSmlVal <= 10) {
// 1..10 = 0..9
$cchar = chr($nSmlVal+47);
} else {
// 11..35 = A..Z
$cchar = chr($nSmlVal+54);
}
return $cchar;
}
function myModulo($vop, $vmod) {
$nVal = $vop - floor($vop/$vmod)*$vmod;
return $nVal;
}
function myDiv($vop, $vmod) {
$nVal = floor($vop/$vmod);
return $nVal;
}
function RemoveHtml($cText) {
$asrctxt = array ("''si", // Strip out javascript
"'<[\/\!]*?[^<>]*?>'si", // Strip out HTML tags
"'([\r\n])[\s]+'", // Strip out white space
"'&(quot|#34);'i", // Replace HTML entities
"'&(amp|#38);'i",
"'&(lt|#60);'i",
"'&(gt|#62);'i",
"'&(nbsp|#160);'i",
"'&(iexcl|#161);'i",
"'&(cent|#162);'i",
"'&(pound|#163);'i",
"'&(copy|#169);'i",
"'(\d+);'e"); // evaluate as php
$areptxt = array ("",
"",
"\\1",
"\"",
"&",
"<",
">",
" ",
chr(161),
chr(162),
chr(163),
chr(169),
"chr(\\1)");
return preg_replace($asrctxt, $areptxt, $cText);
}
?>