s
* why are we getting the file and calling do1image() for non-images? Apparently on web but not
on home machine
------------------------------------------------------------------------------ standard width -- */
function rps($path)
{
return str_replace('\\','/',realpath($path));
}
function is_problem_dir($path)
{
global $is_ts, $is_0s;
$pds_ts = array("/home/", "/install/", "/lib/",
"/mnt/user-store/", "/opt/", "/proc/",
"/sge62/", "/usr/", "/var/", );
$pds_0s = array("/dev/", "/etc/", "/lib/", "/opt/", "/proc/", "/sys/", );
/* Once I added detection of link entries, a full tree listing of 0sites.org
finished in a reasonable time (with an 8 Mbyte lump of HTML!),
so I have disabled the use of this array. */
$probl_dirs=false;
if ($is_ts) { $probl_dirs=$pds_ts; }
if ($is_0s && false) { $probl_dirs=$pds_0s; }
$pdi= $ans= 0;
foreach ($probl_dirs as $pd) {
$pdi++; if ($pd==$path) { $ans=$pdi; break; }
}
return $ans;
}
function is_root($path)
{
global $_g;
return !(strlen($path)>(1+2*$_g['is_dos']));
}
function one_level_down($path,$fnam)
{
return $path .(is_root($path) ? '' : '/'). $fnam;
}
// -----------------------------------
function normal_file($path,$fnam) /* if not normal, do special option for 0sites.org of a
directory which holds details of all the sites hosted there */
{
global $is_0s, $http_header;
if (!$is_0s || $path!="/etc/valiases") return true;
$uri="{$_SERVER['REQUEST_SCHEME']}://$fnam/";
$lnk="". hsc($fnam) ."";
echo "$lnk";
if (!isset($_REQUEST['0ss'])) return false;
$txt= file_get_contents("$path/$fnam");
if ($txt===false) $txt="!!! read err";
if (!strlen($txt)) $txt="!!! zero length";
echo "
". str_replace("\n"," \n",$txt);
if (!rand(0,800)) {
http_get($uri);
echo "$lnk $txt \n$http_header ";
}
return false;
}
// -----------------------------------
function do_head($titext)
{
$titext=hsc($titext);
rwhhead($titext,"","index,follow");
?>
{$_SERVER['SERVER_NAME']}: $titext\n";
}
function do_tail($wmess=false)
{
global $_g;
echo "\n";
if (isset($_REQUEST['API'])) { echo "\n\n". serialize($_g['API']); }
exit();
}
/* I am not installing this on RHaworth.com (on same host as RHaworth.net).
If I add it to the subst_able list it generates spurious file links when we view it
via RHaworth.net. But since we can view it via RHaworth.net there is little point
in supporting its own version.
*/
// -----------------------------------
function missing_check($path)
{
global $_g;
$galdes=array("","",'"640" ','"big" ');
echo " \nThis is a {$galdes[$_g['gal']['type']]}".
"directory for the ".
"".
"{$_g['gal']['title']} image gallery\n";
if ($_g['gal']['type']<3) {
echo "Files missing from this directory: \n";
$msq="select * from `{$_g['gal']['table']}` ".
"where `gal`='{$_g['gal']['code']}' and `seqno`>'#' and `width`>0 ".
"order by `frameno`";
$sres= do_query($msq);
while (($row=mysql_fetch_assoc($sres))!=false) {
if (!file_exists("$path/{$row['frameno']}.jpg")) {
echo "• {$row['frameno']} \n";
}
} /* else {
echo " Files redundant to Commons images are reported on ".
"this page \n";
# Code in gallist.php is now redundant to here. */
}
echo " \n";
}
function gal_img_check($path,$fnam,$frameno)
{
global $_g;
$msq="select `{$_g['gal']['table']}`.*, `uploads`.`filnam` from `{$_g['gal']['table']}` ".
"left join uploads on `{$_g['gal']['table']}`.`frameno`=`uploads`.`frameno` ".
"where `gal`='{$_g['gal']['code']}' and `{$_g['gal']['table']}`.`frameno`='$frameno'";
$sres= do_query($msq); $srow=mysql_fetch_assoc($sres);
$op=" | | ";
if (strlen($srow['filnam']) && $_g['gal']['type']>2) {
$op= " | redundant to Commons";
} else {
if (!mysql_num_rows($sres)) {
$op= " | new";
if (!isset($_g['imd']['takenon'])) $_g['imd']['takenon']=$_g['fmtim'];
# saves having to go to MySQL to add a sequence number for images with no EXIF data
# echo "$fnam {$_g['imd']['lat']},{$_g['imd']['long']} \n";
$_g['gal']['sqli'] .= "('{$_g['gal']['code']}','$frameno','{$_g['imd']['takenon']}','".
substr($_g['imd']['takenon'], 8,2). substr($_g['imd']['takenon'],11,2).
substr($_g['imd']['takenon'],14,2). substr($_g['imd']['takenon'],17,2).
"','{$_g['imd']['width']}','{$_g['imd']['height']}',".
(isset($_g['imd']['lat']) ?
"{$_g['imd']['lat']},{$_g['imd']['long']},1" : "null,null,0") .
"), ";
} elseif ($srow['width'] !=$_g['imd']['width'] ||
$srow['height'] !=$_g['imd']['height'] ||
($srow['takenon']!=$_g['imd']['takenon'] && isset($_g['imd']['takenon']))) {
# $_g['imd'] uses : as separator in dates
$op= " | MySQL has ". ($srow['width']!=$_g['imd']['width']
? ($srow['width']>$_g['imd']['width'] ? "bigger" : "smaller") .
" width value"
: "different date"); # '{$srow['takenon']}' '{$_g['imd']['takenon']}'");
$_g['gal']['sqla'][] = "update `{$_g['gal']['table']}` ".
"set `width` = {$_g['imd']['width']}, `height` = {$_g['imd']['height']}, ".
"`takenon` = '{$_g['imd']['takenon']}' where ".
"`frameno` = '$frameno' and `gal` = '{$_g['gal']['code']}';\n";
} elseif (isset($_g['imd']['lat']) && (!$srow['byGPS'] || !$srow['lat'])) {
$op= " | byGPS or lat/long not set";
$_g['gal']['sqla'][] = "update `{$_g['gal']['table']}` ".
"set `byGPS` = 1, `lat` = {$_g['imd']['lat']}, `long` = {$_g['imd']['long']} where ".
"`frameno` = '$frameno' and `gal` = '{$_g['gal']['code']}';\n";
} else
ll_diff_check();
}
echo $op;
}
function home_img_check($path,$fnam,$frameno)
{
global $_g;
# echo $fnam; varx($_g['imd']);
ll_diff_check();
/*
Do we need this any more? gal_img_check() does it and also sets takenon, lat/long and byGPS
$_g['gal']['sqlt'] .= "update `general` set `width` = {$_g['imd']['width']}, ".
"`height` = {$_g['imd']['height']} where `frameno` = '$frameno';\n";
*/
}
function ll_diff_check()
{
global $_g;
if (!isset($_g['imd']['lat'])) return;
$ll=array('lat'=>$_g['imd']['lat'],'long'=>$_g['imd']['long']);
if (isset($_g['prev'])) $diff=ll_diff($_g['prev'],$ll);
echo " | {$_g['imd']['lat']}/{$_g['imd']['long']} $diff";
$_g['prev']=$ll;
}
function ll_diff($ll1,$ll2)
{
global $_g;
$diffa=$ll1['lat'] -$ll2['lat'];
$diffo=$ll1['long']-$ll2['long']*cos(($ll1['lat']+$ll2['lat'])/2);
return round(10000000/90*sqrt($diffa*$diffa+$diffo*diffo));
}
// -----------------------------------
# href='file:///$pthnam' # don't work ++++ explane
// PTree - from circa 2011 April
function showp_link($pthnam,$fnam)
{
global $_g;
if (stripos(" php htm html ",substr($fnam,strrpos($fnam,".")+1))) {
echo "\n | show";
}
if (stripos($_g['text_exts'],substr($fnam,strrpos($fnam,".")+1)) && isset($_REQUEST['crlf'])) {
$txt=file_get_contents($pthnam);
if (strpos($txt,"\n")!==false) { # file contains an LF
if (strcasecmp(substr($fnam,-4),".php")) { echo " | "; }
echo "\n | ". ((strpos($txt,"\r\n")!==false) == $_g['is_dos'] ? "" : "crlf!");
}
}
}
function dir1dir($path,$fnam="",$lvl=0)
{
global $_g, $img_f; # $_g['gtsz'] is just a check on the logic
$tree=array('fct'=>0, 'rfct'=>0, 'tsz'=>0, 'rtsz'=>0, 'nrcl'=>0,);
# to prevent error_log on UKC02 growing massive
$pthnam=(strlen($fnam) ? one_level_down($path,$fnam) : $path);
$_g['rpl'][$lvl]=strlen($pthnam)+(!is_root($pthnam));
if ($isd=is_dir($pthnam)) {
if ($pthnam==($lnknm=rps($pthnam))) { unset($lnknm); $dir=scandir($pthnam); }
} else {
$dir=false;
}
if (!$dir && !$lvl) return; # do nothing if invalid dir
$norecur = ($lvl<2 ? false : is_problem_dir(substr($pthnam,0,$_g['rpl'][$lvl-2])));
# ^^^^^^^^^^^^^^ just to avoid warning
foreach( $dir as $dn => $di ) {
# echo "$di ";
if ($di!='.' && $di!='..') {
if ($norecur) $tree['nrcl']=1; # don't set until we find something we could recurse
elseif (!$lvl || $_REQUEST['a']!='s') {
$rtree=dir1dir($pthnam,$di,$lvl+1);
$tree['fct']++;
$tree['rfct'] += $rtree['rfct'];
$tree['tsz'] += $rtree['sz'];
$tree['rtsz'] += $rtree['rtsz'];
if ($rtree['nrcl']) $tree['nrcl']=$rtree['nrcl']+1;
}
}
}
$tree['rfct'] += $tree['fct'];
$tree['rtsz'] += $tree['tsz'];
$stat=stat($pthnam); $stat['is_dir']=$isd;
$_g['imd']=array(); # unset($_g['imd']); would create a null value which would blow array_merge()
# echo "$pthnam is_dir = ". var_export(is_dir($pthnam),true) .
# "\nstat = ". var_export(stat($pthnam),true) ." \n";
# $bs= ceil($stat['size']/$_g['blksize']);
$bs = $stat['blocks']*512/$_g['blksize'];
if ($_g['is_dos']) {
if ($isd) { $bs=2; $stat['size']=-1; } # ++++ kludges
else { $bs= ceil($stat['size']/$_g['blksize']); }
}
$tree['sz']=$bs;
$_g['gtsz'] += $bs;
if ($lvl<2 || isset($_REQUEST['test'])) {
if (!$lvl)
echo " | \n";
$_g['fmtim']=date("Y-m-d H:i:s",$stat['mtime']);
echo " | ". ($stat['size']>=0 ? number_format($stat['size']) : "") .
" | $bs | {$_g['fmtim']}\n | ";
if (isset($lnknm)) {
echo hsc($fnam) .
" | → $lnknm";
} elseif (($isd && !$dir) || !$stat) {
# inaccessible directories on 110mb return is_dir = false and stat = false
echo hsc($fnam) .
" | not accessible";
} elseif ($isd) {
echo (!strlen($fnam) ? "this directory" :
"". hsc($fnam) ."").
" | ". number_format($tree['fct']) .
" | ". number_format($tree['tsz']);
if ($tree['nrcl']==2) {
echo " | not recursed";
} else {
echo " | ". number_format($tree['rfct']) .
" | ". number_format($tree['rtsz']) ."";
}
if ($tree['nrcl']>2) echo " | {$tree['nrcl']}";
} else {
# is a file
$is_jpg=(($dotpos=stripos($fnam,'.jpg'))!==false) || (stripos($fnam,'.jpeg')!==false);
$snam=str_ireplace($_g['subst_able'],$_g['subst_itut'],$pthnam);
# if ($pthnam != ($snam=str_replace($_g['subst_able'],$_g['subst_itut'],$pthnam))
# || $is_jpg ) { # **x** see mods outstanding
if ($stat['size']<20971520) $img_f=file_get_contents("$path/$fnam");
/* also needed for CRLF and sha1 tests. Big files blow the memory allocation but
the only ones we have are in the logs directory.
Biggest useful file is a 19M byte zip */
$stat['sz_lf'] =strlen($img_lf=str_replace("\r\n","\n",$img_f));
$stat['sz_crlf']=strlen( str_replace("\n", "\r\n",$img_lf));
# will only be used for text files but no harm in doing it for all
$stat['sha1'] = sha1($img_lf);
# provides meaningful data for all file types
echo ( $snam==$pthnam ? hsc($fnam) :
"". hsc($fnam) ."\n" );
if ($is_jpg) {
do1image(); # in jpgstudy.php
echo " | x".
(isset($_REQUEST['rhcs']) ? "\r\nmove ". hsc($fnam) ." ../1\r\n" : "");
if (isset($_REQUEST['posp'])) {
$newpr=(int)(($stat['mtime']-$_REQUEST['posp'])/10);
if ($newpr>=100 && $newpr<=999) {
rename("$path/$fnam", "$path/$newpr". substr($fnam,3));
echo " | ren: $newpr";
} else {
$posp_lo=$stat['mtime']-9999;
if ($posp_lo>$_g['pmin']) $_g['pmin']=$posp_lo;
$posp_hi=$stat['mtime']-1000;
if ($posp_hi<$_g['pmax']) $_g['pmax']=$posp_hi;
echo " | ". (10*$newpr) ." | | **";
}
}
echo " | ".
sprintf("%4d×%4d",$_g['imd']['width'],$_g['imd']['height']) .
" {$_g['imd']['orient']}".
(($_g['imd']['width']%8)|($_g['imd']['height']%8) ? " !m8" : "");
if (isset($_g['imd']['takenon'])) {
# $stat['mtime'] goes in 2 second increments. Time setting in dirutl.c / .exe
# uses: int setftime(int handle, struct ftime* ftimep) and rounds down.
# If you submit an odd value of time to touch() it rounds up!
# Hence the adjustment below
$newtim=strtotime($_g['imd']['takenon']); if ($newtim % 2) $newtim--;
if ($newtim!=$stat['mtime']) {
$savmo=$stat['mode'];
if ($_g['is_dos'] && !($stat['mode']&2)) chmod($pthnam,0666);
echo " | → {$_g['imd']['takenon']}".
(touch($pthnam,$newtim) ? "" : " failed");
if ($_g['is_dos']) chmod($pthnam,$savmo);
}
} else {
echo " | no taken-on time";
# echo " | ".strtotime($_g['imd']['takenon'])." {$stat['mtime']}";
}
if (strlen($_g['gal']['code'])) {
gal_img_check($path,$fnam,substr($fnam,0,$dotpos));
} elseif ($_g['is_dos']) {
home_img_check($path,$fnam,substr($fnam,0,$dotpos));
}
}
showp_link($pthnam,$fnam);
}
$_g['API'][]=array_merge(array('name'=>$fnam),$stat,$_g['imd']);
if ($bs!=floor($bs)) echo " | !!!";
# on 0sites.org /etc/grub.conf somehow returns a sz of 0.75 !
echo "\n";
}
if (strpos($fnam,"pureftpd-uplo") && isset($_REQUEST['pfd'])) {
$newnam="$path/pfu". substr($fnam,34);
echo "rename of $pthnam → \n$newnam".
(rename($pthnam,$newnam) ? " OK" : " failed") ." \n";
# attempt to tidy RHaworth.com
}
if (!$lvl && $tree['rtsz']+$bs != $_g['gtsz'])
echo "\$tree['rtsz'] {$tree['rtsz']} + $bs != \$_g['gtsz'] {$_g['gtsz']} \n";
# $bs because "this directory" is not included in 'rtsz'
return $tree;
}
function ptree($path)
{
global $_g;
# scandir('.'); # and '/www/com/r/h/a/w/o/r/t/h/rhaworth/htdocs/' for some reason don't work
# shell_exec("ls -sAl $curd"); # has been disabled
$titext="directory of $path";
do_head($titext);
if (strlen($_g['gal']['code'])) missing_check($path);
echo "Directory names link to listing in this format. \n".
"Recursed blocks figures link to tree view. \n";
echo "\n".
" | directory".
" | recursed\n".
" | bytes | blocks | | ".
" | items | blocks | items | blocks\n";
if (!is_root($path)) {
echo " | | ".
"parent directory\n";
}
echo " | | this directory".
" | tree view\n";
$_g['pmax']=99999999999;
# varx ($_g);
dir1dir($path);
$blankrow=" | \n";
echo "$blankrow".
" | | 1 | block = {$_g['blksize']} bytes\n";
if (isset($_g['gal']['sqli'])) {
$_g['gal']['sqla'][]= "insert into `{$_g['gal']['table']}` ".
"(`gal`, `frameno`, `takenon`, `seqno`, `width`, `height`, `lat`, `long`,`byGPS`) values ".
substr($_g['gal']['sqli'],0,strlen($_g['gal']['sqli'])-2) .";\n";
}
if (count($_g['gal']['sqla'])) {
# varx($_g['gal']['sqla']);
echo "$blankrow | | | | ";
if (!isset($_REQUEST['update'])) {
echo "Update table";
} else {
foreach ($_g['gal']['sqla'] as $sql) { do_query($sql); }
echo "Table updated";
}
echo " with details of changes.\n";
}
if (isset($_g['pmin'])) {
$p="posp";
echo "$blankrow | ".
"Warning. Only use $p if you are prepared for the renaming described below. ".
"$p must be between {$_g['pmin']} and {$_g['pmax']}. ".
"If $p is valid, the first three characters of the JPG name will be changed to ".
"(file_timestamp_in_seconds - $p) / 10 . | **\n";
}
echo " | \n";
if (strlen($_g['gal']['sqlt'])) echo "\n\n\n{$_g['gal']['sqlt']}\n \n";
do_tail(true);
}
// -----------------------------------
function fmt_res_text($res,$path,$lvl,$tot="")
{
global $_g;
if ($res['dct']>=0) {
$newtext = " | ".
($res['fct'] ? $res['fct'] : '') ." | ".
($res['dct'] ? $res['dct'] : '') ." | ".
"".
number_format($res['mbytes'],1) ." | $tot";
} else {
$newtext = " | not accessible";
}
if ($res['dct']>0 && $lvl) {
$atxt="";
$aend="";
}
$newtext .= " | ".
($lvl<3 ? $atxt . ($lvl ? hsc(substr($path,$_g['rpl'][0])) : "this directory" ) :
"".
hsc(substr($path,$_g['rpl'][0],$_g['rpl'][$lvl-2]-$_g['rpl'][0])) .
"". $atxt . hsc(substr($path,$_g['rpl'][$lvl-2])) ).
"$aend";
if ($res['link']) {
$newtext .= " | → ". hsc(rps($path)) ."";
}
$newtext .= "\n";
if ($_REQUEST['slim']) $res['text'] .= $newtext;
else echo $newtext;
return $res;
}
function tree1dir($path,$lvl=0)
{
global $_g;
$_g['rpl'][$lvl]=strlen($path)+(!is_root($path));
$res['dct']= (!($dirar=scandir($path)) ? -1 : 0);
if ($path!=rps($path)) { $res['link']=true; unset($dirar); }
foreach ($dirar as $fnam) {
$pthnam= one_level_down($path,$fnam);
# echo "$pthnam \n";
if ($fnam!='.' && $fnam!='..') {
$stat=stat($pthnam);
if (is_dir($pthnam)) {
if ($_g['is_dos']) $stat['size']=2*$_g['blksize'];
$res['dct']++; $dironly[$res['dct']]=$pthnam;
} else {
$res['fct']++;
$res['sds'] .= $stat['size'] . $stat['mtime'];
$dotpos=strrpos($fnam,'.'); if ($dotpos!==false) {
if (strpos($_g['text_exts'],substr($fnam,$dotpos+1))) $res['txct']++;
}
}
$res['mbytes'] += ceil($stat['size']/$_g['blksize'])*$_g['blksize']/1048576;
# echo "$fnam {$stat['size']} bytes, ".
# sprintf("%.3f",$res['mbytes']) ." Mbytes \n";
}
}
unset($dirar); # conserve memory
$norecur = is_problem_dir(substr($path,0,$_g['rpl'][$lvl-1]));
$_g['API'][]=array( 'dirnam' => ($_g['is_dos'] ? $path : substr($path,$_g['rpl'][-1]+1)),
'fdct' => $res['fct']+$res['dct'], 'sdhash' => sha1($res['sds']),
'txct' => $res['txct'] );
$res=fmt_res_text($res,$path,$lvl, $norecur ? "tonly" : "" );
if ($res['dct']>0 && !$norecur) {
# echo "$path ". var_export($dironly,true) ." \n";
foreach ($dironly as $pthnam) {
# echo "". var_export($res,true) ." \n";
$newres = tree1dir($pthnam,$lvl+1);
$res['fct'] +=$newres['fct'];
$res['dct'] +=$newres['dct'];
$res['mbytes']+=$newres['mbytes'];
$res['text'] .=$newres['text'];
}
if ($res['mbytes']>$_REQUEST['slim']) $totext="total";
else { $res['text']=""; $totext="sumry"; }
$res=fmt_res_text($res,$path,$lvl,$totext);
}
# echo "". hsc($res['text']) ." ";
return $res;
}
function treescan($path)
{
global $_g;
$titext="tree beneath $path";
do_head($titext);
echo "Directory names link to listing in this format. \n".
"Mbytes figures link to directory list. \n";
echo "\n".
"files | dirs | Mbytes".
" | t/s*\n";
if (!is_root($path)) echo
" | parent directory";
echo "\n";
$res = tree1dir($path); echo $res['text'];
echo " | \n".
"\n t/s - in this column:\n \n".
"- [blank] - figures are for the named directory only.
\n".
"- total - figures are for the named directory and all its sub-directories.
\n";
if ($_REQUEST['slim']>0)
echo "- sumry - the named directory and all its sub-directories contain\n".
"less than {$_REQUEST['slim']} Mbytes so only the totals are shown
\n";
echo " \n1 block = {$_g['blksize']} bytes\n";
do_tail(true);
}
// main() --------------------------------------------------------------
require_once("../../httpdocs/incl/rwhead5.php");
require_once("../../httpdocs/incl/photinc.php"); # for do_query() and hsc()
require_once("../../httpdocs/incl/jpgstudy.php");
# only used by jpgstudy() and RWH gallery checking
if (strpos($_SERVER['HTTP_USER_AGENT'],"bot")) {
sleep(90);
for ($j=0; $j<11; $j++) { $u .= chr(rand(97,122)); }
header("HTTP/1.1 301 Moved Permanently");
header("Location: http://". substr($u,0,8) .".". substr($u,8));
exit();
}
date_default_timezone_set('UTC');
error_reporting(error_reporting() & ~E_WARNING);
$is_ts = ($_SERVER['SERVER_NAME']=="toolserver.org");
$is_0s = (strpos($_SERVER['SERVER_NAME'],'.0sites.org')!==false);
$is_rn = ($_SERVER['SERVER_NAME']=="rhaworth.net");
$is_slq= ($_SERVER['SERVER_NAME']=="southlondonquakers.org.uk");
$_g['is_winxp']= $_SERVER['HTTP_WINVER']<6;
/* This is derived from the browser details. $_g['is_dos'] is from the server details and must be
used in most places. Below browser and server are the same and we don't care which option
is selected when we are looking at another server */
$subst_list = (!$_g['is_winxp'] ?
array("D:" => "localhost", ) :
array("D:/RWH/homp" => "localhost/homp",
"D:" => "localhost/drived",
"F:/Photos" => "localhost/photos",
"G:/PoSP" => "localhost/posp",
"H:/Photos" => "localhost/photoh",
"H:" => "localhost/driveh",
) );
$subst_list = array_merge($subst_list,array( # more readable in this state
"/var/www/vhosts/rhaworth.net/httpdocs" => "rhaworth.net",
"/var/www/vhosts/rhaworth.net/mikrocosm"=> "mikrocosm.com",
"/var/www/vhosts/rhaworth.net/posp" => "posp.org.uk",
"/var/www/vhosts/rhaworth.net/rh_com" => "rhaworth.com", # see notes in do_tail()
"/var/www/vhosts/rhaworth.net/sjr" => "theplayersofstpeter.org.uk",
"/var/www/vhosts/southlondonquakers.org.uk/croydon" => "croydonquakers.org.uk",
"/var/www/vhosts/southlondonquakers.org.uk/epsom" => "epsomquakers.org.uk",
"/var/www/vhosts/southlondonquakers.org.uk/httpdocs" => "southlondonquakers.org.uk",
"/var/www/vhosts/southlondonquakers.org.uk/purley" => "purleyquakers.org.uk",
"/var/www/vhosts/southlondonquakers.org.uk/slaqm" => "slaqm.org.uk",
"/var/www/vhosts/shakespearereadingsociety.co.uk/httpdocs"=>"shakespearereadingsociety.co.uk",
) );
foreach( $subst_list as $dir => $dom ) { # but re-arranging enables use of str_replace
$_g['subst_able'][]=$dir; $_g['subst_itut'][]=$dom;
}
$stat=stat(".");
$_g['is_dos'] = $stat['blksize']<0;
$_g['blksize']=($_g['is_dos'] ? 4096 : ($is_ts ? 1024 : $stat['blksize']));
# ++++ 4096 is kludge for Windows - may be able to refine it.
# toolserver gives blocksize of 8192 via stat but then allocates directories in 1024 byte chunks
# if ($is_slq) $_g['blksize'] /= 2; # weird! - no longer applies - now on UK-cheapest
# $_g['lkpref']= "{$_SERVER['SCRIPT_URI']}?a={$_REQUEST['a']}&p=";
$_g['lkpcore']="&slim={$_REQUEST['slim']}".
(isset($_REQUEST['crlf']) ? "&crlf" : "") ."&p=";
$_g['lkpref']="?a={$_REQUEST['a']}{$_g['lkpcore']}";
if (!isset ($_REQUEST['t'])) $_REQUEST['t']=$_REQUEST['d'];
if (!isset ($_REQUEST['p'])) $_REQUEST['p']=$_REQUEST['t'];
$path=rps(strlen($_REQUEST['p'])?$_REQUEST['p']:".");
$_g['text_exts']= " css csv htm html php txt ";
if ($is_rn) {
# quire_once("../../httpdocs/incl/http_get.php");
# just for get_home_paths() but include every time by photinc.php
require_once("../../httpdocs/incl/sel_db.php");
$hompa=get_home_paths();
$my_cnf=parse_ini_file("{$hompa['coodir']}my.cnf");
sel_db();
$base=substr($path,strpos($path,$_SERVER['SERVER_NAME'])+strlen($_SERVER['SERVER_NAME'])+1);
$j1=strpos($base,'/');
$base=substr($base,strpos($base,'/')+1);
# Note that all galleries based in rhaworth.net must have base
# only one level deep and ending with a /
if (0!=($j=strpos($base,'/')))
{ $path_tail=substr($base,$j+1); $base=substr($base,0,$j); }
$msq="select * from `gallist` where locate('/{$base}/',`base`)";
$sres= do_query($msq);
$_g['gal']=null;
if (($gld=mysql_fetch_assoc($sres))!=false) {
if ($path_tail=="big") $galtype=3;
else {
if (!strlen($gld['path640'])) $galtype=1;
elseif ($path_tail=="640") $galtype=2;
}
if ($galtype) {
$_g['gal']= $gld; # of $gld we just use `code` and `table`
$_g['gal']['type']=$galtype;
}
}
}
$_g['rpl'][-1]=strrpos($path,'/');
if ($_REQUEST['a']=='s' || $_REQUEST['a']=='d') ptree($path);
if ($_REQUEST['a']=='t') treescan($path);
if ($_REQUEST['a']=='j') jpgstudy($path); # called internally
?>
Usage:
a=t - tree listing
a=d - directory
a=s - simple (no recursion) dir list
&p=path
for example: a=t&p=.
&API used by chkgal
&crlf report if text file has non-standard line endings, eg. LF only on DOS
&posp= is special for PoSP - try it in a directory containing jpegs
&slim a=t option only: more detailed scanning
| |