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


PHP Browser::getIPAddress方法代码示例

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


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

示例1: checkloginAction

 function checkloginAction()
 {
     $this->_helper->layout->disableLayout();
     $this->_helper->viewRenderer->setNoRender(TRUE);
     $session = SessionWrapper::getInstance();
     $formvalues = $this->_getAllParams();
     // debugMessage($formvalues);
     # check that an email has been provided
     if (isEmptyString(trim($this->_getParam("email")))) {
         $session->setVar(ERROR_MESSAGE, $this->_translate->translate("profile_email_error"));
         $session->setVar(FORM_VALUES, $this->_getAllParams());
         // return to the home page
         $this->_helper->redirector->gotoUrl(decode($this->_getParam(URL_FAILURE)));
     }
     if (isEmptyString(trim($this->_getParam("password")))) {
         $session->setVar(ERROR_MESSAGE, $this->_translate->translate("profile_password_error"));
         $session->setVar(FORM_VALUES, $this->_getAllParams());
         // return to the home page
         $this->_helper->redirector->gotoUrl(decode($this->_getParam(URL_FAILURE)));
     }
     # check which field user is using to login. default is username
     $credcolumn = "username";
     $login = (string) trim($this->_getParam("email"));
     // $password = encode(sha1(trim($this->_getParam("password"))));
     # check if credcolumn is emai
     $validator = new Zend_Validate_EmailAddress();
     if ($validator->isValid($login)) {
         $usertable = new UserAccount();
         if ($usertable->findByEmail($login)) {
             $credcolumn = 'email';
         }
     }
     if (stringContains('!@#', $login)) {
         $credcolumn = 'trx';
         $loginarray = explode('.', $login);
         // debugMessage($loginarray);
         $id = $loginarray[0];
     }
     // debugMessage($credcolumn); exit;
     $browser = new Browser();
     $audit_values = $browser_session = array("browserdetails" => $browser->getBrowserDetailsForAudit(), "browser" => $browser->getBrowser(), "version" => $browser->getVersion(), "useragent" => $browser->getUserAgent(), "os" => $browser->getPlatform(), "ismobile" => $browser->isMobile() ? '1' : 0, "ipaddress" => $browser->getIPAddress());
     // debugMessage($audit_values);
     if ($credcolumn == 'email' || $credcolumn == 'username') {
         $authAdapter = new Zend_Auth_Adapter_DbTable(Zend_Registry::get("dbAdapter"));
         // define the table, fields and additional rules to use for authentication
         $authAdapter->setTableName('useraccount');
         $authAdapter->setIdentityColumn($credcolumn);
         $authAdapter->setCredentialColumn('password');
         $authAdapter->setCredentialTreatment("sha1(?) AND status = '1' ");
         // set the credentials from the login form
         $authAdapter->setIdentity($login);
         $authAdapter->setCredential($this->_getParam("password"));
         // new class to audit the type of Browser and OS that the visitor is using
         if (!$authAdapter->authenticate()->isValid()) {
             // debugMessage('invalid'); exit;
             // add failed login to audit trail
             $audit_values['module'] = 1;
             $audit_values['usecase'] = '1.1';
             $audit_values['transactiontype'] = USER_LOGIN;
             $audit_values['status'] = "N";
             $audit_values['transactiondetails'] = "Login for user with id '" . $this->_getParam("email") . "' failed. Invalid username or password";
             // exit();
             $this->notify(new sfEvent($this, USER_LOGIN, $audit_values));
             // return to the home page
             if (!isArrayKeyAnEmptyString(URL_FAILURE, $formvalues)) {
                 $session->setVar(ERROR_MESSAGE, "Invalid Email or Username or Password. <br />Please Try Again.");
                 $this->_helper->redirector->gotoUrl(decode($this->_getParam(URL_FAILURE)));
             } else {
                 $session->setVar(ERROR_MESSAGE, "Invalid Email or Username or Password. <br />Please Try Again.");
                 $this->_helper->redirector->gotoSimple('login', "user");
             }
             return false;
         }
         // user is logged in sucessfully so add information to the session
         $user = $authAdapter->getResultRowObject();
         $useraccount = new UserAccount();
         $useraccount->populate($user->id);
     }
     // exit;
     # trx login
     if ($credcolumn == 'trx') {
         $useraccount = new UserAccount();
         $useraccount->populate($id);
         // debugMessage($result); exit();
         if (isEmptyString($useraccount->getID())) {
             // return to the home page
             if (!isArrayKeyAnEmptyString(URL_FAILURE, $formvalues)) {
                 $session->setVar(ERROR_MESSAGE, "Invalid Email or Username or Password. <br />Please Try Again.");
                 $this->_helper->redirector->gotoUrl(decode($this->_getParam(URL_FAILURE)));
             } else {
                 $session->setVar(ERROR_MESSAGE, "Invalid Email or Username or Password. <br />Please Try Again.");
                 $this->_helper->redirector->gotoSimple('login', "user");
             }
             return false;
         }
     }
     // debugMessage($useraccount->toArray()); exit();
     $session->setVar("userid", $useraccount->getID());
     $session->setVar("username", $useraccount->getUserName());
     $session->setVar("type", $useraccount->getType());
//.........这里部分代码省略.........
开发者ID:7thZoneTechnology,项目名称:hrms-1,代码行数:101,代码来源:UserController.php

示例2: processattendanceAction

 function processattendanceAction()
 {
     $this->_helper->layout->disableLayout();
     $this->_helper->viewRenderer->setNoRender(TRUE);
     $session = SessionWrapper::getInstance();
     $config = Zend_Registry::get("config");
     $this->_translate = Zend_Registry::get("translate");
     $validshift = false;
     $formvalues = $this->_getAllParams();
     /* $formvalues = array(
       	 "id" => "",
       			"successmessage" => "Check-In Successfull",
       			"datein" => "Apr 24, 2015",
       			"timein" => "8:40 PM",
       			"inremarks" => "",
       			"status" => "",
       			"userid" => "93"
       	); */
     // debugMessage($formvalues);  //  exit;
     $id = decode($formvalues['id']);
     $formvalues['id'] = $id;
     $timesheet = new Timesheet();
     $user = new UserAccount();
     $user->populate($formvalues['userid']);
     # no shift available at all on profile
     // validate that user is checking into right shift
     if (isEmptyString($id)) {
         $checkindate = date('Y-m-d', strtotime($formvalues['datein']));
         $checkintime = date('H:i:s', strtotime($formvalues['timein']));
         $checkinfulldate = $checkindate . ' ' . $checkintime;
         debugMessage('checkin: ' . $checkinfulldate);
         // if user is already checkin, throw exception
         if (isCheckedIn($formvalues['userid'], $checkindate)) {
             $message = "Check-In failed. Active session already exists";
             $session->setVar(ERROR_MESSAGE, $message);
             exit;
         }
         $hasshift = false;
         $scheduleentry = getSessionEntry($user->getID());
         // debugMessage($scheduleentry);
         if (!isEmptyString($scheduleentry['id']) && !isEmptyString($user->getShift()) && $scheduleentry['status'] == 1) {
             $hasshift = true;
         }
         if ($hasshift) {
             $shift = new ShiftSchedule();
             $shift->populate($scheduleentry['id']);
             // debugMessage($shift->toArray());
             $validstartdate = $checkindate;
             $validstarttime = !isEmptyString($shift->getStartTime()) ? $shift->getStartTime() : $shift->getSession()->getStartTime();
             $validfullstartdate = $validstartdate . ' ' . $validstarttime;
             debugMessage('startin: ' . $validfullstartdate);
             # compute end date and time
             $endtime = !isEmptyString($shift->getEndTime()) ? $shift->getEndTime() : $shift->getSession()->getEndTime();
             $endday = $checkindate;
             $starthr = date('H', strtotime($validstarttime));
             //debugMessage($starthr);
             $endhr = date('H', strtotime($endtime));
             //debugMessage($endhr);
             if ($endhr < $starthr) {
                 $nxtday = date('Y-m-d', strtotime($checkindate . " + 1 day"));
                 $endday = $nxtday;
             }
             $validenddate = $endday;
             $validendtime = $endtime;
             $validfullenddate = $validenddate . ' ' . $validendtime;
             debugMessage('ending: ' . $validfullenddate);
             // validate start and end dates for each session
             $rangevalid = false;
             if (strtotime($checkinfulldate) >= strtotime($shift->getStartDate() . ' 00:00:00')) {
                 $rangevalid = true;
                 if (!isEmptyString($shift->getEndDate())) {
                     $rangevalid = false;
                     if (strtotime($checkinfulldate) <= strtotime($shift->getEndDate() . ' 23:00:00')) {
                         $rangevalid = true;
                     }
                 }
             }
             // also check if the days of the week are in the valid range
             if ($rangevalid) {
                 $todaywkno = date('w', strtotime($checkinfulldate));
                 // debugMessage($todaywkno);
                 $wkdaysprofiled = $user->getDaysOfWeekArray();
                 // debugMessage($wkdaysprofiled);
                 if (!isEmptyString($scheduleentry['workingdays'])) {
                     $wkdaysprofiled = explode(',', preg_replace('!\\s+!', '', trim($scheduleentry['workingdays'])));
                     // debugMessage($wkdaysprofiled);
                 }
                 if (count($wkdaysprofiled) > 0) {
                     if (!in_array($todaywkno, $wkdaysprofiled)) {
                         $rangevalid = false;
                     }
                 }
             }
             // now validate the time within the session
             if ($rangevalid) {
                 if (strtotime($checkinfulldate) >= strtotime($validfullstartdate) && strtotime($checkinfulldate) < strtotime($validfullenddate)) {
                     $validshift = true;
                     $browser = new Browser();
                     $audit_values = $browser_session = array("browserdetails" => $browser->getBrowserDetailsForAudit(), "browser" => $browser->getBrowser(), "version" => $browser->getVersion(), "useragent" => $browser->getUserAgent(), "os" => $browser->getPlatform(), "ismobile" => $browser->isMobile() ? '1' : 0, "ipaddress" => $browser->getIPAddress());
                     $formvalues['sessionid'] = $scheduleentry['sessionid'];
//.........这里部分代码省略.........
开发者ID:7thZoneTechnology,项目名称:hrms-1,代码行数:101,代码来源:TimesheetsController.php


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