當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Utility::getRandomStr方法代碼示例

本文整理匯總了PHP中Utility::getRandomStr方法的典型用法代碼示例。如果您正苦於以下問題:PHP Utility::getRandomStr方法的具體用法?PHP Utility::getRandomStr怎麽用?PHP Utility::getRandomStr使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Utility的用法示例。


在下文中一共展示了Utility::getRandomStr方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: Create

 /**
  * Create new user
  * @access  public
  * @param   user_group_id: user group ID (1 [admin] or 2 [user])
  *          login: login name
  *          pwd: password
  *          email: email
  *          first_name: first name
  *          last_name: last name
  * @return  user id, if successful
  *          false and add error into global var $msg, if unsuccessful
  * @author  Cindy Qi Li
  */
 public function Create($user_group_id, $login, $pwd, $email, $first_name, $last_name, $is_author, $organization, $phone, $address, $city, $province, $country, $postal_code, $status)
 {
     global $addslashes;
     /* email check */
     $login = $addslashes(strtolower(trim($login)));
     $email = $addslashes(trim($email));
     $first_name = $addslashes(str_replace('<', '', trim($first_name)));
     $last_name = $addslashes(str_replace('<', '', trim($last_name)));
     $organization = $addslashes(trim($organization));
     $phone = $addslashes(trim($phone));
     $address = $addslashes(trim($address));
     $city = $addslashes(trim($city));
     $province = $addslashes(trim($province));
     $country = $addslashes(trim($country));
     $postal_code = $addslashes(trim($postal_code));
     if ($this->isFieldsValid('new', $user_group_id, $login, $email, $first_name, $last_name, $is_author, $organization, $phone, $address, $city, $province, $country, $postal_code)) {
         if ($status == "") {
             if (defined('TR_EMAIL_CONFIRMATION') && TR_EMAIL_CONFIRMATION) {
                 $status = TR_STATUS_UNCONFIRMED;
             } else {
                 $status = TR_STATUS_ENABLED;
             }
         }
         /* insert into the db */
         $sql = "INSERT INTO " . TABLE_PREFIX . "users\n\t\t\t              (login,\n\t\t\t               password,\n\t\t\t               user_group_id,\n\t\t\t               first_name,\n\t\t\t               last_name,\n\t\t\t               email,\n\t\t\t               is_author,\n\t\t\t               organization,\n\t\t\t               phone,\n\t\t\t               address,\n\t\t\t               city,\n\t\t\t               province,\n\t\t\t               country,\n\t\t\t               postal_code,\n\t\t\t               web_service_id,\n\t\t\t               status,\n\t\t\t               create_date\n\t\t\t               )\n\t\t\t       VALUES ('" . $login . "',\n\t\t\t               '" . $pwd . "',\n\t\t\t               " . $user_group_id . ",\n\t\t\t               '" . $first_name . "',\n\t\t\t               '" . $last_name . "', \n\t\t\t               '" . $email . "',\n\t\t\t               " . $is_author . ",\n\t\t\t               '" . $organization . "',\n\t\t\t               '" . $phone . "',\n\t\t\t               '" . $address . "',\n\t\t\t               '" . $city . "',\n\t\t\t               '" . $province . "',\n\t\t\t               '" . $country . "',\n\t\t\t               '" . $postal_code . "',\n\t\t\t               '" . Utility::getRandomStr(32) . "',\n\t\t\t               " . $status . ", \n\t\t\t               now())";
         if (!$this->execute($sql)) {
             $msg->addError('DB_NOT_UPDATED');
             return false;
         } else {
             return mysql_insert_id();
         }
     } else {
         return false;
     }
 }
開發者ID:harriswong,項目名稱:AContent,代碼行數:48,代碼來源:UsersDAO.class.php

示例2: Create

 /**
  * Create a new consumer record
  * @access  public
  * @param   consumer
  * @return  consumer id, if successful
  *          false and add error into global var $msg, if unsuccessful
  * @author  Cindy Qi Li
  */
 public function Create($consumer, $expire_threshold)
 {
     global $addslashes, $msg;
     $missing_fields = array();
     /* email check */
     $consumer = $addslashes(trim($consumer));
     /* login name check */
     if ($consumer == '') {
         $missing_fields[] = _AT('consumer');
     }
     if ($missing_fields) {
         $missing_fields = implode(', ', $missing_fields);
         $msg->addError(array('EMPTY_FIELDS', $missing_fields));
     }
     if (!$msg->containsErrors()) {
         /* insert into the db */
         $consumer_key = Utility::getRandomStr(16);
         $consumer_secret = Utility::getRandomStr(16);
         $sql = "INSERT INTO " . TABLE_PREFIX . "oauth_server_consumers\n\t\t\t              (consumer,\n\t\t\t               consumer_key,\n\t\t\t               consumer_secret,\n\t\t\t               expire_threshold,\n\t\t\t               create_date\n\t\t\t               )\n\t\t\t       VALUES ('" . $consumer . "',\n\t\t\t               '" . $consumer_key . "',\n\t\t\t               '" . $consumer_secret . "',\n\t\t\t               " . $expire_threshold . ",\n\t\t\t               now()\n\t\t\t              )";
         if (!$this->execute($sql)) {
             $msg->addError('DB_NOT_UPDATED');
             return false;
         } else {
             return mysql_insert_id();
         }
     } else {
         return false;
     }
 }
開發者ID:harriswong,項目名稱:AContent,代碼行數:37,代碼來源:OAuthServerConsumersDAO.class.php

示例3: header

    if (isset($_GET['tile'])) {
        header('Location: ' . $_base_path . 'tools/tile/index.php');
    } else {
        header('Location: ../index.php');
    }
    exit;
}
/* check if ../content/import/ exists */
$import_path = TR_TEMP_DIR . 'import/';
$content_path = TR_TEMP_DIR;
if (!is_dir($import_path)) {
    if (!@mkdir($import_path, 0700)) {
        $msg->addError('IMPORTDIR_FAILED');
    }
}
$import_path .= Utility::getRandomStr(16) . '/';
if (is_dir($import_path)) {
    clr_dir($import_path);
}
if (!@mkdir($import_path, 0700)) {
    $msg->addError('IMPORTDIR_FAILED');
}
if ($msg->containsErrors()) {
    if (isset($_GET['tile'])) {
        header('Location: ' . $_base_path . 'tools/tile/index.php');
    } else {
        header('Location: ../index.php');
    }
    exit;
}
/* extract the entire archive into TR_COURSE_CONTENT . import/$course using the call back function to filter out php files */
開發者ID:harriswong,項目名稱:AContent,代碼行數:31,代碼來源:ims_import.old.php

示例4: new_access_token

 function new_access_token($token, $consumer)
 {
     /*{{{*/
     $access_token_key = Utility::getRandomStr(18);
     $access_token_secret = Utility::getRandomStr(18);
     $request_token_row = $this->oauthServerTokensDAO->getByTokenAndType($token, 'request');
     $this->oauthServerTokensDAO->Create($request_token_row[0]['consumer_id'], $access_token_key, 'access', $access_token_secret, $request_token_row[0]['user_id']);
     $this->oauthServerTokensDAO->deleteByTokenAndType($token, 'request');
     $access_token = new OAuthToken($access_token_key, $access_token_secret);
     return $access_token;
 }
開發者ID:harriswong,項目名稱:AContent,代碼行數:11,代碼來源:MyOAuthServer.class.php


注:本文中的Utility::getRandomStr方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。