sortkeys[$i][0]],$b[$this->sortkeys[$i][0]]); if ($this->sortkeys[$i][1] == "DESC") $r = $r * -1; if($r==0) { $i++; if ($this->sortkeys[$i]) $r = $this->_sortcmp($a, $b, $i); } return $r; } function msort() { if(count($this->sortkeys)) { usort($this->data,array($this,"_sortcmp")); } } } function getkey($index, $stuff){ foreach ($stuff->data as $key => $item){ if ($item['id']==$index){ $ret=$key; break; } } return $ret; } function validemail($addr){ return eregi("^[a-z0-9]+([_.-][a-z0-9]+)*@([a-z0-9]+([.-][a-z0-9]+)*)+\\.[a-z]{2,4}$", $addr); } function clearoldadmins() { global $log, $now, $adminexpire; include($log); if (count($admins)>0){ $i=0; $fp=fopen($log, "w"); fputs($fp, ""); fclose($fp); } } function saveposts($stuff){ global $dat; $fp=fopen($dat, "w"); foreach ($stuff->data as $post){ $line=$post['id']."|".$post['time']."|".$post['name']."|".$post['email']."|".$post['www']."|".$post['post']."|".$post['ip']."\n"; fputs($fp, $line); } fclose($fp); } function isloggedin() { global $log, $now, $adminexpire; include($log); $logged=false; if (count($admins)>0){ foreach ($admins as $line){ if ($line['hash']==md5($_GET['hash'])) $logged=true; } } return $logged; } function showmenu() { global $txtsign, $txtview, $txtadmin, $me, $getvars; echo ''; } function emailencoder ($str){ for ($i=0; $i< strlen($str); $i++){ $n=rand(0,10); if ($n>5) $foo.="&#".ord($str[$i]).";"; else $foo.="&#x".sprintf("%X", ord($str[$i])).";"; } return $foo; } // ************************** MAIN **************************** // ************************************************************ // init $foo=file($dat); $stuff= new mdasort; $stuff->sortkeys = array(array('time','DESC')); if (count($foo)==0){ $empty=true; $nextindex=1; }else{ $i=0; foreach ($foo as $line){ $line=explode("|", rtrim($line)); $stuff->data[$i] = array("id" => $line[0], "time" => $line[1], "name" => $line[2], "email" => $line[3], "www" => $line[4], "post" => $line[5]); $i++; } $stuff->sortkeys = array(array('id','DESC')); $stuff->msort(); $foo=current($stuff->data); $nextindex=$foo['id']+1; $stuff->sortkeys = array(array('time','DESC')); $stuff->msort(); $numposts=count($stuff->data); } clearoldadmins(); showmenu(); // admin stuff if ($do=="admin") { if ($action=="login"){ if ($name==$adminname && $pwd==$adminpwd){ include($log); $fp=fopen($log, "w"); fputs($fp, "0){ foreach ($admins as $line){ fputs($fp, "\$admins[$i]['time']=".$line[time]."; \$admins[$i]['hash']='".$line['hash']."';\n"); $i++; } } fputs($fp, "\$admins[$i]['time']=".$now."; \$admins[$i]['hash']='".md5($hash)."';\n?>"); fclose($fp); echo ''; } } if ($action=="delete" && isloggedin()){ $todel=getkey($id, $stuff); unset($stuff->data[$todel]); $stuff->msort(); saveposts($stuff); $do="view"; }else{ ?>
Text abgeben Admin Login


» $txtbadname"; if ($email!=""){ if (!validemail($email)) $error.="
» $txtbademail"; } if ($msg=="") $error.="
» $txtbadmsg"; if (strtoupper($answer)!=$txtanswer) $error.="
» $txtbadanswer"; if ($error===false){ if ($id=="new"){ $index=$numposts; $id=$nextindex; $time=$now; $saveit=true; }else if (isloggedin() && is_numeric($id)){ $index=getkey($id, $stuff); $saveit=true; } if ($saveit){ $stuff->data[$index]['id']=$id; $stuff->data[$index]['time']=$time; $stuff->data[$index]['name']=htmlentities(strip_tags($name), ENT_QUOTES); $stuff->data[$index]['email']=strip_tags($email); $stuff->data[$index]['www']=strip_tags($www); $stuff->data[$index]['post']=str_replace(array("\r", "\n"), array("", "
"), htmlentities(strip_tags($msg), ENT_QUOTES)); $stuff->data[$index]['ip']=getenv("REMOTE_ADDR"); saveposts($stuff); $stuff->msort(); $empty=false; } $do="view"; }else echo '
'.$txterrors.''.$error.'

'; }else{ if ($action=="edit" && isloggedin()){ $post=$stuff->data[getkey($id, $stuff)]; $name= html_entity_decode($post['name'], ENT_QUOTES); $email=$post['email']; $www=$post['www']; $msg=stripslashes(str_replace("
", "\n", html_entity_decode($post['post'], ENT_QUOTES))); $time=$post['time']; }else{ $name=""; $email=""; $www=""; $msg=""; $time="notset"; $id="new"; } ?>
Text abgeben ()
data as $post){ if ($post['id']!=0 && $i>=$from && $i< ($from+$ppp) ){ $post['post']=str_replace($badwords, "******", $post['post']); $match=array("{name}", "{time}", "{website}", "{post}", "{edit}", "{delete}"); if (isloggedin()) $replace=array( ($post['email']!="") ? "".$post['name']."" : $post['name'], date("d. M Y", $post['time']), ($post['www']!="") ? "Website" : "", stripslashes($post['post']), "$txtedit", "$txtdelete" ); else $replace=array( ($post['email']!="") ? "".$post['name']."" : $post['name'], date("d. M Y", $post['time']), ($post['www']!="") ? "Website" : "", stripslashes($post['post']), "", "" ); $html.=str_replace($match, $replace, $tpl); } $i++; } echo $html; $numpages=(fmod($numposts,$ppp)>0) ? floor($numposts/$ppp)+1 : ($numposts/$ppp); echo '
'; echo (($from>1) ? "zurück " : "").(!(($from+$ppp>$numposts)) ? " weiter" : ""); echo '
'; } } ?>