国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

Home php教程 PHP源碼 PHP detects image Trojans

PHP detects image Trojans

Nov 09, 2016 pm 02:31 PM

<?php   

class Upload {  
    
      private static $image = null;  
      private static $status = 0;  
      private static $suffix = null;  
      private static $imageType = array(&#39;.jpg&#39;, &#39;.bmp&#39;,&#39;.gif&#39;,&#39;.png&#39;);  
      private static $message = array(  
            &#39;0&#39; => &#39;沒有錯誤發(fā)生,文件上傳成功。&#39;,  
            &#39;1&#39; => &#39;上傳的文件超過了 php.ini 中 upload_max_filesize 選項限制的值。&#39;,  
            &#39;2&#39; => &#39;上傳文件的大小超過了 HTML 表單中 MAX_FILE_SIZE 選項指定的值。&#39;,  
            &#39;3&#39; => &#39;文件只有部分被上傳。&#39;,  
            &#39;4&#39; => &#39;沒有文件上傳。&#39;,  
            &#39;5&#39; => &#39;未能通過安全檢查的文件。&#39;,  
            &#39;6&#39; => &#39;找不到臨時文件夾。&#39;,  
            &#39;7&#39; => &#39;文件寫入失敗。&#39;,  
            &#39;8&#39; => &#39;文件類型不支持&#39;,  
            &#39;9&#39; => &#39;上傳的臨時文件丟失。&#39;,  
      );  
    
      //@ 開始執(zhí)行文件上傳  
      public static function start($feild = &#39;file&#39;) {  
            if (!empty($_FILES)) {  
                self::$status = $_FILES[$feild][&#39;error&#39;];  
               if (self::$status > 0)  
                      return array(&#39;status&#39; => self::$status, &#39;msg&#39; => self::$message[self::$status]);  
                  self::$image = $_FILES[$feild][&#39;tmp_name&#39;];  
                  self::$suffix = strtolower(strrchr($_FILES[$feild][&#39;name&#39;], &#39;.&#39;));  
                  return array(&#39;status&#39; => self::_upload(), &#39;path&#39; => self::$image, &#39;msg&#39; => self::$message[self::$status]);  
           } else {  
                  return array(&#39;status&#39; => self::$status, &#39;msg&#39; => self::$message[self::$status]);  
           }  
}  
    
    //@ 私有 上傳開始  
    private static function _upload($path = &#39;./upload/&#39;) {  
        date_default_timezone_set(&#39;PRC&#39;);  
        $newFile = $path . date(&#39;Y/m/d/His&#39;) . rand(100, 999) . self::$suffix;  
        self::umkdir(dirname($newFile));  
        if (is_uploaded_file(self::$image) && move_uploaded_file(self::$image, $newFile)) {  
            self::$image = $newFile;  
            if (in_array(self::$suffix, self::$imageType))  
                return self::checkHex();  
            else 
                return self::$status = 0;  
        } else {  
            return self::$status = 9;  
        }  
    }  
    
    //@ 私有 16進制檢測 黑客  
    private static function checkHex() {  
        if (file_exists(self::$image)) {  
            $resource = fopen(self::$image, &#39;rb&#39;);  
            $fileSize = filesize(self::$image);  
            fseek($resource, 0);  
            if ($fileSize > 512) { // 取頭和尾  
                $hexCode = bin2hex(fread($resource, 512));  
                fseek($resource, $fileSize - 512);  
                $hexCode .= bin2hex(fread($resource, 512));  
            } else { // 取全部  
                $hexCode = bin2hex(fread($resource, $fileSize));  
            }  
            fclose($resource);  
            /* 匹配16進制中的 */ 
            /* 匹配16進制中的 */ 
            /* 匹配16進制中的

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)