collectgame /gamecrawler/wp/youxisoso/verify.php

Language PHP Lines 159
MD5 Hash f7470169ab46eb77c790baef80787968 Estimated Cost $2,484 (why?)
Repository http://collectgame.googlecode.com/svn/trunk/ View Raw File
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
<?php   
/**
 Template Name:shengchengyz
 */
class YL_Security_Secoder {   
    //????session???  
    public static $seKey = 'verify_py';   //??????
    public static $expire = 3000;     // ????????s?    
    //??????????01IO???????  
    public static $codeSet = '3456789ABCDEFGHJKLMNPQRTUVWXY';   
    public static $fontSize = 26;     // ???????(px)   
    public static $useCurve = true;   // ???????   
    public static $useNoise = true;   // ??????    
    public static $imageH = 0;        // ??????   
    public static $imageL = 0;        // ??????   
    public static $length = 4;        // ?????   
    public static $bg = array(243, 251, 254);  // ??   
       
    protected static $_image = null;     // ???????   
    protected static $_color = null;     // ???????   
       
    /**  
     * ???????????????session?  
     */  
    public static function entry() {   
        // ???(px)   
        self::$imageL || self::$imageL = self::$length * self::$fontSize * 1.5 + self::$fontSize*1.5;    
        // ???(px)   
        self::$imageH || self::$imageH = self::$fontSize * 2;   
        // ???? self::$imageL x self::$imageH ???   
        self::$_image = imagecreate(self::$imageL, self::$imageH);    
        // ????         
        imagecolorallocate(self::$_image, self::$bg[0], self::$bg[1], self::$bg[2]);    
        // ?????????   
        self::$_color = imagecolorallocate(self::$_image, mt_rand(1,120), mt_rand(1,120), mt_rand(1,120));   
        // ?????????????????????   
        $ttf = dirname(__FILE__) . '/ttfs/t' . mt_rand(1, 10) . '.ttf';     
  
        if (self::$useNoise) {   
            // ???   
            self::_writeNoise();   
        }    
        if (self::$useCurve) {   
            // ????   
            self::_writeCurve();   
        }   
           
        // ????   
        $code = array(); // ???   
        $codeNX = 0; // ????N???????   
        if(empty($code) == true){
        	for ($i = 0; $i<self::$length; $i++) {   
	            $code[$i] = self::$codeSet[mt_rand(0, 28)];   
	            $codeNX += mt_rand(self::$fontSize*1.2, self::$fontSize*1.6);   
	            // ????????   
            imagettftext(self::$_image, self::$fontSize, mt_rand(-40, 70), $codeNX, self::$fontSize*1.5, self::$_color, $ttf, $code[$i]);   
        	}   
        }
        
           
        // ?????   
        isset($_SESSION) || session_start();   
        $_SESSION[self::$seKey]['code'] = join('', $code); // ???????session, ????????  
        $_SESSION[self::$seKey]['time'] = time();  // ???????   
                       
        header('Pragma: no-cache');
        header("content-type: image/JPEG; charset=utf-8");   
       
        // ????   
        imageJPEG(self::$_image);    
        imagedestroy(self::$_image);   
    }   
       
    /**   
     * ?????????????????????????(????????????)   
     *      ?????????y=Asin(?x+?)+b  
     *      ?????????????  
     *        A?????????????????  
     *        b??????Y???????????????????  
     *        ???????X??????????????????  
     *        ????????????T=2?/????  
     */  
    protected static function _writeCurve() {   
        $A = mt_rand(1, self::$imageH/2);                  // ??   
        $b = mt_rand(-self::$imageH/4, self::$imageH/4);   // Y??????   
        $f = mt_rand(-self::$imageH/4, self::$imageH/4);   // X??????   
        $T = mt_rand(self::$imageH*1.5, self::$imageL*2);  // ??   
        $w = (2* M_PI)/$T;   
                           
        $px1 = 0;  // ?????????   
        $px2 = mt_rand(self::$imageL/2, self::$imageL * 0.667);  // ?????????              
        for ($px=$px1; $px<=$px2; $px=$px+ 0.9) {   
            if ($w!=0) {   
                $py = $A * sin($w*$px + $f)+ $b + self::$imageH/2;  // y = Asin(?x+?) + b   
                $i = (int) ((self::$fontSize - 6)/4);   
                while ($i > 0) {    
                    imagesetpixel(self::$_image, $px + $i, $py + $i, self::$_color);  
					//???????imagettftext?imagestring??????                     
                    $i--;   
                }   
            }   
        }   
           
        $A = mt_rand(1, self::$imageH/2);                  // ??           
        $f = mt_rand(-self::$imageH/4, self::$imageH/4);   // X??????   
        $T = mt_rand(self::$imageH*1.5, self::$imageL*2);  // ??   
        $w = (2* M_PI)/$T;         
        $b = $py - $A * sin($w*$px + $f) - self::$imageH/2;   
        $px1 = $px2;   
        $px2 = self::$imageL;   
        for ($px=$px1; $px<=$px2; $px=$px+ 0.9) {   
            if ($w!=0) {   
                $py = $A * sin($w*$px + $f)+ $b + self::$imageH/2;  // y = Asin(?x+?) + b   
                $i = (int) ((self::$fontSize - 8)/4);   
                while ($i > 0) {            
                    imagesetpixel(self::$_image, $px + $i, $py + $i, self::$_color); 
					//??(while)???????imagettftext?imagestring?????????
					//????while?????????       
                    $i--;   
                }   
            }   
        }   
    }   
       
    /**  
     * ???  
     * ???????????????  
     */  
    protected static function _writeNoise() {   
        for($i = 0; $i < 10; $i++){   
            //????   
            $noiseColor = imagecolorallocate(   
                              self::$_image,    
                              mt_rand(150,225),    
                              mt_rand(150,225),    
                              mt_rand(150,225)   
                          );   
            for($j = 0; $j < 5; $j++) {   
                // ???   
                imagestring(   
                    self::$_image,   
                    5,    
                    mt_rand(-10, self::$imageL),    
                    mt_rand(-10, self::$imageH),    
                    self::$codeSet[mt_rand(0, 28)], // ?????????????   
                    $noiseColor  
                );   
            }   
        }   
    }   
}   
  

//??????????? ??????
YL_Security_Secoder::$useNoise = true;  //??????  
YL_Security_Secoder::$useCurve = true;   //????????
YL_Security_Secoder::entry(); 

?>
Back to Top