Slumpack
05-26-2004, 07:03 AM
This is what i have, what it does is saving a bunch of text from a textbox into .txt file but for some reason it doesn't work !!
i tried and it work on my local machine and it work on my other webserver (with PHP 4.3.6 -- all of the server) could it be the PHP configuration ?
<?
$vars = array('ref', 'body');
$varstr = '';
foreach ($vars as $var) {
if(isset($_POST[$var]))
{
*$vvar=$_POST[$var];
*$$var= $vvar;
}
}
if(!isset($ref) or !isset($body) or !file_exists('../'.$ref)) die('fail');
if(substr($ref,-1)!='/') {
$path_parts = pathinfo($ref);
$dir=$path_parts["dirname"];
$file=$path_parts["basename"];
$dfile='../'.$dir.'/descr.txt';
}
else {
$dir=$ref;
$file='__dir';
$dfile='../'.$dir.'descr.txt';
}
if($lines = @file($dfile)) {
foreach($lines as $str) {
* *list($key,$var)= explode("\t", $str);
* *$data[$key]=rtrim($var,"\r\n");
}
}
*$data [$file]=urlencode(stripslashes($body));
*asort($data);
*if($fp=@fopen($dfile,'w')){
* foreach($data as $key=>$val) {
* *if($val!='') fputs($fp,$key."\t".$val."\r\n") or die('fail');
* }
* echo ('Save was successfull');
*} else echo ("Error: Can't create file");
?>
Thanks
i tried and it work on my local machine and it work on my other webserver (with PHP 4.3.6 -- all of the server) could it be the PHP configuration ?
<?
$vars = array('ref', 'body');
$varstr = '';
foreach ($vars as $var) {
if(isset($_POST[$var]))
{
*$vvar=$_POST[$var];
*$$var= $vvar;
}
}
if(!isset($ref) or !isset($body) or !file_exists('../'.$ref)) die('fail');
if(substr($ref,-1)!='/') {
$path_parts = pathinfo($ref);
$dir=$path_parts["dirname"];
$file=$path_parts["basename"];
$dfile='../'.$dir.'/descr.txt';
}
else {
$dir=$ref;
$file='__dir';
$dfile='../'.$dir.'descr.txt';
}
if($lines = @file($dfile)) {
foreach($lines as $str) {
* *list($key,$var)= explode("\t", $str);
* *$data[$key]=rtrim($var,"\r\n");
}
}
*$data [$file]=urlencode(stripslashes($body));
*asort($data);
*if($fp=@fopen($dfile,'w')){
* foreach($data as $key=>$val) {
* *if($val!='') fputs($fp,$key."\t".$val."\r\n") or die('fail');
* }
* echo ('Save was successfull');
*} else echo ("Error: Can't create file");
?>
Thanks