<?php

/**************************************************************************/
/* Module Gbook MX v2.0 Copyright (c) 2004 by Víctor Simental             */
/* $Revision 30/01/2004 - $Id admin.php - v4.1.2    EPX $                 */ 
/* @URI: http://www.phpwebmasters.com                                     */ 
/* ============================================                           */
/* Based in Gbook MX v4.1.0 Copyright (c) 2003 by                         */
/* Víctor Simental - http://gbookmx.sourceforge.net                       */
/* ============================================                           */
/* GbookMX is Based in the Gbook v1.0 for PHP Nuke Copyright (c) 2003 by  */
/* http://www.PHP-Mania.com.ar                                            */
/* Programed and Design By Víctor Simental and German Cúevas              */
/* vicmx@phpwebmasters.com                                                */
/*                                                                        */
/* This program is free software. You can redistribute it and/or modify   */
/* it under the terms of the GNU General Public License as published by   */
/* the Free Software Foundation; either version 2 of the License.         */
/**************************************************************************/

if (!eregi("modules.php", $_SERVER['PHP_SELF'])) {   
 die ("You can't access this file directly...");
}
if(!@file_exists("modules/$module_name/copyright.php"))
	  die("<h1>Your Gbook MX its an copy ilegal<br> <b>DO NOT REMOVE THE COPYRIGHT. YOU'RE NOT ALLOWED TO REMOVE NOR EDIT THIS.!!!!</b></h1>");
$module_name = basename(dirname(__FILE__));
if(@file_exists("modules/$module_name/install.php")) die("Please delete install.php in <b>modules/$module_name/install.php</b>!");
	
/*********************************************************/
/* Administration Main Function                          */
/*********************************************************/

function admin_menu(){
global $module_name;
    Table();
    echo "<center><a href=\"modules.php?name=$module_name\"><b>"._SEEGB."</b></a> | <a href=\"modules.php?name=$module_name&amp;op=admin&amp;action=Settings\"><b>"._SETTINGS."</b></a> | \n"
	    ."<a href=\"modules.php?name=$module_name&amp;op=admin&amp;action=Ban_Ip\"><b>"._BANIP."</b></a> | <a href=\"admin.php?op=logout\"><b>"._LOGOUTADMIN."</b></a></center>";
    EndTable();
	echo "<br>";
}

function adminMain() {
    global $admin, $sitename;
    include ("header.php");
    Table();
    echo "<center><b>$sitename: "._ADMIN_."</b></center>";
    EndTable();
    echo "<br>";
    admin_menu();
    include ("footer.php");
}

function settings(){			
    include ("header.php");
	global $module_name, $sitename, $genero_field, $pais_field, $ciudad_field, $icq_field, $msn_field, $yim_field, $aim_field, $website_field, $countrylang;
	global $num_sign, $adminmail, $welcome, $html_code, $emoticon, $allowhtml, $showipuser, $mailadmin, $mailuser, $writemailadmin, $writemailuser, $displayorder, $online, $offline, $censured, $wordscensured;
	global $tableheader, $bordercolor,$Colortab, $Colortab2;
	
	echo "\n<script>\n"
		."function cambiacolor(theform,color) {\n"
		."\t\ttheform.style.backgroundColor = color;\n"
		."\t\t }\n"
		."</script>\n";
    Table();
    echo "<center><b>$sitename: "._ADMIN_."</b></center>";
    EndTable();
	echo "<br>";
	admin_menu();    
    Table();
	echo "\n<form action=\"modules.php?name=$module_name&amp;op=admin\" method=\"post\">\n";
	echo "\t<table align=\"center\" border=\"0\" width=\"95%\">\n";
	echo "\t<tr><td width=\"100%\" valign=\"top\" colspan=\"2\"><center><b>"._ACTIVEFIELDS."</b></center></td></tr>\n";
	echo "\t<tr><td width=\"50%\" valign=\"top\">"._ACTIVEGENERO."&nbsp;&nbsp;<img src=\"modules/$module_name/images/male.gif\" align=\"absmiddle\" alt=\""._MALE."\">&nbsp;<img src=\"modules/$module_name/images/female.gif\" align=\"absmiddle\" alt=\""._FEMALE."\"></td><td width=\"50%\" valign=\"top\">\n";
	if($genero_field == 1){
	echo "<input type='radio' name='Gok' value='1' checked>"._ADMINYES." &nbsp;
	<input type='radio' name='Gok' value='0'>"._ADMINNO."";
    } else {
	echo "<input type='radio' name='Gok' value='1'>"._ADMINYES." &nbsp;
	<input type='radio' name='Gok' value='0' checked>"._ADMINNO."";
    }
	echo "</td></tr>\n";
	echo "\t<tr><td width=\"50%\" valign=\"top\">"._ACTIVEPAIS."&nbsp;&nbsp;<img src=\"modules/$module_name/images/location.gif\" align=\"absmiddle\" alt=\""._PAIS."\"></td><td width=\"50%\" valign=\"top\">\n";
	if($pais_field == 1){
	echo "<input type='radio' name='Pok' value='1' checked>"._ADMINYES." &nbsp;
	<input type='radio' name='Pok' value='0'>"._ADMINNO."";
    } else {
	echo "<input type='radio' name='Pok' value='1'>"._ADMINYES." &nbsp;
	<input type='radio' name='Pok' value='0' checked>"._ADMINNO."";
    }
	echo "</td></tr>\n";
	echo "\t<tr><td width=\"50%\" valign=\"top\">"._ACTIVECIUDAD."&nbsp;&nbsp;<img src=\"modules/$module_name/images/location.gif\" align=\"absmiddle\" alt=\""._CIUDAD."\"></td><td width=\"50%\" valign=\"top\">\n";
	if($ciudad_field == 1){
	echo "<input type='radio' name='Cok' value='1' checked>"._ADMINYES." &nbsp;
	<input type='radio' name='Cok' value='0'>"._ADMINNO."";
    } else {
	echo "<input type='radio' name='Cok' value='1'>"._ADMINYES." &nbsp;
	<input type='radio' name='Cok' value='0' checked>"._ADMINNO."";
    }
	echo "</td></tr>\n";
	echo "\t<tr><td width=\"50%\" valign=\"top\">"._ACTIVEICQ."&nbsp;&nbsp;<img src=\"modules/$module_name/images/icq.gif\" align=\"absmiddle\" alt=\""._ICQ."\"></td><td width=\"50%\" valign=\"top\">\n";
	if($icq_field == 1){
	echo "<input type='radio' name='Iok' value='1' checked>"._ADMINYES." &nbsp;
	<input type='radio' name='Iok' value='0'>"._ADMINNO."";
    } else {
	echo "<input type='radio' name='Iok' value='1'>"._ADMINYES." &nbsp;
	<input type='radio' name='Iok' value='0' checked>"._ADMINNO."";
    }
	echo "</td></tr>\n";
	echo "\t<tr><td width=\"50%\" valign=\"top\">"._ACTIVEMSN."&nbsp;&nbsp;<img src=\"modules/$module_name/images/msn.gif\" align=\"absmiddle\" alt=\""._MSN."\"></td><td width=\"50%\" valign=\"top\">\n";
	if($msn_field == 1){
	echo "<input type='radio' name='Mok' value='1' checked>"._ADMINYES." &nbsp;
	<input type='radio' name='Mok' value='0'>"._ADMINNO."";
    } else {
	echo "<input type='radio' name='Mok' value='1'>"._ADMINYES." &nbsp;
	<input type='radio' name='Mok' value='0' checked>"._ADMINNO."";
    }
	echo "</td></tr>\n";
	echo "\t<tr><td width=\"50%\" valign=\"top\">"._ACTIVEYIM."&nbsp;&nbsp;<img src=\"modules/$module_name/images/yim.gif\" align=\"absmiddle\" alt=\""._YIM."\"></td><td width=\"50%\" valign=\"top\">\n";
	if($yim_field == 1){
	echo "<input type='radio' name='Yok' value='1' checked>"._ADMINYES." &nbsp;
	<input type='radio' name='Yok' value='0'>"._ADMINNO."";
    } else {
	echo "<input type='radio' name='Yok' value='1'>"._ADMINYES." &nbsp;
	<input type='radio' name='Yok' value='0' checked>"._ADMINNO."";
    }
	echo "</td></tr>\n";	
	echo "\t<tr><td width=\"50%\" valign=\"top\">"._ACTIVEAIM."&nbsp;&nbsp;<img src=\"modules/$module_name/images/aim.gif\" align=\"absmiddle\" alt=\""._AIM."\"></td><td width=\"50%\" valign=\"top\">\n";
	if($aim_field == 1){
	echo "<input type='radio' name='Aok' value='1' checked>"._ADMINYES." &nbsp;
	<input type='radio' name='Aok' value='0'>"._ADMINNO."";
    } else {
	echo "<input type='radio' name='Aok' value='1'>"._ADMINYES." &nbsp;
	<input type='radio' name='Aok' value='0' checked>"._ADMINNO."";
    }
	echo "</td></tr>\n";
	echo "\t<tr><td width=\"50%\" valign=\"top\">"._ACTIVEWEB."<img src=\"modules/$module_name/images/home.gif\" align=\"absmiddle\" alt=\""._WEBSITE."\"></td><td width=\"50%\" valign=\"top\">\n";
	if($website_field == 1){
	echo "<input type='radio' name='Wok' value='1' checked>"._ADMINYES." &nbsp;
	<input type='radio' name='Wok' value='0'>"._ADMINNO."";
    } else {
	echo "<input type='radio' name='Wok' value='1'>"._ADMINYES." &nbsp;
	<input type='radio' name='Wok' value='0' checked>"._ADMINNO."";
    }
	echo "</td></tr>\n";
	echo "\t<tr><td width=\"100%\" valign=\"top\" colspan=\"2\"><center><b>"._GENERALCONFIGURATION."</b></center></td></tr>\n";
	echo "\t<tr><td width=\"50%\" valign=\"top\">"._NADMINPAGES."</td><td width=\"50%\" valign=\"top\"> <input type='text' name='num_pag' value='$num_sign' size='3'></td></tr>\n";
	echo "\t<tr><td width=\"50%\" valign=\"top\">"._WELLCOME."</td><td width=\"50%\" valign=\"top\"> <input type='text' name='meswell' value='$welcome' size='30'></td></tr>\n";
	echo "\t<tr><td width=\"50%\" valign=\"top\">"._ALLOWHTMLCODE."</td><td width=\"50%\" valign=\"top\">\n";
	if($html_code == 1){
	echo "<input type='radio' name='Hok' value='1' checked>"._ADMINYES." &nbsp;
	<input type='radio' name='Hok' value='0'>"._ADMINNO."";
    } else {
	echo "<input type='radio' name='Hok' value='1'>"._ADMINYES." &nbsp;
	<input type='radio' name='Hok' value='0' checked>"._ADMINNO."";
    }
	echo "</td></tr>\n";
	echo "\t<tr><td width=\"50%\" valign=\"top\">"._ALLOWEMOTICON."</td><td width=\"50%\" valign=\"top\">\n";
	if($emoticon == 1){
	echo "<input type='radio' name='Eok' value='1' checked>"._ADMINYES." &nbsp;
	<input type='radio' name='Eok' value='0'>"._ADMINNO."";
    } else {
	echo "<input type='radio' name='Eok' value='1'>"._ADMINYES." &nbsp;
	<input type='radio' name='Eok' value='0' checked>"._ADMINNO."";
    }
	echo "</td></tr>\n";
	echo "\t<tr><td width=\"50%\" valign=\"top\">"._ALLOWHTML."</td><td width=\"50%\" valign=\"top\">\n";
	if($allowhtml == 1){
	echo "<input type='radio' name='Htok' value='1' checked>"._ADMINYES." &nbsp;
	<input type='radio' name='Htok' value='0'>"._ADMINNO."";
    } else {
	echo "<input type='radio' name='Htok' value='1'>"._ADMINYES." &nbsp;
	<input type='radio' name='Htok' value='0' checked>"._ADMINNO."";
    }
	echo "</td></tr>\n";
	echo "\t<tr><td width=\"50%\" valign=\"top\">"._LANG."</td><td width=\"50%\" valign=\"top\"><select name='langs'>\n";
	
	$handle=opendir('modules/'.$module_name.'/language');
    while ($file = readdir($handle)) {
	if (ereg("^lang\-(.+)\.php", $file, $matches)) {
            $langFound = $matches[1];
            $languageslist .= "$langFound ";
        }
    }
    closedir($handle);
	$languageslist = explode(" ", $languageslist);
    sort($languageslist);
    for ($i=0; $i < sizeof($languageslist); $i++) {
	if($languageslist[$i]!="") {
	    echo "<option name='langs' value='$languageslist[$i]' ";
		if($languageslist[$i]==$countrylang) echo "selected";
		echo ">".ucfirst($languageslist[$i])."</option>\n";
	}
    }
    echo "</select>\n</td></tr>\n";
	echo "\t<tr><td width=\"50%\" valign=\"top\">"._SHOWIPUSER."&nbsp;&nbsp;<img src=\"modules/$module_name/images/ip.gif\" align=\"absmiddle\" alt='"._IP."'></td><td width=\"50%\" valign=\"top\">\n";
	if ($showipuser==yes){
	echo "<input type='radio' name='showip' value='yes' checked>"._ADMINYES." &nbsp;
	<input type='radio' name='showip' value='no'>"._ADMINNO."";
    } else {
	echo "<input type='radio' name='showip' value='yes'>"._ADMINYES." &nbsp;
	<input type='radio' name='showip' value='no' checked>"._ADMINNO."";
    }
	echo "</td></tr>";
	
	echo "\t<tr><td width=\"50%\" valign=\"top\">"._SENDEMAILADMIN."</td><td width=\"50%\" valign=\"top\">\n";
	if ($mailadmin==yes){
	echo "<input type='radio' name='sendemailadmin' value='yes' checked>"._ADMINYES." &nbsp;
	<input type='radio' name='sendemailadmin' value='no'>"._ADMINNO."";
    } else {
	echo "<input type='radio' name='sendemailadmin' value='yes'>"._ADMINYES." &nbsp;
	<input type='radio' name='sendemailadmin' value='no' checked>"._ADMINNO."";
    }
	echo "</td></tr>\n";
	
	echo "\t<tr><td width=\"50%\" valign=\"top\">"._EMAILADMIN."</td><td width=\"50%\" valign=\"top\"><textarea name='foradmin' cols='18' rows='5'>".$writemailadmin."</textarea>\n</td></tr>\n";
	
	echo "\t<tr><td width=\"50%\" valign=\"top\">"._SENDEMAILUSER."</td><td width=\"50%\" valign=\"top\">\n";
	if ($mailuser==yes){
	echo "<input type='radio' name='sendemailuser' value='yes' checked>"._ADMINYES." &nbsp;
	<input type='radio' name='sendemailuser' value='no'>"._ADMINNO."";
    } else {
	echo "<input type='radio' name='sendemailuser' value='yes'>"._ADMINYES." &nbsp;
	<input type='radio' name='sendemailuser' value='no' checked>"._ADMINNO."";
    }
	echo "</td></tr>\n";
	echo "\t<tr><td width=\"50%\" valign=\"top\">"._EMAILUSER."</td><td width=\"50%\" valign=\"top\"><textarea name='foruser' cols='18' rows='5'>".$writemailuser."</textarea>\n</td></tr>\n";
	
	echo "\t<tr><td width=\"50%\" valign=\"top\">"._ORDER."</td><td width=\"50%\" valign=\"top\">\n";
	if ($displayorder==ASC){
	echo "<input type='radio' name='order' value='ASC' checked>"._ASC." &nbsp;
	<input type='radio' name='order' value='DESC'>"._DESC."";
    } else {
	echo "<input type='radio' name='order' value='ASC'>"._ASC." &nbsp;
	<input type='radio' name='order' value='DESC' checked>"._DESC."";
    }
	echo "</td></tr>\n";
	
	echo "\t<tr><td width=\"50%\" valign=\"top\">"._ENABLED."</td><td width=\"50%\" valign=\"top\">\n";
	if ($online==yes){
	echo "<input type='radio' name='enabled' value='yes' checked>"._ADMINYES." &nbsp;
	<input type='radio' name='enabled' value='no'>"._ADMINNO."";
    } else {
	echo "<input type='radio' name='enabled' value='yes'>"._ADMINYES." &nbsp;
	<input type='radio' name='enabled' value='no' checked>"._ADMINNO."";
    }
	echo "</td></tr>\n";
	echo "\t<tr><td width=\"50%\" valign=\"top\">"._OFFLINEMESSAGE."</td><td width=\"50%\" valign=\"top\"><textarea name='disabled' cols='18' rows='5'>".$offline."</textarea>\n</td></tr>\n";
	
	echo "\t<tr><td width=\"50%\" valign=\"top\">"._CENSORWORD."</td><td width=\"50%\" valign=\"top\">\n";
	if ($censured==on){
	echo "<input type='radio' name='censorenabled' value='on' checked>"._ADMINYES." &nbsp;
    <input type='radio' name='censorenabled' value='off'>"._ADMINNO."";
    } else {
	echo "<input type='radio' name='censorenabled' value='on'>"._ADMINYES." &nbsp;
	<input type='radio' name='censorenabled' value='off' checked>"._ADMINNO."";
    }
	echo "</td></tr>\n";
	echo "\t<tr><td width=\"50%\" valign=\"top\">"._WORDCENSURED."</td><td width=\"50%\" valign=\"middle\"><textarea name='censuradas' cols='18' rows='5'>".$wordscensured."</textarea>\n</td></tr>\n";
	echo "\t<tr><td width=\"100%\" valign=\"top\" colspan=\"2\"><center><b>"._STYLE."</b></center></td></tr>\n";
	echo "\t<tr colspan='2'><td width=\"50%\" valign=\"top\">"._TABLEHEADER."</td><td width=\"25%\" valign=\"top\"> <input type='text' name='headercolor' value='$tableheader' onchange='cambiacolor(this.form.previewheadercolor,this.value)'></td><td width=\"25%\" valign=\"top\">"
	."<input type='button' id='previewheadercolor' value='               ' style='background-color:$tableheader' DISABLED></td></tr>\n";
	echo "\t<tr colspan='2'><td width=\"50%\" valign=\"top\">"._BORDERCOLOR."</td><td width=\"25%\" valign=\"top\"> <input type='text' name='tableborder' value='$bordercolor' onchange='cambiacolor(this.form.previewtableborder,this.value)'></td><td width=\"25%\" valign=\"top\">"
	."<input type='button' id='previewtableborder' value='               ' style='background-color:$bordercolor' DISABLED></td></tr>\n";
	echo "\t<tr colspan='2'><td width=\"50%\" valign=\"top\">"._COLORTAB." </td><td width=\"25%\" valign=\"top\"><input type='text' name='tabcolor' value='$Colortab' onchange='cambiacolor(this.form.previewtabcolor,this.value)'></td><td width=\"25%\" valign=\"top\">"
	."<input type='button' id='previewtabcolor' value='               ' style='background-color:$Colortab' DISABLED></td></tr>\n";
	echo "\t<tr colspan='2'><td width=\"50%\" valign=\"top\">"._COLORTAB2."</td><td width=\"25%\" valign=\"top\"> <input type='text' name='tabcolor2' value='$Colortab2' onchange='cambiacolor(this.form.previewtabcolor2,this.value)'></td><td width=\"25%\" valign=\"top\">"
	."<input type='button' id='previewtabcolor2' value='               ' style='background-color:$Colortab2' DISABLED></td></tr>\n";
	echo "</table>\n"
	."<center><input type=\"hidden\" name=\"action\" value=\"save\">\n<input type=\"submit\" value=\""._ADMINSAVECHANGES."\">\n</form></center>";
    EndTable();
    include ("footer.php");
}
	

function del_entry(){
global $id, $confirm;
include("header.php");
global $module_name, $sitename, $mysql, $prefix;
    Table();
    echo "<center><b>$sitename: "._ADMIN_."</b></center>";
    EndTable();
	echo "<br>";
    admin_menu();
	Table();
     if($confirm=="ok"){
     $mysql->sql_query("DELETE FROM ".$prefix."_gbook WHERE id='$id'");	 
	 echo _THEMESSAGEWITH ." <b>$id</b>, "._WASDELETED ."<br>" ._REDIRECCIONADO ."\n";
     echo "<META HTTP-EQUIV=Refresh CONTENT=\"3; URL=modules.php?name=$module_name\">\n";
     }
     else {
     echo "<center>"._CONFIRMDELETE."<br><a href=\"modules.php?name=$module_name&amp;op=admin&amp;action=delete&amp;id=$id&amp;confirm=ok\">"._ADMINYES."</a> - <a href=\"modules.php?name=$module_name\">"._ADMINNO."</a></center>";
     }
     EndTable();
include("footer.php");
}

function edit_entry(){
global $id, $act, $firma, $mysql, $prefix, $module_name, $sitename;

if($act=="go"){
     $firmabr=nl2br($firma);
	 $mysql->sql_query("UPDATE ".$prefix."_gbook SET firma='$firmabr' WHERE id='$id'");
     Header("Location: modules.php?name=$module_name");
     }
     else{

include("header.php");
    Table();
    echo "<center><b>$sitename: "._ADMIN_."</b></center>";
    EndTable();
    echo "<br>";
	admin_menu();
    Table();
  $edit=$mysql->sql_query("SELECT * FROM ".$prefix."_gbook WHERE id='$id'");
	  if($datos=$mysql->sql_fetch_assoc($edit)){
  $firmasinbr=str_replace("<br />","",$datos["firma"]);
  
  echo "<center><b>"._EDITMESSAGE." ".$datos["nombre"]." "._WHITID." $id</b></center>\n"
     ."<form action=\"modules.php?name=$module_name&amp;op=admin&amp;action=edit&amp;act=go\" method=\"post\">\n"
	 ."<table align='center' border='0' width='70%'>\n<tr><td width='50%' valign='top'><b>"._NOMBRE."</b> <img src=\"modules/$module_name/images/user.gif\" align=\"absmiddle\"></td>\n<td width='50%' valign='top'>".$datos["nombre"]."</td></tr>\n"
	 ."<tr><td width='50%' valign='top'><b>"._EMAIL."</b></td>\n<td width='50%' valign='top'>";
	 if($datos["email"]){
  echo "<a href=\"mailto:".$datos["email"]."\"><img src=\"modules/$module_name/images/email.gif\" border=\"0\" alt=\"".$datos["email"]."\"></a>\n";
	     }
  echo "</td></tr>\n"
	 ."<tr><td width='50%' valign='top'><b>"._GENERO."</b></td>\n<td width='50%' valign='top'><img src=\"modules/$module_name/images/".$datos["genero"].".gif\" align=\"absmiddle\"></td></tr>\n"
	 ."<tr><td width='50%' valign='top'><b>"._PAIS."</b></td>\n<td width='50%' valign='top'><img src=\"modules/$module_name/images/flags/".$datos["bandera"]."\" border=\"0\" align=\"absmiddle\"></td></tr>\n"
	 ."<tr><td width='50%' valign='top'><b>"._CIUDAD."</b></td>\n<td width='50%' valign='top'> ".$datos["ciudad"]."</td></tr>\n"
     ."<tr><td width='50%' valign='top'></td><td width='50%' valign='top'>";
		if($datos["url"]){
  echo "<a href=\"".$datos["url"]."\" target=\"_blank\"><img src=\"modules/$module_name/images/home.gif\" border=\"0\" align=\"absmiddle\" alt=\"".$datos["url"]."\"></a>\n";
	     }
	    if($datos["msn"]){
  echo "<img src=\"modules/$module_name/images/msn.gif\" align=\"absmiddle\" border=\"0\" alt=\"".$datos["msn"]."\">\n";	
		 } 
		if($datos["yim"]){
  echo "<a href=\"http://edit.yahoo.com/config/send_webmesg?.target=".$datos["yim"]."&.src=pg\"><img src=\"modules/$module_name/images/yim.gif\" align=\"absmiddle\" border=\"0\" alt=\"".$datos["yim"]."\"></a>\n";	
		} 
		if($datos["aim"]){
  echo "<a href=\"aim:goim?screenname=".$datos["aim"]."&amp;message=Hello+Are+you+there?\"><img src=\"modules/$module_name/images/aim.gif\" align=\"absmiddle\" border=\"0\"></a>\n";	
		} 
    	if($datos["icq"]){
  echo "<a href=\"http://wwp.icq.com/scripts/search.dll?to=".$datos["icq"]."\"><img src=\"modules/$module_name/images/icq.gif\" align=\"absmiddle\" border=\"0\"></a>\n";
	    }
  echo "<tr><td width='50%' valign='middle'><b>"._MENSAJE." </b><img src=\"modules/$module_name/images/file.gif\" align=\"absmiddle\"></td>\n<td width='50%' valign='top'><textarea name='firma' wrap='virtual' cols='40' rows='10'>".stripslashes($firmasinbr)."</textarea>\n</td></tr></table>\n"
      ."<input type='hidden' name='id' value='".$datos["id"]."'>\n<br><center><input type='submit' value='"._UPDATE."'></center>\n</form>";
	}
	else  {
	echo "<center><b>"._NOID."</b></center>";
	}
 }
	EndTable();
include("footer.php");
}


function admin_comment(){
global $id, $add, $comentario, $mysql, $prefix, $module_name, $sitename, $bgcolor2, $bgcolor1;

if($add=="Admin_Comment"){
	 $comentariobr=nl2br($comentario);
	 $mysql->sql_query("UPDATE ".$prefix."_gbook SET comentario='$comentariobr' WHERE id='$id'");
     Header("Location: modules.php?name=$module_name");
     }
     else{

include("header.php");

    Table();
    echo "<center><b>$sitename: "._ADMIN_."</b></center>";
    EndTable();
	echo "<br>";
    admin_menu();	  
    Table();
  $edit=$mysql->sql_query("SELECT * FROM ".$prefix."_gbook WHERE id='$id'");
	  if($datos=$mysql->sql_fetch_assoc($edit)){
  $comentariobr=str_replace("<br />","",$datos["comentario"]);
  
  echo "<center><b>"._ADDCOMMENTMESS." $id</b>\n</center><br>\n"
      ."<form action=\"modules.php?name=$module_name&amp;op=admin&amp;action=Add_Comment&amp;add=Admin_Comment\" method=\"post\">\n"
      ."<table align='center' border='0' width='70%' cellspacing=\"1\" cellpadding=\"5\" bgcolor=\"$bgcolor2\">\n"
      ."<tr><td bgcolor=\"$bgcolor1\">".emoticon($datos["firma"])."\n</td></tr>\n</table>\n"
	  ."<br>\n"
      ."<table align='center' border='0' width='70%'>\n<tr><td width='50%' valign='middle'><b>"._ADMINMENSAJE."</b></td>\n"
	  ."<td width='50%' valign='top'>\n<textarea name='comentario' wrap='virtual' cols='40' rows='10'>".stripslashes($comentariobr)."</textarea>\n"
	  ."</td></tr>\n</table>\n"
	  ."<input type='hidden' name='id' value='".$datos["id"]."'>\n<center>\n<input type='submit' value='"._ADDCOMMENT."'>\n</center>\n</form>";
	}
	else  {
	echo "<center><b>"._NOID."</b></center>";
  }
}	  
	  
	EndTable();
include("footer.php");
}

function banip($ipban, $addip){
global $mysql, $sitename, $module_name, $prefix;
       	if($addip=="ok"){
    $mysql->sql_query("INSERT INTO ".$prefix."_gbook_banip (ip) VALUES ('$ipban')");
	 Header("Location: modules.php?name=$module_name&op=admin&action=Ban_Ip");
     }
     else{
  include("header.php");
    Table();
    echo "<br><center><b>$sitename: "._ADMIN_."</b></center><br>";
    EndTable();
    echo "<br>";
	admin_menu();
    Table();
    echo "<br><center><b>"._BANIP."</b><br><br>\n"
    ."<form action=\"modules.php?name=$module_name&op=admin&action=Ban_Ip\" method=\"post\">\n"
	."<table border=\"0\">\n"
	."<tr><td><b>"._ADDBANIP."</b></td>\n<td><input type=\"text\" name=\"ipban\" size=\"15\" maxlength=\"25\">  "._BANIPEXAMPLE."</td></tr>\n"
 	."<tr><td>\n<input type=\"hidden\" name=\"addip\" value=\"ok\">\n<input type=\"submit\" value=\""._SEND."\">\n"
	."</td></tr></table>\n</form>\n";
    echo _DELIP."<br>\n<form name=menuchooser>\n"
    ."<select name=\"menu\" onChange=\"self.location = this.options[this.selectedIndex].value;\">\n"
    ."<option value=#selected>"._SELIP."</option>\n";
	
    $ipresult=$mysql->sql_query("SELECT ip FROM ".$prefix."_gbook_banip");
 while(list($ipban) = $mysql->sql_fetch_row($ipresult)){
	echo "<option value=\"modules.php?name=$module_name&op=admin&action=Del_Ip&amp;ipban=$ipban\">$ipban</option>\n";
	}
		echo "</center></form><br>\n";
    EndTable();
    include("footer.php");
  }
}

function del_ipban($ipban, $confirm){
include("header.php");
global $module_name, $sitename, $mysql, $prefix;
    Table();
    echo "<br><center><b>$sitename: "._ADMIN_."</b></center><br>";
    EndTable();
    echo "<br>";
	admin_menu();
    Table();
    if($confirm=="ok"){
	
    $mysql->sql_query("DELETE FROM ".$prefix."_gbook_banip WHERE ip='$ipban'");
	echo _THEIP ." <b>$ipban</b>, "._IPWASDELETED ."<br>" ._REDIRECCIONADO ."\n";
    echo "<META HTTP-EQUIV=Refresh CONTENT=\"3; URL=modules.php?name=$module_name&op=admin&action=Ban_Ip\">\n";
    }
    else {
	echo "<center>"._CONFIRMDELETEIP."<br><a href=\"modules.php?name=$module_name&op=admin&action=Del_Ip&amp;ipban=$ipban&amp;confirm=ok\">"._ADMINYES."</a> - <a href=\"modules.php?name=$module_name&op=admin&action=Ban_Ip\">"._ADMINNO."</a></center>";
    }
    EndTable();
include("footer.php");
}


    switch($action) {

	default:
	adminMain();
	break;
	
	case "save":
	guardar_datos($num_pag, $meswell, $tabcolor, $tabcolor2, $headercolor, $tableborder, $langs, $showip, $sendemailadmin, $sendemailuser, $order, $foradmin, $foruser, $enabled, $disabled, $censorenabled, $censuradas, $Gok, $Pok, $Cok, $Iok, $Mok, $Yok, $Aok, $Wok, $Hok, $Eok, $Htok);
	Header("Location: modules.php?name=$module_name&op=admin&action=Settings");
	break;

	case "Settings":
	settings();
	break;
	
	case "delete":
	del_entry();
	break;
    
	case "edit":
	edit_entry();
	break;
    
	case "Add_Comment":
	admin_comment();
	break;
	
	case "Ban_Ip":
	banip($ipban, $addip);
	break;
    
	case "Del_Ip":
	del_ipban($ipban, $confirm);
	break;
	}

?>