用于发送消息时生成msg id.

@return int
979882
public static function makeMsgId()
    {
        static $sequence = 0;
        static $t = 0;
        if (!$t) {
            $t = static::getMillisecond();
            $t = ($t - $t % 1000) / 1000;
            $t = $t % 10000 * 10000;
        }
        //获取msgId
        ++$sequence;

        return $t + $sequence;
    }
113244
protected function generateId()
    {
        $len = 32; //32 bytes = 256 bits
        if (function_exists('random_bytes')) {
            $bytes = random_bytes($len);
        } elseif (function_exists('openssl_random_pseudo_bytes')) {
            $bytes = openssl_random_pseudo_bytes($len);
        } else {
            //Use a hash to force the length to the same as the other methods
            $bytes = hash('sha256', uniqid((string) mt_rand(), true), true);
        }

        //We don't care about messing up base64 format here, just want a random string
        return str_replace(['=', '+', '/'], '', base64_encode(hash('sha256', $bytes, true)));
    }
849773
public function delete($msg_id)
    {
        if (empty($msg_id)) {
            $this->setError('参数缺失');

            return false;
        }

        $queryStr           = [];
        $queryStr['msg_id'] = $msg_id;

        $this->module = 'message';

        $res = $this->_post('mass/delete', $queryStr);

        return $res;
    }
925396
public function generateId(): string
    {
        if ($this->saveHandler != null && method_exists($this->saveHandler, 'generateId')) {
            return $this->saveHandler->generateId($id);
        }

        $id = session_create_id();

        // hash by length
        if ($this->options['hash']) {
            switch ($this->options['hashLength']) {
                case 32: $id = hash('md5', $id); break;
                case 40: $id = hash('sha1', $id); break;
                case 64: $id = hash('sha256', $id); break;
                case 128: $id = hash('sha512', $id); break;
                default:
                    throw new SessionException("No valid 'hashLength' option given, only ".
                        "'32,40,64,128' are accepted");
            }
            $id = strtoupper($id);
        }

        return $id;
    }
351693
public function getPID()
    {
        $id = (string) $this->objectID;

        // PID is stored as little-endian, flip it around
        $pid = substr($id, 16, 2) . substr($id, 14, 2);
        return hexdec($pid);
    }
197668
protected function generateConnectionId()
    {
        $max_unsigned_int = 4294967295;
        if (self::$_connectionIdRecorder >= $max_unsigned_int) {
            self::$_connectionIdRecorder = 0;
        }
        while(++self::$_connectionIdRecorder <= $max_unsigned_int) {
            if(!isset($this->_clientConnections[self::$_connectionIdRecorder])) {
                break;
            }
        }
        return self::$_connectionIdRecorder;
    }
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;
    }
772975
public function create_sid(): string
    {
        $string = '';
        $caracters = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-';

        $countCaracters = 62;
        for ($i = 0; $i < 127; ++$i) {
            $string .= $caracters[\rand(0, $countCaracters)];
        }

        $sql = 'SELECT COUNT(id) FROM sessions WHERE id=:id';
        $params = ['id' => $string];
        $count = $this->db->count($sql, $params);
        if ($count !== 0) {
            return $this->create_sid();
        }

        return $string;
    }
1249071
private static function messageId(){
    return sprintf("%04x%04x-%04x-%04x-%04x-%04x%04x%04x",
      mt_rand(0, 0xffff),
      mt_rand(0, 0xffff),
      mt_rand(0, 0xffff),
      mt_rand(0, 0x0fff) | 0x4000,
      mt_rand(0, 0x3fff) | 0x8000,
      mt_rand(0, 0xffff),
      mt_rand(0, 0xffff),
      mt_rand(0, 0xffff)
    );
  }
653759
private function generateId()
    {
        $randomNumber = mt_rand(0, mt_getrandmax());
        $ipAddressFragment = md5(substr($this->ipAddress, 0, 5));
        $timestamp = md5(microtime(true) . $this->now);

        return hash('sha256', $randomNumber . $ipAddressFragment . $this->salt . $timestamp);
    }
1304763
public static function generateId()
    {
        static $inc = 0;

        $ts = pack('N', time());
        $m = substr(md5(gethostname()), 0, 3);
        $pid = pack('n', 1);
        $trail = substr(pack('N', $inc++), 1, 3);

        $bin = sprintf('%s%s%s%s', $ts, $m, $pid, $trail);
        $id = '';
        for ($i = 0; $i < 12; $i++) {
            $id .= sprintf('%02X', ord($bin[$i]));
        }

        return strtolower($id);
    }
842222
public static function GUID()
	{
		if ( function_exists( 'com_create_guid' ) === true )
		{
			return trim( com_create_guid(), '{}' );
		}

		return sprintf( '%04X%04X-%04X-%04X-%04X-%04X%04X%04X', mt_rand( 0, 65535 ), mt_rand( 0, 65535 ), mt_rand( 0, 65535 ), mt_rand( 16384, 20479 ), mt_rand( 32768, 49151 ), mt_rand( 0, 65535 ), mt_rand( 0, 65535 ), mt_rand( 0, 65535 ) );
	}
538494
protected function getNextId()
    {
        $keys = $this->getFileManager()->keys();
        $ids = array();
        foreach($keys as $key) {
            if(preg_match('/^'.$this->getHash().'/', $key)) {
                $ids[] = str_replace($this->getHash(), '', $key);
            }
        }
        if(empty($ids)) {
            return 1;
        }
        
        $maxId = max($ids);
        
        return $maxId + 1;
    }
680571
private function findNumberOfSentMails() {
        $sendCount = 0;
        if ($this->messageFormat->getVersion() === 'v3.1') {
            $messages = $this->resultApi->getBody()['Messages'];
            foreach ($messages as $message) {


                if (isset($message['To'])) {
                    $sendCount += count($message['To']);
                }
                if (isset($message['Bcc']) && (!empty($message['Bcc']))) {
                    $sendCount += count($message['Bcc']);
                }
                if (isset($message['Cc']) && (!empty($message['Cc']))) {
                    $sendCount += count($message['Cc']);
                }
            }
            return $sendCount;
        }
        if ($this->messageFormat->getVersion() === 'v3') {
            if (isset($this->resultApi->getBody()['Sent'])) {
                $sendCount += count($this->resultApi->getBody()['Sent']);
            }
            return $sendCount;
        }
        return $sendCount;
    }
321838
protected function generateId()
    {
        $inputId = static::$idPrefix . $this->getName();
        if ($this->isMultiple()) {
            $inputId = "{$inputId}-{$this->instances}";
        }
        $this->setAttribute('id', $inputId);
        return $inputId;
    }
807399
public function getBotID() : int
    {
        // If it is not valid
        if (!isset($this->_bot_id) || $this->_bot_id == 0) {
            // get it again
            $this->_bot_id = ($this->getMe())['id'];
        }

        return $this->_bot_id ?? 0;
    }
92971
public function get_unique_id() {
        global $CFG;

        if (!is_null($this->uniqueid)) {
            return $this->uniqueid;
        }

        // Generate a unique id for this site, this model and this time splitting method, considering the last time
        // that the model target and indicators were updated.
        $ids = array($CFG->wwwroot, $CFG->prefix, $this->model->id, $this->model->version);
        $this->uniqueid = sha1(implode('$$', $ids));

        return $this->uniqueid;
    }