Activity Stream
48,167 MEMBERS
6359 ONLINE
besthostingforums On YouTube Subscribe to our Newsletter besthostingforums On Twitter besthostingforums On Facebook besthostingforums On facebook groups

Page 1 of 4 123 ... LastLast
Results 1 to 10 of 31
  1.     
    #1
    Member
    Website's:
    maxneeds.info

    Question PHP Scan dir for idetical files

    I am not good with php and will ask for help...

    * The folder is named 'fav'
    * There are subfolders in 'fav'
    * Each subfolder may contain a .txt file

    Needed -->
    * Check for identical .txt file names in all subfolders
    * Sort 10 most repeating identicals,show(echo) their contents and show(echo) times repeated (in brackets such as this one )

    And.. that's it !
    I hope you'll code it easily for me..

    THANKS !
    Porsche_maniak Reviewed by Porsche_maniak on . PHP Scan dir for idetical files I am not good with php and will ask for help... * The folder is named 'fav' * There are subfolders in 'fav' * Each subfolder may contain a .txt file Needed --> * Check for identical .txt file names in all subfolders * Sort 10 most repeating identicals,show(echo) their contents and show(echo) times repeated (in brackets such as this one :D ) Rating: 5

  2.   Sponsored Links

  3.     
    #2
    Member
    Website's:
    maxneeds.info
    If i am unclear with something please tell..

  4.     
    #3
    Member
    Website's:
    litewarez.net litewarez.com triniwarez.com
    Well this would have to be done recursively.

    PHP Code: 

    $storage 
    = array();
    function 
    ScanForTextFiles($folder)
    {
        global 
    $storage;
        
    $resource opendir($folder);
        while(
    false != ($file readdir($resource)))
        {
             
    $current $folder $file;
             if(
    $file != '.' || $file != '..' && is_dir$current )) //Changed to file from current
             
    {
                   
    ScanForTextFiles($current);
             }elseif(
    is_file($current) && substr($current,-3) == 'txt'//Updated to check format
             
    {
                if(!isset(
    $storage[$file]))
                {
                     
    $storage[$file] = 0//Start with 0 counts
                
    }else
                {
                   
    $storage[$file]++; //Add 1 more count
                
    }
            }
        }
    }
    ScanForTextFiles('path/to/fav/'); //WITH LAST SLASH 
    //Then just sort $storage to print how you want it..

    Code is untested.
    Join Litewarez.net today and become apart of the community.
    Unique | Clean | Advanced (All with you in mind)
    Downloads | Webmasters


    Notifications,Forum,Chat,Community all at Litewarez Webmasters


  5.     
    #4
    Member
    Website's:
    maxneeds.info
    I tried everything and gives errors.
    Also i saw that it finds files in fav folder which are outside it (one level down).

    Btw the folder is just 'fav/' and i want to be sorted in numeric and show the most 10..

    opendir(fav/..login.php) [function.opendir]: failed to open dir: No such file or directory in

  6.     
    #5
    Member
    Website's:
    litewarez.net litewarez.com triniwarez.com
    try now and report back.
    Join Litewarez.net today and become apart of the community.
    Unique | Clean | Advanced (All with you in mind)
    Downloads | Webmasters


    Notifications,Forum,Chat,Community all at Litewarez Webmasters


  7.     
    #6
    Member
    Website's:
    maxneeds.info
    error without last slash

    Code: 
    Warning: opendir(fav....................................................................................................................................................................................................................................New Text Document.txt) [function.opendir]: failed to open dir: No such file or directory in C:\xampp\htdocs\downloads\stats.php on line 219
    
    Warning: readdir() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\downloads\stats.php on line 220
    
    Warning: opendir(fav.......................................................................................................................................................................................................................................) [function.opendir]: failed to open dir: No such file or directory in C:\xampp\htdocs\downloads\stats.php on line 219
    Error with last slash
    Code: 
    Warning: opendir(fav/..options_cgi.php) [function.opendir]: failed to open dir: No such file or directory in C:\xampp\htdocs\downloads\stats.php on line 219
    
    Warning: readdir() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\downloads\stats.php on line 220
    
    Warning: opendir(fav/..partner1.html) [function.opendir]: failed to open dir: No such file or directory in C:\xampp\htdocs\downloads\stats.php on line 219
    
    Warning: readdir() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\downloads\stats.php on line 220
    
    Warning: opendir(fav/..people.html) [function.opendir]: failed to open dir: No such file or directory in C:\xampp\htdocs\downloads\stats.php on line 219
    - This one shows files which are outside the folder...

  8.     
    #7
    Member
    Website's:
    litewarez.net litewarez.com triniwarez.com
    PHP Code: 
    <?php
    function RecurseFolderLister($d)
    {
        
    $BasePath realpath($d);
        
    $Storage = array();
        
        if(
    is_dir($BasePath))
        {
            
    $resource opendir($BasePath);
            while(
    false !== ($directory readdir($resource)))
            {
                if(
    is_dir($BasePath '/' $directory) && !in_array($directory,array('.','..'))) //DirCheck the TypeCheck
                
    {
                    
    $Storage array_merge($Storage,RecurseFolderLister($BasePath '/' $directory));
                }else
                {
                    if(
    is_file($BasePath '/' $directory) && substr($directory,-3) == 'txt')
                    {
                        
    //We have text file
                        
    $key basename($BasePath '/' $directory);
                        
                        if(!isset(
    $Storage[$key]))
                        {
                            
    $Storage[$key] = 0;
                        }
                        
    $Storage[$key]++;
                    }
                }
            }
        }
        return 
    $Storage;
    }
    $Storage RecurseFolderLister('fav');
    asort($Storage); //Sort them
    var_dump($Storage);
    ?>
    Sorted!
    Join Litewarez.net today and become apart of the community.
    Unique | Clean | Advanced (All with you in mind)
    Downloads | Webmasters


    Notifications,Forum,Chat,Community all at Litewarez Webmasters


  9.     
    #8
    Member
    Website's:
    maxneeds.info
    So far so good...
    I used :
    Code: 
    $entry_arrayz[ 'entry' ]  .= $Storage = RecurseFolderLister('fav'); asort($Storage); var_dump($Storage);
    where $entry_arrayz[ 'entry' ] is the place where sorted $storage will show,but i get :

    Code: 
    array(1) { ["entry100620-034822.txt"]=> int(1) } 
    
    Array
    
    How to print that thing ?
    Also in the following case i've put entry100620-034822.txt in 2 different folders (which means entry100620-034822.txt is repeating 2 times) and a.txt (just 1)

    Code: 
    array(2) { ["a.txt"]=> int(1) ["entry100620-034822.txt"]=> int(1) }
    
    Array
    So another question - Is there "* Sort 10 most repeating identicals,show(echo) their contents and show(echo) times repeated (in brackets such as this one )" in your code ?

    I am really bad in PHP so sorry that i am asking such a stupid questions.

  10.     
    #9
    Member
    Website's:
    litewarez.net litewarez.com triniwarez.com
    hmm,

    Just do

    PHP Code: 
    $entry_arrayz'entry' ] = RecurseFolderLister('fav');

    var_dump($entry_arrayz['entry']); 
    Tell me you get and what you SHOULD get :/

    And this code will do the following

    scann all directories within the directory you specify, load all files that are .txt files into an array, and count how many times it came accross that file

    The output would be like so

    Code: 
    Array(
        'Name' > Count
        'Name' > Count
        'Name' > Count
        'Name' > Count
    )
    Like
    Code: 
    Array(
        'readme.txt' > 12
        'about.txt' > 3
        'test.txt' > 1
        'readmeAgain.txt' > 1
       
    )
    Join Litewarez.net today and become apart of the community.
    Unique | Clean | Advanced (All with you in mind)
    Downloads | Webmasters


    Notifications,Forum,Chat,Community all at Litewarez Webmasters


  11.     
    #10
    Member
    Website's:
    maxneeds.info
    I've tried
    Code: 
    $entry_arrayz[ 'entry' ] = RecurseFolderLister('fav');
    
    var_dump($entry_arrayz['entry']);
    but it's the same...

    Btw read my prev post if haven't (i edited it)..

Page 1 of 4 123 ... LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 0
    Last Post: 30th Nov 2011, 03:02 AM
  2. Scan Forum Ids
    By vietnammoney in forum Webmaster Resources
    Replies: 1
    Last Post: 12th Oct 2011, 05:36 PM
  3. Boot Time Scan In Quick Heal
    By supernova in forum General Discussion
    Replies: 5
    Last Post: 17th Mar 2011, 08:07 PM
  4. Always scan files befor opeing...
    By MrPeanut420 in forum Useful Sites
    Replies: 3
    Last Post: 5th Feb 2010, 09:57 AM
  5. How to Scan & Stop Uploading Infected Files to Your Server
    By ashutariyal in forum Tutorials and Guides
    Replies: 8
    Last Post: 13th Aug 2009, 06:09 AM

Tags for this Thread

BE SOCIAL