• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Utility类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中Utility的典型用法代码示例。如果您正苦于以下问题:PHP Utility类的具体用法?PHP Utility怎么用?PHP Utility使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Utility类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: renderHead

 public function renderHead()
 {
     $page = $this->plugin->getData('page');
     if ($page !== 'photos' && $page !== 'photo-detail' && $page !== 'albums') {
         return;
     }
     $photo = null;
     if ($page === 'photos') {
         $photo = array_shift($this->plugin->getData('photos'));
     } elseif ($page === 'photo-detail') {
         $photo = $this->plugin->getData('photo');
     } elseif ($page === 'albums') {
         $albums = $this->plugin->getData('albums');
         if (count($albums) > 0 && !empty($albums[0]['cover'])) {
             $photo = $albums[0]['cover'];
         }
     }
     if (empty($photo)) {
         return;
     }
     $utility = new Utility();
     $tags = '';
     $title = $photo['title'] !== '' ? $photo['title'] : "{$photo['filenameOriginal']} on Trovebox";
     $tags .= $this->addTag('og:site_name', sprintf('%s Trovebox site', ucwords($utility->posessive($utility->getEmailHandle($this->config->user->email, false), false))));
     $tags .= $this->addTag('og:title', $photo['title']);
     $tags .= $this->addTag('og:url', $photo['url']);
     $tags .= $this->addTag('og:image', $photo['pathBase']);
     return $tags;
 }
开发者ID:gg1977,项目名称:frontend,代码行数:29,代码来源:FacebookLikePlugin.php


示例2: getAvatarFromEmail

 /**
  * Get an avatar given an email address
  * See http://en.gravatar.com/site/implement/images/ and http://en.gravatar.com/site/implement/hash/
  *
  * @return string
  */
 public function getAvatarFromEmail($size = 50, $email = null)
 {
     if ($email === null) {
         $email = $this->session->get('email');
     }
     // TODO return standard avatar
     if (empty($email)) {
         return;
     }
     $user = $this->getUserByEmail($email);
     if (isset($user['attrprofilePhoto']) && !empty($user['attrprofilePhoto'])) {
         return $user['attrprofilePhoto'];
     }
     $utilityObj = new Utility();
     if (empty($this->config->site->cdnPrefix)) {
         $hostAndProtocol = sprintf('%s://%s', $utilityObj->getProtocol(false), $utilityObj->getHost(false));
     } else {
         $hostAndProtocol = sprintf('%s%s', $utilityObj->getProtocol(false), $this->config->site->cdnPrefix);
     }
     if (!$this->themeObj) {
         $this->themeObj = getTheme();
     }
     $defaultUrl = sprintf('%s%s', $hostAndProtocol, $this->themeObj->asset('image', 'profile-default.png', false));
     $hash = md5(strtolower(trim($email)));
     return sprintf("http://www.gravatar.com/avatar/%s?s=%s&d=%s", $hash, $size, urlencode($defaultUrl));
 }
开发者ID:hfiguiere,项目名称:frontend,代码行数:32,代码来源:User.php


示例3: renderHead

 public function renderHead()
 {
     $page = $this->plugin->getData('page');
     if ($page !== 'photos' && $page !== 'photo-detail' && $page !== 'albums') {
         return;
     }
     $photo = null;
     if ($page === 'photos') {
         $photo = array_shift($this->plugin->getData('photos'));
     } elseif ($page === 'photo-detail') {
         $photo = $this->plugin->getData('photo');
     } elseif ($page === 'albums') {
         $albums = $this->plugin->getData('albums');
         if (count($albums) > 0 && !empty($albums[0]['cover'])) {
             $photo = $albums[0]['cover'];
         }
     }
     if (empty($photo)) {
         return;
     }
     $utility = new Utility();
     $tags = '';
     $title = $photo['title'] !== '' ? $photo['title'] : "{$photo['filenameOriginal']} on Trovebox";
     $tags .= $this->addTag('twitter:card', 'photo');
     $tags .= $this->addTag('twitter:site', '@openphoto');
     $tags .= $this->addTag('twitter:url', sprintf('%s://%s%s', $utility->getProtocol(false), $utility->getHost(), $utility->getPath()));
     $tags .= $this->addTag('twitter:title', $title);
     $tags .= $this->addTag('twitter:description', 'Trovebox lets you keep all your photos from different services and mobile devices safe in one spot.');
     $tags .= $this->addTag('twitter:image', $photo['pathBase']);
     $tags .= $this->addTag('twitter:image:width', '1280');
     return $tags;
 }
开发者ID:hfiguiere,项目名称:frontend,代码行数:32,代码来源:TwitterCardPlugin.php


示例4: update_groups

/**
* Update the groups for this user
* @param none
*/
function update_groups($memberid, $to_add)
{
    $util = new Utility();
    $user = new User($memberid);
    $orig = array_keys($user->groups);
    $groups_to_add = $util->getAddedItems($orig, $to_add);
    $groups_to_remove = $util->getRemovedItems($orig, $to_add);
    $user->add_groups($groups_to_add);
    $user->remove_groups($groups_to_remove);
    close_window();
}
开发者ID:razagilani,项目名称:srrs,代码行数:15,代码来源:group_edit.php


示例5: renderHead

 public function renderHead()
 {
     $utility = new Utility();
     $photo = $this->plugin->getData('photo');
     $tags = '';
     $title = $photo['title'] !== '' ? $photo['title'] : "{$photo['filenameOriginal']} on OpenPhoto";
     $tags .= $this->addTag('og:site_name', sprintf('%s OpenPhoto site', ucwords($utility->posessive($utility->getEmailHandle($this->config->user->email, false), false))));
     $tags .= $this->addTag('og:title', $photo['title']);
     $tags .= $this->addTag('og:url', $photo['url']);
     $tags .= $this->addTag('og:image', $photo['pathBase']);
     return $tags;
 }
开发者ID:nicolargo,项目名称:frontend,代码行数:12,代码来源:FacebookLikePlugin.php


示例6: diagnostics

 /**
  * Gets diagnostic information for debugging.
  *
  * @return array
  */
 public function diagnostics()
 {
     $utilityObj = new Utility();
     $diagnostics = array();
     $aclCheck = $this->fs->get_bucket_acl($this->bucket);
     if ((int) $aclCheck->status == 200) {
         $storageSize = $this->fs->get_bucket_filesize($this->bucket, true);
         $diagnostics[] = $utilityObj->diagnosticLine(true, sprintf('Connection to bucket "%s" is okay.', $this->bucket));
         $diagnostics[] = $utilityObj->diagnosticLine(true, sprintf('Total space used in bucket "%s" is %s.', $this->bucket, $storageSize));
     } else {
         $diagnostics[] = $utilityObj->diagnosticLine(false, sprintf('Connection to bucket "%s" is NOT okay.', $this->bucket));
     }
     return $diagnostics;
 }
开发者ID:nicolargo,项目名称:frontend,代码行数:19,代码来源:FileSystemS3.php


示例7: hasOpenSession

 public function hasOpenSession()
 {
     $util = new Utility();
     $config = new Configuration();
     $dbName = $config->settings->authDatabaseName;
     $sessionID = $util->getSessionCookie();
     $query = "SELECT DISTINCT sessionID FROM " . $dbName . ".Session WHERE loginID = '" . $this->loginID . "' AND sessionID='" . $sessionID . "'";
     $result = $this->db->processQuery($query, 'assoc');
     if (isset($result['sessionID'])) {
         return true;
     } else {
         return false;
     }
 }
开发者ID:ualbertalib,项目名称:organizations,代码行数:14,代码来源:User.php


示例8: UpdateById

 protected function UpdateById($args)
 {
     $object_id = $args[0];
     $metas = $args[1];
     $old_data = Utility::AssColumn($this->GetById(array($object_id)), 'meta_key');
     foreach ($metas as $k => $v) {
         if ($v && $v !== $old_data[$k]['meta_value']) {
             $m = array();
             if ($old_data[$k]) {
                 $m['id'] = $old_data[$k]['id'];
             }
             $m[$this->_fetch_id_name] = $object_id;
             $m['meta_key'] = $k;
             $m['meta_value'] = $v;
             $new_data[] = $m;
         }
     }
     if (!$new_data) {
         return;
     }
     $mm = D($this->_table_name);
     foreach ($new_data as $d) {
         $mm->create($d);
         $mm->saveOrUpdate();
     }
     return;
 }
开发者ID:Germey,项目名称:yinxingpm,代码行数:27,代码来源:MetasModel.class.php


示例9: showPrice

 /**
  * [price description]
  * @param  [float or array] $arg [it could be float or an array, if its array you can put
  *         'amount' to display,'discount' that it already has, 'thousandSuffix' if you wanna use that format ]
  *         if you use 'discount' the return is gonna be something like that 'The final value is USD 7.50 (after a 25% discount)'
  *         this function works with config('app.payment_method') then there could be Points or Currency
  * @return [String]      [Formated number or explaint of discount]
  */
 public static function showPrice($arg)
 {
     $options = ['amount' => '', 'discount' => 0, 'thousandSuffix' => 1];
     if (is_array($arg)) {
         $options = $arg + $options;
         if (isset($options['price'])) {
             $options['amount'] = $options['price'];
         }
     } else {
         $options['amount'] = $arg;
     }
     switch (config('app.payment_method')) {
         case 'Points':
             $points = Utility::thousandSuffix($options['amount']);
             if ($options['thousandSuffix']) {
                 $points .= " <small>" . trans('store.points') . "</small>";
             }
             return $points;
         default:
             setlocale(LC_MONETARY, config('app.lc_monetary'));
             $format = '%i';
             if ($options['discount']) {
                 $format = str_replace('##', $options['discount'], trans('product.globals.price_after_discount'));
             }
             return self::money_format($format, $options['amount']);
     }
 }
开发者ID:masterpowers,项目名称:antVel,代码行数:35,代码来源:Utility.php


示例10: __construct

 public function __construct($data)
 {
     $this->name = isset($data['name']) ? $data['name'] : '';
     $this->tag = isset($data['tag']) ? $data['tag'] : '';
     $this->tag_type = isset($data['tag_type']) ? $data['tag_type'] : '';
     $this->content = isset($data['content']) ? $data['content'] : '';
     $this->before = isset($data['before']) ? $data['before'] : '';
     $this->after = isset($data['after']) ? $data['after'] : '';
     $this->attributes = isset($data['attributes']) ? $data['attributes'] : array();
     $this->hide = isset($data['hide']) ? $data['hide'] : false;
     $this->suppress_filters = isset($data['suppress_filters']) ? $data['suppress_filters'] : true;
     $this->markup = '';
     if (isset($data['post'])) {
         $this->post_object = $data['post'];
     } else {
         $this->post_object = get_post();
     }
     // Ensures that the 'class' attribute is set if it wasn't passed in with attributes.
     if (!isset($this->attributes['class'])) {
         $this->attributes['class'] = array();
     }
     // Add the Atom name as a class
     $this->attributes['class'][] = $this->name;
     if (!empty($data['class'])) {
         $classes_arr = Utility::parse_classes_as_array($data['class']);
         if (!empty($classes_arr)) {
             $this->attributes['class'] = array_merge($this->attributes['class'], $classes_arr);
         }
     }
     unset($this->class);
     // Filter the Atom properties.
     $atom_structure_filter = $this->name . '_properties_filter';
     apply_filters($atom_structure_filter, $this, $data);
     Atom::add_debug_entry('Filter', $atom_structure_filter);
 }
开发者ID:Clark-Nikdel-Powell,项目名称:Pattern-Library,代码行数:35,代码来源:class.atom-template.php


示例11: sync_event_users

function sync_event_users()
{
    $current_users = OutboundUsers::GetPartnerUsers(1);
    $current_users_by_mobile = Utility::AssColumn($current_users, 'mobile');
    $users = Users::GetUsers(NULL, 0, 50000);
    global $g_user_type;
    global $g_active_status;
    foreach ($users as $i => $eu) {
        if (!$current_users_by_mobile[$eu['mobile']]) {
            $new_id = OutboundUsers::AddCommonUser(1, $eu);
            $new_ids[] = $new_id;
            //添加默认标签
            if ($eu['user_type'] && $eu['user_type'] !== 'other') {
                $gid = OutboundUserGroups::AddGroup(1, $g_user_type[$eu['user_type']]);
                OutboundUserGroups::AddMap($new_id, $gid);
            }
            if ($eu['active_status']) {
                $gid = OutboundUserGroups::AddGroup(1, $g_active_status[$eu['active_status']]);
                OutboundUserGroups::AddMap($new_id, $gid);
            }
            $current_users_by_mobile[$eu['mobile']] = 1;
        }
    }
    return $new_ids;
}
开发者ID:Germey,项目名称:yinxingpm,代码行数:25,代码来源:mail.php


示例12: handleGET

 /**
  * Handles a GET request
  *
  * @return none, but populates $this->JSON
  */
 public function handleGET()
 {
     if (!empty($this->JSON)) {
         return;
     }
     $config = $this->Factory->config();
     $useProjects = $config->getSetting("useProjects");
     $useEDC = $config->getSetting("useEDC");
     if ($useEDC === '1' || $useEDC === 'true') {
         $useEDC = true;
     } else {
         $useEDC = false;
     }
     $PSCID = $config->getSetting("PSCID");
     $PSCIDFormat = \Utility::structureToPCRE($PSCID['structure'], "SITE");
     $type = $PSCID['generation'] == 'sequential' ? 'auto' : 'prompt';
     $settings = ["useEDC" => $useEDC, "PSCID" => ["Type" => $type, "Regex" => $PSCIDFormat]];
     if ($useProjects && $useProjects !== "false" && $useProjects !== "0") {
         $projects = \Utility::getProjectList();
         $projArray = [];
         foreach ($projects as $project) {
             $projArray[$project] = $settings;
         }
         $this->JSON = ["Projects" => $projArray];
     } else {
         $this->JSON = ["Projects" => array("loris" => $settings)];
     }
 }
开发者ID:frankbiospective,项目名称:Loris,代码行数:33,代码来源:Projects.php


示例13: execute

 /**
  * Send the HTTP request, with optional parameters
  * $params and $header. First parameter $requestURL
  * is also optional, if the URL already been set by
  * the getRequestURL() method.
  *
  * @param   string  The request url.
  * @param   array   Optional. Parameters to post.
  * @param   array   Optional. Http header.
  * @return  array | string
  */
 public function execute($requestURL = NULL, $params = NULL, $header = NULL)
 {
     if ($requestURL === NULL) {
         $requestURL = $this->getRequestURL();
     }
     $curlHandle = curl_init();
     // Default curl options array
     $curlOptions = array(CURLOPT_URL => $requestURL, CURLOPT_CONNECTTIMEOUT => 30, CURLOPT_TIMEOUT => 30, CURLOPT_RETURNTRANSFER => 1, CURLOPT_SSL_VERIFYPEER => 0, CURLOPT_HEADER => 0, CURLOPT_POST => $this->getHttpMethod() === 'POST');
     curl_setopt_array($curlHandle, $curlOptions);
     // The parameters array must be turned into an URL-encoded query string.
     if ($params !== NULL && $this->getHttpMethod() === 'POST') {
         // The access token should not be included in the post data.
         if (array_key_exists("oauth_token", $params)) {
             unset($params['oauth_token']);
         }
         curl_setopt($curlHandle, CURLOPT_POSTFIELDS, http_build_query($params));
     }
     if ($header !== NULL) {
         curl_setopt($curlHandle, CURLOPT_HTTPHEADER, $header);
     }
     $response = curl_exec($curlHandle);
     // Save the received http code.
     $this->setLastHttpCode(curl_getinfo($curlHandle, CURLINFO_HTTP_CODE));
     curl_close($curlHandle);
     // If the response is in JSON, convert it to an array
     $response = Utility::convertJSON($response);
     return $response;
 }
开发者ID:pkrll,项目名称:Philotes,代码行数:39,代码来源:Request.php


示例14: updateDetail

 public function updateDetail($arrPost)
 {
     Utility::pushArrAreaID($arrPost);
     //  区域ID
     if (empty($arrPost['endtime'])) {
         $arrPost['endtime'] = '';
     }
     if (!empty($arrPost['photos']) && stristr($arrPost['photos'], '|')) {
         $arrPost['photos'] = Utility::sortImg($arrPost['photos']);
         // 排序
     }
     // 需要 处理的 数字大小
     $arrParam = array('floor', 'floortotal', 'roomnumber', 'livingnumber', 'houseage', 'toiletnumber');
     Utility::checkMaxNum($arrPost, $arrParam);
     $arrPost['aroundpoint'] = empty($arrPost['aroundpoint']) ? '' : implode(',', $arrPost['aroundpoint']);
     $arrPost['livepoint'] = empty($arrPost['livepoint']) ? '' : implode(',', $arrPost['livepoint']);
     $this->strRequestApi = empty($arrPost['id']) ? $this->arrRequestApi['SECOND_HOUSE_ADD'] : $this->arrRequestApi['SECOND_HOUSE__UPDATE'];
     $this->arrRequest = $arrPost;
     $arrResultList = $this->updateParentDetail();
     // D($arrPost);
     // D($arrResultList);
     // exit();
     // 成功跳转
     if ($arrResultList['errorCode'] === 0 || $arrResultList['errorCode'] === 2) {
         Utility::location('secondHouse.php');
     }
     // Utility::UIWindowAlert( '请填写完整。');
     // Utility::location( null , '填写信息有误,请耐心检查下。');
     Utility::location(null, ACTION_ERROR);
 }
开发者ID:alonexy,项目名称:lea,代码行数:30,代码来源:WalletController.php


示例15: Create

 public static function Create($mobile, $user_id, $secret = null, $enable = false)
 {
     if (!Utility::IsMobile($mobile, true)) {
         return;
     }
     $secret = $secret ? $secret : Utility::VerifyCode();
     $table = new Table('toolsbind', array('user_id' => $user_id, 'tools' => $mobile, 'enable' => $enable ? 'Y' : 'N', 'secret' => $secret));
     $condition = array('user_id' => $user_id, 'tools' => $mobile, 'enable' => 'N');
     $haveone = DB::GetTableRow('toolsbind', $condition);
     if ($haveone) {
         return Table::UpdateCache('toolsbind', $haveone['id'], array('secret' => $secret, 'enable' => 'N'));
     }
     //已经绑定了本号码
     $loginbind = array('user_id' => $user_id, 'tools' => $mobile, 'enable' => 'Y');
     $havebind = DB::GetTableRow('toolsbind', $loginbind);
     if ($havebind) {
         return false;
     }
     //$table->insert(array( 'user_id', 'tools','secret', 'enable'));
     DB::Insert('toolsbind', array('user_id' => $user_id, 'tools' => $mobile, 'secret' => $secret, 'enable' => 'N', 'create_time' => time()));
     $have = Table::Fetch('toolsbind', $mobile, 'tools');
     if ($have && 'Y' == $have['enable']) {
         return true;
     }
 }
开发者ID:norain2050,项目名称:zuituware,代码行数:25,代码来源:ZToolsbind.class.php


示例16: Create

 public static function Create($user_row, $uc = true)
 {
     if (function_exists('zuitu_uc_register') && $uc) {
         $pp = $user_row['password'];
         $em = $user_row['email'];
         $un = $user_row['username'];
         $ret = zuitu_uc_register($em, $un, $pp);
         if (!$ret) {
             return false;
         }
     }
     $user_row['password'] = self::GenPassword($user_row['password']);
     $user_row['create_time'] = $user_row['login_time'] = time();
     $user_row['ip'] = Utility::GetRemoteIp();
     $user_row['secret'] = md5(Utility::GenSecret(12));
     $user_row['id'] = DB::Insert('user', $user_row);
     $_rid = abs(intval(cookieget('_rid')));
     if ($_rid) {
         $r_user = Table::Fetch('user', $_rid);
         if ($r_user) {
             ZInvite::Create($r_user, $user_row);
         }
     }
     if ($user_row['id'] == 1) {
         Table::UpdateCache('user', $user_row['id'], array('manager' => 'Y', 'secret' => ''));
     }
     return $user_row['id'];
 }
开发者ID:BGCX262,项目名称:zuitu-svn-to-git,代码行数:28,代码来源:ZUser.class.php


示例17: actionIndexing

 /**
  * This is the default 'index' action that is invoked
  * when an action is not explicitly requested by users.
  */
 public function actionIndexing()
 {
     ini_set('max_execution_time', 0);
     ob_start();
     $index = new Zend_Search_Lucene(Yii::getPathOfAlias($this->_indexFilesPath), true);
     $criteria = new CDbCriteria();
     $criteria->compare('t.publish', 1);
     $criteria->order = 'album_id DESC';
     //$criteria->limit = 10;
     $model = Albums::model()->findAll($criteria);
     foreach ($model as $key => $item) {
         if ($item->media_id != 0) {
             $images = Yii::app()->request->baseUrl . '/public/album/' . $item->album_id . '/' . $item->cover->media;
         } else {
             $images = '';
         }
         $doc = new Zend_Search_Lucene_Document();
         $doc->addField(Zend_Search_Lucene_Field::UnIndexed('id', CHtml::encode($item->album_id), 'utf-8'));
         $doc->addField(Zend_Search_Lucene_Field::Text('media', CHtml::encode($images), 'utf-8'));
         $doc->addField(Zend_Search_Lucene_Field::Text('title', CHtml::encode($item->title), 'utf-8'));
         $doc->addField(Zend_Search_Lucene_Field::Text('body', CHtml::encode(Utility::hardDecode(Utility::softDecode($item->body))), 'utf-8'));
         $doc->addField(Zend_Search_Lucene_Field::Text('url', CHtml::encode(Utility::getProtocol() . '://' . Yii::app()->request->serverName . Yii::app()->createUrl('album/site/view', array('id' => $item->album_id, 't' => Utility::getUrlTitle($item->title)))), 'utf-8'));
         $doc->addField(Zend_Search_Lucene_Field::UnIndexed('date', CHtml::encode(Utility::dateFormat($item->creation_date, true) . ' WIB'), 'utf-8'));
         $doc->addField(Zend_Search_Lucene_Field::UnIndexed('creation', CHtml::encode($item->user->displayname), 'utf-8'));
         $index->addDocument($doc);
     }
     echo 'Album Lucene index created';
     $index->commit();
     $this->redirect(Yii::app()->createUrl('article/search/indexing'));
     ob_end_flush();
 }
开发者ID:OmmuOpenSource,项目名称:OOS-Company-Profile,代码行数:35,代码来源:SearchController.php


示例18: getUserGroupId

 public function getUserGroupId($user_id, $team_id)
 {
     $groups = D("UserGroups")->getTeamGroups($team_id);
     $group_ids = Utility::GetColumn($groups);
     $group = M("UserGroupMapping")->where(array("user_group_id" => array("in", $group_ids), "user_id" => $user_id))->getField("user_group_id");
     return $group;
 }
开发者ID:Germey,项目名称:yinxingpm,代码行数:7,代码来源:UsersModel.class.php


示例19: __construct

 function __construct($username, $password, $tenantID)
 {
     if (strlen($username) == 0 || strlen($password) == 0) {
         throw new Exception("Invalid username or password.");
     }
     $userDetails = User::getUserDetails($username);
     if ($userDetails["active"] == 0) {
         throw new Exception("This user account is inactive. Please check your email for activation instructions.");
     } else {
         $saltedPassword = Utility::saltAndHash($password, $userDetails["password"]);
         //echo 'salted:' . $saltedPassword;
         //echo Utility::saltAndHash($password);
         $query = 'call validateUser(' . Database::queryString($username);
         $query .= ',' . Database::queryString($saltedPassword);
         $query .= ',' . Database::queryNumber($tenantID) . ');';
         $result = Database::executeQuery($query);
         if (!$result) {
             throw new Exception('Unable to validate that username/password combination.');
         } else {
             $userid = 0;
             while ($o = mysqli_fetch_object($result)) {
                 $userid = $o->userid;
                 $name = $o->name;
             }
             if ($userid > 0) {
                 $this->id = $userid;
                 $this->name = $name;
             } else {
                 throw new Exception("Unable to validate that username/password combination.");
             }
         }
     }
 }
开发者ID:robertmoss,项目名称:foodfinder_main,代码行数:33,代码来源:user.php


示例20: 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



注:本文中的Utility类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Utils类代码示例发布时间:2022-05-23
下一篇:
PHP Utilities类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap