PHP script to omit root owned files

Discussion in 'Programming/Scripts' started by LinuxAdminWannaBe, Oct 1, 2013.

  1. LinuxAdminWannaBe

    LinuxAdminWannaBe New Member

    Hi guys,

    I have created a PHP script for listing files and redirect it on a txtfile. This is only successful if i search a location which is non root. How could i update it to omit those root owned files.

    Appreciate your help.
    Thanks

    PHP:
    <?php

    // FIND .tar FILES AND SAVE IN A TEXT //

    function ob_file_callback($buffer)
      {
        global 
    $ob_file;
        
    fwrite($ob_file,$buffer);
      }

    $ob_file fopen('tarfile.txt','w');
    ob_start('ob_file_callback');


      
    $Loc="/";

      function 
    Find($Path)
        { 
          
    $Find="find $Path -path '*.tar'";
          
    exec($Find,$output,$return_var);
          return 
    $output;    
        }

      
    $result Find($Loc);
          if 
    $result 
          
      
    foreach($result as $single
      
    printf("%s \n",$single);
      return 
    $single;


    ob_end_flush()

    ?>
     

Share This Page