Results 1 to 8 of 8

Thread: please help Folder scan. it Can't scan all my files in the folder of my download site

  1. #1
    Join Date
    Dec 2013
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default please help Folder scan. it Can't scan all my files in the folder of my download site

    1) Script Title:
    scanner sript , mysql.class script
    2) Script URL (on DD):

    3) Describe problem:
    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

    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" => 
                
    ); 
                
    $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;
            }
        }



    i wish you can suggest or post a code, recode,advice to run this or to make this scanner better and faster and can scan hug of files.
    Last edited by demonhellions; 12-05-2013 at 01:07 PM. Reason: wrong grammar and typographical

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    1. I don't think this belongs here. Is this related to a Dynamic Drive script? I think this is a question about PHP and/or MySQL. Do you know which one you're having trouble with? We can help you by moving it to the right sub-forum.

    2. What are you trying to accomplish? What's a "folder scan"? (I understand you can "scanning folders", but what specifically is the purpose?)

    3. What is your experience with PHP/MySQL? Do you generally understand how the code works or did you just install it from a 3rd party website?
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. #3
    Join Date
    Dec 2013
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    1. I don't think this belongs here. Is this related to a Dynamic Drive script? I think this is a question about PHP and/or MySQL. Do you know which one you're having trouble with? We can help you by moving it to the right sub-forum.

    im sorry for the wrong thread, you can now move this to correct section this is about php, again im sorry ...

    2. What are you trying to accomplish? What's a "folder scan"? (I understand you can "scanning folders", but what specifically is the purpose?)

    What are you trying to accomplish? im just tying to improve this folder scanner and to fix this erorr 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 it take to long to load when i run the /scan.php
    sometimes it show
    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.



    What's a "folder scan"? folder Scan. This will scan the folders and add the new files on my database

    but what specifically is the purpose? i am using (auto index scrip) this script have folder scan ,when im uploading using ftp client before the files show on my site index, it well need to scan first.

    3. What is your experience with PHP/MySQL? Do you generally understand how the code works or did you just install it from a 3rd party website?
    yes i just install it ,

  4. #4
    Join Date
    Dec 2013
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    hello im willing to wait here everyday

  5. #5
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Honestly, this looks quite complicated. It's probably a relatively easy solution once it is clear what is wrong, but it would take a lot of work to figure out exactly what is wrong. I have now moved this to the right section so someone may see it and be able to help, but I would recommend either:
    1. Learn PHP and MySQL so you can fix this yourself. (Generally, I would not recommend using PHP code unless you, very generally, understand what it does!)
    2. Hire someone who can do this for you. They will need access to your server to test and fix it.
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  6. #6
    Join Date
    Dec 2013
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    hello djr33 can i hire someone here for free

    Attachment 5292Attachment 5293

    someone told me that it can be fix by using the
    RecursiveDirectoryIterator
    but i cant understand because this is my first time in php
    i try to changes the
    foreach($folder_files as $f)
    to
    PHP Code:
    foreach (new RecursiveDirectoryIterator('/') as $folder) {  
         print 
    $folder->getFilename(); 
        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" => 
    but it show error
    proc
    Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in /home/content/50/113050/html/lib/mysql.class.php on line 41
    tmpdatawebcgi-bin.mediarootlib64..etcbinusroptdevsbinselinuxmntt mpsrvvarlibbootsyshome
    and other share there own indexer script but i dont know how configure this script on my scanner. to match it on my database
    PHP Code:
    function recScan$mainDir$allData = array() ) 

    // hide files 
    $hidefiles = array( 
    "."
    ".."
    ".htaccess"
    ".htpasswd"
    "index.php"
    "php.ini"
    "error_log" ) ; 

    //start reading directory 
    $dirContent scandir$mainDir ) ; 

    foreach ( 
    $dirContent as $key => $content 

    $path $mainDir '/' $content 

    // if is readable / file 
    if ( ! in_array$content$hidefiles ) ) 

    if ( 
    is_file$path ) && is_readable$path ) ) 

    $allData[] = $path 


    // if is readable / directory 
    // Beware ! recursive scan eats ressources ! 
    else 
    if ( 
    is_dir$path ) && is_readable$path ) ) 

    /*recursive*/ 
    $allData recScan$path$allData ) ; 




    return 
    $allData 

    PHP Code:
    <?php 

    if($_GET['scan'] == 'now'
        { 
            
    $allData recScan("./content"); 

            foreach(
    $allData as $value
            { 
    // check if the item is already indexed <> 
                
    $value str_replace('./','',$value); 
                
    $check mysql_fetch_array(mysql_query("SELECT * FROM portal_files WHERE path='" 
                    
    $value "'")); 

                
    // if not just store it in database <this is a duplicate-check , prevents for double index> 
                
    if(empty($check['id'])) 
                {
    //index file path , size , extension 
                        
    $path_parts pathinfo($value); 
                    
    $value str_replace('./','',$value); 
                    
    $insert mysql_query("INSERT INTO portal_files SET path='" 
                        
    mysql_real_escape_string($value) . "', 
                    size='" 
    format_bytes(filesize("./" $value "")) . "', extension='".$path_parts['extension']."' "); 
                } 

                else 
                { 
                    echo 
    'No new items were detected'

                    echo 
    '</div>'
                    include 
    'footer.php'

                    exit; 
                } 
            } 

            
    //if everything is ok print the message 
            
    $count_items mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM portal_files")); 
            echo 
    '' $count_items[0] . ' files were indexed.'
        }  

    ?>

  7. #7
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    hello djr33 can i hire someone here for free
    Members here are volunteers and will help, but there is a limit to what we will do for free. If someone sees an obvious problem, I'm sure they will help. But as I said, this seems complicated, so think about considering other options.
    but i cant understand because this is my first time in php
    I understand. This is why I suggest hiring someone who can do this correctly and make sure everything is set up and working on your server. Or you can spend the time to learn how to do this. It's possible, but it won't be fast. Most importantly, you should be aware of what the code is doing on your server (or hire someone who you can trust to do it for you) because PHP can be very dangerous and cause major problems if it contains code you don't understand-- I strongly recommend not running code you do not understand, because it could cause security vulnerabilities, make permanent changes in the files on the server or just cause strange/unreliable behavior on the server.

    Think of PHP like a car-- it's important to drive carefully: you should have a license [=experience] and understand what you're doing. Or you could hire someone to drive the car for you.
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  8. #8
    Join Date
    Dec 2013
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    thank you very much for the good information , maybe i just wait for the second person who wll riply to this thread and willing to help me to edit,modify or add additional fanction on my site script through accessing my server . with out any condition ..

Similar Threads

  1. Scan files before uploading
    By sponge.nika in forum PHP
    Replies: 4
    Last Post: 01-10-2011, 06:24 PM
  2. Live Antivirus Scan for file upload
    By lucaaat in forum Looking for such a script or service
    Replies: 9
    Last Post: 11-02-2010, 05:14 PM
  3. scan a page for a piece of text
    By lankinator in forum JavaScript
    Replies: 4
    Last Post: 06-03-2007, 08:36 PM
  4. errors with scan.next()
    By craigtb in forum Java
    Replies: 0
    Last Post: 04-06-2007, 11:32 PM
  5. looking to scan browser and redirect to it's site
    By PDA_User in forum JavaScript
    Replies: 18
    Last Post: 08-07-2006, 06:32 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •