archivo gb.class.php
Código PHP:
//esta es la funcion a la cual quiero hacerle llegar el valor de esa variable.
function get_entries($entry,$last_entry) {
// $ valor es la variable que recibe por metodo post
$valor = (isset($_POST['valor']));
global $GB_UPLOAD, $GB_PG;
$entry = intval($entry);
$last_entry = intval($last_entry);
$img = new gb_image();
$img->set_border_size($this->db->VARS["img_width"], $this->db->VARS["img_height"]);
$LANG = &$this->db->LANG;
$id = $this->total-$entry;
$HOST = '';
$COMMENT = '';
$GB_ENTRIES = '';
$i=0;
$template['entry'] = $this->template->get_template($this->db->GB_TPL['entry']);
$template['com'] = $this->template->get_template($this->db->GB_TPL['com']);
$template['url'] = $this->template->get_template($this->db->GB_TPL['url']);
$template['icq'] = $this->template->get_template($this->db->GB_TPL['icq']);
$template['aim'] = $this->template->get_template($this->db->GB_TPL['aim']);
$template['email'] = $this->template->get_template($this->db->GB_TPL['email']);
$template['image'] = $this->template->get_template($this->db->GB_TPL['image']);
$result = $this->db->query("select x.*, y.p_filename, y.width, y.height from ".$this->db->table['data']." x left join ".$this->db->table['pics']." y on
// se supone $valor es el valor que recibe desde mi formulario por metodo post
// pero no lo recibe...
(x.id=y.msg_id and y.book_id=2 )
where x.type='$valor' order by x.id desc limit $entry, $last_entry"
);
while ($row = $this->db->fetch_array($result)) {
$row['email2'] = "";
$DATE = $this->db->DateFormat($row['date']);
$MESSAGE = nl2br($row['comment']);
if ($row['p_filename'] && ereg("^img-",$row['p_filename'])) {
if (file_exists("$this->path/$GB_UPLOAD/t_$row[p_filename]")) {
$row['p_filename'] = "t_$row[p_filename]";
}
$new_img_size = $img->get_img_size_format($row['width'], $row['height']);
eval("\$USER_PIC = \"".$template['image']."\";");
} else {
$USER_PIC = '';
}
if ($this->db->VARS["smilies"] == 1) {
$MESSAGE = $this->db->emotion($MESSAGE);
}
if (!$row['location']) {
$row['location'] = "-";
}
$bgcolor = ($i % 2) ? $this->db->VARS["tb_color_2"] : $this->db->VARS["tb_color_1"];
$i++;
if ($row['url']) {
eval("\$URL = \"".$template['url']."\";");
} else {
$URL = '';
}
if ($row['icq'] && $this->db->VARS["allow_icq"]==1) {
eval("\$ICQ = \"".$template['icq']."\";");
} else {
$ICQ = '';
}
if ($row['aim'] && $this->db->VARS["allow_aim"]==1) {
eval("\$AIM = \"".$template['aim']."\";");
} else {
$AIM = '';
}
if ($row['email']) {
/* E-mail Hack */
$row['email2'] = str_replace("@", "(at)", $row['email']);
$row['email2'] = str_replace(".", "(dot)", $row['email2']);
$row['email'] = "javascript:getEmail('".$this->db->encryptEmail("mailto:".$row['email'])."')";
eval("\$EMAIL = \"".$template['email']."\";");
} else {
$EMAIL = '';
}
if ($this->db->VARS["allow_gender"]==1) {
$GENDER = ($row['gender']=="f") ? " <img src=\"$GB_PG[base_url]/img/female.gif\" width=\"12\" height=\"12\">" : " <img src=\"$GB_PG[base_url]/img/male.gif\" width=\"12\" height=\"12\">";
} else {
$GENDER = '';
}
if ($this->db->VARS["show_ip"] == 1) {
$hostname = ( eregi("^[-a-z_]+", $row['host']) ) ? "Host" : "IP";
$HOST = "$hostname: $row[host]\n";
}
$this->db->query("select * from ".$this->db->table['com']." where id='$row[id]' order by com_id asc");
while ($com = $this->db->fetch_array($this->db->result)) {
$com['comments'] = nl2br($com['comments']);
eval("\$COMMENT .= \"".$template['com']."\";");
}
$GB_COMMENT = (IS_MODULE && eregi("\?",$GB_PG["comment"])) ? "$GB_PG[comment]&gb_id=$row[id]" : "$GB_PG[comment]?gb_id=$row[id]";
eval("\$GB_ENTRIES .= \"".$template['entry']."\";");
$COMMENT = "";
$id--;
}
$TPL['GB_ENTRIES'] = $GB_ENTRIES;
return $TPL;
}
}
?>
Es decir Index.php incluye a gb.class.php que es la que esta arriba
Index.php
He recortado partes no necesarias del codigo dejando solo las que van a trabajar.
Código PHP:
if (IS_MODULE) {
if (!eregi("modules.php", $_SERVER['PHP_SELF'])) {
die ("You can't access this file directly...");
}
$ModName = basename(dirname( __FILE__ ));
ob_start();
include("header.php");
$GB_PG["base_url"] .= "/modules/$ModName";
$GB_SELF = basename($_SERVER['PHP_SELF']);
$GB_PG["index"] = "$GB_SELF?op=modload&name=$ModName&file=index";
$GB_PG["admin"] = "$GB_SELF?op=modload&name=$ModName&file=index&agbook=admin";
$GB_PG["comment"] = "$GB_SELF?op=modload&name=$ModName&file=index&agbook=comment";
$GB_PG["addentry"] = "$GB_SELF?op=modload&name=$ModName&file=index&agbook=addentry";
if (!isset($agbook)) {
$agbook = '';
}
switch ($agbook) {
case "addentry":
include_once $include_path."/lib/vars.class.php";
include_once $include_path."/lib/add.class.php";
include_once $include_path."/lib/phrase.class.php";
$gb_post = new addentry($include_path);
if (isset($_POST["gb_action"])) {
$gb_post->type = (isset($_POST["gb_type"])) ? $_POST["gb_type"] : '';
$gb_post->name = (isset($_POST["gb_name"])) ? $_POST["gb_name"] : '';
$gb_post->email = (isset($_POST["gb_email"])) ? $_POST["gb_email"] : '';
$gb_post->url = (isset($_POST["gb_url"])) ? $_POST["gb_url"] : '';
$gb_post->comment = (isset($_POST["gb_comment"])) ? $_POST["gb_comment"] : '';
$gb_post->location = (isset($_POST["gb_location"])) ? $_POST["gb_location"] : '';
$gb_post->icq = (isset($_POST["gb_icq"])) ? $_POST["gb_icq"] : 0;
$gb_post->aim = (isset($_POST["gb_aim"])) ? $_POST["gb_aim"] : '';
$gb_post->gender = (isset($_POST["gb_gender"])) ? $_POST["gb_gender"] : '';
$gb_post->userfile = (isset($_FILES["userfile"]["tmp_name"]) && $_FILES["userfile"]["tmp_name"] != "") ? $_FILES : '';
$gb_post->user_img = (isset($_POST["gb_user_img"])) ? $_POST["gb_user_img"] : '';
$gb_post->preview = (isset($_POST["gb_preview"])) ? 1 : 0;
$gb_post->private = (isset($_POST["gb_private"])) ? 1 : 0;
$gb_post->token = (isset($_POST["gb_token"])) ? $_POST["gb_token"] : '';
$gb_post->gb_captcha = (isset($_POST["gb_captcha"])) ? $_POST["gb_captcha"] : '';
echo $gb_post->process($_POST["gb_action"]);
} else {
echo $gb_post->process();
}
$gb_post->db->close_db();
break;
default:
include_once $include_path."/lib/vars.class.php";
include_once $include_path."/lib/gb.class.php";
$gb = new guestbook($include_path);
$entry = (isset($_GET["entry"])) ? $_GET["entry"] : 0;
$entry = (isset($_POST["entry"])) ? $_POST["entry"] : $entry;
echo $gb->show_entries(intval($entry));
$gb->db->close_db();
}
ob_end_flush();
$base_path = dirname(dirname($include_path));
chdir("$base_path");
include("$base_path/footer.php");
} else {
include_once $include_path."/lib/vars.class.php";
include_once $include_path."/lib/gb.class.php";
$gb = new guestbook($include_path);
$entry = (isset($_GET["entry"])) ? $_GET["entry"] : 0;
$entry = (isset($_POST["entry"])) ? $_POST["entry"] : $entry;
echo $gb->show_entries(intval($entry));
}
?>
Código HTML:
//y este es mi formulario <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Documento sin título</title> </head> <body> <p>Select Type </p> <form id="form1" name="form1" method="post" action="index.php"> <label> <select name="valor" size="1" id="valor"> <option value="false">Please Select</option> <option value="0">0</option> <option value="2">2</option> </select> </label> <p> <label> <input type="submit" name="Submit" value="Enviar" /> </label> </p> </form> <p> </p> </body> </html>
Muchas gracias
A. Acosta