Location: PHPKode > projects > Spam free PHP GuestBook > guestbook/gb/admin/include/clsadmin.php
<?php
/*
Copyright (c) 2008 http://ramui.com/. All right reserved.
This product is protected by copyright and distributed under licenses restricting copying, distribution. Permission is granted to the public to download and use this script provided that this Notice and any statement of authorship are reproduced in every page on all copies of the script.
*/
class admin extends clsmain
{
private function show_boardsettings()
{
        $query  = "SELECT* FROM ".$this->prefix."settings";
        $result = @mysql_query($query);
        $row = @mysql_fetch_array($result, MYSQL_ASSOC);
		$list= glob("../templates/*",GLOB_ONLYDIR);
		$option='';
		foreach ($list as $template){
		$template=str_replace("../templates/", "", $template);
		$option.=(($row['defaultstyle']==$template)? '<option selected value="' : '<option value="').$template.'">'.$template.'</option>';}
        $blocksite=(($row['blocksite']=='Y')? '<span style="color:#338833;">Unblock this site..</span>' : '<span style="color:#883333;">Block this site..</span>');
		$this->build_head("Site informations:", '<script type="text/javascript" src="script/admin.js"></script>');
        include "include/editsite.php";
        $this->build_footer();
}

private function save_boardsettings()
{
        $sitename=trim(fw_strip_slashes(rawurldecode($_POST["sitename"])));
        $description=trim(fw_strip_slashes(rawurldecode($_POST["description"])));
        $keywords=trim(fw_strip_slashes(rawurldecode($_POST["keywords"])));
		$postsize=trim($_POST["postsize"]);
		$commentsize=trim($_POST["commentsize"]);
		$listcount=trim($_POST["listcount"]);
		$defaultstyle=trim(fw_strip_slashes(rawurldecode($_POST["defaultstyle"])));
		$approval=((isset($_POST["approval"]))? 'A' : '');
		$nofollow=((isset($_POST["nofollow"]))? 'Y' : '');
		$allowemail=((isset($_POST["allowemail"]))? 'Y' : '');
		$verify=((isset($_POST["verify"]))? 'Y' : '');
		$imagewidth=trim($_POST["imagewidth"]);
		$imageheight=trim($_POST["imageheight"]);
		$imagecount=trim($_POST["imagecount"]);
		$description=fw_remove_smarttag($description);
		$description=str_replace("\n"," ",str_replace("\r","",$description));
        $query="UPDATE ".$this->prefix."settings SET sitename = '%s', description = '%s', keywords = '%s', defaultstyle = '%s', verifyuser = '$verify', postsize = %d, commentsize = %d, listcount = %d, approval = '$approval', nofollow = '$nofollow', allowemail = '$allowemail', imagecount = %d";
        $query=sprintf($query,mysql_real_escape_string($sitename),mysql_real_escape_string($description),mysql_real_escape_string($keywords),mysql_real_escape_string($defaultstyle),$postsize,$commentsize,$listcount,$imagecount);
		if(!empty($imagecount)){$query.=sprintf(", imagewidth = %d, imageheight = %d",$imagewidth,$imageheight);}
		if(!@mysql_query($query)){echo '<span style="color:red">Error! '.mysql_error().'</span>';}
        else{echo '<span style="color:green">Data has been updated.</span>';}
        exit;
}
private function block_site()
{
        $query = "SELECT blocksite FROM ".$this->prefix."settings";
        $result = @mysql_query($query);
        $row = @mysql_fetch_array($result, MYSQL_ASSOC);
		if($row['blocksite']=='Y'){$blocksite=''; $message='<span style="color:#883333;">Block this site..</span>';}
		else{$blocksite='Y'; $message='<span style="color:#338833;">Unblock this site..</span>';}
		if(@mysql_query("UPDATE ".$this->prefix."settings SET blocksite = '$blocksite'")){echo $message;}
		exit;
}

public function get_query($query)
{
if ($this->validate_user()){
      switch ($query[1]) {
          case "1":
              $this->show_boardsettings();
          break;
          case "2":
              $this->save_boardsettings();
          break;
          case "3":
              $this->block_site();
          break;
          case "5":
              $this->log_out();
          break;
          default :
              $this->show_boardsettings();
      }
}
else {if(($query[1]==1)||empty($query[1])){$this->log_in();}}
}
}
?>
Return current item: Spam free PHP GuestBook