Welcome, Guest
  • Author Topic: php file scan help  (Read 2420 times)

    nnnswordfish

    • Server what's that
    • *
    • Posts: 49
      • View Profile
      • Email
    php file scan help
    « on: 01/10/08, 14:53 »
    Hi again  my action script file loads an XML file, dynamically created with PHP and php scans the mp3/a directory and creats list files and folders in tree component of flash using as script.

     its scans mp3/a/ dir and folders and files in it(mp3/a/50z/candyshop.mp3) but if e.g. i have mp3/a/50z/2005 album/indaclub.mp3 it doesnot scun it. can someone modifi this script?i whant to scan with it mp3/a/50z/ subfolders and sub files too.can someone do this? thanks :)

    here is php script

    <?php
    $dir 
    "mp3/a/";



    echo 
    "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n";
    echo 
    "<music>\n";

    // Open a known directory, and proceed to read its contents
    if (is_dir($dir)) {
        if (
    $dh opendir($dir)) {
            while ((
    $file readdir($dh)) !== false) {
             
    $subdir $file;         
             if (
    $subdir != "." && $subdir != ".." && $subdir != "_notes") {
                echo 
    "<artist label=\"$subdir\" >\n";
                
    //Scan the subdirectories
                
    if ($sh opendir($dir $subdir."/")) {
                   while ((
    $sfile readdir($sh)) !== false) {
                   if (
    $sfile != "." && $sfile != "..") {
                     
    $subfile $sfile;
                         echo 
    "<song url=\"$dir$subdir/$subfile\" label=\"" $subfile "\" />\n";  
                      
                      }
                      
                   }
                   
    closedir($sh);
                
                }
                echo 
    "</artist>\n";         
             
             }         
             
            }
            
    closedir($dh);
        } 
    }
    echo 
    "</music>"
    ?>

    Jorge Solis

    • Global Moderator
    • Systems Administrator
    • *****
    • Posts: 14616
      • View Profile
    Re: php file scan help
    « Reply #1 on: 01/11/08, 04:22 »
    If you want to recursively scan inner folders, you need a recursive script for tree traversal like this http://www.safalra.com/programming/php/directory-tree-traversal/

    Jorge

    nnnswordfish

    • Server what's that
    • *
    • Posts: 49
      • View Profile
      • Email
    Re: php file scan help
    « Reply #2 on: 01/11/08, 09:09 »
    and it will works with tree component of flash 8.0? ???

    Jorge Solis

    • Global Moderator
    • Systems Administrator
    • *****
    • Posts: 14616
      • View Profile
    Re: php file scan help
    « Reply #3 on: 01/11/08, 09:29 »
    If you build the adecuate XML as needed by the component will work

    Jorge