本文整理汇总了PHP中str_shuffle函数的典型用法代码示例。如果您正苦于以下问题:PHP str_shuffle函数的具体用法?PHP str_shuffle怎么用?PHP str_shuffle使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了str_shuffle函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: postAction
public function postAction(Request $request)
{
$repo = $this->get('tekstove.user.repository');
/* @var $repo \Tekstove\ApiBundle\Model\User\UserRepository */
$recaptchaSecret = $this->container->getParameter('tekstove_api.recaptcha.secret');
$requestData = \json_decode($request->getContent(), true);
$userData = $requestData['user'];
$recaptchaData = $requestData['recaptcha'];
$user = new User();
try {
$recaptcha = new \ReCaptcha\ReCaptcha($recaptchaSecret);
$recaptchaResponse = $recaptcha->verify($recaptchaData['g-recaptcha-response']);
if (!$recaptchaResponse->isSuccess()) {
$recaptchaException = new UserHumanReadableException("Recaptcha validation failed");
$recaptchaException->addError("recaptcha", "Validation failed");
throw $recaptchaException;
}
$user->setUsername($userData['username']);
$user->setMail($userData['mail']);
$user->setPassword($this->hashPassword($userData['password']));
$user->setapiKey(sha1(str_shuffle(uniqid())));
$repo->save($user);
} catch (UserHumanReadableException $e) {
$view = $this->handleData($request, $e->getErrors());
$view->setStatusCode(400);
return $view;
}
}
示例2: solt
/**
* @param int $length
* @return string
* @throws \Exception
*/
public static final function solt($length)
{
if ((int) $length > 62) {
throw new \Exception('Max solt length can not be more that 62 characters!');
}
return substr(str_shuffle(implode(array_merge(range('a', 'z'), range('A', 'Z'), range('0', '9')))), 0, $length);
}
示例3: sendEventSMS
/**
* Send register sms
* @param $mobile
* @param $event
* @return bool
*/
public function sendEventSMS($mobile, $event)
{
if (empty($mobile) || !isset(self::$types[$event])) {
return 4001;
}
# Detection is already register
$user = ORM::factory('user');
$count = $user->where('mobile', '=', $mobile)->find_all()->count();
if (empty($count)) {
$cache = Cache::instance();
$lastSendTime = $cache->get(self::$types[$event]['sendTimeKey'] . $mobile);
if (!empty($lastSendTime) && time()->{$lastSendTime} < self::MIN_SEND_TIME) {
return 2001;
}
$code = substr(str_shuffle('0123456789'), 0, 6);
if (self::sendSMS($mobile, $code, self::$types[$event]['tplID']) === TRUE) {
$cache->set(self::$types[$event]['codeKey'] . $mobile, $code);
$cache->set(self::$types[$event]['sendTimeKey'] . $mobile, time());
return TRUE;
} else {
return 2003;
}
} else {
return 2000;
}
}
示例4: __construct
public function __construct($mainDirectory, $originalName, $structure = TRUE, $fixNewName = null)
{
if (!(is_string($originalName) && strlen($originalName) > 0)) {
return;
}
if (!is_dir($mainDirectory)) {
mkdir($mainDirectory, 0777, TRUE);
}
if (!is_writable($mainDirectory)) {
chmod($mainDirectory, 0777);
}
$actDir = $mainDirectory;
if ($structure === TRUE) {
$date = date('Y/m/d/');
if (!is_dir($actDir = $mainDirectory . $date)) {
mkdir($actDir, 0777, TRUE);
chmod($actDir, 0777);
}
}
$explOriginal = explode(DIRECTORY_SEPARATOR, $originalName);
$expl = explode('.', $explOriginal[count($explOriginal) - 1]);
$fileName = '';
if ($fixNewName === NULL) {
for ($i = 0; $i < count($expl) - 1; $i++) {
$fileName .= $expl[$i] . '-';
}
$fileName .= str_shuffle(substr(md5(rand(0, time())), 0, 10));
$fileName .= '.' . $expl[count($expl) - 1];
} else {
$fileName = $fixNewName;
}
$this->newFileName = $actDir . strtolower($fileName);
}
示例5: __construct
/**
* Constructor
* @param WC_Gateway_Komoju $gateway
*/
public function __construct($gateway)
{
$this->gateway = $gateway;
$this->notify_url = $this->gateway->notify_url;
$this->request_id = substr(str_shuffle("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, 6);
$this->Komoju_endpoint = '/ja/api/' . $this->gateway->accountID . '/transactions/';
}
示例6: activate
/**
*
*/
public function activate()
{
$params = array();
$params['username'] = vc_post_param('username');
$params['version'] = WPB_VC_VERSION;
$params['key'] = vc_post_param('key');
$params['api_key'] = vc_post_param('api_key');
$params['url'] = get_site_url();
$params['ip'] = isset($_SERVER['SERVER_ADDR']) ? $_SERVER['SERVER_ADDR'] : '';
$params['dkey'] = substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, 20);
$string = 'activatelicense?';
$request_url = self::getWpbControlUrl(array($string, http_build_query($params, '', '&')));
$response = wp_remote_get($request_url, array('timeout' => 300));
if (is_wp_error($response)) {
echo json_encode(array('result' => false));
die;
}
$result = json_decode($response['body']);
if (!is_object($result)) {
echo json_encode(array('result' => false));
die;
}
if ((bool) $result->result === true || (int) $result->code === 401 && isset($result->deactivation_key)) {
$this->setDeactivation(isset($result->code) && (int) $result->code === 401 ? $result->deactivation_key : $params['dkey']);
vc_settings()->set('envato_username', $params['username']);
vc_settings()->set('envato_api_key', $params['api_key']);
vc_settings()->set('js_composer_purchase_code', $params['key']);
echo json_encode(array('result' => true));
die;
}
echo $response['body'];
die;
}
示例7: reset
/**
* 重置密钥
* @param $key
*/
public static function reset($key)
{
$phptime = date("Y-m-d H:i:s.u");
$k = substr(str_shuffle(md5(microtime())), rand(1, 5), 18);
DB::table('passports')->where('key', $key)->update(['secret' => $k, 'updated_at' => $phptime]);
return 1;
}
示例8: random_number
/**
*
* 返回6位随机数
*/
function random_number()
{
$m = '0123456789';
$s = str_shuffle($m);
$str = substr($s, 1, 6);
return $str;
}
示例9: connection
/**
* Cette fonction connecte un utilisateur, et le redirige sur la page d'accueil
* @param string $_POST['mail'] : L'email de l'utilisateur
* @param string $_POST['password'] : Le mot de passe de l'utilisateur
* @return void
*/
public function connection()
{
//Creation de l'object de base de données
global $db;
$email = $_POST['mail'];
$password = $_POST['password'];
if (!($users = $db->getFromTableWhere('users', ['email' => $email]))) {
$_SESSION['errormessage'] = 'Identifiants incorrects.';
header('Location: ' . $this->generateUrl('connect'));
return false;
}
$user = $users[0];
if (sha1($password) != $user['password']) {
$_SESSION['errormessage'] = 'Cet e-mail n\'existe pas.';
header('Location: ' . $this->generateUrl('connect'));
return false;
}
$_SESSION['connect'] = true;
$_SESSION['admin'] = $user['admin'];
$_SESSION['email'] = $user['email'];
$_SESSION['transfer'] = $user['transfer'];
$_SESSION['csrf'] = str_shuffle(uniqid() . uniqid());
header('Location: ' . $this->generateUrl(''));
return true;
}
示例10: postInfos
public function postInfos(Request $request)
{
$user = new User();
echo "Valeur de ma request :: ";
echo "<pre>";
$tabs = array('civilite', 'nom', 'prenom', 'mail', 'telephone', 'mobile', 'datenaiss', 'sport', 'categorie', 'adresse', 'cp', 'ville', 'nationalite');
foreach ($tabs as $tab) {
// echo "\nValeur de ".$tab." ====>>>>> ".$request[$tab];
if ($tab == 'datenaiss') {
$ex = explode("/", $request[$tab]);
// var_dump($ex);
$user->{$tab} = $ex[2] . '-' . $ex[1] . '-' . $ex[0];
} else {
$user->{$tab} = $request[$tab];
}
}
if ($request['classement']) {
$user->classement = $request['classement'];
}
$length = 20;
$user->id = substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, $length);
var_dump($user);
echo "</pre>";
// $user->save();
}
示例11: admin_reset_password
public function admin_reset_password($token = null)
{
if ($this->Auth->loggedIn()) {
$this->redirect('/admin/index');
}
if (!isset($token)) {
if ($this->request->is('post')) {
$user = $this->User->findByEmail($this->request->data['User']['email']);
if (empty($user)) {
$this->Session->setFlash('W bazie nie ma takiego adresu e-mail', 'flash_warning');
$this->redirect('/admin/users/reset_password');
}
$token = Utilities::token();
$this->adminSendMail($this->request->data['User']['email'], 'kAdmin - resetowanie hasła', 'reset_password', array('username' => $user['User']['username'], 'link' => '<a href="' . Router::url('/admin/users/reset_password/' . $token, true) . '">' . Router::url('/admin/users/reset_password/' . $token . $user['User']['id'], true) . '</a>'));
$this->User->id = $user['User']['id'];
$this->User->saveField('token', $token);
$this->set('afterPost', true);
}
} else {
$user = $this->User->findByToken($token);
if (empty($user)) {
throw new NotFoundException('Podany token jest nieprawidłowy.');
}
$pass = substr(str_shuffle('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!$'), 0, 6);
$this->User->id = $user['User']['id'];
$this->User->save(array('token' => null, 'password' => $pass), false);
$this->adminSendMail($user['User']['email'], 'kAdmin - resetowanie hasła', 'new_password', array('password' => $pass, 'username' => $user['User']['username']));
$this->set('afterReset', true);
}
}
示例12: generate
public static function generate()
{
//����������� PHP ���������� captchastring ������ ��������
$captchastring = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyz';
//�������� ������ 6 �������� ����� �� ������������� � ������� ������� str_shuffle
$captchastring = substr(str_shuffle($captchastring), 0, 6);
//������������� ���������� ������ � ������� ��������������� ��������� captchastring,
//���������� 6 ��������
ErSession::saveToSession("code", $captchastring);
//���������� CAPTCHA
//������� ����� ����������� �� ����� background.png
$image = imagecreatefrompng('application/data/images/background.png');
//������������� ���� (R-200, G-240, B-240) �����������, ����������� � $image
$colour = imagecolorallocate($image, 200, 240, 240);
//����������� ���������� font �������� ������
$font = 'application/data/fonts/oswald.ttf';
//������������� ��������� ����� ����� -10 � 10 �������� ��� �������� ������
$rotate = rand(-10, 10);
//������ ����� �� ����������� ������� TrueType (1 �������� - ����������� ($image),
//2 - ������ ������ (18), 3 - ���� �������� ������ ($rotate),
//4, 5 - ��������� ���������� x � y ��� ������ (18,30), 6 - ������ ����� ($colour),
//7 - ���� � ����� ������ ($font), 8 - ����� ($captchastring)
imagettftext($image, 18, $rotate, 28, 32, $colour, $font, $captchastring);
//����� ���������� ����������� � ������� png
header('Content-type: image/png');
//������� �����������
return imagepng($image);
}
示例13: upload
public function upload()
{
$filename = date("Y-m-d", time());
if (!file_exists("../uploads/" . $filename)) {
mkdir("../uploads/" . $filename, 0777);
}
$targetFolder = '../uploads/' . $filename;
$str = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYX";
$verifyToken = md5('unique_salt' . $_POST['timestamp']);
if (!empty($_FILES) && $_POST['token'] == $verifyToken) {
$tempFile = $_FILES['fileField']['tmp_name'];
$targetPath = $targetFolder;
//$_SERVER['DOCUMENT_ROOT'] ."/car/". $targetFolder;
$newname = substr(strrchr($_FILES['fileField']['name'], "."), 0);
//这种方法获取的是图片名称的所有名字进行加密
//$new_name=md5($_FILES['fileField']['name']).$newname;
//这一种方法是获取图片名称不加后缀
//$exName=explode(".",$_FILES['fileField']['name']);
$new_name = substr(str_shuffle($str), 0, 10) . $newname;
//$targetFile = rtrim($targetPath,'/') . '/' .$new_name;
$targetFile = "../uploads/" . $new_name;
// Validate the file type
$fileTypes = array('jpg', 'jpeg', 'gif', 'png');
// File extensions
$fileParts = pathinfo($targetFile);
if (in_array($fileParts['extension'], $fileTypes)) {
move_uploaded_file($tempFile, "../uploads/" . $new_name);
$new_filename = base_url() . "uploads/" . $new_name;
echo $new_filename;
} else {
echo 'Invalid file type.';
}
}
}
示例14: randomJawaban
function randomJawaban($soal = array(), $random = true)
{
if (!is_array($soal)) {
return false;
}
$listNo = array('1234');
$listArray = array();
if ($random) {
do {
$leter = substr(str_shuffle($listNo), 0, 1);
if (!in_array($leter, $listArray)) {
$listArray[] = $leter;
}
$countArray = count($listArray);
} while ($countArray <= 3);
} else {
$listArray = array(1, 2, 3, 4);
}
$dataArrSoal = array();
if ($listArray) {
foreach ($listArray as $key => $value) {
$soal['acakpilihan'][$value] = $soal['pilihan' . $value];
}
}
return $soal;
}
示例15: sendValidation
function sendValidation($email)
{
$errorMessage = "";
$successMessage = "";
if (isset($email)) {
if (match("users", "email", "userid", $email) > 0) {
$errorMessage = "This email is taken.";
} else {
$_SESSION["key"] = substr(str_shuffle(str_repeat('0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', mt_rand(1, 16))), 0, 16);
$_SESSION["email"] = $email;
$subject = "validation";
$message = "\n\t\t\t\t\t\t\t<html>\n\t\t\t\t\t\t\t\t<head>\n\t\t\t\t\t\t\t\t\t<title>validation</title>\n\t\t\t\t\t\t\t\t</head>\n\t\t\t\t\t\t\t\t<body style='background-color: rgba(048,122,183,1); color: rgba(255,255,255,1); font-family: arial, sans-serif; text-align: center; font-size: 50px; border-radius: 10px'>\n\t\t\t\t\t\t\t\t\t<div style='padding-top: 50px; padding-bottom: 50px'>\n\t\t\t\t\t\t\t\t\t\t<a href='http://example.com/welcome.html?email=" . $_SESSION["email"] . "&key=" . $_SESSION["key"] . "'>Validate this email address.</a>\n\t\t\t\t\t\t\t\t\t</div>\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t</body>\n\t\t\t\t\t\t\t</html>";
$headers = 'MIME-Version: 1.0' . "\r\n" . 'Content-type: text/html; charset=iso-8859-1' . "\r\n" . 'From: info@example.com' . "\r\n" . 'Reply-To: info@example.com' . "\r\n" . 'X-Mailer: PHP/' . phpversion();
mail($email, $subject, $message, $headers);
$domain = explode("@", $email);
$domain = $domain[1];
//$successMessage = "https://".$domain;
$successMessage = "http://example.com/welcome.html?email=" . $_SESSION["email"] . "&key=" . $_SESSION["key"];
//testing only
}
} else {
$errorMessage = "Please enter a valid email address.";
}
return $errorMessage . ":|:|:|:" . $successMessage;
}