获取图片消息
@param int $msgid 消息id
@param string $mode 图片尺寸(large/small)
@return jpg二进制文件
504285
public function getMsgImage($msgid,$mode='large'){
		$send_snoopy = new Snoopy; 
		$send_snoopy->rawheaders['Cookie']= $this->cookie;
		$send_snoopy->referer = "https://mp.weixin.qq.com/cgi-bin/getmessage?t=wxm-message&lang=zh_CN&count=50&token=".$this->_token;
		$url = "https://mp.weixin.qq.com/cgi-bin/getimgdata?token=".$this->_token."&msgid=$msgid&mode=$mode&source=&fileId=0";
		$send_snoopy->fetch($url);
		$result = $send_snoopy->results;
		$this->log('msg image:'.$msgid.';length:'.strlen($result));
		if(!$result){
			return false;
		}
		return $result;
	}
253342
public function scale(Int $width, Int $height = -1, String $mode = 'bilinearFixed') : GD
    {
        $this->canvas = imagescale($this->canvas, $width, $height, Helper::toConstant($mode, 'IMG_'));

        return $this;
    }
1307117
public static function generateGUID()
    {
        $guidStr = '';
        for ($i = 1; $i <= 16; $i++) {
            $b = (int)mt_rand(0, 0xff);
            if ($i == 7) {
                $b &= 0x0f;
                $b |= 0x40;
            } // version 4 (random)
            if ($i == 9) {
                $b &= 0x3f;
                $b |= 0x80;
            } // variant
            $guidStr .= sprintf('%02s', base_convert($b, 10, 16));
            if ($i == 4 || $i == 6 || $i == 8 || $i == 10) {
                $guidStr .= '-';
            }
        }

        return $guidStr;
    }
982769
public function getIsCloserToNext( $precision = false, $mode = PHP_ROUND_HALF_UP )
	{
		if ( ! $this->getIsDecimal() ) {
			return false;
		}

		if ( $precision === false ) $precision = $this->scale( $this->_value );
		if ( $precision < 0 ) $precision = $precision = 0;

		$decimalPart = $this->getDecimalPart();
		if ( $precision >= strlen( $decimalPart ) ) return false;

		// Get the portion of the decimal part affected by the scale value
		$decimalPart = substr( $decimalPart, $precision );
		$result = bccomp( "0." . $decimalPart, "0.5", max( $this->scale( $decimalPart ), 1 ) );
		return $mode == PHP_ROUND_HALF_DOWN ? $result == 1 : $result >= 0;
	}
416879
private static long computeMsgIdUsingBracedPhs(MsgNode msgNode) {
    return SoyMsgIdComputer.computeMsgIdUsingBracedPhs(
        buildMsgParts(msgNode), msgNode.getMeaning(), msgNode.getContentType());
  }
27002
protected function createMsgId()
    {
        $msg = hex2bin($this->messageId);
        $chars = str_split($msg);
        $chars_val = array_map('ord', $chars);
        $pos = count($chars_val) - 1;
        while (true) {
            if ($chars_val[$pos] < 255) {
                $chars_val[$pos]++;
                break;
            } else {
                $chars_val[$pos] = 0;
                $pos--;
            }
        }
        $chars = array_map('chr', $chars_val);
        $msg = bin2hex(implode($chars));
        $this->messageId = $msg;

        return $this->messageId;
    }
1140045
public function getGitHashRetrieverCommand($mode = null)
    {
        $mode = is_null($mode) ? $this->config->get('build.mode') : $mode;

        return $this->config->get('git.'.$mode);
    }
1292809
protected function sendImageMsgToJsonString(WxSendImageMsg $msg)
    {
        $formatStr = '{
                        "touser":"%s",
                        "msgtype":"%s",
                        "image":
                        {
                          "media_id":"%s"
                        }
                    }';
        $result = sprintf($formatStr,   $msg->getToUserName(),
                                        $msg->getMsgType(),
                                        $msg->getMediaId()
                        );


        return $result;
    }
154777
private function get_display_mode_selector_html(int $displaymode) : string {
        $baseurl = $this->baseurl;
        $select = new single_select(
            $baseurl,
            'mode',
            forum_get_layout_modes(),
            $displaymode,
            null,
            'mode'
        );
        $select->set_label(get_string('displaymode', 'forum'), ['class' => 'accesshide']);

        return $this->renderer->render($select);
    }
574192
public static function ngettext($msgid1, $msgid2, $n)
  {
    $args = func_get_args();
    array_splice($args, 0, 3, array(ngettext($msgid1, $msgid2, $n)));

    return call_user_func_array('sprintf', $args);
  }
795753
public static function getImg($original, $width = 0, $height = 0, $default = true, $mode = self::THUMB_MODE_CUT)
    {
        $assetUrl = Yii::$app->getAssetManager()->getPublishedUrl('@vendor/jonneyless/yii2-admin-asset/statics');

        if(!file_exists($assetUrl)){
            Yii::$app->getAssetManager()->publish('@vendor/jonneyless/yii2-admin-asset/statics');
        }

        if(substr($original, 0, 4) == 'http'){
            return $original;
        }

        $originalStatic = Folder::getStatic($original);

        if(!file_exists($originalStatic) || is_dir($originalStatic)){
            if($default){
                if($default === true){
                    return Url::getFull($assetUrl . '/img/default.jpg');
                }else{
                    return Url::getStatic($default);
                }
            }else{
                return '';
            }
        }

        list($oWidth, $oHeight) = getimagesize($originalStatic);

        if($width >= $oWidth && $height >= $oHeight){
            return Url::getStatic($original);
        }

        if($mode == self::THUMB_MODE_ADAPT){
            if($width > 0 && $height > 0){
                $scale = min($width / $oWidth, $height / $oHeight);
            }else if($width == 0){
                $scale = $height / $oHeight;
            }else if($height == 0){
                $scale = $width / $oWidth;
            }

            $width = intval($oWidth * $scale);
            $height = intval($oHeight * $scale);

            $mode = ManipulatorInterface::THUMBNAIL_OUTBOUND;
        }else{
            if($width == 0){
                return Url::getStatic($original);
            }

            if($height == 0){
                $height = intval(($oHeight * $width) / $oWidth);
            }

            $mode = $mode == self::THUMB_MODE_CUT ? ManipulatorInterface::THUMBNAIL_OUTBOUND : ManipulatorInterface::THUMBNAIL_INSET;
        }

        $pathInfo = pathinfo($original);

        if($pathInfo['dirname'] == UPLOAD_FOLDER){
            $thumbFolder = THUMB_FOLDER;
        }else{
            $thumbFolder = str_replace(UPLOAD_FOLDER . '/', THUMB_FOLDER . '/', $pathInfo['dirname']);
        }

        $thumb = $thumbFolder . '/' . $pathInfo['filename'] . '_' . $width . 'x' . $height . '.' . $pathInfo['extension'];

        $thumbStatic = Folder::getStatic($thumb);

        if(!file_exists($thumbStatic)){
            Folder::mkdir(Folder::getStatic($thumbFolder));

            YiiImage::thumbnail($originalStatic, $width, $height, $mode)
                ->interlace(ImageInterface::INTERLACE_LINE)
                ->save($thumbStatic, ['quality' => 100]);
        }

        return Url::getStatic($thumb);
    }
648056
public function imageFlip($image, $mode)
    {
        switch($mode) {
            case self::IMG_FLIP_HORIZONTAL: {
                $max_x = imagesx($image) - 1;
                $half_x = $max_x / 2;
                $sy = imagesy($image);
                $temp_image = imageistruecolor($image)? imagecreatetruecolor(1, $sy): imagecreate(1, $sy);
                for ($x = 0; $x < $half_x; ++$x) {
                    imagecopy($temp_image, $image, 0, 0, $x, 0, 1, $sy);
                    imagecopy($image, $image, $x, 0, $max_x - $x, 0, 1, $sy);
                    imagecopy($image, $temp_image, $max_x - $x, 0, 0, 0, 1, $sy);
                }
                break;
            }
            case self::IMG_FLIP_VERTICAL: {
                $sx = imagesx($image);
                $max_y = imagesy($image) - 1;
                $half_y = $max_y / 2;
                $temp_image = imageistruecolor($image)? imagecreatetruecolor($sx, 1): imagecreate($sx, 1);
                for ($y = 0; $y < $half_y; ++$y) {
                    imagecopy($temp_image, $image, 0, 0, 0, $y, $sx, 1);
                    imagecopy($image, $image, 0, $y, 0, $max_y - $y, $sx, 1);
                    imagecopy($image, $temp_image, 0, $max_y - $y, 0, 0, $sx, 1);
                }
                break;
            }
            case self::IMG_FLIP_BOTH: {
                $sx = imagesx($image);
                $sy = imagesy($image);
                $temp_image = imagerotate($image, 180, 0);
                imagecopy($image, $temp_image, 0, 0, 0, 0, $sx, $sy);
                break;
            }
            default:
                return null;
        }
        imagedestroy($temp_image);
    }
266704
public boolean seen(long msgId) {
    boolean seen = nonContiguousMsgIds.contains(msgId) || msgId <= highestContiguousMsgId;
    tryReconcile();
    return seen;
  }
367718
public function getWait($message_type, $msgid)
    {
        return $this->isEmpty($message_type, $msgid) ?
            false : $this->command_awaits[$message_type][$msgid];
    }
847048
private function generateV4GUID(): string
    {
        if (true === \function_exists('com_create_guid')) {
            return trim(com_create_guid(), '{}');
        }

        $data    = openssl_random_pseudo_bytes(16);
        $data[6] = \chr(\ord($data[6]) & 0x0f | 0x40);
        $data[8] = \chr(\ord($data[8]) & 0x3f | 0x80);

        return vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex($data), 4));
    }
90835
public static function getRandomString($length,$mode=0)
    {
        $chars=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","0","1","2","3","4","5","6","7","8","9"];
        if($mode==1){
            $chars=["0","1","2","3","4","5","6","7","8","9"];
        }
        if($mode==2){
            $chars=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"];
        }
        shuffle($chars);
        $max=count($chars)-1;
        $returnValue = "";
        while(strlen($returnValue)<$length){
            $randIndex=rand(0,$max);
            $returnValue .= $chars[$randIndex];
        }
        return $returnValue;
    }
506568
public function getDestSuffix(string $unit = null, string $mode = null)
    {
        return self::getSuffix($this->getDestUnit($unit), $this->getMode($mode));
    }