本文整理汇总了PHP中StringUtil::random方法的典型用法代码示例。如果您正苦于以下问题:PHP StringUtil::random方法的具体用法?PHP StringUtil::random怎么用?PHP StringUtil::random使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringUtil
的用法示例。
在下文中一共展示了StringUtil::random方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionEdit
public function actionEdit()
{
if (EnvUtil::getRequest("formhash")) {
$id = intval(EnvUtil::getRequest("id"));
$name = StringUtil::filterStr(EnvUtil::getRequest("name"));
$url = StringUtil::filterStr(EnvUtil::getRequest("url"));
$icon = StringUtil::filterStr(EnvUtil::getRequest("quicknavimg"));
if (!empty($icon)) {
FileUtil::copyToDir($icon, $this->_iconPath);
$info = pathinfo($icon);
$saveName = $info["basename"];
} else {
$saveName = StringUtil::random(16) . ".png";
$val = EnvUtil::getRequest("fontvalue");
$this->createColorImg($saveName, $val);
}
$data = array("name" => $name, "url" => $url, "description" => "", "icon" => $saveName);
MenuCommon::model()->modify($id, $data);
$this->success(Ibos::lang("Update succeed", "message"), $this->createUrl("quicknav/index"));
} else {
$op = EnvUtil::getRequest("op");
if (empty($op)) {
$id = intval(EnvUtil::getRequest("id"));
$menu = MenuCommon::model()->fetchByPk($id);
if (empty($menu)) {
$this->error(Ibos::lang("Quicknav not fount tip"), $this->createUrl("quicknav/index"));
}
$menu["icon"] = FileUtil::fileName($this->_iconPath . $menu["icon"]);
$this->render("edit", array("menu" => $menu));
} else {
$this->{$op}();
}
}
}
示例2: handleSetting
public function handleSetting($event)
{
$settings = Setting::model()->fetchAllSetting();
$this->_setting =& $settings;
$this->handleCredits();
$this->handleCreditsFormula();
$this->_setting["verhash"] = StringUtil::random(3);
Syscache::model()->modify("setting", $settings);
}
示例3: beforeSave
protected function beforeSave()
{
$viewExtFields = StringUtil::filterStr($_POST["viewextfields"]);
$sumFields = StringUtil::filterStr($_POST["sumfields"]);
$flowConditions = array("flowquerytype" => $_POST["flow_query_type"], "beginuser" => StringUtil::getId($_POST["begin_user"]), "runname" => StringUtil::filterCleanHtml($_POST["run_name"]), "flowstatus" => $_POST["flow_status"], "time1" => $_POST["time1"], "time2" => $_POST["time2"], "time3" => $_POST["time3"], "time4" => $_POST["time4"], "attachname" => StringUtil::filterCleanHtml($_POST["attach_name"]));
$groupbyFields = array("field" => $_POST["group_field"], "order" => $_POST["group_sort"]);
$name = StringUtil::filterCleanHtml($_POST["tplname"]);
$sid = intval(EnvUtil::getRequest("sid"));
$data = array("flowid" => $this->flowid, "uid" => $this->uid, "tplname" => $this->tplNameExists($name, $sid) ? $name . StringUtil::random(3) : $name, "viewextfields" => $viewExtFields, "sumfields" => $sumFields, "flowconditions" => serialize($flowConditions), "groupbyfields" => serialize($groupbyFields), "condformula" => $_POST["condformula"]);
return $data;
}
示例4: actionAdd
public function actionAdd()
{
MainUtil::checkLicenseLimit();
if (EnvUtil::submitCheck("userSubmit")) {
$origPass = filter_input(INPUT_POST, "password", FILTER_SANITIZE_STRING);
$_POST["salt"] = StringUtil::random(6);
$_POST["password"] = !empty($origPass) ? md5(md5($origPass) . $_POST["salt"]) : "";
$_POST["createtime"] = TIMESTAMP;
$_POST["guid"] = StringUtil::createGuid();
$this->dealWithSpecialParams();
$data = User::model()->create();
$newId = User::model()->add($data, true);
if ($newId) {
UserCount::model()->add(array("uid" => $newId));
$ip = Ibos::app()->setting->get("clientip");
UserStatus::model()->add(array("uid" => $newId, "regip" => $ip, "lastip" => $ip));
UserProfile::model()->add(array("uid" => $newId));
if (!empty($_POST["auxiliarydept"])) {
$deptIds = StringUtil::getId($_POST["auxiliarydept"]);
$this->handleAuxiliaryDept($newId, $deptIds, $_POST["deptid"]);
}
if (!empty($_POST["auxiliarypos"])) {
$posIds = StringUtil::getId($_POST["auxiliarypos"]);
$this->handleAuxiliaryPosition($newId, $posIds, $_POST["positionid"]);
}
$newUser = User::model()->fetchByPk($newId);
$users = UserUtil::loadUser();
$users[$newId] = UserUtil::wrapUserInfo($newUser);
User::model()->makeCache($users);
OrgUtil::update();
OrgUtil::hookSyncUser($newId, $origPass, 1);
$this->success(Ibos::lang("Save succeed", "message"), $this->createUrl("user/index"));
} else {
$this->error(Ibos::lang("Add user failed"), $this->createUrl("user/index"));
}
} else {
$deptid = "";
$manager = "";
$account = Ibos::app()->setting->get("setting/account");
if ($account["mixed"]) {
$preg = "[0-9]+[A-Za-z]+|[A-Za-z]+[0-9]+";
} else {
$preg = "^[A-Za-z0-9\\!\\@\\#\$\\%\\^\\&\\*\\.\\~]{" . $account["minlength"] . ",32}\$";
}
if ($deptid = EnvUtil::getRequest("deptid")) {
$deptid = StringUtil::wrapId(EnvUtil::getRequest("deptid"), "d");
$manager = StringUtil::wrapId(Department::model()->fetchManagerByDeptid(EnvUtil::getRequest("deptid")), "u");
}
$this->setPageTitle(Ibos::lang("Add user"));
$this->setPageState("breadCrumbs", array(array("name" => Ibos::lang("Organization"), "url" => $this->createUrl("department/index")), array("name" => Ibos::lang("User manager"), "url" => $this->createUrl("user/index")), array("name" => Ibos::lang("Add user"))));
$this->render("add", array("deptid" => $deptid, "manager" => $manager, "passwordLength" => $account["minlength"], "preg" => $preg));
}
}
示例5: create
public function create($ip, $uid)
{
$this->isNew = true;
$this->var = $this->newGuest;
$this->setKey("sid", StringUtil::random(6));
$this->setKey("uid", $uid);
$this->setKey("ip", $ip);
if ($uid) {
$this->setKey("invisible", UserUtil::getUserProfile("invisible"));
}
$this->setKey("lastactivity", time());
$this->sid = $this->var["sid"];
return $this->var;
}
示例6: setCommonBg
private function setCommonBg($src)
{
$bgPath = "data/home/";
$random = StringUtil::random(16);
$bgBig = $random . "_big.jpg";
$bgMiddle = $random . "_middle.jpg";
$bgSmall = $random . "_small.jpg";
FileUtil::createFile($bgPath . $bgBig, "");
FileUtil::createFile($bgPath . $bgMiddle, "");
FileUtil::createFile($bgPath . $bgSmall, "");
Ibos::import("ext.ThinkImage.ThinkImage", true);
$imgObj = new ThinkImage(THINKIMAGE_GD);
$imgObj->open($src)->thumb(1000, 300, 1)->save($bgPath . $bgBig);
$imgObj->open($src)->thumb(520, 156, 1)->save($bgPath . $bgMiddle);
$imgObj->open($src)->thumb(400, 120, 1)->save($bgPath . $bgSmall);
$data = array("desc" => "", "status" => 0, "system" => 0, "image" => $random);
$addRes = BgTemplate::model()->add($data);
return $addRes;
}
示例7: actionBackup
public function actionBackup()
{
$formSubmit = EnvUtil::submitCheck("dbSubmit");
$type = $msg = $url = "";
$param = array();
if ($formSubmit) {
$status = DatabaseUtil::databaseBackup();
extract($status);
$this->{$type}($msg, $url, $param);
} else {
$data = array();
$tablePrefix = Ibos::app()->setting->get("config/db/tableprefix");
if (EnvUtil::getRequest("setup") == "1") {
$status = DatabaseUtil::databaseBackup();
extract($status);
$this->{$type}($msg, $url, $param);
}
$data["defaultFileName"] = date("Y-m-d") . "_" . StringUtil::random(8);
$data["tables"] = DatabaseUtil::getTablelist($tablePrefix);
$this->render("backup", $data);
}
}
示例8: handleInitInput
public function handleInitInput($event)
{
if (isset($_GET["GLOBALS"]) || isset($_POST["GLOBALS"]) || isset($_COOKIE["GLOBALS"]) || isset($_FILES["GLOBALS"])) {
throw new RequestException(Ibos::lang("Parameters error", "error"));
}
$global = Ibos::app()->setting->toArray();
$config = $global["config"];
$preLength = strlen($global["config"]["cookie"]["cookiepre"]);
foreach ($_COOKIE as $key => $value) {
if (substr($key, 0, $preLength) == $config["cookie"]["cookiepre"]) {
$global["cookie"][substr($key, $preLength)] = $value;
}
}
$global["sid"] = $global["cookie"]["sid"] = isset($global["cookie"]["sid"]) ? StringUtil::ihtmlSpecialChars($global["cookie"]["sid"]) : "";
if (empty($global["cookie"]["saltkey"])) {
$global["cookie"]["saltkey"] = StringUtil::random(8);
MainUtil::setCookie("saltkey", $global["cookie"]["saltkey"], 86400 * 30, 1, 1);
}
$global["authkey"] = md5($global["config"]["security"]["authkey"] . $global["cookie"]["saltkey"]);
Ibos::app()->setting->copyFrom($global);
}
示例9: getTargetFileName
protected function getTargetFileName()
{
return date("His") . strtolower(StringUtil::random(16));
}
示例10: add
/**
* 新增用户
* @param array $userData
* @return int insertId
*/
static function add($userData)
{
$salt = StringUtil::random(10);
// 初始化
$db = DatabaseFactory::open();
$result = $db->createCommand("\n\t\t\tINSERT INTO `g_user` (username,mobile,password,salt)\n\t\t\t\tVALUES (:username,:mobile,:password,:salt)\n\t\t")->execute(array(':username' => $userData['username'], ':mobile' => $userData['mobile'], ':password' => self::encodePassword($userData['password'], $salt), ':salt' => $salt));
if ($result) {
$userId = $db->getInsertId();
$redis = self::getRedis();
$redis->connect($userId)->del(sprintf(self::$REDIS_KEYS['getById'], $userId));
$redis->connect($userData['username'])->del(sprintf(self::$REDIS_KEYS['getByUsername'], $userData['username']));
$redis->connect($userData['mobile'])->del(sprintf(self::$REDIS_KEYS['getByMobile'], $userData['mobile']));
return $userId;
} else {
return false;
}
}
示例11: testRandom
/**
* Tests the random string generator.
*/
public function testRandom()
{
for ($i = 1; $i <= 32; $i++) {
$random = StringUtil::random($i);
$this->assertEquals($i, strlen($random));
$this->assertRegExp('~^[a-z0-9]+$~i', $random);
}
}
示例12: addUser
private function addUser()
{
if (Ibos::app()->request->isAjaxRequest) {
$fields = array("username", "password", "realname", "mobile", "deptid", "positionid", "email");
if (empty($_POST["username"]) || empty($_POST["password"])) {
$this->ajaxReturn(array("isSuccess" => false, "msg" => Ibos::lang("Username or password not empty")));
}
foreach ($fields as $field) {
if (isset($_POST[$field]) && !empty($_POST[$field])) {
$_POST[$field] = StringUtil::filterDangerTag($_POST[$field]);
}
}
$salt = StringUtil::random(6);
$userData = array("salt" => $salt, "username" => $_POST["username"], "password" => !empty($_POST["password"]) ? md5(md5($_POST["password"]) . $salt) : "", "realname" => $_POST["realname"], "mobile" => $_POST["mobile"], "createtime" => TIMESTAMP, "deptid" => intval($_POST["deptid"]), "positionid" => intval($_POST["positionid"]), "email" => $_POST["email"]);
$newId = User::model()->add($userData, true);
if ($newId) {
UserCount::model()->add(array("uid" => $newId));
$ip = Ibos::app()->setting->get("clientip");
UserStatus::model()->add(array("uid" => $newId, "regip" => $ip, "lastip" => $ip));
UserProfile::model()->add(array("uid" => $newId));
$newUser = User::model()->fetchByPk($newId);
$users = UserUtil::loadUser();
$users[$newId] = UserUtil::wrapUserInfo($newUser);
User::model()->makeCache($users);
OrgUtil::update();
$res["isSuccess"] = true;
} else {
$res["isSuccess"] = false;
$res["msg"] = Ibos::lang("Add user failed");
}
$this->ajaxReturn($res);
}
}
示例13: processingTempFile
private function processingTempFile($urlParam)
{
$file = PATH_ROOT . "/data/update/IBOS " . $urlParam["version"] . " Release[" . $urlParam["release"] . "]/updatelist.tmp";
$authKey = Ibos::app()->setting->get("config/security/authkey");
@unlink($file);
@unlink(PATH_ROOT . "/data/update.php");
Cache::model()->deleteByPk("upgrade_step");
Cache::model()->deleteByPk("upgrade_run");
Setting::model()->updateSettingValueByKey("upgrade", "");
CacheUtil::update();
$randomStr = StringUtil::random(6);
$oldUpdateDir = "/data/update/";
$newUpdateDir = "/data/update-" . $randomStr . "/";
$oldBackDir = "/data/back/";
$newBackDir = "/data/back-" . $randomStr . "/";
FileUtil::copyDir(PATH_ROOT . $oldUpdateDir, PATH_ROOT . $newUpdateDir);
FileUtil::copyDir(PATH_ROOT . $oldBackDir, PATH_ROOT . $newBackDir);
FileUtil::clearDirs(PATH_ROOT . $oldUpdateDir);
FileUtil::clearDirs(PATH_ROOT . $oldBackDir);
$data["step"] = 5;
$data["data"]["msg"] = Ibos::lang("Upgrade successful", "", array("{version}" => "IBOS" . VERSION . " " . VERSION_DATE, "{saveUpdateDir}" => $newUpdateDir, "{saveBackDir}" => $newBackDir));
$this->render("upgradeSuccess", $data);
}
示例14: sendVerify
protected function sendVerify($operation, $data)
{
$session = new CHttpSession();
$session->open();
if ($operation == "email") {
$val = StringUtil::random(8);
} elseif ($operation == "mobile") {
$val = StringUtil::random(5, 1);
}
$verifyVal = md5($val);
$verifyName = $operation;
$session[$verifyName] = $verifyVal;
$session["verifyData"] = $data;
$res = $this->makeVerify($operation, $data, $val);
$session->close();
return $res;
}
示例15: foreach
<th><?php
echo $lang['Volume'];
?>
</th>
<th><?php
echo $lang['Operation'];
?>
</th>
</tr>
</thead>
<?php
foreach ($list['exportLog'] as $key => $value) {
?>
<?php
$info = $value[1];
$random = StringUtil::random(5);
$info['method'] = $info['type'] != 'zip' ? $info['method'] == 'multivol' ? $lang['DBMultivol'] : $lang['DBShell'] : '';
$info['volume'] = count($value);
?>
<tbody>
<tr>
<td>
<label class="checkbox">
<input type="checkbox" data-check='key' value="<?php
echo $key;
?>
" name="key[<?php
echo $key;
?>
]">
</label>