tips:findbadphp.php
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
tips:findbadphp.php [2011-12-20 14:20] – 81.214.62.65 | tips:findbadphp.php [2013-08-31 01:25] – Fixed needle and haystack being the wrong way round, and improved trailing characters search to accept trailing new lines which PHP ignores. 81.83.194.5 | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | <?php session_start(); | + | ====== findbadphp.php ====== |
- | ob_start(); | + | |
- | ?> | + | Use this script to find corrupted PHP files. Place it in your wiki root and call it from your browser. |
- | < | + | |
- | <html xmlns=" | + | |
- | < | + | |
- | <meta http-equiv=" | + | |
- | <link rel=" | + | |
- | < | + | |
- | </ | + | |
- | < | + | |
- | <form action=" | + | |
- | <div id=" | + | |
- | < | + | |
- | Raporlama Sayfasına giriş için lütfen size verilmiş olan kullanıcı adını ve şifreyi giriniz | + | |
- | <br /> | + | |
- | <br /> | + | |
- | <div id=" | + | |
- | <div id=" | + | |
- | + | ||
- | <br /> | + | |
- | <input type=" | + | |
- | < | + | |
- | <?php | + | |
- | if (isset($_REQUEST[' | + | |
- | + | ||
- | if ($_POST[' | + | |
- | echo('< | + | |
- | }else | + | |
- | { | + | |
- | if (!isset($_SESSION)) {session_start(); | + | |
- | + | ||
- | $_SESSION[' | + | |
- | header (" | + | |
- | $_SESSION[' | + | |
- | } | + | |
- | + | ||
- | } | + | |
- | ?> | + | |
- | | + | <code php findbad.php> |
- | <form> | + | <?php |
- | </body> | + | /** |
- | </html> | + | * This script will search all PHP files in the same directory |
+ | * and below and will check for trailing or leading whitespaces | ||
+ | * and UTF-8 BOMs | ||
+ | */ | ||
+ | header(" | ||
+ | |||
+ | echo " | ||
+ | flush(); | ||
+ | traverse(dirname(__FILE__)); | ||
+ | echo " | ||
+ | |||
+ | function traverse($dir){ | ||
+ | if ($dh = opendir($dir)) { | ||
+ | while (($file = readdir($dh)) !== false) { | ||
+ | //skip hidden files and upper dirs | ||
+ | if(preg_match('/ | ||
+ | if(is_dir($dir.'/' | ||
+ | traverse($dir.'/' | ||
+ | continue; | ||
+ | } | ||
+ | flush(); | ||
+ | |||
+ | if(!preg_match('/ | ||
+ | $check = @file_get_contents(" | ||
+ | if(!$check){ | ||
+ | echo " | ||
+ | continue; | ||
+ | } | ||
+ | |||
+ | if($check == " | ||
+ | echo " | ||
+ | continue; | ||
+ | } | ||
+ | |||
+ | if($check != '<? | ||
+ | echo " | ||
+ | continue; | ||
+ | } | ||
+ | |||
+ | $check = file_get_contents(" | ||
+ | filesize(" | ||
+ | $pos = strpos($check, | ||
+ | if($pos !== false && !(substr($check, | ||
+ | echo " | ||
+ | continue; | ||
+ | } | ||
+ | } | ||
+ | | ||
+ | } | ||
+ | } | ||
+ | </ |
tips/findbadphp.php.txt · Last modified: 2022-01-26 05:56 by schplurtz