/** * Authenticate the user * * @return Response */ public function store() { try { $userAgent = array("platform" => Useragent::platform(), "browser" => Useragent::browser(), "version" => Useragent::version(), "mobile" => Useragent::mobile(), "robot" => Useragent::robot(), "agent" => Useragent::agent_string(), "accept_lang" => Useragent::accept_lang(), "accept_charset" => Useragent::accept_charset(), "ip_address" => $_SERVER['REMOTE_ADDR']); if (Input::get('password')) { $authService = new SoapClient(Config::get('wsdl.auth')); $token = $authService->authenticateEmail(array("email" => Input::get('email'), "password" => Input::get('password'), "userAgent" => print_r($userAgent, true))); ini_set('soap.wsdl_cache_enabled', '0'); ini_set('user_agent', "PHP-SOAP/" . PHP_VERSION . "\r\n" . "AuthToken: " . $token->AuthToken); Session::put('user.token', $token); try { $userService = new SoapClient(Config::get('wsdl.user')); $result = $userService->getUserByEmail(array("email" => Input::get('email'))); $user = $result->user; if ($user->businessAccount == true) { if (isset($user->addresses) && is_object($user->addresses)) { $user->addresses = array($user->addresses); } } Session::put('user.data', $user); return array('success' => 'true'); } catch (InnerException $ex) { throw new Exception($ex->faultstring); } } } catch (Exception $ex) { return array('error' => $ex->getMessage()); } }
function deviceInfo() { $client = Client::get_instance(); // Referral $client->referrer = Useragent::referrer(); // Heavy detections will be cached in cookie $cookieStore = array('device', 'browser', 'browserVersion', 'os', 'country', 'city', 'lat', 'lon', 'timezone'); $device_info_cookie = Cookie::get('device_info'); if ($device_info_cookie && ($device_info_cookie = json_decode($device_info_cookie))) { foreach ($cookieStore as $key) { $client->{$key} = $device_info_cookie->{$key}; } } else { // Device and browser // Use Mobile_Detect for better device recognition $client->device = Useragent::is_mobile() ? 'phone' : 'computer'; $client->browser = Useragent::browser(); $client->browserVersion = Useragent::version(); $client->os = Useragent::platform(); // Geolocation // Defaults to Kyiv $gb = new IPGeoBase(); $geo = $gb->getRecord($client->ip); $client->country = empty($geo['cc']) ? 'UA' : $geo['cc']; $client->city = empty($geo['city']) ? 'Киев' : $geo['city']; $client->lat = empty($geo['lat']) ? 50.4501 : $geo['lat']; $client->lon = empty($geo['lon']) ? 30.5234 : $geo['lon']; $client->timezone = empty($geo['timezone']) ? Config::get('application.timezone', 'Europe/Kiev') : $geo['timezone']; $cookieStoreData = new \stdClass(); foreach ($cookieStore as $key) { $cookieStoreData->{$key} = $client->{$key}; } Cookie::make('device_info', json_encode($cookieStoreData), 60 * 60 * 4); } }
/** * Include any code in this function to add custom template variables. * * Called from within Geeklog for: * - 'header' (site header) * - 'footer' (site footer) * - 'storytext', 'featuredstorytext', 'archivestorytext' (story templates) * - 'story' (story submission) * - 'comment' (comment submission form) * - 'registration' (user registration form) * - 'contact' (email user form) * - 'emailstory' (email story to a friend) * - 'loginblock' (login form in the side bar) * - 'loginform' (login form in the content area) * - 'search' (advanced search form; simple search is usually part of 'header') * * This function is called whenever PLG_templateSetVars is called, i.e. in * addition to the templates listed here, it may also be called from plugins. * * @param string $templatename name of the template, e.g. 'header' * @param ref &$template reference to the template * @return void * @see PLG_templateSetVars * */ function CUSTOM_templateSetVars($templatename, &$template) { // define a {hello_world} variable available in header.thtml and // a {hello_again} variable available in the story templates global $_CONF, $_PLUGINS, $_USER, $LANG01, $LANG_JPN, $page, $topic; switch ($templatename) { case 'header': // User Agent: 'custom_class', 'custom_os', 'custom_browser', 'custom_version', 'custom_alias', 'custom_mobile' $ua = Useragent::getInstance(); $ua->setTemplateVars($template); $template->set_var('hello_world', 'Hello, world!'); // 話題ID:topic_id $template->set_var('topic_id', $topic); // 静的ページID:sp_id $pageurl = COM_getCurrentURL(); if (strpos($pageurl, "staticpages")) { $template->set_var('sp_id', $page); } // HOME状態:home_id ('home','sub') if (COM_isFrontpage()) { $home_id = 'sub'; } else { $home_id = 'home'; } $template->set_var('home_id', $home_id); // ログインしている時 if (COM_isAnonUser()) { $login_status = 'guest'; $prof_url_jp = "{$_CONF['site_url']}/"; } else { $login_status = 'member'; $prof_url_jp = "{$_CONF['site_url']}/users.php?mode=profile&uid={$_USER['uid']}"; } // ログイン状態:login_status ('member','guest') $template->set_var('login_status', $login_status); // プロフィールのURL:prof_url_jp $template->set_var('prof_url_jp', $prof_url_jp); break; case 'storytext': case 'featuredstorytext': case 'archivestorytext': $template->set_var('hello_again', 'Hello (again)!'); break; } // Sets the name of the current plugin as {plugin_name} $pluginFound = FALSE; if (isset($_PLUGINS) and count($_PLUGINS) > 0) { $pattern = '|^' . preg_quote($_CONF['site_url'], '|') . '/(?:admin/plugins/)?(.+?)/|'; if (preg_match($pattern, COM_getCurrentURL(), $match)) { foreach ($_PLUGINS as $plugin) { if (strcasecmp($plugin, $match[1]) === 0) { $template->set_var('plugin_name', $plugin); $pluginFound = TRUE; break; } } } } if ($pluginFound === FALSE) { $template->set_var('plugin_name', ''); } }