$str_md5=md5(uniqid()); $rand = mt_rand(1, 28); $str1=substr($str_md5,$rand,6); $rand = mt_rand(1, 28); $str2=substr($str_md5,$rand,6); $rand = mt_rand(1, 28); $str3=substr($str_md5,$rand,6); $code=substr($str1.$str2.$str3,0,8);
PHP_FUNCTION(get_random__num_str)
{
int length=8;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &length) == FAILURE)
{
length=8;
}
length++;
int flag, i;
char* string;
__uint64_t timestamp = realtime();
__uint64_t retval;
int len;
char buf[128];
if (timestamp == 0ULL) {
RETURN_FALSE;
}
spin_lock(lock, pid);
if (context->last_timestamp == timestamp) {
context->sequence = (context->sequence + 1) & context->sequence_mask;
if (context->sequence == 0) {
timestamp = skip_next_millis();
}
} else {
context->sequence = 0; /* Back to zero */
}
context->last_timestamp = timestamp;
retval = ((timestamp - context->twepoch) << context->timestamp_left_shift)
| (context->datacenter_id << context->datacenter_id_shift)
| (worker_id << context->worker_id_shift)
| context->sequence;
spin_unlock(lock, pid);
//printf('%ld',retval);
srand((unsigned)retval);
//srand((unsigned) time(NULL ));
if ((string = (char*) emalloc(length)) == NULL )
{
//myLog("Malloc failed!flag:14\n");
RETURN_NULL() ;
}
for (i = 0; i < length - 1; i++)
{
flag = rand() % 3;
switch (flag)
{
case 0:
string[i] = '1' + rand() % 5;
break;
case 1:
string[i] = '2' + rand() % 7;
break;
case 2:
string[i] = '0' + rand() % 10;
break;
default:
string[i] = '9';
break;
}
}
string[length - 1] = '\0';
RETURN_STRINGL(string,length,0);
}
PHP_FUNCTION(get_random_str)
{
int length=8;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &length) == FAILURE)
{
length=8;
}
length++;
int flag, i;
char* string;
__uint64_t timestamp = realtime();
__uint64_t retval;
int len;
char buf[128];
if (timestamp == 0ULL) {
RETURN_FALSE;
}
spin_lock(lock, pid);
if (context->last_timestamp == timestamp) {
context->sequence = (context->sequence + 1) & context->sequence_mask;
if (context->sequence == 0) {
timestamp = skip_next_millis();
}
} else {
context->sequence = 0; /* Back to zero */
}
context->last_timestamp = timestamp;
retval = ((timestamp - context->twepoch) << context->timestamp_left_shift)
| (context->datacenter_id << context->datacenter_id_shift)
| (worker_id << context->worker_id_shift)
| context->sequence;
spin_unlock(lock, pid);
//printf('%ld',retval);
srand((unsigned)retval);
//srand((unsigned) time(NULL ));
if ((string = (char*) emalloc(length)) == NULL )
{
//myLog("Malloc failed!flag:14\n");
RETURN_NULL() ;
}
for (i = 0; i < length - 1; i++)
{
flag = rand() % 3;
switch (flag)
{
case 0:
string[i] = 'A' + rand() % 26;
break;
case 1:
string[i] = 'a' + rand() % 26;
break;
case 2:
string[i] = '0' + rand() % 10;
break;
default:
string[i] = 'x';
break;
}
}
string[length - 1] = '\0';
RETURN_STRINGL(string,length,0);
}
[ukey] ukey.datacenter = integer ukey.worker = integer ukey.twepoch = uint64
$ cd ./ukey $ phpize $ ./configure $ make $ sudo make install
<?php
$id = ukey_next_id();
echo $id;
$timestamp = ukey_to_timestamp($id);
echo date('Y-m-d H:i:s', $timestamp);
$info = ukey_to_machine($id)
var_dump($info);
?>
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有