<?php
/*
  ===============================================================

  inGenio X
  http://ingenio.area421.com

  Created by 
  Julian Moreno Hidalgo (Software developer)
  Jesus Moreno Hidalgo (Communication's tree)

  inGenio X is a free software licensed under CC-GNU GPL

  ===============================================================
*/

	// valor "1" en desarrollo y "0" en internet
	ini_set("display_errors", "0");

	// Attempt...
	define("IGNX", 1);

	// conex, config, login  global
	require("inc.global.php");

/******* CONFIGURACION  ***********/

$titulo = INGENIO_NOMBRE." ".INGENIO_VERSION;
$archivo_php = $_SERVER['SCRIPT_NAME'];

/******* CONFIGURACION FIN ********/

	$cadena_get_comple = $_SERVER['QUERY_STRING'];
	$cadena_get = strstr($_SERVER['QUERY_STRING'],"msj=1&");
	$no_get = $cadena_get_comple == "" ? 1 : 0 ;
	$tabla_get = "tabla=".IDIOMA_ADMIN;
	$campoid = "lenID";
	$ig = $_GET;
	$in = $_POST;

if (isset($in["guardar"]))
{
	
		
	$topic = entrada_gral_html($in["topic"]);
	$topic_pre = entrada_gral_html($in["topic_pre"]);
	$topic_pre_1 = entrada_gral_html($in["topic_pre_1"]);
	$topic_pre_2 = entrada_gral_html($in["topic_pre_2"]);
	$topic_pre_3 = entrada_gral_html($in["topic_pre_3"]);
	$topic_pre_4 = entrada_gral_html($in["topic_pre_4"]);
	$topic_pre_5 = entrada_gral_html($in["topic_pre_5"]);
	$ayuda = entrada_sin_tags_html($in["ayuda"]);
	$qs = "INSERT INTO ".IDIOMA_ADMIN." (topic,topic_pre,topic_pre_1,topic_pre_2,topic_pre_3,topic_pre_4,topic_pre_5,ayuda) VALUES ('".$topic."','".$topic_pre."','".$topic_pre_1."','".$topic_pre_2."','".$topic_pre_3."','".$topic_pre_4."','".$topic_pre_5."','".$ayuda."')";
	myquery($qs,"[01]");
	$inid = myinsertid();
	
	Redir ($archivo_php."?".$campoid."=".$inid."&msj=1&".$in["listado_get"]);


}

if (isset($ig["lenID"]) || isset($in["lenID"]))
{
	// asignar ID gral
	$fileID_gral = isset($ig["lenID"]) ? $ig["lenID"] : $in["lenID"];
	
	
	if (isset($in["actualizar"]))
	{
	
		// asignar el ID
		$inid = $fileID_gral;
		
		$topic_pre = entrada_gral_html($in["topic_pre"]);
		$topic_pre_1 = entrada_gral_html($in["topic_pre_1"]);
		$topic_pre_2 = entrada_gral_html($in["topic_pre_2"]);
		$topic_pre_3 = entrada_gral_html($in["topic_pre_3"]);
		$topic_pre_4 = entrada_gral_html($in["topic_pre_4"]);
		$topic_pre_5 = entrada_gral_html($in["topic_pre_5"]);
		$ayuda = entrada_sin_tags_html($in["ayuda"]);
		$qs = "UPDATE ".IDIOMA_ADMIN." SET topic_pre='".$topic_pre."',topic_pre_1='".$topic_pre_1."',topic_pre_2='".$topic_pre_2."',topic_pre_3='".$topic_pre_3."',topic_pre_4='".$topic_pre_4."',topic_pre_5='".$topic_pre_5."',ayuda='".$ayuda."' WHERE lenID='".$fileID_gral."'";
		myquery($qs,"[04]");
		
		Redir ($archivo_php."?".$campoid."=".$inid."&msj=1&".$in["listado_get"]);

	}

	// extraer los datos de la base
	$qt = myquery("SELECT * FROM ".IDIOMA_ADMIN." WHERE lenID='".$fileID_gral."'","[05]");
	$row = myfetch($qt);


} else {


/***** NUEVO ******/

$row = array();
$row["lenID"] = "";
$row["topic"] = "";
$row["topic_pre"] = "";
$row["topic_pre_1"] = "";
$row["topic_pre_2"] = "";
$row["topic_pre_3"] = "";
$row["topic_pre_4"] = "";
$row["topic_pre_5"] = "";
$row["ayuda"] = "";

}

?>
<!DOCTYPE html
    PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3c.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<?php echo '<meta http-equiv="content-type" content="text/html; charset='.CONFIG_2.'" />'; ?>
<title><?php echo $titulo; ?></title>
<?php include("inc.head.php"); ?>

<?php include("inc.formjs.php"); ?>

</head>
<body>

<table border="0" cellspacing="0" cellpadding="0" align="center">
<tr><td valign="top">

<?php include("inc.menu.php"); ?>

</td><td valign="top" width="100%">

<?php include("inc.copy.php"); ?>

<div class="contenido">

<?php
	if (isset($ig[$campoid]) || isset($in["actualizar"]))
	{
?>
<div class="div_rotulo_top_sec">
<img class="img_icon_pag" src="../skins_admin/<?php echo substr($row_comp['skin_admin'],0,-4); ?>/imgs/icon_editar.png" />
&nbsp;&nbsp;&nbsp;
<span class="rotulo_top_sec"><?php  echo LEN_ADMIN_146; ?></span>
</div>
<?php
	} else {
?>
<div class="div_rotulo_top_sec">
<img class="img_icon_pag" src="../skins_admin/<?php echo substr($row_comp['skin_admin'],0,-4); ?>/imgs/icon_php.png" />
&nbsp;&nbsp;&nbsp;
<span class="rotulo_top_sec"><?php  echo LEN_ADMIN_10; ?></span>
</div>
<?php
	}
?>

<form enctype="multipart/form-data" action="<?php echo $archivo_php; ?>" onsubmit="return validar_ingreso(this);" method="post" name="principal">
<?php
	if (isset($ig["lenID"]) || isset($in["actualizar"]))
	{

		if ($cadena_get)
		{
			$listado_get = substr($cadena_get,6);
			
		} else {
			
			// si se entra desde la web
			if ($cadena_get_comple == $campoid."=".$fileID_gral)
			{
				$listado_get = str_replace($campoid."=".$fileID_gral, $tabla_get, $cadena_get_comple);
						
			} else {
			
				$listado_get = str_replace($campoid."=".$fileID_gral."&","", $cadena_get_comple);
			}

		}
		
		echo '<div class="rotulo">'.LEN_ADMIN_47.'</div>';
		
		// gestionar
		echo '&nbsp;&nbsp;<a title="'.salida_popups(LEN_ADMIN_9).'"';
		echo ' href="listados.php?'.$listado_get.'"';
		echo ' class="conex_tip">';
		echo '<img class="img_icon_ini" src="../skins_admin/'.substr($row_comp['skin_admin'],0,-4).'/imgs/icon_configuracion.png" />';
		echo '</a>';
		echo '&nbsp;&nbsp;(#'.$fileID_gral.')';

	} else {
		echo '<div class="rotulo">'.LEN_ADMIN_47.'</div>';	
		
		// gestionar
		echo '<a title="'.salida_popups(LEN_ADMIN_9).'"';
		echo ' href="listados.php?'.$tabla_get.'"';
		echo ' class="conex_tip">';
		echo '<img class="img_icon_ini" src="../skins_admin/'.substr($row_comp['skin_admin'],0,-4).'/imgs/icon_configuracion.png" />';
		echo '</a>';
	}

	if (isset($ig["msj"]))
	{
		echo '<br /><br /><span class="mensaje">'.LEN_ADMIN_22.'</span>&nbsp;&nbsp;';
	
	}
?>

<br /><br /><br />
<div class="div_destacar_grupos">
<?php  echo LEN_ADMIN_87; ?><br /><br />
<textarea name="ayuda" class="input_editor_otro" rows="6"><?php echo $row["ayuda"]; ?></textarea>
</div>

<br /><br />
<div class="div_destacar_grupos">
<?php
	
	if ($no_get && !isset($in["actualizar"]))
	{

?>
* <?php  echo LEN_ADMIN_88; ?><br /><br />
<textarea name="topic" class="input_editor" rows="6"><?php echo $row["topic"]; ?></textarea>
<?php
	
	} else {
		echo '<strong>'.LEN_ADMIN_88.'</strong><br /><br />';
		echo $row["topic"];

	} // del if
?>
</div>

<br /><br />
<div class="div_destacar_grupos">
* <?php  echo LEN_ADMIN_89; ?><br /><br />
<textarea name="topic_pre" class="input_editor" rows="6"><?php echo $row["topic_pre"]; ?></textarea>

<br /><br />
<?php  echo LEN_ADMIN_89; ?> (1)<br /><br />
<textarea name="topic_pre_1" class="input_editor" rows="6"><?php echo $row["topic_pre_1"]; ?></textarea>

<br /><br />
<?php  echo LEN_ADMIN_89; ?> (2)<br /><br />
<textarea name="topic_pre_2" class="input_editor" rows="6"><?php echo $row["topic_pre_2"]; ?></textarea>

<br /><br />
<?php  echo LEN_ADMIN_89; ?> (3)<br /><br />
<textarea name="topic_pre_3" class="input_editor" rows="6"><?php echo $row["topic_pre_3"]; ?></textarea>

<br /><br />
<?php  echo LEN_ADMIN_89; ?> (4)<br /><br />
<textarea name="topic_pre_4" class="input_editor" rows="6"><?php echo $row["topic_pre_4"]; ?></textarea>

<br /><br />
<?php  echo LEN_ADMIN_89; ?> (5)<br /><br />
<textarea name="topic_pre_5" class="input_editor" rows="6"><?php echo $row["topic_pre_5"]; ?></textarea>
</div>

<div style="text-align:center;margin:20px 0px 20px 0px;">
<?php
	if (isset($ig["lenID"]) || isset($in["actualizar"]))
	{
?>
<input type="submit" value="<?php echo LEN_ADMIN_17;?>" class="boton">
<input type="hidden" name="<?php echo $campoid; ?>" value="<?php echo $fileID_gral; ?>">
<input type="hidden" name="actualizar" value="1">
<input type="hidden" name="listado_get" value="<?php echo $listado_get; ?>">
<?php
	} else {
?>
<input type="submit" value="<?php echo LEN_ADMIN_16;?>" class="boton">
<input type="hidden" name="guardar" value="1">
<input type="hidden" name="listado_get" value="<?php echo $tabla_get; ?>">
&nbsp;&nbsp;&nbsp;<input type="reset" value="<?php echo LEN_ADMIN_18;?>" class="boton">
<?php
	}
?>
</div>

</form>
</div>

</td></tr></table>

</body>
</html>
<?php
	include("inc.fin.php");
?>