Foros del Web » Creando para Internet » Sistemas de gestión de contenidos »

PHP-Nuke phpMyAgenda

Estas en el tema de phpMyAgenda en el foro de Sistemas de gestión de contenidos en Foros del Web. Buen dia tengo por acá una aplicación de agenda que parece practica ademas la baje de la sourceforge sin embargo no logro instalarla. Por el ...
  #1 (permalink)  
Antiguo 18/02/2011, 16:08
Avatar de ryor310575  
Fecha de Ingreso: febrero-2011
Mensajes: 54
Antigüedad: 13 años, 2 meses
Puntos: 2
phpMyAgenda

Buen dia tengo por acá una aplicación de agenda que parece practica ademas la baje de la sourceforge sin embargo no logro instalarla. Por el momento es solo una forma que al llenarse ejecuta un Script de PHP. La cosa es que sin importar lo que haga siempre muestra la forma nunca ejecuta el Script. El if de control es "if(!isset($filled))" y no se si esa variable filled es algo de PHP. Puesto que el NAME en el IMPUT SUBMIT no tiene esa variable. Acá coloco el código aunque el código es largo la estructura me parece que es la siguiente.

Espero obtener algo de ayuda asi como espero que esta ayuda también colabore con el foro. Sigo investigando por mi cuenta.

================================================== ==
<html>
<head>
<title>phpMyAgenda Setup Script</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" href="style.css" type="text/css">
</head>

<body bgcolor="#FFFFFF" text="#000000">

<?php
if(!isset($filled)):
?>
<form>
...
...
<input type="submit" name="Submit" value="Generate configuration file and database">
</form>
<?php else :
{
...
...
}
endif;
?>
</body>
</html>

================================================== ==


================================================== ==
<html>
<head>
<title>phpMyAgenda Setup Script</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" href="style.css" type="text/css">
</head>

<body bgcolor="#FFFFFF" text="#000000">
<p><font face="Verdana, Arial, Helvetica, sans-serif"><img src="images/logo25.gif" width="85" height="49" align="absmiddle"><font size="5"><b><font color="#336699">phpMyAgenda
</font><font face="Verdana, Arial, Helvetica, sans-serif"><font size="5"><b><font color="#336699">Setup</font></b></font></font></b></font></font></p>

<?php
if(!isset($filled)):
?>
<p><font face="Verdana, Arial, Helvetica, sans-serif" size="2">Please fill the
following form to configure phpmyagenda</font></p>

<form name="form1" method="post" action="">
<input type="hidden" name="filled" value="0">
<table width="100%" border="0">
<tr>
<td colspan="2" height="2">
<p class="calendar_selday">General Setup</p>
</td>
</tr>
<tr>
<td width="28%" class="tdsingletitle2">WWW root : </td>
<td width="72%" class="normal">
<p>
<input type="text" name="agendaroot" size="40">
<br>
<span class="result_description">This is the root url of the agenda
: http://<b>www.mysite.fr</b>/agenda/install.php3<br>
</span></p>
</td>
</tr>
<tr>
<td width="28%" class="tdsingletitle2" height="40">Agenda installation folder
: </td>
<td width="72%" class="normal" height="40">
<p class="result_description">
<input type="text" name="wwwroot" size="40">
<br>
This is the folder in which you have installed phpmyagenda : http://www.mysite.fr/<b>agenda</b....php3<br>
</p>
</td>
</tr>
<tr>
<td width="28%" class="tdsingletitle2">Default language : </td>
<td width="72%">
<select name="defaultlang">
<option value="1">Fran&ccedil;ais</option>
<option value="2">English</option>
<option value="3">Espanol</option>
<option value="4">German</option>
<option value="5">Slovene</option>
</select>
</td>
</tr>
<tr>
<td colspan="2" height="10">
<p class="calendar_selday">Database Setup</p>
</td>
</tr>
<tr>
<td width="28%" class="tdsingletitle2">Database host : </td>
<td width="72%" class="normal">
<p>
<input type="text" name="dbhost" size="40">
<br>
<span class="result_description">This is the url of your mysql server</span></p>
</td>
</tr>
<tr>
<td width="28%" class="tdsingletitle2">Database name : </td>
<td width="72%" class="normal">
<p>
<input type="text" name="dbname" size="40" value="phpmyagenda">
<br>
<span class="result_description">This is the name of the database that
will be created</span></p>
</td>
</tr>
<tr>
<td width="28%" class="tdsingletitle2">Database user : </td>
<td width="72%" class="normal">
<p>
<input type="text" name="dbuser" size="40">
<br>
<span class="result_description">This is the name you use to connect
to the database</span></p>
</td>
</tr>
<tr>
<td width="28%" class="tdsingletitle2">Database pass : </td>
<td width="72%" class="normal">
<p>
<input type="password" name="dbpass" size="40">
<br>
<span class="result_description">This is the password you use to connect
to the database</span></p>
</td>
</tr>
</table>
<p align="center">
<input type="submit" name="Submit" value="Generate configuration file and database">
</p>
</form>
<?php else :
{
$file_tpl = "application.tpl";
$tpl = fopen($file_tpl , "r");
if($tpl == false)
{
echo "Unable to open file '$file_tpl'. Check that this file is present and re-launch the install script";
die();
}
$file_appli = "application.php3";
$appli = fopen($file_appli , "w+");
if($appli == false)
{
echo "Unable to create file '$file_appli'. Unable to continue the installation.";
die();
}
$content = fread($tpl , filesize($file_tpl));
echo "<span class='normal'>Setting folders...ok</span><br>";
$content = eregi_replace("{WWWROOT}" , $wwwroot , $content);
$content = eregi_replace("{AGENDAROOT}" , $agendaroot , $content);
echo "<span class='normal'>Setting default language...ok</span><br>";
$content = eregi_replace("{DEFAULTLANG}" , $defaultlang , $content);
echo "<span class='normal'>Setting database information...ok</span><br>";
$content = eregi_replace("{DBHOST}" , $dbhost , $content);
$content = eregi_replace("{DBNAME}" , $dbname , $content);
$content = eregi_replace("{DBUSER}" , $dbuser , $content);
$content = eregi_replace("{DBPASS}" , $dbpass , $content);
echo "<span class='normal'>Saving configuration...";
$result = fwrite($appli , $content);
if($result == 0)
{
echo "<br>Unable to write '$file_appli'. Setup aborted. phpMyAgenda is not properly installed.</span><br>";
die();
}
else
echo ("ok</span><br>");
echo "<span class='normal'>Connecting to database...";
if(!$dbh = @mysql_pconnect($dbhost, $dbuser, $dbpass))
{
echo "<b>Can't connect to $dbhost as $dbuser</b>. Setup aborted. phpMyAgenda is not properly installed.</span>";
die();
}
else
echo "ok</span><br>";
echo "<span class='normal'>Creating database $dbname...";
if(!@mysql_query("CREATE DATABASE ".$dbname))
{
if(!@mysql_select_db($dbname))
{
echo "<b>Can't create database $dbname</b>. Setup aborted. phpMyAgenda is not properly installed.</span>";
die();
}
else
echo "ok</span><br>";
}
else
echo "ok</span><br>";
echo "<span class='normal'>Selecting database $dbname...";
if(!@mysql_select_db($dbname))
{
echo "<b>Can't select database $dbname</b>. Setup aborted. phpMyAgenda is not properly installed.</span>";
die();
}
else
echo "ok</span><br>";

echo "<span class='normal'>Creating tables and predefined accounts...";
// read dump from phpmyadmin
/* $Id: db_readdump.php3,v 1.12 1999/11/24 11:20:37 tobias Exp $ */
@set_time_limit(10000);
function split_sql($sql)
{
$sql = trim($sql);
$buffer = array();
$ret = array();
$in_string = false;

for($i=0; $i<strlen($sql); $i++)
{
if($sql[$i] == ";" && !$in_string)
{
$ret[] = substr($sql, 0, $i);
$sql = substr($sql, $i + 1);
$i = 0;
}

if($in_string && ($sql[$i] == $in_string) && $buffer[0] != "\\")
{
$in_string = false;
}
elseif(!$in_string && ($sql[$i] == "\"" || $sql[$i] == "'") && $buffer[0] != "\\")
{
$in_string = $sql[$i];
}
if(isset($buffer[1]))
{
$buffer[0] = $buffer[1];
}
$buffer[1] = $sql[$i];
}

if (!empty($sql))
{
$ret[] = $sql;
}

return($ret);
}

$sql_file = "phpmyagenda.sql";
if(!empty($sql_file) && $sql_file != "none")
{
$sql_query = fread(fopen($sql_file, "r"), filesize($sql_file));
}

$pieces = split_sql($sql_query);

if (count($pieces) == 1)
{
$sql_query = trim($pieces[0]);
include ("sql.php3");
exit;
}

for ($i=0; $i<count($pieces); $i++)
{
$pieces[$i] = stripslashes(trim($pieces[$i]));
$result = mysql_query ($pieces[$i]) or die();
}
}
echo "ok</span><br>";
echo "<span class='normal'>Adding Administrator account : login = <b>admin</b>, pass = <b>pass</b>... ok</span></br>";
echo "<span class='normal'>Adding Write enable account : login = <b>write</b>, pass = <b>write</b>... ok</span></br>";
echo "<span class='normal'>Adding Read only account : login = <b>read</b>, pass = <b>read</b>... ok</span></br>";
echo "<br><span class='tdsingletitle'>Congratulation, setup has completed successfully.<br></span>";
echo "<br><span class='tdsingletitle2'>Click on the following links to start using phpMyAgenda :<br>";
echo "<br><span class='tdsingletitle2'><a href='agenda.php3'>Visitor interface</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href='./admin/index.php3'>Administrator interface</a><br>";
endif;
?>


<p>&nbsp; </p>
</body>
</html>

================================================== ====
  #2 (permalink)  
Antiguo 23/02/2011, 13:45
Avatar de ryor310575  
Fecha de Ingreso: febrero-2011
Mensajes: 54
Antigüedad: 13 años, 2 meses
Puntos: 2
Respuesta: phpMyAgenda

Si revise y probe con un método adicional que se refiere a 'action="<?php echo $_SERVER['PHP_SELF'] ?>" ' eso me coloca a que el script a ejecutar dea la misma pagina. También leí sobre $_POST, este guarda todas las variables que se colocan en el formulario.

Por lo que entiendo la dinámica de este método es que:

* Al verificar con if(!$_POST['submitted']) if(!$submitted) o if(!isset(submitted)) la pagina se muestra al menos una vez pues la variable debe estar vacía al no haberse mostrado la forma.
* Una vez mostrada la forma la variable contendrá un valor y el IF dara un valor falso cuando se presiona el <input type="submit">, esta vez entonces se ejecutara el script que indique la forma.

Mi problema es que aun antes de darle a submit el la variable tiene un valor eso lo verifique con un echo antes de ejecutar el IF. no importa lo que haga el valor no cambia. No logro dar con el problema, voy a revisar si es algo que tenga que ver con mi servidor.
Para efectos de este post usare un nuevo prrograma colo referencia dado que el anterior es muy largo. El código del archivo 1 es el codigo "unido" forma mas código PHP. El código 2 es el código con solo el formulario y el código 3 es el codigo con solo el script.

CODIGO1
<html>
<head><basefont face="Arial"></head>
<body>
<h2>Address Book</h2>
<?php
// form not yet submitted
// display form
echo $_POST['submit'];
if (!$_POST['submit'])
{
?>
<form action="<?php echo $_SERVER['PHP_SELF'] ?>" method="POST">
<p>Nombre: <input type="text" name="name" /></p>
<p>Edad: <input type="text" name="age" /></p>
<input type="submit" id="submit" name="submit" value="Add">
</form>
<?php
}
else
{
// form submitted
// prepare to insert data
// database access parameters
echo $_SERVER['HTTP_USER_AGENT'] . "<br>";
echo $_SERVER['SERVER_SOFTWARE'] . "<br>";
echo $_SERVER['PHP_SELF'] . "<br>";
echo "Hi " . htmlspecialchars($_POST['name']) . "You are " (int)$_POST['age'] . " years old.<br>";
}
?>
</body>
</html>




CODIGO 2

<html><body>
<form method="POST" action"tst22.php">
<p>Nombre: <input type="text" name="name" /></p>
<p>Edad: <input type="text" name="age" /></p>
<input type="submit" name="submitted" value="add">
</form>
</body></html>


CODIGO 3
<?php
if($_POST['submitted'])
{
echo $_SERVER['HTTP_USER_AGENT'] . "<br>";
echo $_SERVER['SERVER_SOFTWARE'] . "<br>";
echo $_SERVER['PHP_SELF'] . "<br>";
echo "Hi " . htmlspecialchars($_POST['name']) . "You are " (int)$_POST['age'] . " years old.<br>";
}
?>
  #3 (permalink)  
Antiguo 25/02/2011, 22:19
Avatar de ryor310575  
Fecha de Ingreso: febrero-2011
Mensajes: 54
Antigüedad: 13 años, 2 meses
Puntos: 2
Respuesta: phpMyAgenda

Este tema fue solucionado, Al usar un solo archivo con la forma y el Script de PHP se le deben pasar los datos al Script según el metodo POST $_POST['variable'], y en la acción que tomará la forma de pueden hacer una de dos cosas, o dejar action="" o colocar action="<? echo $_SERVER['PHP_SELF']; ?>"

Etiquetas: php, phpmyagenda
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 04:29.