/*
CMSimple sBlog plugin version 0.1 beta 7
by http://www.nmud.de/
is a substantial modification of the CMSimple Guestbook plugin (gbook version 0.1 beta2)
made by http://www.qualifire.de/cmsimple/.
Since sBlog is made for CMSimple and runs only under CMSimple's environment,
this plugin is subject to the AGPL conditions - like CMSimple itself.
Informations about the AGPL-conditions can be found at http://www.cmsimple.dk/?License.
version 0.1 beta 1 (release: 1.4.2006)
Features:
- display of email and website of visitor with on/off toggle.
- comments in chronological or reverse chronological order.
- simple Captcha function with on/off toggle.
- cleanText function with on/off toggle.
- email notice function.
- control of mandatory fields.
- German and English language packs.
version 0.1 beta 2 (release: 26.4.2006)
Changes:
- comment editor is now placed at the bottom, if comments are shown in chronological order. It is placed at the top, if comments are shown in reverse chronological order.
- The simple Captcha function alerts if a wrong number code has been typed in.
- Addition of French, Norwegian, and Danish language packs.
version 0.1 beta 3 (release: 26.4.2006)
Changes:
- one image per message can be shown by adding an image's web address. Warning: New text file structure!!!
- image max size (width/height) can be adjusted.
- images can be viewed in their original size by clicking on the individual image (like in Michael Svarrer's gallery plugin).
- sBlog is more userfriendly now. Each CSS property is explained what's its job is.
version 0.1 beta 4 (release: 4.5.2006)
Changes:
- new deletion function in the admin modul. Files can be deleted now without contact via FTP. However, the deletion of files is irrevocable; there is no alert function to warn you.
- the CSS div#sblog property bug has been fixed (already done in version 0.1 beta 3 build 8). Depending on choosing the chronology option, it moved around. This is fixed now.
- HTML Tidy alerts have been polished (already done in version 0.1 beta 3 build 8).
- the minmax.js file is only read in, if allow_url_fopen=off and only by IE (due to conditional comment, already done in version 0.1 beta 3 build 8).
- some minor bug fixes (already done in version 0.1 beta 3 build 8).
version 0.1 beta 5 (release: 17.5.2006)
Fix:
- just one important fix has been undertaken. In version 0.1 beta 4, the deletion function worked only in Firefox and other Gecko browsers. It did not run in Internet Explorer. Beta 5 now does. Therefore, this version replaces beta 4.
version 0.1 beta 6 (release: 23.5.2006)
Change:
- an optional record release function has been built in. If it is set to "true" in the configurations, each record adds "##" to its first field. This has to be removed before it is shown in the output file.
version 0.1 beta 6 (release: 12.11.2006)
Change: variable mnu to menu: ready for CMSimple 2.7
*/
function sblog($sblogFile) {
GLOBAL $su, $sl, $plugin_cf, $plugin_tx, $pth, $sbfile, $vartl, $imgpath;
$sbname = isset($_POST['sbname']) ? $_POST['sbname'] : $_GET['sbname'];
$sbemail = isset($_POST['sbemail']) ? $_POST['sbemail'] : $_GET['sbemail'];
$sbwebsite = isset($_POST['sbwebsite']) ? $_POST['sbwebsite'] : $_GET['sbwebsite'];
$sbimage = isset($_POST['sbimage']) ? $_POST['sbimage'] : $_GET['sbimage'];
$sbmessage = isset($_POST['sbmessage']) ? $_POST['sbmessage'] : $_GET['sbmessage'];
$sbcc = $_POST['sbcc'];
$rightnumber =$_POST['rightnumber'];
$plugin=basename(dirname(__FILE__),"/");
$sbfile = $pth['folder']['plugins'].$plugin."/content/".$sblogFile."_".$sl.".txt";
$imgpath = $pth['folder']['plugins']."sblog/";
if(eregi("true",$plugin_cf['sblog']['simpleCaptcha'])){
$rightCaptcha = ($sbcc == $rightnumber);
} else $rightCaptcha = "true";
if($sbname && $sbmessage && ($rightCaptcha == "true")){
$sbname = sb_cleantext($sbname);
// $sbemail = sb_cleantext($sbmail);
$sbwebsite = sb_cleantext($sbwebsite);
$sbimage = sb_cleantext($sbimage);
$sbmessage = str_replace(chr(13).chr(10)," ",$sbmessage);
$sbmessage = str_replace(chr(13)," ",$sbmessage);
$sbmessage = str_replace(chr(10)," ",$sbmessage);
$sbmessage = str_replace(";",",",$sbmessage);
if(eregi("true",$plugin_cf['sblog']['cleanText'])){
$sbmessage = sb_cleantext(stripslashes($sbmessage));
}
if (!$fp = fopen($sbfile, 'a')) {
$tvari.=" ERROR: Cannot open file ($sbfile)";
} else {
if(eregi("true",$plugin_cf['sblog']['record_Release'])){
$sbentry = "\n##" . $sbname .";". $sbemail .";". $sbwebsite .";". date($plugin_cf['sblog']['time_format']) .";". date($plugin_cf['sblog']['date_format']) .";". $sbimage .";". $sbmessage .";". $_SERVER["REMOTE_ADDR"] . ";[END OF RECORD]";
} else {
$sbentry = "\n" . $sbname .";". $sbemail .";". $sbwebsite .";". date($plugin_cf['sblog']['time_format']) .";". date($plugin_cf['sblog']['date_format']) .";". $sbimage .";". $sbmessage .";". $_SERVER["REMOTE_ADDR"] . ";[END OF RECORD]";
}
if ($plugin_cf['sblog']['emailNotice'] !=="") {
////////////////////////////////////////////////////
//Mailer:
//
$kopf = $plugin_tx['sblog']['mail_header']." ".$page;
$page = $_SERVER[QUERY_STRING];
$ipbesucher = $_SERVER['REMOTE_ADDR'];
$nachrichtanmich = "\n\n" . $kopf . " ".$plugin_tx['sblog']['mail_file']." \"".$page."\"\n\n"
."*******************************************************\n"
// ." From: ".$kopf." ".$plugin_tx['sblog']['mail_file']." \"".$page."\"\n\n"
." Text: \n".$sbmessage."\n\n From IP: $ipbesucher \n\n"
."*******************************************************\n"
."";
$webmaster=$plugin_cf['sblog']['emailNoticeTo'];
$header ="FROM:CMSimple sBlog <$webmaster>\n";
$header .="X-Mailer :PHP/" . phpversion()."\n";
$header .="X-Sender-IP: " .$_SERVER['REMOTE_ADDR']. "\n";
$header .="Content-Type: text/plain";
mail ($webmaster, $kopf, $nachrichtanmich, $header);
///////////////////////////////////////////////
}
if (fputs($fp,$sbentry) == FALSE)
$tvari.=" ERROR: Cannot write to file ($sbfile)";
fclose($fp);
header('Location: '.$_SERVER['REQUEST_URI']);exit;
}
}
$tvari .= "
\n"; // first DIV encompasses whole output with editor, closes at the bottom
/////// OUTPUT 1 /////////////////////
if(eregi("true",$plugin_cf['sblog']['chronological_order'])){
if(ini_get('allow_url_fopen') != 1){
$vartl = "\n";
}
sb_commentOutput();
$tvari .= $vartl;
$tvari .= " ";
// $tvari .= "
";
}
///////// End of OUTPUT 1 ////////////////////////
$tvari .= "\n";
$tvari .= "\n";
$tvari .= "
\n"; // closing of first DIV
return $tvari;
}
function sb_cleantext($rawcode){
// This will remove HTML tags, javascript sections
// and white space. It will also convert some
// common HTML entities to their text equivalent
// Clever bits cut and pasted from php_manual_en.html#ref.pcre
$search = 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
$replace = array ("",
"",
"\\1",
"\"",
"&",
"<",
">",
" ",
chr(161),
chr(162),
chr(163),
chr(169),
"chr(\\1)");
$sb_cleantext = preg_replace($search, $replace, $rawcode); // delete ."cleaned" when tested
return $sb_cleantext;
}//end of sb_cleantext
function sb_commentOutput() {
GLOBAL $sbfile, $vartl, $imgpath, $plugin_cf, $newwidth, $newheight, $width, $height;
if(is_file($sbfile)){
$fp = fopen($sbfile, "r");
while (!feof($fp)) {
$line = fgets($fp, 4096);
if(substr($line,0,2) != '##'){
list($sbname,$sbemail,$sbwebsite,$sbtime,$sbdate,$sbimage,$sbmessage,$sbipaddr) = split( ";", $line);
$vartm = "";
if ($sbmessage != '') $vartm .= "\n";
if ($sbmessage != '') $vartm .= "