Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

File Permissions overview #5

Open
bueltge opened this issue Aug 8, 2012 · 0 comments
Open

File Permissions overview #5

bueltge opened this issue Aug 8, 2012 · 0 comments
Labels

Comments

@bueltge
Copy link
Owner

bueltge commented Aug 8, 2012

       <table class="widefat">
         <thead>
          <tr>
            <tr>
              <th>File</th>
          <th>Permission</th>
          <th>Size</th>
            </tr>
         </thead>
       <tbody>

<?php  // ----  Root folder


       $iterator = new DirectoryIterator( ABSPATH );

       // don't scan for these files types
       $filetypes = array("jpg", "png", "gif", "jpeg", "ico", "css", "txt");


        foreach ($iterator as $fileinfo) {
           if (!$fileinfo->isDot()) {

                    //get file extension
                    $filetype = pathinfo($fileinfo, PATHINFO_EXTENSION);

            // get permissions in octal
            $stringy = substr(sprintf('%o', $fileinfo->getPerms()), -4);
            ?>

                    </tr>
                   <?php if (!in_array(strtolower($filetype), $filetypes)) {

              //output file name
            echo "<td>" . $fileinfo . "</td>";


                  //check for 777 ! and outputs perms

                   if  ($stringy == '0777'){
                        echo "<td>" . substr(sprintf('%o', $fileinfo->getPerms()), -4) .
                "<span class='red'> &#215; </span>" . "</td>" ;
                   }else{
                    echo "<td>" . substr(sprintf('%o', $fileinfo->getPerms()), -4) .  "</td>" ;
                   }


                 //output file sizes
                     echo "<td>" . number_format($fileinfo->getSize()/1024, 2) . " KB" . "</td>";


           }
        }
    }?>

        </tbody>
      </table>
    </div>

  <!--TAB TWO   -->

  <div>
   <table class="widefat">
    <thead>
      <tr>
        <tr>
         <th>File</th>
         <th>Permission</th>
     <th>Size</th>
        </tr>
    </thead>
  <tbody>

<?php  // ----  wp-admin folder

      $it = new RecursiveDirectoryIterator( ABSPATH . "wp-admin");

           foreach(new RecursiveIteratorIterator($it) as $file) {

        $filetype = pathinfo($file, PATHINFO_EXTENSION);
        $stringy = substr(sprintf('%o', $fileinfo->getPerms()), -4);
        ?>

            </tr>

              <?php if (!in_array(strtolower($filetype), $filetypes)) {

                 echo "<td>" . $file . "</td>";

         //check for 777 !

                   if  ($stringy == '0777'){
                        echo "<td>" . substr(sprintf('%o', $fileinfo->getPerms()), -4) .
                "<span class='red'> &#215; </span>" . "</td>" ;
                   }else{
                    echo "<td>" . substr(sprintf('%o', $fileinfo->getPerms()), -4) .  "</td>" ;
                   }

                        echo "<td>" . number_format($file->getSize()/1024, 2) . " KB" . "</td>";

          }
       }?>


    </tbody>
   </table>
 </div>

  <!--TAB THREE-->

 <div>
   <table class="widefat">
     <thead>
       <tr>
        <tr>
         <th>File</th>
         <th>Permission</th>
     <th>Size</th>
        </tr>
    </thead>
 <tbody>

<?php  // ----  wp-content folder

      $it = new RecursiveDirectoryIterator( ABSPATH . "wp-content" );

           foreach(new RecursiveIteratorIterator($it) as $file) {

        $filetype = pathinfo($file, PATHINFO_EXTENSION);
        $stringy = substr(sprintf('%o', $fileinfo->getPerms()), -4);
        ?>

            </tr>

              <?php if (!in_array(strtolower($filetype), $filetypes)) {

                 echo "<td>" . $file . "</td>";

         //check for 777 !

                   if  ($stringy == '0777'){
                        echo "<td>" . substr(sprintf('%o', $fileinfo->getPerms()), -4) .
                "<span class='red'> &#215; </span>" . "</td>" ;
                   }else{
                    echo "<td>" . substr(sprintf('%o', $fileinfo->getPerms()), -4) .  "</td>" ;
                   }

                        echo "<td>" . number_format($file->getSize()/1024, 2) . " KB" . "</td>";

          }
       }?>

   </tbody>
  </table>
 </div>

  <!--TAB FOUR-->

 <div>
  <table class="widefat">
   <thead>
     <tr>
        <tr>
         <th>File</th>
         <th>Permission</th>
     <th>Size</th>
        </tr>
    </thead>
  <tbody>

   <?php  // ----  wp-includes folder

      $it = new RecursiveDirectoryIterator( ABSPATH . "wp-includes" );

           foreach(new RecursiveIteratorIterator($it) as $file) {

        $filetype = pathinfo($file, PATHINFO_EXTENSION);
        $stringy = substr(sprintf('%o', $fileinfo->getPerms()), -4); ?>

            </tr>

              <?php if (!in_array(strtolower($filetype), $filetypes)) {

                 echo "<td>" . $file . "</td>";

         //check for 777 !

                   if  ($stringy == '0777'){
                        echo "<td>" . substr(sprintf('%o', $fileinfo->getPerms()), -4) .
                "<span class='red'> &#215; </span>" . "</td>" ;
                   }else{
                    echo "<td>" . substr(sprintf('%o', $fileinfo->getPerms()), -4) .  "</td>" ;
                   }


         echo "<td>" . number_format($file->getSize()/1024, 2) . " KB" . "</td>";

          }
       }?>

    </tbody>
   </table>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant