wordfence
Last commit date
css
14 years ago
images
14 years ago
js
14 years ago
lib
14 years ago
readme.txt
14 years ago
screenshot-1.png
14 years ago
screenshot-2.png
14 years ago
screenshot-3.png
14 years ago
screenshot-4.png
14 years ago
screenshot-5.png
14 years ago
visitor.php
14 years ago
wfscan.php
14 years ago
wordfence.php
14 years ago
wfscan.php
67 lines
| 1 | <?php |
| 2 | ignore_user_abort(true); |
| 3 | $wordfence_wp_version = false; |
| 4 | if ( !defined('ABSPATH') ) { |
| 5 | /** Set up WordPress environment */ |
| 6 | if($_SERVER['SCRIPT_FILENAME']){ |
| 7 | $wfBaseDir = preg_replace('/[^\/]+\/[^\/]+\/[^\/]+\/wfscan\.php$/', '', $_SERVER['SCRIPT_FILENAME']); |
| 8 | require_once($wfBaseDir . 'wp-load.php'); |
| 9 | global $wp_version; |
| 10 | global $wordfence_wp_version; |
| 11 | require($wfBaseDir . 'wp-includes/version.php'); |
| 12 | $wordfence_wp_version = $wp_version; |
| 13 | } else { |
| 14 | require_once('../../../wp-load.php'); |
| 15 | require_once('../../../wp-includes/version.php'); |
| 16 | } |
| 17 | } |
| 18 | require_once('lib/wordfenceConstants.php'); |
| 19 | require_once('lib/wfScanEngine.php'); |
| 20 | |
| 21 | class wfScan { |
| 22 | public static function wfScanMain(){ |
| 23 | if(! $_SERVER['HTTP_X_WORDFENCE_CRONKEY']){ exit(); } |
| 24 | $savedKey = explode(',',wfConfig::get('currentCronKey')); |
| 25 | if(time() - $savedKey[0] > 60){ exit(); } //keys only last 60 seconds and are used within milliseconds of creation |
| 26 | if($savedKey[1] != $_SERVER['HTTP_X_WORDFENCE_CRONKEY']){ exit(); } |
| 27 | wfConfig::set('currentCronKey', ''); |
| 28 | ini_set('max_execution_time', 1800); //30 mins |
| 29 | self::becomeAdmin(); |
| 30 | |
| 31 | $scanRunning = wfConfig::get('wf_scanRunning'); |
| 32 | if($scanRunning && time() - $scanRunning < WORDFENCE_MAX_SCAN_TIME){ |
| 33 | return; |
| 34 | } |
| 35 | wfConfig::set('wf_scanRunning', time()); |
| 36 | register_shutdown_function('wfScan::clearScan'); |
| 37 | |
| 38 | $scan = new wfScanEngine(); |
| 39 | $scan->go(); |
| 40 | wfConfig::set('wf_scanRunning', ''); |
| 41 | } |
| 42 | public static function becomeAdmin(){ |
| 43 | global $wpdb; |
| 44 | $ws = $wpdb->get_results("SELECT ID, user_login FROM $wpdb->users"); |
| 45 | $users = array(); |
| 46 | foreach($ws as $user){ |
| 47 | $userDat = get_userdata($user->ID); |
| 48 | array_push($users, array( |
| 49 | 'id' => $user->ID, |
| 50 | 'user_login' => $user->user_login, |
| 51 | 'level' => $userDat->user_level |
| 52 | )); |
| 53 | } |
| 54 | usort($users, 'wfScan::usort'); |
| 55 | wp_set_current_user($users[0]['id'], $users[0]['user_login']); |
| 56 | } |
| 57 | public static function usort($b, $a){ |
| 58 | if($a['level'] == $b['level']){ return 0; } |
| 59 | return ($a['level'] < $b['level']) ? -1 : 1; |
| 60 | } |
| 61 | public static function clearScan(){ |
| 62 | wfConfig::set('wf_scanRunning', ''); |
| 63 | } |
| 64 | } |
| 65 | wfScan::wfScanMain(); |
| 66 | ?> |
| 67 |