123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989 |
- <?php
- namespace crmeb\services;
- class FileService
- {
-
- static public function mk_dir($dir)
- {
- $dir = rtrim($dir, '/') . '/';
- if (!is_dir($dir)) {
- if (mkdir($dir, 0700) == false) {
- return false;
- }
- return true;
- }
- return true;
- }
-
- static function write_file($filename, $writetext, $openmod = 'w')
- {
- if (!self::checkPath($filename)) {
- return false;
- }
- if (!self::checkContent($writetext)) {
- return false;
- }
- if (@$fp = fopen($filename, $openmod)) {
- flock($fp, 2);
- fwrite($fp, $writetext);
- fclose($fp);
- return true;
- } else {
- return false;
- }
- }
-
- static function del_dir($dirName)
- {
- if (!file_exists($dirName)) {
- return false;
- }
- $dir = opendir($dirName);
- while ($fileName = readdir($dir)) {
- $file = $dirName . '/' . $fileName;
- if ($fileName != '.' && $fileName != '..') {
- if (is_dir($file)) {
- self::del_dir($file);
- } else {
- unlink($file);
- }
- }
- }
- closedir($dir);
- return rmdir($dirName);
- }
-
- public function copy_dir($surDir, $toDir)
- {
- $surDir = rtrim($surDir, '/') . '/';
- $toDir = rtrim($toDir, '/') . '/';
- if (!file_exists($surDir)) {
- return false;
- }
- if (!file_exists($toDir)) {
- $this->create_dir($toDir);
- }
- $file = opendir($surDir);
- while ($fileName = readdir($file)) {
- $file1 = $surDir . '/' . $fileName;
- $file2 = $toDir . '/' . $fileName;
- if ($fileName != '.' && $fileName != '..') {
- if (is_dir($file1)) {
- self::copy_dir($file1, $file2);
- } else {
- copy($file1, $file2);
- }
- }
- }
- closedir($file);
- return true;
- }
-
- static function get_dirs($dir)
- {
- $dir = rtrim($dir, '/') . '/';
- $dirArray [][] = NULL;
- if (false != ($handle = opendir($dir))) {
- $i = 0;
- $j = 0;
- while (false !== ($file = readdir($handle))) {
- if (is_dir($dir . $file)) {
- $dirArray ['dir'] [$i] = $file;
- $i++;
- } else {
- $dirArray ['file'] [$j] = $file;
- $j++;
- }
- }
- closedir($handle);
- }
- return $dirArray;
- }
-
- static function get_size($dir)
- {
- $dirlist = opendir($dir);
- $dirsize = 0;
- while (false !== ($folderorfile = readdir($dirlist))) {
- if ($folderorfile != "." && $folderorfile != "..") {
- if (is_dir("$dir/$folderorfile")) {
- $dirsize += self::get_size("$dir/$folderorfile");
- } else {
- $dirsize += filesize("$dir/$folderorfile");
- }
- }
- }
- closedir($dirlist);
- return $dirsize;
- }
-
- static function empty_dir($dir)
- {
- return (($files = @scandir($dir)) && count($files) <= 2);
- }
-
- public function create_dir($dir, $mode = 0777)
- {
- return is_dir($dir) or ($this->create_dir(dirname($dir)) and mkdir($dir, $mode));
- }
-
- public function create_file($path, $over_write = FALSE, $time = NULL, $atime = NULL)
- {
- $path = $this->dir_replace($path);
- $time = empty($time) ? time() : $time;
- $atime = empty($atime) ? time() : $atime;
- if (file_exists($path) && $over_write) {
- $this->unlink_file($path);
- }
- $aimDir = dirname($path);
- $this->create_dir($aimDir);
- return touch($path, $time, $atime);
- }
-
- public function close($path)
- {
- return fclose($path);
- }
-
- public static function read_file($file)
- {
- return @file_get_contents($file);
- }
-
- public function allow_upload_size()
- {
- $val = trim(ini_get('upload_max_filesize'));
- return $val;
- }
-
- public static function byte_format($size, $dec = 2)
- {
- $a = array("B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB");
- $pos = 0;
- while ($size >= 1024) {
- $size /= 1024;
- $pos++;
- }
- return round($size, $dec) . " " . $a[$pos];
- }
-
- public function remove_dir($dir_path, $is_all = FALSE)
- {
- $dirName = $this->dir_replace($dir_path);
- $handle = @opendir($dirName);
- while (($file = @readdir($handle)) !== FALSE) {
- if ($file != '.' && $file != '..') {
- $dir = $dirName . '/' . $file;
- if ($is_all) {
- is_dir($dir) ? $this->remove_dir($dir) : $this->unlink_file($dir);
- } else {
- if (is_file($dir)) {
- $this->unlink_file($dir);
- }
- }
- }
- }
- closedir($handle);
- return @rmdir($dirName);
- }
-
- public function get_basename($file_path)
- {
- $file_path = $this->dir_replace($file_path);
- return basename(str_replace('\\', '/', $file_path));
-
- }
-
- public static function get_ext($file)
- {
- $file = self::dir_replace($file);
-
-
-
-
- return pathinfo($file, PATHINFO_EXTENSION);
- }
-
- public function father_dir($path, $num = 1)
- {
- $path = $this->dir_replace($path);
- $arr = explode('/', $path);
- if ($num == 0 || count($arr) < $num) return pathinfo($path, PATHINFO_BASENAME);
- return substr(strrev($path), 0, 1) == '/' ? $arr[(count($arr) - (1 + $num))] : $arr[(count($arr) - $num)];
- }
-
- public function unlink_file($path)
- {
- $path = $this->dir_replace($path);
- if (file_exists($path)) {
- return unlink($path);
- }
- }
-
- public function handle_file($old_path, $new_path, $type = 'copy', $overWrite = FALSE)
- {
- $old_path = $this->dir_replace($old_path);
- $new_path = $this->dir_replace($new_path);
- if (file_exists($new_path) && $overWrite = FALSE) {
- return FALSE;
- } else if (file_exists($new_path) && $overWrite = TRUE) {
- $this->unlink_file($new_path);
- }
- $aimDir = dirname($new_path);
- $this->create_dir($aimDir);
- switch ($type) {
- case 'copy':
- return copy($old_path, $new_path);
- break;
- case 'move':
- return @rename($old_path, $new_path);
- break;
- }
- }
-
- public function handle_dir($old_path, $new_path, $type = 'copy', $overWrite = FALSE)
- {
- $new_path = $this->check_path($new_path);
- $old_path = $this->check_path($old_path);
- if (!is_dir($old_path)) return FALSE;
- if (!file_exists($new_path)) $this->create_dir($new_path);
- $dirHandle = opendir($old_path);
- if (!$dirHandle) return FALSE;
- $boolean = TRUE;
- while (FALSE !== ($file = readdir($dirHandle))) {
- if ($file == '.' || $file == '..') continue;
- if (!is_dir($old_path . $file)) {
- $boolean = $this->handle_file($old_path . $file, $new_path . $file, $type, $overWrite);
- } else {
- $this->handle_dir($old_path . $file, $new_path . $file, $type, $overWrite);
- }
- }
- switch ($type) {
- case 'copy':
- closedir($dirHandle);
- return $boolean;
- break;
- case 'move':
- closedir($dirHandle);
- return @rmdir($old_path);
- break;
- }
- }
-
- public static function dir_replace($path)
- {
- return str_replace('//', '/', str_replace('\\', '/', $path));
- }
-
- public static function get_templtes($path)
- {
- $path = self::dir_replace($path);
- if (file_exists($path)) {
- $fp = fopen($path, 'r');
- $rstr = fread($fp, filesize($path));
- fclose($fp);
- return $rstr;
- } else {
- return '';
- }
- }
-
- public function rename($oldname, $newname)
- {
- if (($newname != $oldname) && is_writable($oldname)) {
- return rename($oldname, $newname);
- }
- }
-
- public function get_dir_info($dir)
- {
- $handle = @opendir($dir);
- $directory_count = 0;
- $total_size = 0;
- $file_cout = 0;
- while (FALSE !== ($file_path = readdir($handle))) {
- if ($file_path != "." && $file_path != "..") {
-
- $next_path = $dir . '/' . $file_path;
- if (is_dir($next_path)) {
- $directory_count++;
- $result_value = self::get_dir_info($next_path);
- $total_size += $result_value['size'];
- $file_cout += $result_value['filecount'];
- $directory_count += $result_value['dircount'];
- } elseif (is_file($next_path)) {
- $total_size += filesize($next_path);
- $file_cout++;
- }
- }
- }
- closedir($handle);
- $result_value['size'] = $total_size;
- $result_value['filecount'] = $file_cout;
- $result_value['dircount'] = $directory_count;
- return $result_value;
- }
-
- public function change_file_code($path, $input_code, $out_code)
- {
- if (is_file($path))
- {
- $content = file_get_contents($path);
- $content = string::chang_code($content, $input_code, $out_code);
- $fp = fopen($path, 'w');
- return fputs($fp, $content) ? TRUE : FALSE;
- fclose($fp);
- }
- }
-
- public function change_dir_files_code($dirname, $input_code, $out_code, $is_all = TRUE, $exts = '')
- {
- if (is_dir($dirname)) {
- $fh = opendir($dirname);
- while (($file = readdir($fh)) !== FALSE) {
- if (strcmp($file, '.') == 0 || strcmp($file, '..') == 0) {
- continue;
- }
- $filepath = $dirname . '/' . $file;
- if (is_dir($filepath) && $is_all == TRUE) {
- $files = $this->change_dir_files_code($filepath, $input_code, $out_code, $is_all, $exts);
- } else {
- if ($this->get_ext($filepath) == $exts && is_file($filepath)) {
- $boole = $this->change_file_code($filepath, $input_code, $out_code, $is_all, $exts);
- if (!$boole) continue;
- }
- }
- }
- closedir($fh);
- return TRUE;
- } else {
- return FALSE;
- }
- }
-
- public function list_dir_info($dirname, $is_all = FALSE, $exts = '', $sort = 'ASC')
- {
-
- $new = strrev($dirname);
- if (strpos($new, '/') == 0) {
- $new = substr($new, 1);
- }
- $dirname = strrev($new);
- $sort = strtolower($sort);
- $files = array();
- $subfiles = array();
- if (is_dir($dirname)) {
- $fh = opendir($dirname);
- while (($file = readdir($fh)) !== FALSE) {
- if (strcmp($file, '.') == 0 || strcmp($file, '..') == 0) continue;
- $filepath = $dirname . '/' . $file;
- switch ($exts) {
- case '*':
- if (is_dir($filepath) && $is_all == TRUE) {
- $files = array_merge($files, self::list_dir_info($filepath, $is_all, $exts, $sort));
- }
- array_push($files, $filepath);
- break;
- case 'folder':
- if (is_dir($filepath) && $is_all == TRUE) {
- $files = array_merge($files, self::list_dir_info($filepath, $is_all, $exts, $sort));
- array_push($files, $filepath);
- } elseif (is_dir($filepath)) {
- array_push($files, $filepath);
- }
- break;
- case 'file':
- if (is_dir($filepath) && $is_all == TRUE) {
- $files = array_merge($files, self::list_dir_info($filepath, $is_all, $exts, $sort));
- } elseif (is_file($filepath)) {
- array_push($files, $filepath);
- }
- break;
- default:
- if (is_dir($filepath) && $is_all == TRUE) {
- $files = array_merge($files, self::list_dir_info($filepath, $is_all, $exts, $sort));
- } elseif (preg_match("/\.($exts)/i", $filepath) && is_file($filepath)) {
- array_push($files, $filepath);
- }
- break;
- }
- switch ($sort) {
- case 'asc':
- sort($files);
- break;
- case 'desc':
- rsort($files);
- break;
- case 'nat':
- natcasesort($files);
- break;
- }
- }
- closedir($fh);
- return $files;
- } else {
- return FALSE;
- }
- }
-
- public function dir_info($dir)
- {
- return scandir($dir);
- }
-
- public function is_empty($dir)
- {
- $handle = opendir($dir);
- while (($file = readdir($handle)) !== false) {
- if ($file != '.' && $file != '..') {
- closedir($handle);
- return true;
- }
- }
- closedir($handle);
- return false;
- }
-
- public static function list_info($file)
- {
- $dir = array();
- $dir['filename'] = basename($file);
- $dir['pathname'] = strstr(php_uname('s'), 'Windows') ? str_replace('\\', '\\\\', realpath($file)) : realpath($file);
- $dir['owner'] = fileowner($file);
- $dir['perms'] = fileperms($file);
- $dir['inode'] = fileinode($file);
- $dir['group'] = filegroup($file);
- $dir['path'] = dirname($file);
- $dir['atime'] = fileatime($file);
- $dir['ctime'] = filectime($file);
- $dir['perms'] = fileperms($file);
- $dir['size'] = self::byte_format(filesize($file), 2);
- $dir['type'] = filetype($file);
- $dir['ext'] = is_file($file) ? pathinfo($file, PATHINFO_EXTENSION) : '';
- $dir['mtime'] = filemtime($file);
- $dir['isDir'] = is_dir($file);
- $dir['isFile'] = is_file($file);
- $dir['isLink'] = is_link($file);
- $dir['isReadable'] = is_readable($file);
- $dir['isWritable'] = is_writable($file);
- $dir['isUpload'] = is_uploaded_file($file);
- return $dir;
- }
-
- public function open_info($file)
- {
- $file = fopen($file, "r");
- $result = fstat($file);
- fclose($file);
- return $result;
- }
-
- public function change_file($file, $type, $ch_info)
- {
- switch ($type) {
- case 'group' :
- $is_ok = chgrp($file, $ch_info);
- break;
- case 'mode' :
- $is_ok = chmod($file, $ch_info);
- break;
- case 'ower' :
- $is_ok = chown($file, $ch_info);
- break;
- }
- }
-
- public function get_file_type($path)
- {
-
-
-
- return pathinfo($path);
- }
-
- public function get_upload_file_info($file)
- {
- $file_info = $_FILES[$file];
- $info = array();
- $info['type'] = strtolower(trim(stripslashes(preg_replace("/^(.+?);.*$/", "\\1", $file_info['type'])), '"'));
- $info['temp'] = $file_info['tmp_name'];
- $info['size'] = $file_info['size'];
- $info['error'] = $file_info['error'];
- $info['name'] = $file_info['name'];
- $info['ext'] = $this->get_ext($file_info['name']);
- return $info;
- }
-
- public function set_file_name($type)
- {
- switch ($type) {
- case 'hash' :
- $new_file = md5(uniqid(mt_rand()));
- break;
- case 'time' :
- $new_file = time();
- break;
- default :
- $new_file = date($type, time());
- break;
- }
- return $new_file;
- }
-
- public function check_path($path)
- {
- return (preg_match('/\/$/', $path)) ? $path : $path . '/';
- }
-
- public static function down_remote_file($url, $save_dir = '', $filename = '', $type = 0)
- {
- if (trim($url) == '') {
- return array('file_name' => '', 'save_path' => '', 'error' => 1);
- }
- if (trim($save_dir) == '') {
- $save_dir = './';
- }
- if (trim($filename) == '') {
- $ext = strrchr($url, '.');
-
-
-
- $filename = time() . $ext;
- }
- if (0 !== strrpos($save_dir, '/')) {
- $save_dir .= '/';
- }
-
- if (!file_exists($save_dir) && !mkdir($save_dir, 0777, true)) {
- return array('file_name' => '', 'save_path' => '', 'error' => 5);
- }
-
- if ($type) {
- $ch = curl_init();
- $timeout = 5;
- curl_setopt($ch, CURLOPT_URL, $url);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
- $img = curl_exec($ch);
- curl_close($ch);
- } else {
- ob_start();
- readfile($url);
- $img = ob_get_contents();
- ob_end_clean();
- }
-
-
- $fp2 = fopen($save_dir . $filename, 'a');
- fwrite($fp2, $img);
- fclose($fp2);
- unset($img, $url);
- return array('file_name' => $filename, 'save_path' => $save_dir . $filename, 'error' => 0);
- }
- public static function zipopen($filename, $savename)
- {
- $zip = new \ZipArchive;
- $zipfile = $filename;
- $res = $zip->open($zipfile);
- $toDir = $savename;
- if (!file_exists($toDir)) mkdir($toDir, 0777);
- $docnum = $zip->numFiles;
- for ($i = 0; $i < $docnum; $i++) {
- $statInfo = $zip->statIndex($i);
- if ($statInfo['crc'] == 0 && $statInfo['comp_size'] != 2) {
-
- mkdir($toDir . '/' . substr($statInfo['name'], 0, -1), 0777);
- } else {
-
- copy('zip://' . $zipfile . '#' . $statInfo['name'], $toDir . '/' . $statInfo['name']);
- }
- }
- $zip->close();
- return true;
- }
-
- public static function setUtf8($title)
- {
- return iconv('utf-8', 'gb2312', $title);
- }
-
- public static function isWritable($file)
- {
- $file = str_replace('\\', '/', $file);
- if (!file_exists($file)) return false;
- return is_writable($file);
- }
-
- public static function checkPath($path)
- {
- $str = ['/%00/', '"/\/|\~|\,|\。|\!|\?|\“|\”|\【|\】|\『|\』|\:|\;|\《|\》|\’|\‘|\ |\~|\!|\@|\#|\\$|\%|\^|\&|\*|\(|\)|\+|\{|\}|\:|\<|\>|\?|\[|\]|\,|\/|\;|\'|\`|\=|\\\|\|/"'];
- foreach ($str as $value) {
- if (preg_match($value, $path)) {
- return false;
- }
- }
- return true;
- }
-
- public static function checkContent($content)
- {
-
- if ((preg_match('#(\$\w{2,4}\s?=\s?str_replace\("\w+","","[\w_]+"\);\s?)+#s', $content) && preg_match('#(\$\w{2,4}\s?=\s?"[\w\d\+\/\=]+";\s?)+#', $content) && preg_match('#\$[\w]{2,4}\s?=\s\$[\w]{2,4}\(\'\',\s?\$\w{2,4}\(\$\w{2,4}\("\w{1,4}",\s?"",\s?\$\w{2,4}\.\$\w{2,4}\.\$\w{2,4}\.\$\w{2,4}\)\)\);\s+?\$\w{2,4}\(\)\;#', $content))
- ||
- (preg_match('#\$\w+\d\s?=\s?str_replace\(\"[\w\d]+\",\"\",\"[\w\d]+\"\);#s', $content) && preg_match('#\$\w+\s?=\s?\$[\w\d]+\(\'\',\s?\$[\w\d]+\(\$\w+\(\$\w+\(\"[[:punct:]]+\",\s?\"\",\s?\$\w+\.\$\w+\.\$\w+\.\$\w+\)\)\)\);\s?\$\w+\(\);#s', $content))
- ) {
- return false;
- }
-
- if (preg_match('#\$\w+\s?=\s?\$_(?:GET|POST|REQUEST|COOKIE|SERVER)\[.*?\]#is', $content) &&
- preg_match('#\$\w+\s?=\s?(?:new)?\s?array\w*\s?\(.*?_(?:GET|POST|REQUEST|COOKIE|SERVER)\[.*?\].*?\)+#is', $content) &&
- preg_match('#(?:array_(?:reduce|map|udiff|walk|walk_recursive|filter)|u[ak]sort)\s?\(.*?\)+?#is', $content)
- ) {
- return false;
- }
-
- $matches = [
- '/mb_ereg_replace\([\'\*\s\,\.\"]+\$_(?:GET|POST|REQUEST|COOKIE|SERVER)\[[\'\"].*?[\'\"][\]][\,\s\'\"]+e[\'\"]/is',
- '/preg_filter\([\'\"\|\.\*e]+.*\$_(?:GET|POST|REQUEST|COOKIE|SERVER)/is',
- '/create_function\s?\(.*assert\(/is',
- '/ini_get\(\'safe_mode\'\)/i',
- '/get_current_user\(.*?\)/i',
- '/@?assert\s?\(\$.*?\)/i',
- '/proc_open\s?\(.*?pipe\',\s?\'w\'\)/is',
- '/sTr_RepLaCe\s?\([\'\"].*?[\'\"],[\'\"].*?[\'\"]\s?,\s?\'a[[:alnum:][:punct:]]+?s[[:alnum:][:punct:]]+?s[[:alnum:][:punct:]]+?e[[:alnum:][:punct:]]+?r[[:alnum:][:punct:]]+?t[[:alnum:][:punct:]]+?\)/i',
- '/preg_replace_callback\(.*?create_function\(/is',
- '/filter_var(?:_array)?\s?.*?\$_(?:GET|POST|REQUEST|COOKIE|SERVER)\[[\'\"][[:punct:][:alnum:]]+[\'\"]\][[:punct:][:alnum:][:space:]]+?assert[\'\"]\)/is',
- '/ob_start\([\'\"]+assert[\'\"]+\)/is',
- '/new\s?ReflectionFunction\(.*?->invoke\(/is',
- '/PDO::FETCH_FUNC/',
- '/\$\w+.*\s?(?:=|->)\s?.*?[\'\"]assert[\'\"]\)?/i',
- '/\$\w+->(?:sqlite)?createFunction\(.*?\)/i',
- '/eval\([\"\']?\\\?\$\w+\s?=\s?.*?\)/i',
- '/eval\(.*?gzinflate\(base64_decode\(/i',
- '/copy\(\$HTTP_POST_FILES\[\'\w+\'\]\s?\[\'tmp_name\'\]/i',
- '/register_(?:shutdown|tick)_function\s?\(\$\w+,\s\$_(?:GET|POST|REQUEST|COOKIE|SERVER)\[.*?\]\)/is',
- '/register_(?:shutdown|tick)_function\s?\(?[\'\"]assert[\"\'].*?\)/i',
- '/call_user_func.*?\([\"|\']assert[\"|\'],.*\$_(?:GET|POST|REQUEST|COOKIE|SERVER)\[[\'|\"].*\]\)+/is',
- '/preg_replace\(.*?e.*?\'\s?,\s?.*?\w+\(.*?\)/i',
- '/function_exists\s*\(\s*[\'|\"](popen|exec|proc_open|system|passthru)+[\'|\"]\s*\)/i',
- '/(exec|shell_exec|system|passthru)+\s*\(\s*\$_(\w+)\[(.*)\]\s*\)/i',
- '/(exec|shell_exec|system|passthru)+\s*\(\$\w+\)/i',
- '/(exec|shell_exec|system|passthru)\s?\(\w+\(\"http_.*\"\)\)/i',
- '/(?:john\.barker446@gmail\.com|xb5@hotmail\.com|shopen@aventgrup\.net|milw0rm\.com|www\.aventgrup\.net|mgeisler@mgeisler\.net)/i',
- '/Php\s*?Shell/i',
- '/((udp|tcp)\:\/\/(.*)\;)+/i',
- '/preg_replace\s*\((.*)\/e(.*)\,\s*\$_(.*)\,(.*)\)/i',
- '/preg_replace\s*\((.*)\(base64_decode\(\$/i',
- '/(eval|assert|include|require|include_once|require_once)+\s*\(\s*(base64_decode|str_rot13|gz(\w+)|file_(\w+)_contents|(.*)php\:\/\/input)+/i',
- '/(eval|assert|include|require|include_once|require_once|array_map|array_walk)+\s*\(.*?\$_(?:GET|POST|REQUEST|COOKIE|SERVER|SESSION)+\[(.*)\]\s*\)/i',
- '/eval\s*\(\s*\(\s*\$\$(\w+)/i',
- '/((?:include|require|include_once|require_once)+\s*\(?\s*[\'|\"]\w+\.(?!php).*[\'|\"])/i',
- '/\$_(\w+)(.*)(eval|assert|include|require|include_once|require_once)+\s*\(\s*\$(\w+)\s*\)/i',
- '/\(\s*\$_FILES\[(.*)\]\[(.*)\]\s*\,\s*\$_(GET|POST|REQUEST|FILES)+\[(.*)\]\[(.*)\]\s*\)/i',
- '/(fopen|fwrite|fputs|file_put_contents)+\s*\((.*)\$_(GET|POST|REQUEST|COOKIE|SERVER)+\[(.*)\](.*)\)/i',
- '/echo\s*curl_exec\s*\(\s*\$(\w+)\s*\)/i',
- '/new com\s*\(\s*[\'|\"]shell(.*)[\'|\"]\s*\)/i',
- '/\$(.*)\s*\((.*)\/e(.*)\,\s*\$_(.*)\,(.*)\)/i',
- '/\$_\=(.*)\$_/i',
- '/\$_(GET|POST|REQUEST|COOKIE|SERVER)+\[(.*)\]\(\s*\$(.*)\)/i',
- '/\$(\w+)\s*\(\s*\$_(GET|POST|REQUEST|COOKIE|SERVER)+\[(.*)\]\s*\)/i',
- '/\$(\w+)\s*\(\s*\$\{(.*)\}/i',
- '/\$(\w+)\s*\(\s*chr\(\d+\)/i'
- ];
- foreach ($matches as $value) {
- if (preg_match($value, $content)) {
- return false;
- }
- }
- return true;
- }
- }
|