Example #1
0
 function CallAs($user, $command, $parameters = array())
 {
     if ($user == FALSE) {
         $cmd = array($this->user, $this->pass);
     } else {
         $cmd = array($user, $this->user . ':' . $this->pass);
     }
     array_push($cmd, $command);
     array_push($cmd, $parameters);
     fputs($this->socket, itype_fromphp($cmd) . "\n");
     $line = fgets($this->socket, 128000);
     if ($line === false) {
         //die('Transport layer error occured in the RPC system: fgets() failed.');
         $result = 'Transport layer error occured in the RPC system: fgets() failed.';
     }
     $line = str_replace(array("\r", "\n"), array("", ""), $line);
     $parsedResponse = itype_parse($line);
     if ($parsedResponse[0] == 'empty') {
         //die('IType parsing error occured in RPC system when parsing the string "' . $line . '"');
         $response = $line;
     }
     $response = itype_flat($parsedResponse);
     if (IsError($response)) {
         $code = GetCode($response);
         if ($code != 'RPC_ERROR') {
             //die('Runtime error occured in the RPC system: [' . $code . '] ' . GetResult($response));
             $response = $code;
         }
     }
     return $response;
 }
Example #2
0
    }
    return $result;
}
function createAuthNumImg($randStr, $imgW = 100, $imgH = 40, $fontName)
{
    $image = imagecreate($imgW, $imgH);
    $color_white = imagecolorallocate($image, 255, 255, 255);
    $color_gray = imagecolorallocate($image, 228, 228, 228);
    $color_black = imagecolorallocate($image, 255, 102, 204);
    $color_radom = imagecolorallocate($image, rand(1, 200), rand(1, 200), rand(10, 250));
    for ($i = 0; $i < 2000; $i++) {
        $c = imagecolorallocate($image, rand(1, 200), rand(1, 200), rand(10, 250));
        imagesetpixel($image, mt_rand(0, $imgW), mt_rand(0, $imgH), $c);
        //Ìí¼ÓÔÓµã
    }
    imagerectangle($image, 0, 0, $imgW - 1, $imgH - 1, $color_gray);
    imagettftext($image, 50, mt_rand(-2, 2), rand(0, 20), 50, $color_radom, $fontName, $randStr);
    for ($i = 10; $i < $imgH; $i += 10) {
        imageline($image, 0, $i, $imgW, $i, $color_gray);
    }
    //»­ºáÏß
    for ($i = 10; $i < $imgW; $i += 10) {
        imageline($image, $i, 0, $i, $imgH, $color_gray);
    }
    //»­ÊúÏß
    imagepng($image);
    imagedestroy($image);
}
$str = GetCode(5, 1);
$_SESSION['VerifyCode'] = md5(strtoupper($str));
createAuthNumImg($str, 250, 50, "includes/3dlet.ttf");