<?php
/**************************************************************************/
/* Module Gbook MX v2.0 Copyright (c) 2004 by Víctor Simental             */
/* $Revision 30/01/2004 - $Id funciones.inc.php - v4.2.3    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...");
}

function guardar_datos($numero, $bienvenida, $color, $color2, $color3, $color4, $idioma, $mostrarip, $envioadmin, $enviouser, $order, $textmailadmin, $textmailuser, $on, $off, $activo, $thewords, $gok, $pok, $cok, $iok, $mok, $yok, $aok, $wok, $hok, $eok, $htok){
global $module_name;
	$file=fopen("modules/$module_name/includes/settings.php","w");//Necesita chmode, normalmente 666 o 777

	$archivocont="<?php\n";
	$archivocont.="/**************************************************************************/\n";
	$archivocont.="/* Module Gbook MX v2.0 Copyright (c) 2004 by Víctor Simental             */\n";
	$archivocont.="/* \$Revision 30/01/2004 - \$Id sttings.php - v4.2.3        EPX \$           */\n";
	$archivocont.="/* @URI: http://www.phpwebmasters.com                                     */\n";
	$archivocont.="/* ============================================                           */\n";
	$archivocont.="/* Based in Gbook MX v4.1.0 Copyright (c) 2003 by                         */\n";
	$archivocont.="/* Víctor Simental - http://gbookmx.sourceforge.net                       */\n";
	$archivocont.="/* ============================================                           */\n";
	$archivocont.="/* GbookMX is Based in the Gbook v1.0 for PHP Nuke Copyright (c) 2003 by  */\n";
	$archivocont.="/* http://www.PHP-Mania.com.ar                                            */\n";
	$archivocont.="/* Programed and Design By Víctor Simental and German Cúevas              */\n";
	$archivocont.="/* vicmx@phpwebmasters.com                                                */\n";
	$archivocont.="/*                                                                        */\n";
	$archivocont.="/* This program is free software. You can redistribute it and/or modify   */\n";
	$archivocont.="/* it under the terms of the GNU General Public License as published by   */\n";
	$archivocont.="/* the Free Software Foundation; either version 2 of the License.         */\n";
	$archivocont.="/**************************************************************************/\n\n";
	$archivocont.="if (!eregi(\"modules.php\", \$_SERVER['PHP_SELF'])) { \n";
	$archivocont.=" die (\"You can't access this file directly...\");\n";
	$archivocont.="}\n";
	$archivocont.="/*****************************************************************************/\n";
	$archivocont.="/* This is the config file for the Gbook MX ver.4.1.0                        */\n";
	$archivocont.="/* Do not edit manually ---- Hecho en México --- Made in México              */\n";
	$archivocont.="/*****************************************************************************/\n\n";
	$archivocont.="############################################################\n";
	$archivocont.="# Atencion!!!, este fichero No se debe editar manualmente  #\n";
	$archivocont.="############################################################\n\n";
	$archivocont.="\$html_code=$hok;\n";
	$archivocont.="\$emoticon=$eok;\n";
	$archivocont.="\$allowhtml=$htok;\n";
	$archivocont.="\$genero_field=$gok;\n";
	$archivocont.="\$pais_field=$pok;\n";
	$archivocont.="\$ciudad_field=$cok;\n";
	$archivocont.="\$icq_field=$iok;\n";
	$archivocont.="\$msn_field=$mok;\n";
	$archivocont.="\$yim_field=$yok;\n";
	$archivocont.="\$aim_field=$aok;\n";
	$archivocont.="\$website_field=$wok;\n";
	$archivocont.="\$num_sign=\"$numero\";\n";
	$archivocont.="\$welcome=\"$bienvenida\";\n";
	$archivocont.="\$Colortab=\"$color\";\n";
	$archivocont.="\$Colortab2=\"$color2\";\n";
	$archivocont.="\$tableheader=\"$color3\";\n";
	$archivocont.="\$bordercolor=\"$color4\";\n";
	$archivocont.="\$countrylang=\"$idioma\";\n";
	$archivocont.="\$showipuser=\"$mostrarip\";\n";
	$archivocont.="\$mailadmin=\"$envioadmin\";\n";
	$archivocont.="\$mailuser=\"$enviouser\";\n";
	$archivocont.="\$writemailadmin=\"$textmailadmin\";\n";
	$archivocont.="\$writemailuser=\"$textmailuser\";\n";
	$archivocont.="\$displayorder=\"$order\";\n";
	$archivocont.="\$online=\"$on\";\n";
	$archivocont.="\$offline=\"$off\";\n";
	$archivocont.="\$censured=\"$activo\";\n";
	$archivocont.="\$wordscensured=\"$thewords\";\n\n\n\n\n\n\n";
	$archivocont.="\$copy=\"Gbook MX\";\n";
	$archivocont.="\$Gver=\"v2.0\";\n";
	$archivocont.="\n?>";
//<div align=\"right\"><a href=\"http://www.php-mania.com.ar\" target=\"_blank\">Powered by &copy;".$modulecopy." ".$modulever."</a></div>";
	fwrite($file,$archivocont);
	   fclose($file);
	   }	   
		   
function Convertir_Fecha($data)
	{
	$data = strtotime($data);
	$data = strftime(_HORAFECHA, $data);
	return($data);
	}

function Comprobar_Fecha($data)
	{
	$data = strtotime($data);
	$data = strftime("%d %m %Y", $data);
        if($data==date("d m Y")){
	return true;
        }
        else{
         return false;}
	}

function realip(){
  if ($for = getenv('HTTP_X_FORWARDED_FOR')){
      $afor = explode(",", $for);
	  return trim($afor[0]);
	  }else
	  {
    return getenv('REMOTE_ADDR');
   }
 }

function quotes($mensaje) {
    $mensaje = str_replace("\'","&#39;",$mensaje); 
    $mensaje = str_replace('\"',"&quot;",$mensaje);
    $mensaje = ereg_replace("''","'",$mensaje);
    $mensaje = ereg_replace('""','"',$mensaje);
    $mensaje = str_replace("\\\\","&#92",$mensaje);	
    
    return $mensaje;
}


function emoticon($message) {
global $module_name;
 include("modules/$module_name/includes/settings.php");
	//This array was modify in one function
 $smile = array(
  ":)"         => '<img src="modules/'.$module_name.'/images/smilies/sm1.gif">',
  ":-)"        => '<img src="modules/'.$module_name.'/images/smilies/sm1.gif">',
  ":("         => '<img src="modules/'.$module_name.'/images/smilies/sm2.gif">',
  ":-("        => '<img src="modules/'.$module_name.'/images/smilies/sm2.gif">',
  ";)"         => '<img src="modules/'.$module_name.'/images/smilies/sm3.gif">',
  ";-)"        => '<img src="modules/'.$module_name.'/images/smilies/sm3.gif">',
  ":D"         => '<img src="modules/'.$module_name.'/images/smilies/sm4.gif">',
  ":-D"        => '<img src="modules/'.$module_name.'/images/smilies/sm4.gif">',
  ":p"         => '<img src="modules/'.$module_name.'/images/smilies/sm5.gif">',
  ":-p"        => '<img src="modules/'.$module_name.'/images/smilies/sm5.gif">',
  ":cool:"     => '<img src="modules/'.$module_name.'/images/smilies/sm6.gif">',


  ":|"         => '<img src="modules/'.$module_name.'/images/smilies/sm7.gif">',
  ":-|"        => '<img src="modules/'.$module_name.'/images/smilies/sm7.gif">',
  ":sleepy:"   => '<img src="modules/'.$module_name.'/images/smilies/sm8.gif">',  
  ":o"         => '<img src="modules/'.$module_name.'/images/smilies/sm9.gif">',
  ":-o"        => '<img src="modules/'.$module_name.'/images/smilies/sm9.gif">',
  ":confused:" => '<img src="modules/'.$module_name.'/images/smilies/sm10.gif">',
  ":whoah:"    => '<img src="modules/'.$module_name.'/images/smilies/sm11.gif">',  
  ":devil:"    => '<img src="modules/'.$module_name.'/images/smilies/sm12.gif">',
  ":king:"     => '<img src="modules/'.$module_name.'/images/smilies/sm13.gif">',
  ":sperm:"     => '<img src="modules/'.$module_name.'/images/smilies/sm14.gif">',
  ":no:"       => '<img src="modules/'.$module_name.'/images/smilies/sm15.gif">',
  ":alarm:"    => '<img src="modules/'.$module_name.'/images/smilies/sm16.gif">',
  ":rambo:"    => '<img src="modules/'.$module_name.'/images/smilies/sm17.gif">',
  ":hands:"    => '<img src="modules/'.$module_name.'/images/smilies/sm18.gif">',
  ":mmm:"      => '<img src="modules/'.$module_name.'/images/smilies/sm19.gif">',
  ":d:"        => '<img src="modules/'.$module_name.'/images/smilies/sm20.gif">',


  ":8O"        => '<img src="modules/'.$module_name.'/images/smilies/sm21.gif">',
  ":x"         => '<img src="modules/'.$module_name.'/images/smilies/sm22.gif">',
  ":kiss:"     => '<img src="modules/'.$module_name.'/images/smilies/sm23.gif">',
  ":invisible:" => '<img src="modules/'.$module_name.'/images/smilies/sm24.gif">',
  ":ciclops:"  => '<img src="modules/'.$module_name.'/images/smilies/sm25.gif">',
  ":alien:"    => '<img src="modules/'.$module_name.'/images/smilies/sm26.gif">',
  ":triste:"   => '<img src="modules/'.$module_name.'/images/smilies/sm27.gif">',
  ":flash:"    => '<img src="modules/'.$module_name.'/images/smilies/sm28.gif">',
  ":nuke:"     => '<img src="modules/'.$module_name.'/images/smilies/sm29.gif">',
  ":??:"       => '<img src="modules/'.$module_name.'/images/smilies/sm30.gif">',
  ":idea:"     => '<img src="modules/'.$module_name.'/images/smilies/sm31.gif">',
  ":news:"     => '<img src="modules/'.$module_name.'/images/smilies/sm32.gif">',
  ":bad:"      => '<img src="modules/'.$module_name.'/images/smilies/sm33.gif">',
  ":good:"     => '<img src="modules/'.$module_name.'/images/smilies/sm34.gif">',


  ":globo:"    => '<img src="modules/'.$module_name.'/images/smilies/sm35.gif">',
  ":flame:"    => '<img src="modules/'.$module_name.'/images/smilies/sm36.gif">',
  ":dance:"    => '<img src="modules/'.$module_name.'/images/smilies/sm37.gif">',
  ":hippie:"   => '<img src="modules/'.$module_name.'/images/smilies/sm38.gif">',
  ":cheleando:" => '<img src="modules/'.$module_name.'/images/smilies/sm39.gif">',
  ":cal:"      => '<img src="modules/'.$module_name.'/images/smilies/sm40.gif">',
  ":ghost:"    => '<img src="modules/'.$module_name.'/images/smilies/sm41.gif">',
  ":smooker:"  => '<img src="modules/'.$module_name.'/images/smilies/sm42.gif">',
  ":cold:"     => '<img src="modules/'.$module_name.'/images/smilies/sm43.gif">',
  
  ":calavera:"     => '<img src="modules/'.$module_name.'/images/smilies/sm44.gif">',
  ":ko:"     => '<img src="modules/'.$module_name.'/images/smilies/sm45.gif">',
  ":boomb:"     => '<img src="modules/'.$module_name.'/images/smilies/sm46.gif">',
  ":singing:"     => '<img src="modules/'.$module_name.'/images/smilies/sm47.gif">',
  ":heart:"     => '<img src="modules/'.$module_name.'/images/smilies/sm48.gif">',
  ":drink:"     => '<img src="modules/'.$module_name.'/images/smilies/sm49.gif">',
  ":flashmx:"     => '<img src="modules/'.$module_name.'/images/smilies/sm50.gif">',
  ":blahblah:"     => '<img src="modules/'.$module_name.'/images/smilies/sm51.gif">',
  ":what?:"     => '<img src="modules/'.$module_name.'/images/smilies/sm52.gif">',
  "::]:"     => '<img src="modules/'.$module_name.'/images/smilies/sm53.gif">',
  ":amazing:"     => '<img src="modules/'.$module_name.'/images/smilies/sm54.gif">',
  ":sleep:"     => '<img src="modules/'.$module_name.'/images/smilies/sm55.gif">',
  ":[D:"     => '<img src="modules/'.$module_name.'/images/smilies/sm56.gif">',
  ":8uch:"     => '<img src="modules/'.$module_name.'/images/smilies/sm57.gif">',
  ":kazaA:"     => '<img src="modules/'.$module_name.'/images/smilies/sm58.gif">',
  ":mysql:"     => '<img src="modules/'.$module_name.'/images/smilies/sm59.gif">',
  ":mmhh:"     => '<img src="modules/'.$module_name.'/images/smilies/sm60.gif">',
  ":[ouch!!]:"     => '<img src="modules/'.$module_name.'/images/smilies/sm61.gif">',
  ":hahaha:"     => '<img src="modules/'.$module_name.'/images/smilies/sm62.gif">',
  ":sshh!:"     => '<img src="modules/'.$module_name.'/images/smilies/sm63.gif">',
  ":cd:"     => '<img src="modules/'.$module_name.'/images/smilies/sm64.gif">',
  ":alienabduction:"     => '<img src="modules/'.$module_name.'/images/smilies/sm65.gif">'

  );
  for(reset($smile); $key=key($smile); next($smile)) {
    if($emoticon == 1){
	  $message = str_replace("$key","$smile[$key]",$message);
	  }
}
	if($html_code == 1){ 
     $message=htmlcode($message);
	 }
	   	if($censured=="on"){
			$arraycensured=explode(" ", $wordscensured);
			foreach($arraycensured as $values){
			$message=censured($values, $message);
			}
		}
	return $message;
 }

function htmlcode($string) {
  $string=eregi_replace("\\[img\\]([^\\[]*)\\[/img\\]","<img src=\"\\1\" border=0>",$string);
  $string=eregi_replace("\\[b\\]([^\\[]*)\\[/b\\]","<b>\\1</b>",$string);
  $string=eregi_replace("\\[i\\]([^\\[]*)\\[/i\\]","<i>\\1</i>",$string);
  $string=eregi_replace("\\[u\\]([^\\[]*)\\[/u\\]","<u>\\1</u>",$string);
  $string=eregi_replace("\\[strike\\]([^\\[]*)\\[/strike\\]","<strike>\\1</strike>",$string);
  $string=eregi_replace("\\[email\\]([^\\[]*)\\[/email\\]","<a href=\"mailto:\\1\">\\1</a>",$string);
  $string=eregi_replace("\\[url\\]www.([^\\[]*)\\[/url\\]","<a href=\"http://www.\\1\" target=\"_blank\">\\1</a>",$string);
  $string=eregi_replace("\\[url\\]([^\\[]*)\\[/url\\]","<a href=\"\\1\" target=\"_blank\">\\1</a>",$string);
  $string=eregi_replace("\\[url=http://([^\\[]+)\\]([^\\[]*)\\[/url\\]","<a href=\"http://\\1\" target=\"_blank\">\\2</a>",$string);
//  $string=eregi_replace("((http|mailto|ftp):\/\/[^[:space:]<>]{1,})","<a href='\\1'>\\1</a>",$string);
  return $string;
}

//Por ejemplo fuck en '#@%*#!' Change this #@%*#! for wherever you want, for example ->****
function censured($word, $string){
 $string=str_replace($word,"#@%*#!",$string);
 return $string;
}

function Table(){
return Opentable();	
}
function EndTable(){
return Closetable();
}

?>