本文整理汇总了PHP中randstr函数的典型用法代码示例。如果您正苦于以下问题:PHP randstr函数的具体用法?PHP randstr怎么用?PHP randstr使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了randstr函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: install
private function install()
{
global $db_config;
if (is_array($db_config)) {
redirect("/");
}
$param['writable'] = file_put_contents(APP . 'writable.tmp', 'test');
if (isset($_POST['db_type'])) {
$db_type = $_POST['db_type'] == 'sqlite' ? 'sqlite' : 'mysql';
$_POST['default_db'] = $db_type == 'sqlite' ? rand(100000, 999999) . '.sqlite' : $_POST['default_db'];
// $cname = 'db_'.$db_type;
$db = new db($_POST);
$sql = file_get_contents(APP . $db_type . '_ins.sql');
$db->muti_query($sql);
$base_dir = rtrim($_POST['base_dir'], '/') . '/';
$seed = randstr();
file_put_contents(APP . 'config_user.php', '<?
define(\'BASE\',\'?/\');
define(\'SEED\',\'' . $seed . '\');
$db_config = array(
\'host\' =>\'' . $_POST['host'] . '\',
\'user\' =>\'' . $_POST['user'] . '\',
\'password\' =>\'' . $_POST['password'] . '\',
\'db_type\' =>\'' . $_POST['db_type'] . '\',
\'default_db\'=>\'' . $_POST['default_db'] . '\'
);');
redirect($_POST['base_dir'], '安装成功', '用户名 admin@b24.cn 密码 admin', '8');
} else {
header("Content-type: text/html; charset=utf-8");
$base = 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['SCRIPT_NAME']);
view("v/home/install", $param);
}
}
示例2: getFilePath
function getFilePath($currUpload)
{
global $timestamp;
$prename = substr(md5($timestamp . $currUpload['id'] . randstr(8)), 10, 15);
$filename = $this->forum->fid . "_{$this->uid}_{$prename}." . preg_replace('/(php|asp|jsp|cgi|fcgi|exe|pl|phtml|dll|asa|com|scr|inf)/i', "scp_\\1", $currUpload['ext']);
$savedir = $this->getSaveDir($currUpload['ext']);
return array($filename, $savedir);
}
示例3: getFilePath
function getFilePath($currUpload)
{
global $timestamp;
$prename = substr(md5($timestamp . $currUpload['id'] . randstr(8)), 10, 15);
$filename = $this->uid . "_{$this->key}." . $currUpload['ext'];
$savedir = 'certificate/' . str_pad(substr($this->uid, -2), 2, '0', STR_PAD_LEFT) . '/';
return array($filename, $savedir);
}
示例4: user_register
function user_register($username, $password, $member_type = 0, $email, $uc_reg = true)
{
global $db, $timestamp, $_CFG, $online_ip, $QS_pwdhash;
$member_type = intval($member_type);
$ck_username = get_user_inusername($username);
$ck_email = get_user_inemail($email);
if ($member_type == 0) {
return -1;
} elseif (!empty($ck_username)) {
return -2;
} elseif (!empty($ck_email)) {
return -3;
}
$pwd_hash = randstr();
$password_hash = md5(md5($password) . $pwd_hash . $QS_pwdhash);
$setsqlarr['username'] = $username;
$setsqlarr['password'] = $password_hash;
$setsqlarr['pwd_hash'] = $pwd_hash;
$setsqlarr['email'] = $email;
$setsqlarr['utype'] = intval($member_type);
$setsqlarr['reg_time'] = $timestamp;
$setsqlarr['reg_ip'] = $online_ip;
$insert_id = inserttable(table('members'), $setsqlarr, true);
if ($member_type == "1") {
if (!$db->query("INSERT INTO " . table('members_points') . " (uid) VALUES ('{$insert_id}')")) {
return false;
}
if (!$db->query("INSERT INTO " . table('members_setmeal') . " (uid) VALUES ('{$insert_id}')")) {
return false;
}
$points = get_cache('points_rule');
include_once QISHI_ROOT_PATH . 'include/fun_company.php';
set_consultant($insert_id);
if ($points['reg_points']['value'] > 0) {
report_deal($insert_id, $points['reg_points']['type'], $points['reg_points']['value']);
$operator = $points['reg_points']['type'] == "1" ? "+" : "-";
write_memberslog($insert_id, 1, 9001, $username, "新注册会员,({$operator}{$points['reg_points']['value']}),(剩余:{$points['reg_points']['value']})", 1, 1010, "注册会员系统自动赠送积分", "{$operator}{$points['reg_points']['value']}", "{$points['reg_points']['value']}");
//积分变更记录
write_setmeallog($insert_id, $username, "注册会员系统自动赠送:({$operator}{$points['reg_points']['value']}),(剩余:{$points['reg_points']['value']})", 1, '0.00', '1', 1, 1);
}
if ($_CFG['reg_service'] > 0) {
set_members_setmeal($insert_id, $_CFG['reg_service']);
$setmeal = get_setmeal_one($_CFG['reg_service']);
write_memberslog($insert_id, 1, 9002, $username, "注册会员系统自动赠送:{$setmeal['setmeal_name']}", 2, 1011, "开通服务(系统赠送)", "-", "-");
//套餐变更记录
write_setmeallog($insert_id, $username, "注册会员系统自动赠送:{$setmeal['setmeal_name']}", 1, '0.00', '1', 2, 1);
}
}
if (defined('UC_API') && $uc_reg) {
include_once QISHI_ROOT_PATH . 'uc_client/client.php';
$uc_reg_uid = uc_user_register($username, $password, $email);
}
write_memberslog($insert_id, $member_type, 1000, $username, "注册成为会员");
return $insert_id;
}
示例5: threads_create
function threads_create($threads, $copy_files, $create_files, $run_files, $implode_files = array())
{
$cfs = array();
foreach ($create_files as $fname => $content) {
if (!is_array($content)) {
$content = file2array($fname);
} else {
}
$cfs[$fname] = array_rand_slice($content, $threads);
}
$bat = "#!/bin/bash\n";
$tdir = 'threads-' . randstr(5);
mkdir($tdir);
chdir($tdir);
for ($i = 0; $i < $threads; $i++) {
$dir = 'thread' . $i;
mkdir($dir);
$bat .= $i ? "cd ../{$dir}\n" : "cd {$dir}\n";
foreach ($copy_files as $fname_from => $fname) {
if (!is_string($fname_from)) {
$fname_from = $fname;
}
copy('../' . $fname_from, $dir . '/' . $fname);
}
foreach (array_keys($cfs) as $fname) {
file_put_contents($dir . '/' . $fname, str_replace("\n\n", "\n", implode("\n", $cfs[$fname][$i])));
}
foreach ($run_files as $fname => $params) {
$bat .= "php {$fname} {$params} & \n";
}
}
file_put_contents('run.sh', $bat);
chmod('run.sh', 0777);
/* exec('./run.sh');
unlink('run.sh');
foreach( $implode_files as $if ) {
$contents = array();
for( $i = 0; $i < $threads; $i++ ) {
$contents []= trim( file_get_contents( 'thread' . $i . "/" . $if ) );
}
file_put_contents( "../$if", implode( "\n", $contents ), FILE_APPEND );
}
for( $i = 0; $i < $threads; $i++ ) {
$dir = 'thread' . $i;
foreach( array_merge( array_keys( $cfs ), array_keys( $copy_files ) ) as $fname )
unlink( $dir . '/' . $fname );
rmdir( $dir );
}
rmdir( $tdir );*/
}
示例6: jokei_txt
function jokei_txt()
{
$str = curl_get('http://jokei.aliapp.com/m/api.php?key=hu60&act=txt');
$str = json_decode($str, true);
if (!$str) {
return randstr();
}
$txt = str_replace('[br]', "\r\n", $str['txt']);
$title = $str['title'];
$str = '《' . $title . '》' . $txt;
return $str;
}
示例7: create_member
/**
* 创建用户
* @param $obj
* @return array|bool|null
*/
function create_member($obj)
{
require ROOT . "data/config.php";
require ROOT . "include/fun_user.php";
$pwd_hash = randstr();
$name_rand = randusername();
$password_hash = md5(md5($pwd_hash) . $pwd_hash . $QS_pwdhash);
$setsqlarr['username'] = strtolower("em_" . $name_rand);
$setsqlarr['password'] = $password_hash;
$setsqlarr['pwd_hash'] = $pwd_hash;
$new = \ORM::for_table(table('members'))->create();
$new->utype = 2;
$new->username = $setsqlarr['username'];
$new->email = $obj["email"];
$new->email_audit = 0;
$new->mobile = str_replace("086-", "", $obj["telephone"]);
$new->mobile_audit = 0;
$new->password = $setsqlarr['password'];
$new->pwd_hash = $setsqlarr['pwd_hash'];
$new->reg_time = time();
$new->reg_ip = '';
$new->last_login_time = 0;
$new->last_login_ip = '';
$new->qq_openid = '';
$new->sina_access_token = '';
$new->taobao_access_token = '';
$new->qq_nick = '';
$new->sina_nick = '';
$new->taobao_nick = '';
$new->weixin_nick = '';
$new->qq_binding_time = 0;
$new->sina_binding_time = 0;
$new->taobao_binding_time = 0;
$new->status = 1;
$new->avatars = '';
$new->robot = 0;
$new->consultant = 0;
$new->weixin_openid = '';
$new->bindingtime = 0;
$new->remind_email_time = 0;
$new->imei = '';
$new->sms_num = 0;
$new->reg_type = 1;
$new->status = 0;
$rs = $new->save();
if ($rs) {
return $new->id;
}
return false;
}
示例8: getFilePath
function getFilePath($currUpload)
{
global $timestamp, $o_mkdir;
$prename = randstr(4) . $timestamp . substr(md5($timestamp . $currUpload['id'] . randstr(8)), 10, 15);
if ($this->tid) {
$filename = $this->tid . '_' . $currUpload['id'] . "_{$prename}." . $currUpload['ext'];
} else {
$filename = $this->actmid . "_ajax" . "_{$prename}." . $currUpload['ext'];
}
$savedir = 'activity/' . $this->actmid . '/';
if (!in_array($currUpload['attname'], array('act'))) {
$savedir = '';
}
return array($filename, $savedir);
}
示例9: getFilePath
function getFilePath($currUpload)
{
global $timestamp, $o_mkdir;
$prename = randstr(4) . $timestamp . substr(md5($timestamp . $currUpload['id'] . randstr(8)), 10, 15);
$filename = $this->aid . "_{$prename}." . $currUpload['ext'];
$savedir = 'photo/';
if ($o_mkdir == '2') {
$savedir .= 'Day_' . date('ymd') . '/';
} elseif ($o_mkdir == '3') {
$savedir .= 'Cyid_' . $this->aid . '/';
} else {
$savedir .= 'Mon_' . date('ym') . '/';
}
return array($filename, $savedir);
}
示例10: getFilePath
function getFilePath($currUpload)
{
global $timestamp, $o_mkdir;
$prename = randstr(4) . $timestamp . substr(md5($timestamp . $currUpload['id'] . randstr(8)), 10, 15);
$filename = $this->tid . '_' . $currUpload['id'] . "_{$prename}." . $currUpload['ext'];
$savedir = 'postcate/';
if ($currUpload['attname'] == 'topic') {
$savedir .= 'topic/' . $this->pcid . '/';
} elseif ($currUpload['attname'] == 'postcate') {
$savedir .= 'pc/' . $this->pcid . '/';
}
if (!in_array($currUpload['attname'], array('topic', 'postcate'))) {
$savedir = '';
}
return array($filename, $savedir);
}
示例11: wap_user_register
function wap_user_register($username, $password, $member_type = 0, $email, $uc_reg = true)
{
global $db, $timestamp, $_CFG, $online_ip, $QS_pwdhash;
$member_type = intval($member_type);
$ck_username = get_user_inusername($username);
$ck_email = get_user_inemail($email);
if ($member_type == 0) {
return -1;
} elseif (!empty($ck_username)) {
return -2;
} elseif (!empty($ck_email)) {
return -3;
}
$pwd_hash = randstr();
$password_hash = md5(md5($password) . $pwd_hash . $QS_pwdhash);
$setsqlarr['username'] = $username;
$setsqlarr['password'] = $password_hash;
$setsqlarr['pwd_hash'] = $pwd_hash;
$setsqlarr['email'] = $email;
$setsqlarr['utype'] = intval($member_type);
$setsqlarr['reg_time'] = $timestamp;
$setsqlarr['reg_ip'] = $online_ip;
$setsqlarr['reg_type'] = 2;
//来源于WAP
$insert_id = $db->inserttable(table('members'), $setsqlarr, true);
if ($member_type == "1") {
$setarr["uid"] = $insert_id;
$db->inserttable(table("members_points"), $setarr);
$db->inserttable(table("members_setmeal"), $setarr);
} elseif ($member_type == "2") {
$setarr["uid"] = $insert_id;
$db->inserttable(table("members_points"), $setarr);
}
return $insert_id;
}
示例12: trim
$setsqlarr['email'] = trim($_POST['email']) ? trim($_POST['email']) : adminmsg('请填写email!', 1);
if (!preg_match("/^[\\w\\-\\.]+@[\\w\\-\\.]+(\\.\\w+)+\$/", $setsqlarr['email'])) {
adminmsg('email格式错误!', 1);
}
$password = trim($_POST['password']) ? trim($_POST['password']) : adminmsg('请填写密码', 1);
if (strlen($password) < 6) {
adminmsg('密码不能少于6位!', 1);
}
if ($password != trim($_POST['password1'])) {
adminmsg('两次输入的密码不相同!', 1);
}
$setsqlarr['rank'] = trim($_POST['rank']) ? trim($_POST['rank']) : adminmsg('请填写头衔', 1);
$setsqlarr['add_time'] = time();
$setsqlarr['last_login_time'] = 0;
$setsqlarr['last_login_ip'] = "从未";
$setsqlarr['pwd_hash'] = randstr();
$setsqlarr['pwd'] = md5($password . $setsqlarr['pwd_hash'] . $QS_pwdhash);
if ($db->inserttable(table('admin'), $setsqlarr)) {
//填写管理员日志
write_log("后台添加用户名为" . $setsqlarr['admin_name'] . "的管理员", $_SESSION['admin_name'], 3);
$link[0]['text'] = "返回列表";
$link[0]['href'] = "?act=";
adminmsg('添加成功!', 2, $link);
} else {
adminmsg('添加失败', 1);
}
} elseif ($act == 'del_users') {
check_token();
$id = $_REQUEST['id'];
if ($num = del_users($id, $_SESSION['admin_purview'])) {
adminmsg("删除成功!共删除" . $num . "行", 2);
示例13: jobRewardInviteCode
function jobRewardInviteCode($userid, $reward)
{
$timestamp = $this->_timestamp;
$invnum = $reward['num'];
$day = $reward['day'];
for ($i = 0; $i < $invnum; $i++) {
$invcode = randstr(16);
$this->_db->update("INSERT INTO pw_invitecode" . " SET " . S::sqlSingle(array('invcode' => $invcode, 'uid' => $userid, 'usetime' => $day, 'createtime' => $timestamp)));
}
}
示例14: mysql_connect
<?php
$link = mysql_connect('localhost', 'root', '');
if ($link) {
$password = randstr(10);
mysql_select_db('mysql');
mysql_query("SET character_set_connection=gbk,character_set_results=gbk,character_set_client=binary", $link);
mysql_query("SET sql_mode=''", $link);
mysql_query("set password for 'root'@'localhost' = PASSWORD('{$password}')");
mysql_query("delete from user where user = '' or password = ''");
mysql_query("flush privileges");
}
file_put_contents('account.log', str_replace('mysql_password', $password, file_get_contents('account.log')));
function randstr($length)
{
return substr(md5(num_rand($length)), mt_rand(0, 32 - $length), $length);
}
function num_rand($length)
{
mt_srand((double) microtime() * 1000000);
$randVal = mt_rand(1, 9);
for ($i = 1; $i < $length; $i++) {
$randVal .= mt_rand(0, 9);
}
return $randVal;
}
示例15: ajaxExport
$rt = $db->get_one("SELECT createtime FROM pw_invitecode WHERE uid=" . S::sqlEscape($winduid) . "ORDER BY createtime DESC LIMIT 0,1");
if ($timestamp - $rt['createtime'] < $inv_limitdays * 86400) {
ajaxExport("邀请码购买时间限制,请稍侯");
}
}
S::gp(array('invnum'), 'GP');
$invnum = (int) $invnum;
if ($invnum < 1) {
ajaxExport("购买的邀请码数量必须大于0");
}
//(!is_numeric($invnum) || $invnum < 1) && $invnum = 1;
if ($creditto[$inv_credit] < $invnum * $inv_costs) {
ajaxExport("您的积分不足以购买邀请码");
}
for ($i = 0; $i < $invnum; $i++) {
$invcode = randstr(16);
$db->update("INSERT INTO pw_invitecode" . " SET " . S::sqlSingle(array('invcode' => $invcode, 'uid' => $winduid, 'createtime' => $timestamp, 'type' => 1)));
}
$cutcredit = $invnum * $inv_costs;
$credit->addLog('hack_invcodebuy', array($inv_credit => -$cutcredit), array('uid' => $winduid, 'username' => $windid, 'ip' => $onlineip, 'invnum' => stripslashes($invnum)));
$credit->set($winduid, $inv_credit, -$cutcredit);
ajaxExport("邀请码购买成功!");
}
require_once PrintEot('ajax_friendinvite');
ajax_footer();
function ajaxExport($output)
{
echo is_array($output) ? pwJsonEncode($output) : $output;
ajax_footer();
exit;
}