f= parameter being a file name");
if (($j1=strpos($_SERVER['SCRIPT_FILENAME'],'/vhosts/'))!==FALSE) {
$vhroot=substr($_SERVER['SCRIPT_FILENAME'],0,
$j2=strpos($_SERVER['SCRIPT_FILENAME'],'/',$j1+9)+1);
$patherr="
The PHP processor at UKCheapest has a weird querk: it blows with a message of
\"you don't have permission ...\" if there is ../../ anywhere in the request string.
So the filename must be specified relative to the root of the virtual host.
Thus for this script itself you would specify: f=". substr($_SERVER['SCRIPT_FILENAME'],$j2) .
"
\n";
}
$filnam=(!$j1 ? $_REQUEST['f'] : substr($_SERVER['SCRIPT_FILENAME'],0,$j2) . $_REQUEST['f'] );
$stat1=stat($filnam);
if (!$stat1)
exit("{$patherr}$filnam : not found
\n".
"you may add &rev for reverse action");
# echo "
". var_export($stat1,true); $_g['in']=file($filnam,FILE_IGNORE_NEW_LINES); $_g['in'][]= ""; $newf=implode((substr($_SERVER['OS'],0,3)=='Win') != isset($_REQUEST['rev']) ? "\r\n" : "\n",$_g['in']); $ns=file_put_contents($filnam,$newf); touch($filnam,$stat1['mtime']); # but stat($filnam) does not change ! at least as far as 'size' goes echo "$filnam : ". ($ns ? ($ns==$stat1['size'] ? "unchanged" : "{$stat1['size']} → {$ns} bytes") : "no action - probably write protected"); ?>