/*
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);
if(substr($line,0,2) != '##'){
@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++;
}
} // end of - if(substr($line,0,2) != '##') -
}
$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);
}
?>
/*
CMSimple version 2.4 beta 5 - January 2005
Small - simple - smart
© 1999-2005 Peter Andreas Harteg - peter@harteg.dk
This program is free software; you can redistribute it and/or modify it under the terms of the Affero General Public License (AGPL) as published by Affero, Inc. version 1. All files in the CMSimple distribution (except other language files than English and Danish) are covered by this license.
IMPORTANT NOTICE: As covered by the AGPL Section 2(d), the "Powered by CMSimple"-link to cmsimple.dk must under no circumstances be removed from pages generated by this program (except in print facility). If you want to remove or hide this link from your pages, you must purchase CMSimple under a commercial license. This also applies testing purposes and setup at an intranet or internal network.
Please be aware, that the AGPL in Section 2(d) requires, that any modified version of the program runned public (ie. on the Internet) must have an additional download facility for the modified version. This also applies to any modification of the template. Therefore you should purchase a commercial license, if you do not want the design of your internet site to fall under the AGPL license.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the AGPL for more details.
A copy of the Affero General Public License is available at http://www.cmsimple.dk/?License/AGPL, if not, write to Affero, Inc., 510 Third Street, Suite 225, San Francisco, CA 94107 USA.
This copyright note must under no circumstances be removed from this file and any distribution of code covered by this license.
For further information about this license and how to purchase a commercial license, please see http://www.cmsimple.dk/?License
For downloads and information about installation, please see http://www.cmsimple.dk
*/
?>