本文整理汇总了PHP中StringHelper::generateRandomString方法的典型用法代码示例。如果您正苦于以下问题:PHP StringHelper::generateRandomString方法的具体用法?PHP StringHelper::generateRandomString怎么用?PHP StringHelper::generateRandomString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringHelper
的用法示例。
在下文中一共展示了StringHelper::generateRandomString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getUrlUploadSingleImage
public static function getUrlUploadSingleImage($obj, $user_id)
{
$ext_arr = array('png', 'jpg', 'jpeg', 'bmp');
$name = StringHelper::filterString($obj['name']);
$storeFolder = Yii::getPathOfAlias('webroot') . '/images/' . date('Y-m-d', time()) . '/' . $user_id . '/';
if (!file_exists($storeFolder)) {
mkdir($storeFolder, 0777, true);
}
$tempFile = $obj['tmp_name'];
$ext = strtolower(pathinfo($name, PATHINFO_EXTENSION));
$random_string = StringHelper::generateRandomString(15);
$targetFile = $storeFolder . time() . $random_string . '.' . $ext;
$pathUrl = 'images/' . date('Y-m-d', time()) . '/' . $user_id . '/' . time() . $random_string . '.' . $ext;
if (in_array($ext, $ext_arr)) {
if (move_uploaded_file($tempFile, $targetFile)) {
// ImageResize::resize_image($pathUrl, '', 1400, 470);
return $pathUrl;
} else {
return NULL;
}
} else {
return NULL;
}
}
示例2: date
<div class="container-fluid">
<div class="navbar-header">
<h3>SancSoft Task Manager</h3>
</div>
</div>
</nav>
<div class="panel panel-primary sanctm-panel">
<div class="panel-heading">Add a Task</div>
<div class="panel-body">
<form id="task-form" method="POST">
<div class="form-group">
<label for="input-title">Title</label>
<input name="title" type="text" class="form-control" id="input-title" placeholder="Title"
value="<?php
echo $stringHelper->generateRandomString();
?>
">
</div>
<div class="form-group">
<label for="input-description">Description</label>
<textarea name="desc" class="form-control" id="input-description" placeholder="Description"><?php
echo $stringHelper->generateRandomString();
?>
</textarea>
</div>
<div class="form-group">
<label for="input-duedate">Due Date</label>
<input name="due_date" type="date" id="input-duedate" value="<?php
echo date('Y-m-d');
?>
示例3: actionActivate
public function actionActivate()
{
$request = Yii::app()->request;
try {
$token = StringHelper::filterString($request->getQuery('token'));
if ($token != '') {
$check = Provider::model()->findByAttributes(array('token' => $token));
if ($check) {
$password = StringHelper::generateRandomString(5);
$check->token = '';
$check->password = md5($password);
$check->save('FALSE');
$subject = 'Mật khẩu tài khoản provider Meboo của bạn';
$to_email = $check->email;
$from_email = 'hotro@meboo.vn';
$from_name = 'Hỗ trợ Meboo';
$message = 'Mật khẩu tài khoản Meboo Provider của bạn: ' . $password;
MailQueue::model()->addMailQueue($message, $from_email, $from_name, $to_email, $subject);
MailQueue::model()->addMailQueue('Có provider mới', $from_email, $from_name, 'huynt57@gmail.com', 'Có provider mới');
Yii::app()->user->setFlash('success', 'Vui lòng kiểm tra email để lấy mật khẩu đăng nhập');
$this->redirect(Yii::app()->createUrl('user/login'));
} else {
Yii::app()->user->setFlash('error', 'Token đã hết hạn !');
$this->redirect(Yii::app()->createUrl('user/login'));
}
} else {
Yii::app()->user->setFlash('error', 'Token không tồn tại');
$this->redirect(Yii::app()->createUrl('user/login'));
}
} catch (Exception $ex) {
ResponseHelper::JsonReturnError($ex->getMessage(), 'Error');
}
}