i have some troubles on my download site script , i have a Total Space Used: 35.18 GB, 36.751 of files, and my folder scanner did not work now. it can't scan all my files to add it on my database,now my other files are not showing even i already uploaded in my site folder, btw im uploading files using ftp client,so i need to use scanner to show it on my site index. when i try to scan it say
error
500 Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator and inform them of the time the error occurred, and the actions you performed just before this error. More information about this error may be available in the server error log.
or error
Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in /home/content/50/118050/html/lib/mysql.class.php on line 41
im just hoping if anyone can help me here to resolved this problem,...
heres the code
i wish you can suggest or post a code, recode,advice to run this or to make this scanner better and faster and can handle hug of files.
error
500 Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator and inform them of the time the error occurred, and the actions you performed just before this error. More information about this error may be available in the server error log.
or error
Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in /home/content/50/118050/html/lib/mysql.class.php on line 41
im just hoping if anyone can help me here to resolved this problem,...
heres the code
PHP Code:
// scan.php
@set_time_limit(0);
include "../inc/init.php";
if(!is_admin()) {
header("Location: $set->url");exit;
}
$links[] = mai_img("arr.gif")." <a href='index.php'>$lang->admincp </a>";
$links[] = mai_img("arr.gif")." Scan Folders ";
$folder_count = 0;
$files_count = 0;
// grab the files
$db_fl = $db->select("SELECT * FROM `".MAI_PREFIX."files`");
foreach($db_fl as $file)
$db_files[] = $file->path;
$folder_files = scaner("../files/");
foreach($folder_files as $f){
$f = rtrim($f,"/");
if(!in_array($f,$db_files)){
$db_files[] = $f;
if(is_dir("..".$f)){
$dir = $db->get_row("SELECT `id` FROM `".MAI_PREFIX."files` WHERE `path`='".dirname($f)."'");
$add = array(
"path" => $db->escape($f),
"name" => $db->escape(basename($f)),
"time" => time(),
"indir" => (int)$dir->id,
"size" => 0
);
$db->insert_array(MAI_PREFIX."files",$add);
$folder_count++;
}else{
$dir = $db->get_row("SELECT `id` FROM `".MAI_PREFIX."files` WHERE `path`='".dirname($f)."'");
$add = array(
"path" => $db->escape($f),
"name" => $db->escape(basename($f)),
"time" => time(),
"indir" => (int)$dir->id,
"size" => filesize("..".$f)
);
$db->insert_array(MAI_PREFIX."files",$add);
$files_count++;
}
}
}
// check for extra files
$tmp_files = array_map("_rtrim",$folder_files);
$extra = array_diff(array_merge($tmp_files, $db_files), array_intersect($tmp_files, $db_files));
foreach($extra as $extra)
$db->query("DELETE FROM `".MAI_PREFIX."files` WHERE `path`='".$db->escape($extra)."'");
include "../header.php";
echo "<div class='content'>Scan Complete !<br/>
New folders: ".$folder_count."<br/>
New files: ".$files_count."<br/>
</div>
";
include "../footer.php";
// functions
function _rtrim($v){
return rtrim($v,"/");
}
function scaner($path)
{
static $f_arr;
@chmod($path,0777);
$arr = glob($path.'/*');
if(is_array($arr)){
foreach($arr as $vv){
if(is_dir($vv)){
$f_arr[] = substr($vv,2).'/';
scaner($vv);
}else{
$f_arr[] = substr($vv,2);
}
}
}
return $f_arr;
PHP Code:
mysql.class.php
if(extension_loaded('mysqli')) {
class dbConn {
var $link = null;
function __construct($db_host,$db_user,$db_pass,$db_name){
$this->link = @mysqli_connect($db_host, $db_user, $db_pass, $db_name);
if (!$this->link) die('Connect Error (' . mysqli_connect_errno() . ') '.mysqli_connect_error());
mysqli_select_db($this->link, $db_name) or die(mysqli_error($this->link));
return true;
}
function select($q){
$result = mysqli_query($this->link,$q);
if(mysqli_num_rows($result) > 0)
while($res = mysqli_fetch_object($result))
$arr[] = $res;
if($arr) return $arr;
return false;
}
function get_row($q){
$result = mysqli_query($this->link,$q);
if(mysqli_num_rows($result) == 1)
$arr = mysqli_fetch_object($result);
if($arr) return $arr;
return false;
}
function count($q){
$result = mysqli_query($this->link,$q);
return mysqli_num_rows($result);
}
function query($q){
return mysqli_query($this->link,$q);
}
function escape($str){
return mysqli_real_escape_string($this->link,$str);
}
function insert($q){
if(mysqli_query($this->link,$q))
return mysqli_insert_id($this->link);
return false;
}
function insert_array($table,$array){
$q = "INSERT INTO `$table`";
$q .=" (`".implode("`,`",array_keys($array))."`) ";
$q .=" VALUES ('".implode("','",array_values($array))."') ";
if(mysqli_query($this->link,$q))
return mysqli_insert_id($this->link);
return false;
}
}
} else { // we use the old mysql
class dbConn {
var $link = null;
function __construct($db_host,$db_user,$db_pass,$db_name){
$this->link = @mysql_connect($db_host, $db_user, $db_pass);
if (!$this->link) die('Connect Error (' . mysql_errno() . ') '.mysql_error());
mysql_select_db($db_name, $this->link) or die(mysql_error($this->link));
return true;
}
function select($q){
$result = mysql_query($q, $this->link);
if(mysql_num_rows($result) > 0)
while($res = mysql_fetch_object($result))
$arr[] = $res;
if($arr) return $arr;
return false;
}
function get_row($q){
$result = mysql_query($q, $this->link);
if(mysql_num_rows($result) == 1)
$arr = mysql_fetch_object($result);
if($arr) return $arr;
return false;
}
function count($q){
$result = mysql_query($q, $this->link);
return mysql_num_rows($result);
}
function query($q){
return mysql_query($q, $this->link);
}
function escape($str){
return mysql_real_escape_string($str, $this->link);
}
function insert($q){
if(mysql_query($q, $this->link))
return mysql_insert_id($this->link);
return false;
}
function insert_array($table,$array){
$q = "INSERT INTO `$table`";
$q .=" (`".implode("`,`",array_keys($array))."`) ";
$q .=" VALUES ('".implode("','",array_values($array))."') ";
if(mysql_query($q, $this->link))
return mysql_insert_id($this->link);
return false;
}
}
}
Comment