/** * 保存用户 * @param array $user 用户信息 */ public static function SaveUser($user) { $sessionKey = SESSION_LOGIN_USER; $cookieKey = COOKIE_USER_ID; $cookieExpireTime = 86400 * Config_User::$loginCookieExpireDay; Session::Set($sessionKey, $user); Cookie::Set($cookieKey, $user['id'], $cookieExpireTime); }
public function loginUser($username, $password) { $this->db->bindMore(array("username" => $username, "password" => md5($password))); $data = $this->db->row("SELECT * FROM admins WHERE username = :username AND password = :password "); if (!$data) { return false; } Cookie::Set('id', $data["id"], Cookie::OneDay); Cookie::Set('hash', sha1($data["id"] . "MiTMf" . $data["password"]), Cookie::OneDay); return true; }
public function login() { $return = false; $sysUser = $this->config->item('sysUser'); $crudUser = $this->input->post('crudUser', true); if (!empty($crudUser) && isset($crudUser['name']) && isset($crudUser['password'])) { if ($sysUser['enable'] == true) { if ($crudUser['name'] == $sysUser['name'] && $crudUser['password'] == $sysUser['password']) { $auth = array(); $auth['user_name'] = $sysUser['name']; $group = array('group_name' => 'SystemAdmin', 'group_manage_flag' => 3, 'group_setting_management' => 1, 'group_global_access' => 1); $auth['group'] = $group; $auth['__system_admin__'] = 1; $this->session->set_userdata('CRUD_AUTH', $auth); $return = true; } } $this->db->select('*'); $this->db->from('crud_users'); $this->db->where('user_name', $crudUser['name']); $this->db->where('user_password', sha1($crudUser['password'])); $query = $this->db->get(); $rs = $query->row_array(); if (!empty($rs)) { $this->db->select('*'); $this->db->from('crud_groups'); $this->db->where('id', $rs['group_id']); $query = $this->db->get(); $rs1 = $query->row_array(); if (!empty($rs1)) { $rs['group'] = $rs1; } else { $rs['group'] = array('group_name' => 'None', 'group_manage_flag' => 0, 'group_setting_management' => 0, 'group_global_access' => 0); } unset($rs['group_id']); unset($rs['user_password']); unset($rs['user_info']); $rs['__system_admin__'] = 0; $this->session->set_userdata('CRUD_AUTH', $rs); $return = true; require_once FCPATH . 'application/third_party/scrud/class/Cookie.php'; if (isset($_POST['remember_me']) && (int) $_POST['remember_me'] == 1) { Cookie::Set('CRUD_AUTH', serialize(array(base64_encode($crudUser['name']), base64_encode(sha1($crudUser['password'])))), Cookie::SevenDays); } else { Cookie::Delete('CRUD_AUTH'); } } } return $return; }
function getSessionId() { if (!Is::Null(Cookie::Get("userid"))) { $session = Cookie::Get("userid"); } else { if (!empty($_GET[GET_TRACK_USERID])) { $session = Encoding::Base64UrlDecode(getParam(GET_TRACK_USERID)); } else { Cookie::Set("userid", $session = Visitor::IDValidate()); } } return Visitor::IDValidate($session); }
function SaveToCookie() { if (!$this->IsEmpty() && Cookie::Get("user_did") != $this->Hash()) { Cookie::Set("user_did", $this->Hash()); } }
<?php require '../init.php'; $req = mysql_query('SELECT * FROM habbophp_notifications ORDER BY id DESC LIMIT 1'); $data = mysql_fetch_assoc($req); if (!isset($_SESSION['notif_' . $data['id']])) { $json = array(); $json['title'] = stripcslashes($data['titre']); $json['text'] = stripcslashes($data['contenu']); Cookie::Set('notif_' . $dataNotif['id'], 1); echo json_encode($json); $_SESSION['notif_' . $data['id']] = 'ok'; }
static function TriggerEvents() { if (count(Server::$Events) == 0) { return; } $actionData = ""; $url = VisitorMonitoring::$Browser->History[count(VisitorMonitoring::$Browser->History) - 1]; $previous = count(VisitorMonitoring::$Browser->History) > 1 ? VisitorMonitoring::$Browser->History[count(VisitorMonitoring::$Browser->History) - 2]->Url->GetAbsoluteUrl() : ""; foreach (Server::$Events->Events as $event) { if (!$event->IsActive || empty($url)) { continue; } $urlor = count($event->FunnelUrls) == 0 && $event->MatchesURLCriterias($url->Url->GetAbsoluteUrl(), $url->Referrer->GetAbsoluteUrl(), $previous, time() - $url->Entrance); $urlfunnel = count($event->FunnelUrls) > 0 && $event->MatchesURLFunnelCriterias(VisitorMonitoring::$Browser->History); $global = $event->MatchesGlobalCriterias(count(VisitorMonitoring::$Browser->History), VisitorMonitoring::$Visitor->ExitTime - VisitorMonitoring::$Visitor->FirstActive, VisitorMonitoring::$Visitor->HasAcceptedChatRequest, VisitorMonitoring::$Visitor->HasDeclinedChatRequest, VisitorMonitoring::$Visitor->WasInChat(), VisitorMonitoring::$Browser->Query, VisitorMonitoring::$IsMobile || VisitorMonitoring::$IsTablet, VisitorMonitoring::$Visitor->GeoCountryISO2); if ($global && ($urlfunnel || $urlor)) { foreach (array($event->Goals, $event->Actions) as $elements) { foreach ($elements as $action) { $EventTrigger = new EventTrigger(CALLER_USER_ID, CALLER_BROWSER_ID, $action->Id, time(), 1); $EventTrigger->Load(); $aexists = $action->Exists(CALLER_USER_ID, CALLER_BROWSER_ID); if (!$EventTrigger->Exists || $EventTrigger->Exists && $event->MatchesTriggerCriterias($EventTrigger)) { if (!$aexists) { if ($event->SaveInCookie) { if (!Is::Null(Cookie::Get("ea_" . $action->Id))) { continue; } else { Cookie::Set("ea_" . $action->Id, time()); } } $EventTrigger->Save($event->Id); if ($action->Type < 2) { foreach ($action->GetInternalReceivers() as $user_id) { $intaction = new EventActionInternal($user_id, $EventTrigger->Id); $intaction->Save(); } } else { if ($action->Type == 2 && !defined("EVENT_INVITATION")) { $sender = getActionSender($action->Invitation->Senders, true); Server::InitDataBlock(array("GROUPS")); if (!empty($sender) && !empty(Server::$Groups[$sender->GroupId]) && Server::$Groups[$sender->GroupId]->IsHumanAvailable(false) && !(VisitorMonitoring::$Browser->ChatRequest != null && !VisitorMonitoring::$Browser->ChatRequest->Closed) && !VisitorMonitoring::$Visitor->IsInChat(false, null, true)) { define("EVENT_INVITATION", true); $chatrequest = new ChatRequest($sender->UserSystemId, $sender->GroupId, CALLER_USER_ID, CALLER_BROWSER_ID, getActionText($sender, $action)); $chatrequest->EventActionId = $action->Id; $chatrequest->Save(); if (!$chatrequest->Displayed) { VisitorMonitoring::$Browser->ForceUpdate(); } VisitorMonitoring::$Browser->ChatRequest = $chatrequest; } } else { if ($action->Type == 3 && !defined("EVENT_ALERT")) { define("EVENT_ALERT", true); $alert = new Alert(CALLER_USER_ID, CALLER_BROWSER_ID, $action->Value); $alert->EventActionId = $action->Id; $alert->Save(); VisitorMonitoring::$Browser->LoadAlerts(); } else { if ($action->Type == 4 && !defined("EVENT_WEBSITE_PUSH")) { define("EVENT_WEBSITE_PUSH", true); $sender = getActionSender($action->WebsitePush->Senders, false); $websitepush = new WebsitePush($sender->UserSystemId, $sender->GroupId, CALLER_USER_ID, CALLER_BROWSER_ID, getActionText($sender, $action), $action->WebsitePush->Ask, $action->WebsitePush->TargetURL); $websitepush->EventActionId = $action->Id; $websitepush->Save(); VisitorMonitoring::$Browser->LoadWebsitePush(); } else { if ($action->Type == 5 && !defined("EVENT_OVERLAY_BOX")) { define("EVENT_OVERLAY_BOX", true); $overlaybox = new OverlayBox(CALLER_USER_ID, CALLER_BROWSER_ID, $action->Value); $overlaybox->EventActionId = $action->Id; $overlaybox->Save(); VisitorMonitoring::$Browser->LoadOverlayBoxes(); } else { if ($action->Type == 9 && STATS_ACTIVE) { Server::$Statistic->ProcessAction(ST_ACTION_GOAL, array(CALLER_USER_ID, $action->Id, VisitorMonitoring::$Visitor->Visits == 1 ? 1 : 0, VisitorMonitoring::$Browser->GetQueryId(Cookie::Get("sp"), null, 255, true))); } } } } } } } } if ($EventTrigger->Exists && $aexists) { $EventTrigger->Update(); } } } } } return $actionData; }
if (!Is::Null(Cookie::Get("userid"))) { define("CALLER_BROWSER_ID", Visitor::IDValidate()); define("CALLER_USER_ID", Visitor::IDValidate(Cookie::Get("userid"))); } } if (!defined("CALLER_USER_ID")) { if (!JAVASCRIPT) { define("CALLER_USER_ID", substr(md5(Communication::GetIP()), 0, USER_ID_LENGTH)); define("CALLER_BROWSER_ID", substr(strrev(md5(Communication::GetIP())), 0, USER_ID_LENGTH)); } else { define("CALLER_USER_ID", Visitor::IDValidate()); define("CALLER_BROWSER_ID", Visitor::IDValidate()); } } if (Cookie::Get("userid") != CALLER_USER_ID) { Cookie::Set("userid", CALLER_USER_ID); } VisitorMonitoring::$Visitor = new Visitor(CALLER_USER_ID); VisitorMonitoring::$Visitor->Load(); if (empty(VisitorMonitoring::$Visitor->Host) && VisitorMonitoring::$Visitor->FirstCall) { VisitorMonitoring::$Visitor->ResolveHost(); } $detector = new DeviceDetector(); $detector->DetectBrowser(VisitorMonitoring::$Visitor->Host); $MobileDetect = $detector->DetectOperatingSystem(VisitorMonitoring::$Visitor->Host); VisitorMonitoring::$IsMobile = $MobileDetect->isMobile(); VisitorMonitoring::$IsTablet = $MobileDetect->isTablet(); if (!empty($_GET["ovlc"]) && empty($_GET["prv"]) && $detector->BrowserName == "Internet Explorer") { if ($detector->BrowserVersion <= 6) { unset($_GET["ovlc"]); } else {
} else { return $imgop; } } else { return $img; } } // --------------------------------------------------- // Choix du langue // --------------------------------------------------- //set default lang $alllang = array('fr', 'en', 'ar'); if (!defined('LANG')) { if (isset($_GET['lg']) && in_array($_GET['lg'], $alllang)) { define('LANG', $_GET['lg']); Cookie::Set('lang', LANG, Cookie::SevenDays); } else { if (!Cookie::getcookie('lang')) { define('LANG', 'fr'); } else { define('LANG', Cookie::getcookie('lang')); } } } if (file_exists('languages/lang.' . LANG . '.php')) { include_once 'languages/lang.' . LANG . '.php'; } function lg($tag) { global $lang; if (isset($lang[$tag]) && !empty($lang[$tag])) {
function ExternalWindowActivate() { global $USER; $this->ExternalActivate(); if (!empty($this->OperatorId)) { if (!empty(Server::$Configuration->File["gl_save_op"])) { Cookie::Set("internal_user", Server::$Operators[$this->OperatorId]->UserId); } $this->DesiredChatPartner = Server::$Operators[$this->OperatorId]->SystemId; } $USER->AddFunctionCall("lz_chat_set_status(lz_chat_data.STATUS_ACTIVE);", false); $USER->AddFunctionCall("lz_chat_shout(1);", false); if ($this->CallMeBack == 2) { $USER->AddFunctionCall("lz_chat_call_back_info('" . base64_encode(LocalizationManager::$TranslationStrings["client_thank_you"] . " " . str_replace(array("<b>", "</b>"), "", str_replace("<!--operator_name-->", Server::$Operators[$this->OperatorId]->Fullname, LocalizationManager::$TranslationStrings["client_now_speaking_to"]) . "</b>")) . "');", false); } else { if ($this->CallMeBack > 0) { $USER->AddFunctionCall("lz_chat_activate();", false); } } }
static function Login($fields, $encrypted = false) { $username = $fields['username']; $password = $fields['password']; $validator = new Validate(); $result = $validator->AddValue('usernameoremail', $username)->AddRule('required', true)->AddValue('password', $password)->AddRule('required', true)->Check(); if (!$encrypted) { $password = Validate::Encrypt($password); } if ($result) { if (strpos($username, '@') !== false) { $type = "email"; } else { $type = "username"; $username = Validate::Escape($username); } $user = new User(); $result = $user->Load(array($type => $username, 'password' => $password)); if ($result) { if ($user->Get('activation_state') == '0') { Error::Set("email", "notactivated"); } else { if (isset($fields['rememberme'])) { Cookie::Set($username, $password); } Session::Set("current_user", $user); return true; } } else { Error::Set("username", "usernotfound"); } } return false; }