This is my script for counting file size in folders, but when I put this script on normal text page it shows error: Warning: in_array() [function.in-array]: Wrong datatype for second argument in statistics.php on line 20 <?php if (session_id() == ""){ session_start(); } $maxupload=1024000000; // in byte $dir='jdownloads'; $notcount=array('index.html','listing.php','descriptionfile.txt'); dirs($dir); $sizeinbyte=($_SESSION[tots]==0)?'0':$_SESSION[tots]; $_SESSION[tots]=array(); unset($_SESSION[tots]); function dirs($dir){ global $notcount; if ($handle = opendir($dir)) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { if(is_dir($dir.'/'.$file)){ dirs($dir.'/'.$file); }else{ if (!in_array($file, $notcount)) { $fl=filesize($dir.'/'.$file); $_SESSION[tots]=$_SESSION[tots]+$fl; } } } } closedir($handle); } } ?> PHP:
try not to use globals.. <?php if (session_id() == ""){ session_start(); } $maxupload=1024000000; // in byte $dir='jdownloads'; $notcount=array('index.html','listing.php','descriptionfile.txt'); dirs($dir, $notcount); $sizeinbyte=($_SESSION[tots]==0)?'0':$_SESSION[tots]; $_SESSION[tots]=array(); unset($_SESSION[tots]); function dirs($dir, $notcount){ if ($handle = opendir($dir)) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { if(is_dir($dir.'/'.$file)){ dirs($dir.'/'.$file); }else{ if (!in_array($file, $notcount)) { $fl=filesize($dir.'/'.$file); $_SESSION[tots]=$_SESSION[tots]+$fl; } } } } closedir($handle); } } ?> PHP:
No, the error is already being reported, statcache has no effect on this script, and the session is already being stared (and has nothing to do with the error anyway). There's a dirs() call in xeons' script where $notcount isn't passed properly, which is probably causing the error.
<?php if (session_id() == ""){ session_start(); } function dirs($dir, $notcount) { $file = ''; if ($handle = opendir($dir)) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { if(is_dir($dir.'/'.$file)) { dirs($dir.'/'.$file); } else { if (!in_array($file, $notcount)) { $fl=filesize($dir.'/'.$file); $_SESSION[tots]=$_SESSION[tots]+$fl; } } } } closedir($handle); } } $maxupload=1024000000; // in byte $dir='jdownloads'; $notcount=array('index.html','listing.php','descriptionfile.txt'); dirs($dir, $notcount); $sizeinbyte=($_SESSION[tots]==0)?'0':$_SESSION[tots]; $_SESSION[tots]=array(); unset($_SESSION[tots]); ?> PHP: try this one.. although i didnt test it..