Foros del Web » Programando para Internet » PHP »

Se borra la variable

Estas en el tema de Se borra la variable en el foro de PHP en Foros del Web. hola, tengo el siguiente codigo se trata de un administrador de contenidos , el problema se me presenta en el siguiente archivo, donde al presionar ...
  #1 (permalink)  
Antiguo 05/03/2009, 05:07
 
Fecha de Ingreso: marzo-2009
Mensajes: 1
Antigüedad: 15 años, 8 meses
Puntos: 0
Se borra la variable

hola, tengo el siguiente codigo
se trata de un administrador de contenidos , el problema se me presenta en el siguiente archivo, donde al presionar guardar no logro que me tome la variable chicas
desde ya agradezco mucho la colaboracion

page_pictures.php
Código:
<?php
require dirname(__FILE__).'/includes/functions.php';

$folder = $_GET["folder"];
$name = $_GET["name"];

//this var is used in header.php
//used in the javascript for dragging the <li> tags
$list = "pic";

require dirname(__FILE__).'/includes/header.php';

// get categorias/menu.xml file
$p =& new xmlParser();
$p->parse('../' . $folder . '/fotos.xml');
$pictures = isset($p->output[0]['child']) ? $p->output[0]['child'] : array();

?>
 		<h1>Pictures for <?php echo $name; ?> gallery</h1>
	  	<hr />
		<br>
		<form name="form_save" action="save_pictures.php" method="post" onsubmit="return save_pics('pic_list');">
		<input type="hidden" name="folder" value="<?php echo $folder; ?>">
		<input type="hidden" name="gallery" value="<?php echo $name; ?>">
		<input type="hidden" name="pic_names" value="">
		<input type="hidden" name="pic_chicas" value="">
        <input type="hidden" name="pic_descs" value="">
		<input type="hidden" name="pic_deletes" value="">
		<p><input type="submit" value="Save Changes/Delete Selected"/></p>
		<ul id="pic_list" class="sortable boxy">
			<?php print_pictures($pictures, $folder); ?>
		</ul>
		<p><input type="submit" value="Save Changes/Delete Selected"/></p>
		</form>
		<script language="JavaScript" type="text/javascript"><!--
			<?php print_pic_vars($pictures); ?>
		//-->
		</script>
<?php

require dirname(__FILE__).'/includes/footer.php';

function print_pictures($pics, $folder){
	$pics_html = "";
	$count = 0;
	
	$template = '<li id="pic_%NUM%">
				<div class="handle2"></div>
				<table class="text">
					<tr>
						<td valign="middle" class="pic_box"><img src="../../%CHICA%" border="0"></td>
						<td class="pic_content" valign="top">
							<span class="pic_name">%NAME%</span><input type="checkbox" name="delete_%NUM%">delete<br>
							<textarea name="desc_%NUM%" class="pic_desc" onBlur="this.className=\'pic_desc\'" onFocus="this.className=\'pic_desc_on\'">%DESC%</textarea>
						</td>
					</tr>
				</table>
			</li>';
	//array of vars used in template
	$pic_vars = array("%NUM%", "%NAME%","%CHICA%", "%FOLDER%", "%DESC%");
	
	foreach ($pics as $pic){
		//array of replacement values for template		
		$pic_values = array($count+1, $pics[$count]['attrs']['LOCATION'], $pics[$count]['attrs']['CHICA'], $folder , $pics[$count]['attrs']['DESC']);
		$pics_html .= str_replace($pic_vars, $pic_values, $template);
		
		++$count;
	}
	echo $pics_html;
}

function print_pic_vars($pics){
	$count = 1;
	foreach ($pics as $pic){
		echo("var pic_$count = \"" . $pic['attrs']['LOCATION'] . "\";\r\n");
	    //echo("var pic_chicas_$count = \"" . $pic['attrs']['CHICA'] . "\";\r\n");
		//var folder_3 = "balh";
		++$count;
	}
}
?>
el archivo que guarda es save_pictures.php
Código:
<?php
//check user
require dirname(__FILE__).'/includes/check_user.php';

require dirname(__FILE__).'/includes/functions.php';

//get the post variables
$deletes = explode(",",$_POST['pic_deletes']);
$names = explode(",",$_POST['pic_names']);
$chicas = explode(",",$_POST['pic_chicas']);
$descs = explode("<break>",$_POST['pic_descs']);
$folder = $_POST['folder'];
$gallery = $_POST['gallery'];
// -------delete any pictures that need it-------
if($deletes[0] != ""){
	foreach($deletes as $delete){
		//get the server path to the picture to delete
		$pic = realpath("../" . $folder. "/" . $delete);
		$pic_thumb = realpath("../" . $folder. "/thumbs/" . $delete);
		//delete picture and its thumbnail
		if(file_exists($pic)){
			unlink($pic);
		} 
		if(file_exists($pic_thumb)){
			unlink($pic_thumb);
		}
	}
}


// ------  save new fotos.xml -------

$filename = realpath("../" . $folder . "/fotos.xml");

//make xml for new fotos.xml
$xml = "<pictures>\n";

if($names[0] != ""){
	foreach($names as $key => $value){
		$xml .= "\t<image location=\"". $value . "\" chica=\"". $chicas[$key]. "\" desc=\"" . stripslashes($descs[$key]) . "\" />\n";
	}
}

$xml .= "</pictures>";

// make sure fotos.xml exists and is writable
if (is_writable($filename)) {
	//open the file
   if (!$handle = fopen($filename, 'wb')) {
         error("Cannot open file");
         exit;
   }

   // writing new xml
   if (fwrite($handle, $xml) === FALSE) {
       error("Cannot write to file");
       exit;
   }
   
   fclose($handle);

} else {
   error("fotos.xml does not seem to be writable. Check that you have changed its CHMOD settings to 777.");
}

//go back to picture admin for this gallery
header("Location:page_pictures.php?name=$gallery&folder=$folder");
?>
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 21:16.