当前位置: 首页>>代码示例>>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;未经允许,请勿转载。