当前位置: 首页>>代码示例>>PHP>>正文


PHP func::getRemoteAddress方法代码示例

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


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

示例1: ajax

 function ajax()
 {
     switch (func::GET('act')) {
         case 'item-u-update':
             $this->input->postm(array('id' => TYPE_UINT, 'uid' => TYPE_UINT, 'p' => TYPE_STR), $p);
             $nUserID = $this->security->getUserID();
             $nItemID = $p['id'];
             if (!$nItemID || empty($p['p']) || !$nUserID) {
                 $this->ajaxResponse(Errors::ACCESSDENIED);
             }
             $aItem = $this->db->one_array('SELECT id, cat1_id FROM ' . TABLE_BBS_ITEMS . ' 
                 WHERE id = ' . $nItemID . ' AND status = ' . BBS_STATUS_NEW . ' 
                     AND pass = ' . $this->security->encodeBBSEditPass($p['p']));
             if (!empty($aItem)) {
                 $this->db->execute('UPDATE ' . TABLE_BBS_ITEMS . ' SET user_id = ' . $nUserID . ' WHERE id = ' . $nItemID);
                 // закрепляем за пользователем
                 $this->db->execute('UPDATE ' . TABLE_USERS . ' SET items = items+1 WHERE user_id = ' . $nUserID);
                 // обновляем счетчик объявлений пользователя
             }
             $sUID = $this->security->getUID(false, 'post');
             $bPayPublication = !$this->checkFreePublicationsLimit($aItem['cat1_id'], $nUserID, $sUID);
             $this->ajaxResponse(array('res' => !empty($aItem), 'pp' => $bPayPublication));
             break;
         case 'item-edit-pass':
             $p = $this->input->postm(array('id' => TYPE_UINT, 'pass' => TYPE_STR));
             $aResponse = array();
             do {
                 if (!$p['id']) {
                     $this->errors->set(Errors::IMPOSSIBLE);
                     break;
                 }
                 if (empty($p['pass'])) {
                     $this->errors->set('editpass_empty');
                     break;
                 }
                 if ($this->isEditPassGranted($p['id'])) {
                     $aResponse['result'] = true;
                     break;
                 }
                 $aData = $this->db->one_array('SELECT id, user_id FROM ' . TABLE_BBS_ITEMS . ' 
                           WHERE id = ' . $p['id'] . ' AND pass = ' . $this->security->encodeBBSEditPass($p['pass']));
                 if (empty($aData)) {
                     $this->errors->set(Errors::ACCESSDENIED);
                     break;
                 } else {
                     if ($aData['user_id'] > 0) {
                         $userID = $this->security->getUserID();
                         if ($userID > 0) {
                             if ($aData['user_id'] != $userID) {
                                 $this->errors->set('editpass_not_owner');
                             } else {
                                 $aResponse['result'] = true;
                                 break;
                             }
                         } else {
                             $this->errors->set('editpass_auth');
                         }
                     } else {
                         $this->grantEditPass($p['id']);
                         $aResponse['result'] = true;
                     }
                 }
             } while (false);
             $aResponse['errno'] = $this->errors->no();
             $this->ajaxResponse($aResponse);
             break;
         case 'item-claim':
             $p = $this->input->postm(array('id' => TYPE_UINT, 'reasons' => TYPE_ARRAY_UINT, 'comment' => TYPE_STR, 'captcha' => TYPE_STR));
             $p['comment'] = func::cleanComment($p['comment']);
             $aResponse = array();
             do {
                 if (!$p['id']) {
                     $this->errors->set(Errors::IMPOSSIBLE);
                     break;
                 }
                 if (empty($p['reasons']) && $p['comment'] == '') {
                     $this->errors->set('enter_claim_reason');
                     break;
                 }
                 $nUserID = $this->security->getUserID();
                 if (!$nUserID) {
                     $oProtection = new CCaptchaProtection();
                     if (!$oProtection->valid(isset($_SESSION['c2']) ? $_SESSION['c2'] : '', $p['captcha'])) {
                         $aResponse['captcha_wrong'] = 1;
                         $this->errors->set('claim_wrong_captcha');
                         break;
                     }
                 }
                 unset($_SESSION['c2']);
                 $nReasons = array_sum($p['reasons']);
                 $res = $this->db->execute('INSERT INTO ' . TABLE_BBS_ITEMS_CLAIMS . ' (item_id, user_id, comment, reasons, ip, created)
                     VALUES(' . $p['id'] . ', ' . $nUserID . ', ' . $this->db->str2sql($p['comment']) . ', ' . $nReasons . ', :ip, ' . $this->db->getNOW() . ')
                 ', array(':ip' => func::getRemoteAddress()));
                 if ($res) {
                     config::saveCount('bbs_items_claims', 1);
                     bff::sendMailTemplate(array('user' => !$nUserID ? 'Аноним' : $this->security->getUserEmail(), 'claim' => $this->getItemClaimText($nReasons, nl2br($p['comment'])), 'item_url' => SITEURL . '/item/' . $p['id']), 'admin_bbs_claim', config::get('mail_admin', BFF_EMAIL_SUPPORT));
                 }
             } while (false);
             $aResponse['result'] = $this->errors->no();
             $this->ajaxResponse($aResponse);
//.........这里部分代码省略.........
开发者ID:Sywooch,项目名称:dobox,代码行数:101,代码来源:bbs.class.php

示例2: ajax

 function ajax()
 {
     if (bff::$isAjax) {
         switch (func::GETPOST('act')) {
             case 'subscribe':
                 /*
                  * При подписке:
                  * - email выступает в дальнейшем в качестве логина
                  * - пароль генерируется автоматически
                  */
                 $sName = $this->input->post('name', TYPE_NOHTML);
                 $sEmail = mb_strtolower($this->input->post('email', TYPE_NOHTML));
                 $response = '';
                 do {
                     if (empty($sEmail) || !func::IsEmailAddress($sEmail)) {
                         $response = 0;
                         break;
                         // некорректно указан email
                     }
                     $isSubscribed = $this->db->one_data('SELECT user_id FROM ' . TABLE_USERS . ' WHERE login=' . $this->db->str2sql($sEmail));
                     if ($isSubscribed) {
                         $response = 2;
                         break;
                         // данный email уже подписан
                     }
                     $sPassword = func::generator();
                     //'email' - для рассылки, 'login' - для авторизации
                     $nUserID = $this->userCreate(array('login' => $sEmail, 'email' => $sEmail, 'password' => $sPassword, 'name' => $sName, 'subscribed' => 1, 'ip_reg' => func::getRemoteAddress(true)), self::GROUPID_MEMBER);
                     if ($nUserID) {
                         $response = 1;
                         // успешно подписались
                         # высылаем письмо (ставим в очередь на рассылку)
                         CMail::SendQueue('subscribe', array('user_id' => $nUserID));
                     } else {
                         $response = 4;
                         // системная ошибка
                     }
                 } while (false);
                 $this->ajaxResponse(array('result' => $response));
                 break;
             case 'enter':
                 if ($this->security->isLogined()) {
                     $this->ajaxResponse(array('result' => 'login-ok'));
                 }
                 $aData = $this->input->postm(array('email' => TYPE_STR, 'pass' => TYPE_STR, 'reg' => TYPE_BOOL));
                 if (!func::IsEmailAddress($aData['email'])) {
                     $this->errors->set('wrong:email');
                     break;
                     //email не корректный
                 }
                 if ($this->security->checkBan(false, func::getRemoteAddress(), $aData['email'], true)) {
                     $this->errors->set(Errors::ACCESSDENIED);
                     break;
                     //не прошли бан-фильтр
                 }
                 if ($aData['reg']) {
                     //регистрация
                     if (empty($aData['pass']) || strlen($aData['pass']) < 3) {
                         $this->errors->set('password_short');
                         break;
                         //пароль слишком короткий
                     }
                     $aData['email_hash'] = func::getEmailHash($aData['email']);
                     if ($this->isEmailExists($aData['email_hash'])) {
                         $this->errors->set('email_exist');
                         break;
                         //email уже занят
                     }
                     $this->getActivationInfo($sCode, $sLink);
                     $nUserID = $this->userCreate(array('login' => $aData['email'], 'email' => $aData['email'], 'email_hash' => $aData['email_hash'], 'password' => $aData['pass'], 'ip_reg' => Func::getRemoteAddress(true), 'activatekey' => $sCode, 'activated' => 0), self::GROUPID_MEMBER);
                     if ($nUserID) {
                         //$this->userAUTH($aData['email'], $aData['pass'], null, true);
                         $res = bff::sendMailTemplate(array('password' => $aData['pass'], 'email' => $aData['email'], 'activate_link' => "<a href=\"{$sLink}\">{$sLink}</a>"), 'member_registration', $aData['email']);
                         $this->ajaxResponse(array('result' => 'reg-ok'));
                     } else {
                         $this->ajaxResponse(Errors::IMPOSSIBLE);
                     }
                 } else {
                     //авторизация
                     $nResult = $this->userAUTH($aData['email'], $aData['pass'], null, true);
                     if ($nResult == 1) {
                         //$this->security->setRememberMe('u', $aData['email'], $aData['pass']);
                         bff::i()->Bbs_getFavorites(true);
                         $bReload = false;
                         if (!empty($_SERVER['HTTP_REFERER'])) {
                             if (stripos($_SERVER['HTTP_REFERER'], '/item/') !== FALSE || stripos($_SERVER['HTTP_REFERER'], '/items/fav') !== FALSE) {
                                 $bReload = true;
                             }
                         }
                         $userMenu = $this->tplFetch('user.menu.tpl');
                         $this->ajaxResponse(array('result' => 'login-ok', 'usermenu' => $userMenu, 'reload' => $bReload));
                     } else {
                         $mResponse = null;
                         switch ($nResult) {
                             case 0:
                                 $this->errors->set('email_or_pass_incorrect');
                                 break;
                             case -3:
                                 $this->errors->set('activate_first');
                                 break;
//.........这里部分代码省略.........
开发者ID:Sywooch,项目名称:dobox,代码行数:101,代码来源:users.class.php

示例3: mod_add

 function mod_add()
 {
     if (!$this->haveAccessTo('users-edit')) {
         return $this->showAccessDenied();
     }
     $this->input->postm(array('login' => TYPE_STR, 'avatar' => TYPE_STR, 'name' => TYPE_STR, 'email' => TYPE_STR, 'password' => TYPE_STR, 'password2' => TYPE_STR, 'balance' => TYPE_NUM, 'skype' => TYPE_STR, 'email2' => TYPE_STR, 'phone' => TYPE_STR, 'group_id' => TYPE_ARRAY_INT, 'cat' => TYPE_ARRAY_UINT), $aData);
     $aData['admin'] = 0;
     if (bff::$isPost) {
         do {
             //                if($aData['city_id']<=0) {
             //                    $this->errors->set('wrong:city'); break;
             //                }
             $aData['email_hash'] = func::getEmailHash($aData['email']);
             if (!$aData['login']) {
                 $this->errors->set('empty:login');
                 break;
             }
             if (!$aData['email']) {
                 $this->errors->set('empty:email');
                 break;
             } elseif (!Func::IsEmailAddress($aData['email'])) {
                 $this->errors->set('wrong:email');
                 break;
             }
             if ($this->isLoginExists($aData['login'])) {
                 $this->errors->set('login_exist');
                 break;
             }
             if ($this->isEmailExists($aData['email_hash'])) {
                 $this->errors->set('email_exist');
                 break;
             }
             if (!$aData['password']) {
                 $this->errors->set('empty:password');
                 break;
             } elseif ($aData['password'] != $aData['password2']) {
                 $this->errors->set('password_confirmation');
                 break;
             }
             if ($this->errors->no()) {
                 $aGroupID = $aData['group_id'];
                 //array
                 $aData['member'] = 0;
                 $aData['ip_reg'] = func::getRemoteAddress(true);
                 $aData['activated'] = 1;
                 $aData['cat'] = join(',', $aData['cat']);
                 unset($aData['password2'], $aData['group_id']);
                 $nRecordID = $this->userInsert($aData);
                 if ($nRecordID > 0) {
                     $avatar = new CAvatar(TABLE_USERS, USERS_AVATAR_PATH, 'avatar', 'user_id');
                     $avatar->update($nRecordID, false, true);
                     if (empty($aGroupID)) {
                         $aGroupID = array(USERS_GROUPS_MEMBER);
                     } else {
                         $this->assignUser2Groups($nRecordID, $aGroupID);
                     }
                     # обновляем, является ли юзер администратором
                     $bIsAdmin = 0;
                     if (!(count($aGroupID) == 1 && current($aGroupID) == self::GROUPID_MEMBER)) {
                         if (in_array(self::GROUPID_SUPERADMIN, $aGroupID) || in_array(self::GROUPID_MODERATOR, $aGroupID)) {
                             $bIsAdmin = 1;
                         } else {
                             $aUserGroups = $this->getGroups(null, $aGroupID);
                             foreach ($aUserGroups as $v) {
                                 if ($v['adminpanel'] == 1) {
                                     $bIsAdmin = 1;
                                     break;
                                 }
                             }
                         }
                         if ($bIsAdmin) {
                             $this->db->execute('UPDATE ' . TABLE_USERS . ' SET admin=' . $bIsAdmin . ' WHERE user_id=' . $nRecordID);
                         }
                     }
                 }
                 $this->adminRedirect(Errors::SUCCESSFULL, (!$aData['member'] ? 'admin_' : '') . 'listing');
             }
         } while (false);
         $this->input->postm(array('password2' => TYPE_STR, 'group_id' => TYPE_ARRAY_INT), $aData);
         func::array_2_htmlspecialchars($aData, null, true);
         $aActiveGroupsID = $aData['group_id'];
     } else {
         $aActiveGroupsID = array();
     }
     $aData = array_merge($aData, array('password2' => '', 'user_id' => ''));
     //assign groups
     $exists_options = '';
     $active_options = '';
     $aGroups = $this->getGroups(array(USERS_GROUPS_MEMBER, USERS_GROUPS_SUPERADMIN));
     for ($i = 0; $i < count($aGroups); $i++) {
         if (in_array($aGroups[$i]['group_id'], $aActiveGroupsID)) {
             $active_options .= '<option value="' . $aGroups[$i]['group_id'] . '" style="color:' . $aGroups[$i]['color'] . ';">' . $aGroups[$i]['title'] . '</option>';
         } else {
             $exists_options .= '<option value="' . $aGroups[$i]['group_id'] . '" style="color:' . $aGroups[$i]['color'] . ';">' . $aGroups[$i]['title'] . '</option>';
         }
     }
     $this->tplAssign('exists_options', $exists_options);
     $this->tplAssign('active_options', $active_options);
     //$aData['city_options'] = bff::i()->Sites_geoCityOptions($aData['city_id'], 'edit');
     $aData['edit'] = false;
//.........这里部分代码省略.........
开发者ID:Sywooch,项目名称:dobox,代码行数:101,代码来源:users.adm.class.php

示例4: createBill_InGift

 /**
  * Создание счета, тип: подарок
  * @param integer $nUserID ID пользователя
  * @param float $fUserBalance текущий баланс пользователя
  * @param float $fAmount сумма счета
  * @param string $sDescription описание
  * @return integer ID счета
  */
 function createBill_InGift($nUserID, $fUserBalance, $fAmount, $sDescription = '')
 {
     $now = $this->db->getNOW();
     $this->db->execute('INSERT INTO ' . TABLE_BILLS . ' (user_id, user_balance, type, status, amount, description, created, payed, ip) 
         VALUES( ' . $nUserID . ', ' . $fUserBalance . ', ' . self::typeInGift . ', ' . self::statusCompleted . ', ' . $fAmount . ', 
                 :desc, ' . $now . ', ' . $now . ', :ip)', array(':desc' => $sDescription, ':ip' => func::getRemoteAddress()));
     $nBillID = $this->db->insert_id(TABLE_BILLS, 'id');
     if (empty($nBillID)) {
         $this->log('Неудалось создать счет: подарок');
         $nBillID = 0;
     }
     return $nBillID;
 }
开发者ID:Sywooch,项目名称:dobox,代码行数:21,代码来源:bills.bl.class.php


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