Autor Zpráva
NS
Profil *
Zdravím, potreboval by som pomôcť so stránkovaním tohto pluginu(scriptu) .
Script už má nejaké tie roky, bohužiaľ kolega sa o webstránku nestaral už nejaký ten rok, čiže žiadne aktualizácie, úpravy a podobné veci neboli robené najmenej rok.
Script funguje veľmi jednoducho, komentáre sa zapisujú do txt súborov ktoré sa nachádzajú v zložke content. Má napr stránku technológie a tam php kód, ktorý zobrazí komentáre zo súboru technologie.txt atď. atď ..

Požiadal ma, či by som mu stým stránkovaním nemohol pomôcť, ale vôbec neviem ako začať v tomto guláši :)

Hlavná časť Scriptu index.php
<?


function commentss($commentssFile) {

GLOBAL $su, $sl, $plugin_cf, $plugin_tx, $pth, $gbfile, $vartl, $imgpath;
$gbname = isset($_POST['gbname']) ? $_POST['gbname'] : $_GET['gbname'];
$gbemail = isset($_POST['gbemail']) ? $_POST['gbemail'] : $_GET['gbemail'];
$gbwebsite = isset($_POST['gbwebsite']) ? $_POST['gbwebsite'] : $_GET['gbwebsite'];
$gbimage = isset($_POST['gbimage']) ? $_POST['gbimage'] : $_GET['gbimage'];
$gbmessage = isset($_POST['gbmessage']) ? $_POST['gbmessage'] : $_GET['gbmessage'];
$gbcc = $_POST['gbcc'];
$rightnumber =$_POST['rightnumber'];
$plugin=basename(dirname(__FILE__),"/");
$gbfile = $pth['folder']['plugins'].$plugin."/content/".$commentssFile."_".$sl.".txt";
$imgpath = $pth['folder']['plugins']."commentss/";
if(eregi("true",$plugin_cf['commentss']['simpleCaptcha'])){
$rightCaptcha = ($gbcc == $rightnumber);
} else $rightCaptcha = "true";

$gbname = gb_cleantext($gbname);
// $gbemail = gb_cleantext($gbmail);
$gbwebsite = gb_cleantext($gbwebsite);
$gbimage = gb_cleantext($gbimage);
$gbmessage = str_replace(chr(13).chr(10),"<br />",$gbmessage);
$gbmessage = str_replace(chr(13),"<br />",$gbmessage);
$gbmessage = str_replace(chr(10),"<br />",$gbmessage);
$gbmessage = str_replace(";",",",$gbmessage);

if(eregi("true",$plugin_cf['commentss']['cleanText'])){
$gbmessage = gb_cleantext(stripslashes($gbmessage));
}
if (!$fp = fopen($gbfile, 'a')) {
$tvari.="<br />ERROR: Cannot open file ($gbfile)";
} else {
if(eregi("true",$plugin_cf['commentss']['record_Release'])){
$gbentry = "\n##" . $gbname .";". $gbemail .";". $gbwebsite .";". date($plugin_cf['commentss']['time_format']) .";". date($plugin_cf['commentss']['date_format']) .";". $gbimage .";". $gbmessage .";". $_SERVER["REMOTE_ADDR"] . ";[END OF RECORD]";
} else {
$gbentry = "\n" . $gbname .";". $gbemail .";". $gbwebsite .";". date($plugin_cf['commentss']['time_format']) .";". date($plugin_cf['commentss']['date_format']) .";". $gbimage .";". $gbmessage .";". $_SERVER["REMOTE_ADDR"] . ";[END OF RECORD]";
}


if ($plugin_cf['commentss']['emailNotice'] !=="") {
////////////////////////////////////////////////////
//Mailer:
//
$kopf = $plugin_tx['commentss']['mail_header']." ".$page;
$page = $_SERVER[QUERY_STRING];
$ipbesucher = $_SERVER['REMOTE_ADDR'];
$nachrichtanmich = "\n\n" . $kopf . " ".$plugin_tx['commentss']['mail_file']." \"".$page."\"\n\n"
."*******************************************************\n"
// ." From: ".$kopf." ".$plugin_tx['commentss']['mail_file']." \"".$page."\"\n\n"
." Text: \n".$gbmessage."\n\n From IP: $ipbesucher \n\n"
."*******************************************************\n"
."";
$webmaster=$plugin_cf['commentss']['emailNoticeTo'];
$header ="FROM:CMSimple commentss <$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,$gbentry) == FALSE)
$tvari.="<br />ERROR: Cannot write to file ($gbfile)";
fclose($fp);

header('Location: '.$_SERVER['REQUEST_URI']);exit;
}
}

$tvari .= "<div id=\"commentss\">\n"; // first DIV encompasses whole output with editor, closes at the bottom

/////// OUTPUT 1 /////////////////////

if(eregi("true",$plugin_cf['commentss']['chronological_order'])){
if(ini_get('allow_url_fopen') != 1){
$vartl = "<!--[if IE]><script type=\"text/javascript\" src=\"./plugins/commentss/minmax.js\"></script><![endif]-->\n";
}
gb_commentOutput();
$tvari .= stripslashes($vartl);
$tvari .= "<br />";
// $tvari .= "<p>&nbsp;</p>";
}
///////// End of OUTPUT 1 ////////////////////////
$tvari .= "<br><br><br>";
$tvari .= "<script language = \"JavaScript\" type= \"text/javascript\">\n";
$tvari .= "function commentss_pic_fullsize(PIC_URL, width, height){\n";
$tvari .= "popup_options=\"toolbar=0,scrollbars=0,location=0,statugbar=0,menubar=0,resizable=0\";\n";
$tvari .= "gallery_popup=window.open(\"\", \"\", popup_options + \",width=\" + width + \",height=\" + height);\n";
$tvari .= "gallery_popup.focus();gallery_popup.document.open();\n";
$tvari .= "with(gallery_popup){\n";
$tvari .= "document.write(\"<html><head>\");\n";
$tvari .= "document.write(\"<title>Picture popup<\/title>\");\n";
$tvari .= "document.write(\"<\/head>\");\n";
$tvari .= "document.write(\"<body leftmargin=\\\"0\\\" marginheight=\\\"0\\\" marginwidth=\\\"0\\\" topmargin=\\\"0\\\">\");\n";
$tvari .= "document.write(\"<img border=\\\"0\\\" onclick=\\\"window.close();\\\" src=\\\"\"+ PIC_URL +\"\\\" title=\\\"Close by clicking / Schließen\\\" alt=\\\"Close by clicking / Schließen\\\" />\");\n";
$tvari .= "document.write(\"<\/body><\/html>\");}}\n";
$tvari .="function checkFormField(){\n";
if(eregi("true",$plugin_cf['commentss']['simpleCaptcha'])){
$gbrandom=rand(100000,999999);
$tvari .= "if(document.simpleBlog.gbcc.value == \"\") {alert(\"".$plugin_tx['commentss']['mustwritecaptcha']."\");document.simpleBlog.gbcc.focus();document.simpleBlog.gbcc.style.border='1px solid Red';return false;}\n";
$tvari .= "if(document.simpleBlog.gbcc.value != \"".$gbrandom."\") {alert(\"".$plugin_tx['commentss']['wrongcaptcha']."\");document.simpleBlog.gbcc.focus();document.simpleBlog.gbcc.style.border='1px solid Red';return false;}\n";
}
$tvari .= "if(document.simpleBlog.gbname.value == \"\") {alert(\"".$plugin_tx['commentss']['mustwritename']."\");document.simpleBlog.gbname.focus();document.simpleBlog.gbname.style.border='1px solid Red';return false;}\n";
$tvari .= "if(document.simpleBlog.gbmessage.value == \"\") {alert(\"".$plugin_tx['commentss']['mustwritemes']."\");document.simpleBlog.gbmessage.focus();document.simpleBlog.gbmessage.style.border='1px solid Red';return false;}\n";
if(eregi("true",$plugin_cf['commentss']['record_Release'])) {
$tvari .= "alert(\"".
NS
Profil *
Pokračovanie ....
if(eregi("true",$plugin_cf['commentss']['record_Release'])) {

$tvari .= "alert(\"".$plugin_tx['commentss']['record_release']."\")\n";
}
$tvari .="}\n";
$tvari .= "</script>\n";
$tvari .= "<script language = \"JavaScript\" type= \"text/javascript\">\n";
$tvari .= "function showDetail(iNum)\n";
$tvari .= "{\n";
$tvari .= "var IDName;\n";
$tvari .= "IDdetail = 'detail' + iNum;\n";
$tvari .= "IDnewMessage = 'newMessage' + iNum;\n";
$tvari .= "if (document.getElementById(IDdetail).style.display.indexOf('block') == -1) {\n";
$tvari .= "document.getElementById(IDdetail).style.display = \"block\";\n";
$tvari .= "document.getElementById(IDnewMessage).style.display = \"none\";\n";
$tvari .= "} else {\n";
$tvari .= "document.getElementById(IDdetail).style.display = \"none\";\n";
$tvari .= "document.getElementById(IDnewMessage).style.display = \"block\";\n";
$tvari .= "}\n";
$tvari .= "}\n";
$tvari .= "</script>\n";
$tvari .= "<div id=\"editor\"><div id=\"newMessage1\"><a href=\"javascript:showDetail(1)\">".$plugin_tx['commentss']['txt_newentry'] . "</a><span id=\"noJavascript\"><noscript>" . $plugin_tx['commentss']['txt_nojscript'] . "</noscript></span></div>\n";
$tvari .= "<div id=\"detail1\" style=\"display: none;\">\n";
$tvari .= "<form name=\"simpleBlog\" method=\"post\" action=\"?".$su."\" onSubmit=\"return checkFormField()\">\n";
if(eregi("true",$plugin_cf['commentss']['simpleCaptcha'])){
$tvari.=$plugin_tx['commentss']['txt_simpleCaptcha'].":<span class=\"star\">*</span>&nbsp;".$gbrandom."<br /><input type=\"text\" name =\"gbcc\" size=\"7\" maxlength=\"6\" /><br />\n";
$tvari.="<input type=\"hidden\" name=\"rightnumber\" value=\"".$gbrandom."\" />\n";
}
$tvari .= $plugin_tx['commentss']['txt_name'] . "<span class='star'>*</span>:<br />" . "<input name=\"gbname\" type=\"text\" size=\"40\" maxlength=\"80\" /><br />\n";
if(eregi("true",$plugin_cf['commentss']['email'])){
$tvari .= $plugin_tx['commentss']['txt_email'] . ":<br />" . "<input name=\"gbemail\" type=\"text\" size=\"40\" maxlength=\"80\" /><br />\n";}
if(eregi("true",$plugin_cf['commentss']['website'])){
$tvari .= $plugin_tx['commentss']['txt_website'] . ":<br />" . "<input name=\"gbwebsite\" type=\"text\" size=\"40\" maxlength=\"80\" />&nbsp;<br />\n";}
if(eregi("true",$plugin_cf['commentss']['image'])){
$tvari .= $plugin_tx['commentss']['txt_image'] . ":<br />" . "<input name=\"gbimage\" type=\"text\" size=\"40\" />&nbsp;<br /><div class=\"gbSmallText\">(e.g. www.myWebSite.com/images/myImage.jpg)</div>\n";}
$tvari .= $plugin_tx['commentss']['txt_message'] . "<span class='star'>*</span>:<br />" . "<textarea rows=\"6\" cols=\"40\" name=\"gbmessage\"></textarea><br />\n";
$tvari .= "<span class='star'>*&nbsp;</span>" . $plugin_tx['commentss']['txt_required'] . "<br />&nbsp;<br />\n";
$tvari .= "<div id=\"inputsubmit\"><input type=\"submit\" value=\" " . $plugin_tx['commentss']['txt_submit'] . " \" />&nbsp;<input type=\"reset\" value=\" " . $plugin_tx['commentss']['txt_clear'] . " \" />&nbsp;<input type=\"button\" value=\" " . $plugin_tx['commentss']['hide_editor'] . "\" name=\"hide\" onClick=\"javascript:showDetail(1)\" /></div>\n";
$tvari .= "</form>\n";
$tvari .= "<br /></div></div>\n";
// $tvari .= "&nbsp;<br />\n";

/////// OUTPUT 2 /////////////////////
if(!eregi("true",$plugin_cf['commentss']['chronological_order'])){
if(ini_get('allow_url_fopen') != 1){

$vartIE = "<!--[if IE]><script type=\"text/javascript\" src=\"./plugins/commentss/minmax.js\"></script><![endif]-->\n";
$tvari .= $vartIE;
}
gb_commentOutput();
$tvari .= stripslashes($vartl);
}
///////// End of OUTPUT 2 ////////////////////////
$tvari .= "</div>\n"; // closing of first DIV

return $tvari;
}

function gb_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 ("'<script[^>]*?>.*?</script>'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)");

$gb_cleantext = preg_replace($search, $replace, $rawcode); // delete ."cleaned" when tested
return $gb_cleantext;
}//end of gb_cleantext

function gb_commentOutput() {
GLOBAL $gbfile, $vartl, $imgpath, $plugin_cf, $newwidth, $newheight, $width, $height;
if(is_file($gbfile)){
$fp = fopen($gbfile, "r");
while (!feof($fp)) {
$line = fgets($fp, 4096);
if(substr($line,0,2) != '##'){
list($gbname,$gbemail,$gbwebsite,$gbtime,$gbdate,$gbimage,$gbmessage,$gbipaddr) = split( ";", $line);

$vartm = "";
if ($gbmessage != '') $vartm .= "<hr />\n";
if ($gbmessage != '') $vartm .= "<div class=\"commentssTable\"><table class=\"commentssTable\">\n";
if ($gbmessage != '') $vartm .= "<tr>\n";
if ($gbname == 'Admin') {
$cssclass = 'red';
} else {
$cssclass = 'norm';
}
if (gbmessage != '') $vartm .= "<td class=\"nameBackground\" valign=\"top\"><span class=\"gbname $cssclass\">" . $gbname . "</span>&nbsp;&nbsp;";
if ($gbmessage != '') $vartm .= "<span class=\"gbdatetime\">" . $gbdate . ", " . $gbtime . "</span>&nbsp;|&nbsp;<span class=\"pics\">\n";
if ($gbemail != '') $vartm .= "<a href=\"mailto:" . $gbemail . "\"><img class=\"spic1\" src=\"".$imgpath."./images/email.gif\" border=\"0\" title=\"" . $gbemail . "\" alt=\"" . $gb
NS
Profil *
if (gbmessage != '') $vartm .= "<td class=\"nameBackground\" valign=\"top\"><span class=\"gbname $cssclass\">" . $gbname . "</span>&nbsp;&nbsp;";
			  if ($gbmessage != '') $vartm .= "<span class=\"gbdatetime\">" . $gbdate . ", " . $gbtime . "</span>&nbsp;|&nbsp;<span class=\"pics\">\n";
			  if ($gbemail != '') $vartm .= "<a href=\"mailto:" . $gbemail . "\"><img class=\"spic1\" src=\"".$imgpath."./images/email.gif\" border=\"0\" title=\"" . $gbemail . "\" alt=\"" . $gbemail . "\" /></a>&nbsp;\n";
			  if ($gbwebsite != '') $vartm .= "<a href=\"http://" . $gbwebsite . "\" target=\"_blank\"><img class=\"spic2\" src=\"".$imgpath."./images/website.gif\" border=\"0\" title=\"" . $gbwebsite . "\"  alt=\"" . $gbwebsite . "\" /></a>&nbsp;\n";
			  if ($gbmessage != '') $vartm .= "</span></td></tr>\n";
			  if ($gbimage != ''){
				  makeImg($gbimage);
				  if(ini_get("allow_url_fopen") == 1) {
	//			  if ($newwidth != "" || $newheight != ""){
					  if (eregi("http://", $gbimage)){
					  $vartm .= "<tr><td class=\"imageBackground\" valign=\"top\">
					  <a href=\"javascript:commentss_pic_fullsize('" . $gbimage ."','".$width."','".$height."')\"><img class=\"commentssImage\" src=\"" . $gbimage . "\" width=\"" . $newwidth .  "\" height=\"" . $newheight .  "\" alt=\"" . $gbimage . "\" /></a></td></tr>\n";
					  } else {
						  $vartm .= "<tr><td class=\"imageBackground\" valign=\"top\">
						  <a href=\"javascript:commentss_pic_fullsize('http://" . $gbimage ."','".$width."','".$height."')\"><img class=\"commentssImage\" src=\"http://" . $gbimage . "\" width=\"" . $newwidth .  "\" height=\"" . $newheight .  "\" alt=\"" . $gbimage . "\" /></a></td></tr>\n";
						  }
				  } else { 
				// in case allow_url_fopen = off ---------------
					  if (eregi("http://", $gbimage)){

					  $vartm .= "<tr><td class=\"imageBackground\" valign=\"top\"><img class=\"commentssImage\" src=\"" . $gbimage . "\" alt=\"" . $gbimage . "\" /></td></tr>\n";
					} else {
						  $vartm .= "<tr><td class=\"imageBackground\" valign=\"top\"><img class=\"commentssImage\" src=\"http://" . $gbimage . "\" alt=\"" . $gbimage . "\" /></td></tr>\n";
						  }
					}
			  }
			  if ($gbmessage != '') $vartm .= "<tr><td class=\"messageBackground\" valign=\"top\"><span class=\"gbmessage\">" . $gbmessage . "&nbsp;</span></td>\n";
			  if ($gbmessage != '') $vartm .= "</tr>\n";
			  if ($gbmessage != '') $vartm .= "</table></div>\n";
			  if(eregi("true",$plugin_cf['commentss']['chronological_order'])){
				  $vartl = $vartl . $vartm;
				  } else {
					  $vartl = $vartm . $vartl;
						}
		  } // end of - if(substr($line,0,2) != '##') -
	}
	return $vartl;
	fclose($fp);
   }
}//end of gb_commentOutput

?>


Ak by sa v tomto niekto vyznal a spravil jednoduché stránkovanie bol by som veľmi vďačný. Stačilo by niečo ako
1 - 2 - 3 - 4
alebo aj niečo jednoduchšie ako napr. << 1 >>

Ďakujem za každú pomoc a radu a prajem pekný zvyšok dňa.

PS: Prepáčte že na 3 príspevky, ale nečakal som, že sa to nezmestí
panther
Profil
NS
to si s tím kódem děláš srandu?

a spravil jednoduché stránkovanie
hledal jsi? Řešilo se několikrát i zde na diskusi.
NS
Profil *
panther
Áno hľadal a keby som to bol vedel, tak tu nepíšem. Väčšina tých návodov pracuje s DB a ak nájdem také čo pracuje bez, tak mi to vôbec nefunguje.
Ospravedlňujem sa teda ak je moja téma braná ako "spam", ale ja to bohužiaľ sám nezvládnem. Asi dve hodiny už skúšam všetko čo som našiel, ale keďže v php som len začiatočník tak tento script je nad moje schopnosti.
Mastodont
Profil
NS
Většina lidí tady je dost ochotná, ale těžko najdeš někoho, kdo by tohle přeluštil. Navíc když je to psáno tímto stylem míchajícím PHP a HTML.
Alphard
Profil
NS:
Není to bráno jako spam, to už by tady nebylo, ale nemůžeš čekat, že někdo bude číst cca 300 řádků kódu. Jestli chceš zvýšit šanci na naši pomoc, pokus se to zredukovat. Smaž, co není nutné a přesně popiš chování.
japlavaren
Profil
NS
myslim ze ti s tym nikto nepomoze
povedz kolegovy ze co si navaril nech si aj zje.

ak mas zaujem prerobim to do DB
ozvy sa na
jakub@simpellife.sk
icq: 330-057-838

Vaše odpověď

Mohlo by se hodit


Prosím používejte diakritiku a interpunkci.

Ochrana proti spamu. Napište prosím číslo dvě-sta čtyřicet-sedm: