get() 공개 메소드

Accessor function for properties in the $_SESSION array
public get ( string $name = null ) : string | null
$name string The name of the property to retrieve (optional)
리턴 string | null The value of the property, or null if it does not exist. If no `$name` is provided, return the entire Cookie.
예제 #1
1
function Check_User_Cart()
{
    $Identifier = '';
    if (!Sentry::check()) {
        return false;
    } else {
        $Identifier = Sentry::user()->id;
        if (Cookie::has('Anon_Cart_Extension')) {
            $AnonIdentifier = Cookie::get('Anon_Cart_Extension');
            $dataAnon = Cache::get('user_cart.' . $AnonIdentifier);
            if (Cache::has('user_cart.' . $Identifier)) {
                $dataUser = Cache::get('user_cart.' . $Identifier);
                if ($dataAnon != null && $dataUser != null) {
                    foreach ($dataAnon as $key => $value) {
                        if (!isset($dataUser[$key])) {
                            $dataUser[$key] = $value;
                        }
                    }
                    Cache::forever('user_cart.' . $Identifier, $dataUser);
                    Cache::forget('user_cart.' . $AnonIdentifier);
                }
            } else {
                if ($dataAnon != null) {
                    Cache::forever('user_cart.' . $Identifier, $dataAnon);
                    Cache::forget('user_cart.' . $AnonIdentifier);
                }
            }
        }
    }
}
예제 #2
0
 public function testSetData()
 {
     $this->cookie->set('fairy', 'test');
     $this->cookie->set_cookie_data(array('fairy' => 'Blum'));
     $this->assertEquals(0, count($this->cookie->get_updates()));
     $this->assertEquals('Blum', $this->cookie->get('fairy', 'test'));
 }
예제 #3
0
파일: CookiePool.php 프로젝트: jivoo/http
 /**
  * Add a cookie to the pool.
  *
  * @param Cookie $cookie A cookie.
  */
 public function add(Cookie $cookie)
 {
     if ($cookie instanceof MutableCookie) {
         $this->cookies[$cookie->getName()] = $cookie;
     } elseif ($cookie instanceof ResponseCookie) {
         $this[$cookie->getName()]->set($cookie->get())->setPath($cookie->getPath())->setDomain($cookie->getDomain())->setSecure($cookie->isSecure())->setHttpOnly($cookie->isHttpOnly())->expiresAt($cookie->getExpiration());
     } else {
         $this->cookies[$cookie->getName()] = $this->setDefaults(new MutableCookie($cookie->getName(), $cookie->get()));
     }
 }
예제 #4
0
 /**
  * @runInSeparateProcess
  */
 public function testGet()
 {
     $cookie = new Cookie();
     $cookie->set('testGet');
     $result = $cookie->get('openimporter_cookie');
     $this->assertEquals('testGet', $result);
     $cookie->set('testGet', 'another_name');
     $result = $cookie->get('another_name');
     $this->assertEquals('testGet', $result);
     $result = $cookie->get('random');
     $this->assertFalse($result);
 }
 protected function __trigger()
 {
     $supported_language_codes = LanguageRedirect::instance()->getSupportedLanguageCodes();
     // only do something when there is a set of supported languages defined
     if (!empty($supported_language_codes)) {
         $current_language_code = LanguageRedirect::instance()->getLanguageCode();
         // no redirect, set current language and region in cookie
         if (isset($current_language_code) and in_array($current_language_code, $supported_language_codes)) {
             $Cookie = new Cookie(__SYM_COOKIE_PREFIX_ . 'language-redirect', TWO_WEEKS, __SYM_COOKIE_PATH__);
             $Cookie->set('language', LanguageRedirect::instance()->getLanguage());
             $Cookie->set('region', LanguageRedirect::instance()->getRegion());
         } else {
             $current_path = !isset($current_language_code) ? $this->_env['param']['current-path'] : substr($this->_env['param']['current-path'], strlen($current_language_code) + 1);
             $browser_languages = $this->getBrowserLanguages();
             foreach ($browser_languages as $language) {
                 if (in_array($language, $supported_language_codes)) {
                     $in_browser_languages = true;
                     $browser_language = $language;
                     break;
                 }
             }
             $Cookie = new Cookie(__SYM_COOKIE_PREFIX_ . 'language-redirect', TWO_WEEKS, __SYM_COOKIE_PATH__);
             $cookie_language_code = $Cookie->get('language');
             if (strlen($cookie_language_code) > 0) {
                 $language_code = $Cookie->get('region') ? $cookie_language_code . '-' . $Cookie->get('region') : $cookie_language_code;
             } elseif ($in_browser_languages) {
                 $language_code = $browser_language;
             } else {
                 $language_code = $supported_language_codes[0];
             }
             // redirect and exit
             header('Location: ' . $this->_env['param']['root'] . '/' . $language_code . '/' . $current_path);
             die;
         }
         $all_languages = LanguageRedirect::instance()->getAllLanguages();
         $result = new XMLElement('language-redirect');
         $current_language_xml = new XMLElement('current-language', $all_languages[$current_language_code] ? $all_languages[$current_language_code] : $current_language_code);
         $current_language_xml->setAttribute('handle', $current_language_code);
         $result->appendChild($current_language_xml);
         $supported_languages_xml = new XMLElement('supported-languages');
         foreach ($supported_language_codes as $language) {
             $language_code = new XMLElement('item', $all_languages[$language] ? $all_languages[$language] : $language);
             $language_code->setAttribute('handle', $language);
             $supported_languages_xml->appendChild($language_code);
         }
         $result->appendChild($supported_languages_xml);
         return $result;
     }
     return false;
 }
 public function index()
 {
     $language = Cookie::get('language');
     $this->assign('language', $language);
     $this->assign('browser_id', css_browser_id());
     $this->display();
 }
예제 #7
0
 private function autoLogin()
 {
     try {
         if (\Session::has('userID')) {
         } else {
             //try set session from cookies if no session
             if (!empty(\Cookie::get('userID'))) {
                 $field = array('field' => '_id', 'value' => (string) \Cookie::get('userID'));
                 if (Auth::isExists($field)) {
                     \Session::put('userID', \Cookie::get('userID'));
                     //
                     //return \Response::make()->withCookie(\Cookie::make('userID', \Cookie::get('userID') , self::COOKIE_EXPIRE));
                 } else {
                     throw new AuthCheckException('username', 'auth.username.doesnt.exist');
                 }
             } else {
                 //\Session::forget('userID')->withCookie(\Cookie::forget('userID'))->withCookie(\Cookie::forget('userID'));
                 throw new AuthCheckException('userid', 'auth.userid.doesnt.exist');
             }
         }
     } catch (Exception $e) {
         $return = \Response::json(["message" => "Session logout!"], 400);
         \Session::forget('userID');
         return $return->withCookie(Cookie::forget('userID'))->withCookie(Cookie::forget('userID'));
     }
 }
예제 #8
0
 /**
  * This function determines whether an there is a currently logged in
  * Author for Symphony by using the `$Cookie`'s username
  * and password. If an Author is found, they will be logged in, otherwise
  * the `$Cookie` will be destroyed.
  *
  * @see core.Cookie#expire()
  */
 public function isLoggedIn()
 {
     // Ensures that we're in the real world.. Also reduces three queries from database
     // We must return true otherwise exceptions are not shown
     if (is_null(self::$_instance)) {
         return true;
     }
     if ($this->Author) {
         return true;
     } else {
         $username = self::Database()->cleanValue($this->Cookie->get('username'));
         $password = self::Database()->cleanValue($this->Cookie->get('pass'));
         if (strlen(trim($username)) > 0 && strlen(trim($password)) > 0) {
             $author = AuthorManager::fetch('id', 'ASC', 1, null, sprintf("\n\t\t\t\t\t\t\t`username` = '%s'\n\t\t\t\t\t\t", $username));
             if (!empty($author) && Cryptography::compare($password, current($author)->get('password'), true)) {
                 $this->Author = current($author);
                 self::Database()->update(array('last_seen' => DateTimeObj::get('Y-m-d H:i:s')), 'tbl_authors', sprintf(" `id` = %d", $this->Author->get('id')));
                 // Only set custom author language in the backend
                 if (class_exists('Administration')) {
                     Lang::set($this->Author->get('language'));
                 }
                 return true;
             }
         }
         $this->Cookie->expire();
         return false;
     }
 }
 public function setUp()
 {
     parent::setUp();
     Translatable::disable_locale_filter();
     //Publish all english pages
     $pages = Page::get()->filter('Locale', 'en_US');
     foreach ($pages as $page) {
         $page->publish('Stage', 'Live');
     }
     //Rewrite the french translation groups and publish french pages
     $pagesFR = Page::get()->filter('Locale', 'fr_FR');
     foreach ($pagesFR as $index => $page) {
         $page->addTranslationGroup($pages->offsetGet($index)->ID, true);
         $page->publish('Stage', 'Live');
     }
     Translatable::enable_locale_filter();
     $this->origLocaleRoutingEnabled = Config::inst()->get('MultilingualRootURLController', 'UseLocaleURL');
     Config::inst()->update('MultilingualRootURLController', 'UseLocaleURL', false);
     $this->origDashLocaleEnabled = Config::inst()->get('MultilingualRootURLController', 'UseDashLocale');
     Config::inst()->update('MultilingualRootURLController', 'UseDashLocale', false);
     $this->origAcceptLanguage = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
     $_SERVER['HTTP_ACCEPT_LANGUAGE'] = 'en-US,en;q=0.5';
     $this->origCookieLocale = Cookie::get('language');
     Cookie::force_expiry('language');
     Cookie::set('language', 'en');
     $this->origCurrentLocale = Translatable::get_current_locale();
     Translatable::set_current_locale('en_US');
     $this->origLocale = Translatable::default_locale();
     Translatable::set_default_locale('en_US');
     $this->origi18nLocale = i18n::get_locale();
     i18n::set_locale('en_US');
     $this->origAllowedLocales = Translatable::get_allowed_locales();
     Translatable::set_allowed_locales(array('en_US', 'fr_FR'));
     MultilingualRootURLController::reset();
 }
예제 #10
0
 public function before()
 {
     if ($this->request->action === 'media') {
         // Do not template media files
         $this->auto_render = FALSE;
     } else {
         // Grab the necessary routes
         $this->media = Route::get('docs/media');
         $this->api = Route::get('docs/api');
         $this->guide = Route::get('docs/guide');
         if (isset($_GET['lang'])) {
             $lang = $_GET['lang'];
             // Load the accepted language list
             $translations = array_keys(Kohana::message('userguide', 'translations'));
             if (in_array($lang, $translations)) {
                 // Set the language cookie
                 Cookie::set('userguide_language', $lang, Date::YEAR);
             }
             // Reload the page
             $this->request->redirect($this->request->uri);
         }
         // Set the translation language
         I18n::$lang = Cookie::get('userguide_language', Kohana::config('userguide')->lang);
         // Use customized Markdown parser
         define('MARKDOWN_PARSER_CLASS', 'Kodoc_Markdown');
         // Load Markdown support
         require Kohana::find_file('vendor', 'markdown/markdown');
         // Set the base URL for links and images
         Kodoc_Markdown::$base_url = URL::site($this->guide->uri()) . '/';
         Kodoc_Markdown::$image_url = URL::site($this->media->uri()) . '/';
     }
     parent::before();
 }
예제 #11
0
 public function checklogin()
 {
     $userEmail = isset($_POST["email"]) ? $_POST["email"] : Cookie::get("email");
     $userPassword = isset($_POST["password"]) ? md5($_POST["password"]) : Cookie::get("password");
     //验证用户信息
     $userDao = D('User');
     $user = $userDao->find("email='{$userEmail}' and password='******'", 'id,name,email,sex');
     //验证成功
     if ($user) {
         //更新登录时间
         $userDao->setField('lastLoginTime', time(), "id=" . $user->id);
         //D('Login')->add("userId='$user->id'");
         //记录登陆状态
         Session::set('mid', $user->id);
         Session::set('userInfo', $user);
         Cookie::set('email', $userEmail, 36000000);
         //记住登录
         if ($_POST["autologin"] == 'on') {
             Cookie::set("password", $userPassword, 36000000);
         }
         unset($userEmail, $userPassword);
         //跳转到Home页
         $this->redirect('index', 'Home');
         //验证失败
     } else {
         //跳转到登陆页面
         $this->redirect("login");
     }
 }
예제 #12
0
	public function before()
	{
		parent::before();

		// The user is already logged in
		if (Auth::instance()->logged_in())
		{
			Request::instance()->redirect('');
		}

		// Load the configuration for this provider
		$config = Kohana::config('oauth.'.$this->provider);

		// Create a consumer from the config
		$this->consumer = OAuth_Consumer::factory($config);

		// Load the provider
		$this->provider = OAuth_Provider::factory($this->provider);

		if ($token = Cookie::get($this->cookie))
		{
			// Get the token from storage
			$this->token = unserialize($token);
		}
	}
예제 #13
0
 /**
  * @return UserSession|bool
  * @throws \Kohana_Exception
  */
 public static function Check()
 {
     $conf = \Kohana::$config->load('session')->get('native');
     $condition = (new \DBCriteria())->addColumnCondition(['ip' => \Request::$client_ip, 'iduser' => \Session::instance()->get('user_id', false), 'token' => self::getToken()])->addCondition('`expired`>=UNIX_TIMESTAMP(NOW())');
     /** @var $dbSession UserSession */
     $dbSession = UserSession::model()->find($condition);
     //if we not found row in BD
     if (is_null($dbSession)) {
         return false;
     }
     //If session key destroy in Cookie and Session(memcahed)
     if (!\Cookie::get('user_token', false) and !\Session::instance()->get('user_token', false)) {
         $dbSession->expired = time() + $conf['lifetime'];
         if ($dbSession->save()) {
             \Session::instance()->set('user_id', $dbSession->id);
             \Cookie::set('user_token', $dbSession['token'], time() + $conf['lifetime']);
             \Session::instance()->set('user_token', $dbSession['token']);
             return $dbSession;
             //return true;
         } else {
             \Kohana::$log->add(\Log::WARNING, 'Error to update session in [ID#' . $dbSession->owner->login . ']');
             return true;
         }
     } else {
         if (\Cookie::get('user_token', false) !== \Session::instance()->get('user_token', false)) {
             \Kohana::$log->add(\Log::WARNING, 'Session Key <> Cookie Key');
         }
         $expired = time() + $conf['lifetime'];
         $dbSession->expired = $expired;
         $dbSession->save(false);
         \Cookie::set('user_token', $dbSession->token, $expired);
         return $dbSession;
     }
 }
예제 #14
0
 public function getHome()
 {
     $result = @json_decode(file_get_contents(Config::get('app.server_url') . 'check?access_token=' . Cookie::get('access_token')));
     $url = Request::url();
     $state = md5(uniqid(rand(), TRUE));
     $error = Session::get('error');
     switch ($url) {
         case 'http://app1.dev':
             $redirect = Config::get('app.server_url') . 'oauth?client_id=1&redirect_uri=http://app1.dev/login/1&response_type=code&scope=user&state=' . $state;
             break;
         case 'http://app2.dev':
             $redirect = Config::get('app.server_url') . 'oauth?client_id=2&redirect_uri=http://app2.dev/login/2&response_type=code&scope=user&state=' . $state;
             break;
         case 'http://app3.dev':
             //No redirect start
             $redirect = null;
             break;
         default:
             $redirect = null;
             break;
     }
     //If button click denied no auto-redirect
     if ($error == 'access_denied') {
         $redirect = null;
     }
     if (isset($result->status) && $result->status == 1) {
         return View::make('client.home', array("url" => $url));
     } else {
         if ($redirect) {
             return Redirect::to($redirect);
         } else {
             return View::make('client.login', array("url" => $url, "state" => $state));
         }
     }
 }
예제 #15
0
파일: data.php 프로젝트: ZerGabriel/cms-1
 public function action_index()
 {
     Assets::package('jquery-ui');
     $cur_ds_id = (int) Arr::get($this->request->query(), 'ds_id', Cookie::get('ds_id'));
     $tree = Datasource_Data_Manager::get_tree();
     $cur_ds_id = Datasource_Data_Manager::exists($cur_ds_id) ? $cur_ds_id : Datasource_Data_Manager::$first_section;
     $ds = $this->section($cur_ds_id);
     $this->template->content = View::factory('datasource/content', array('content' => View::factory('datasource/data/index'), 'menu' => View::factory('datasource/data/menu', array('tree' => $tree, 'folders' => Datasource_Folder::get_all()))));
     $this->template->footer = NULL;
     $this->template->breadcrumbs = NULL;
     if ($ds instanceof Datasource_Section) {
         $this->set_title($ds->name);
         $limit = (int) Arr::get($this->request->query(), 'limit', Cookie::get('limit'));
         Cookie::set('ds_id', $cur_ds_id);
         $keyword = $this->request->query('keyword');
         if (!empty($limit)) {
             Cookie::set('limit', $limit);
             $this->section()->headline()->limit($limit);
         }
         $this->template->content->content->headline = $this->section()->headline()->render();
         $this->template->content->content->toolbar = View::factory('datasource/' . $ds->type() . '/toolbar', array('keyword' => $keyword));
         $this->template->set_global(array('datasource' => $ds));
         $this->template_js_params['DS_ID'] = $this->_section->id();
         $this->template_js_params['DS_TYPE'] = $this->_section->type();
     } else {
         $this->template->content->content = NULL;
     }
 }
 public function init()
 {
     $ageMonth = Cookie::get('bmonth');
     $ageDay = Cookie::get('bday');
     $ageYear = Cookie::get('byear');
     $age = Cookie::get('age');
     $allowed_urls = array('/age-gate/');
     if ($age == NULL) {
         if (!$this->isSearchEngine()) {
             if (!in_array($_SERVER['REQUEST_URI'], $allowed_urls)) {
                 Session::set('AgeGateBackURL', urlencode($_SERVER['REQUEST_URI']));
                 $this->redirect(Director::absoluteBaseURL() . "age-gate/");
             }
         }
     } else {
         if (!in_array($_SERVER['REQUEST_URI'], $allowed_urls)) {
             if ($ageMonth == NULL || $ageDay == NULL || $ageYear == NULL) {
                 if (!in_array($_SERVER['REQUEST_URI'], $allowed_urls)) {
                     Session::set('AgeGateBackURL', urlencode($_SERVER['REQUEST_URI']));
                 }
                 $this->redirect(Director::absoluteBaseURL() . "age-gate/");
             }
         }
     }
     parent::init();
 }
예제 #17
0
 public function getThumbsDown($id)
 {
     try {
         $valid_ip = Thumb::where('ip', '=', Puskice::getIP())->where('object_type', '=', 5)->where('object_id', '=', $id)->first();
         if ($valid_ip != null) {
             throw new Exception("Error valid IP", 1);
         }
         $news = News::findOrFail($id);
         $news->thumbs_down++;
         $news->save();
         $thumb = new Thumb();
         $thumb->ip = Puskice::getIP();
         $thumb->object_id = $news->id;
         $thumb->object_type = 5;
         $thumb->save();
         $thumbs = array();
         if (Cookie::get('ps_thumbs')) {
             $cookie = Cookie::get('ps_thumbs');
             $thumbs = unserialize($cookie);
             if (isset($thumbs['page'][$news->id])) {
                 return Response::json(array('status' => 'fail', 'message' => __("Већ сте оценили ову вест")));
             }
         }
         $thumbs['page'][$news->id] = 'down';
         Cookie::queue('ps_thumbs', serialize($thumbs), 2628000);
         return Response::json(array('status' => 'success', 'message' => _("Ваш глас је забележен. Хвала на труду"), 'thumbsUp' => $news->thumbs_up, 'thumbsDown' => $news->thumbs_down));
     } catch (Exception $e) {
         return Response::json(array('status' => 'fail', 'message' => _("Већ сте оценили ову страницу")));
     }
 }
예제 #18
0
 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);
     }
 }
 /**
  * This function determines whether an there is a currently logged in
  * Author for Symphony by using the `$Cookie`'s username
  * and password. If an Author is found, they will be logged in, otherwise
  * the `$Cookie` will be destroyed.
  *
  * @see core.Cookie#expire()
  */
 public function isLoggedIn()
 {
     // Ensures that we're in the real world.. Also reduces three queries from database
     // We must return true otherwise exceptions are not shown
     if (is_null(self::$_instance)) {
         return true;
     }
     if ($this->Author) {
         return true;
     } else {
         $username = self::$Database->cleanValue($this->Cookie->get('username'));
         $password = self::$Database->cleanValue($this->Cookie->get('pass'));
         if (strlen(trim($username)) > 0 && strlen(trim($password)) > 0) {
             $id = self::$Database->fetchVar('id', 0, "SELECT `id` FROM `tbl_authors` WHERE `username` = '{$username}' AND `password` = '{$password}' LIMIT 1");
             if ($id) {
                 self::$Database->update(array('last_seen' => DateTimeObj::get('Y-m-d H:i:s')), 'tbl_authors', " `id` = '{$id}'");
                 $this->Author = AuthorManager::fetchByID($id);
                 Lang::set($this->Author->get('language'));
                 return true;
             }
         }
         $this->Cookie->expire();
         return false;
     }
 }
예제 #20
0
 public function before()
 {
     parent::before();
     //Visits
     $visited = \Cookie::get('visited', false);
     if (!$visited) {
         \Dashboard::log_visitor();
         \Cookie::set("visited", true, time() + 86400);
     }
     // Cart
     \Config::load('cart', true);
     $cartManager = new \Cart\Manager(\Config::get('cart'));
     \CartManager::init($cartManager);
     \CartManager::context('Cart');
     // Set Visitors group default
     \Product\Model_Attribute::set_user_group(3);
     \Theme::instance()->active('frontend');
     \Theme::instance()->set_template($this->template);
     // Set a global variable so views can use it
     $seo = array('meta_title' => '', 'meta_description' => '', 'meta_keywords' => '', 'canonical_links' => '', 'meta_robots_index' => 1, 'meta_robots_follow' => 1);
     \View::set_global('seo', $seo, false);
     \View::set_global('theme', \Theme::instance(), false);
     \View::set_global('logged', $this->check_logged(), false);
     \View::set_global('guest', $this->check_guest(), false);
     \View::set_global('logged_type', $this->check_logged_type(), false);
 }
예제 #21
0
 public function page($page = FALSE)
 {
     if ($locale = Cookie::get('locale')) {
         App::setLocale($locale);
     }
     if (!$page) {
         return Redirect::to(Lang::get('navigation.consumer'), 301);
     }
     $nav = array();
     foreach (['consumer', 'exporter'] as $item) {
         $loc = Lang::get('navigation.' . $item);
         $link = strtolower(str_replace(' ', '-', $loc));
         if ($link == $page) {
             $page = $item;
         }
         $nav[$link] = ucfirst($loc);
     }
     if (!View::exists('layouts.public.' . $page)) {
         App::abort(404);
     }
     $sub_nav = array();
     $view = View::make('layouts.public.' . $page);
     switch ($page) {
         case 'exporter':
             $sub_nav = ['assortment', 'horticulture', 'certification', 'contact'];
             $picturebox = new Picturebox\PictureboxManager();
             $view->with('picturebox', $picturebox);
             break;
     }
     $view->with('sub_nav', $sub_nav);
     return $view->with('nav', $nav);
 }
 public function studentadd()
 {
     $course_id = $_POST['course_id'];
     $homework_id = $_POST['homework_id'];
     $userid = Cookie::get('userid');
     $upload = new UploadFile($_POST['file']);
     $upload->allowExts = array('jpg', 'png');
     $upload->savePath = './../Public/Uploads/homework/studentimages/';
     if (!$upload->upload()) {
         $this->error($upload->getErrorMsg());
     } else {
         $info = $upload->getUploadFileInfo();
         $student_work = M('student_work');
         $student_work->homework_id = $homework_id;
         $student_work->user_id = $userid;
         $student_work->answer_img = $info[0]['savename'];
         $result = $student_work->add();
         if ($result) {
             $this->assign("jumpUrl", "__APP__/Homework/User/id/{$course_id}");
             $this->success("添加成功");
         } else {
             $this->assign("jumpUrl", "__APP__/Homework/User/id/{$course_id}");
             $this->error("添加不成功!");
         }
     }
 }
예제 #23
0
 public function mySchool()
 {
     // $academy_id = Session::get('school_id_session');
     $academy_id = Cookie::get('school_id_session');
     $mySchool = Academy::where('id', $academy_id)->first();
     return $mySchool;
 }
 public function update()
 {
     $id = intval($_REQUEST['id']);
     $model = D("FriendLink");
     if (false === ($data = $model->create())) {
         $this->error($model->getError());
     }
     // 更新数据
     $list = $model->save($data);
     if (false !== $list) {
         if ($upload_list = $this->uploadImages()) {
             $img = $upload_list[0]['recpath'] . $upload_list[0]['savename'];
             if (!empty($img)) {
                 $old_img = D("FriendLink")->where('id = ' . $id)->getField('img');
                 if (!empty($old_img)) {
                     @unlink(FANWE_ROOT . $old_img);
                 }
                 D("FriendLink")->where('id = ' . $id)->setField('img', $img);
             }
         }
         $this->saveLog(1, $id);
         $this->assign('jumpUrl', Cookie::get('_currentUrl_'));
         $this->success(L('EDIT_SUCCESS'));
     } else {
         //错误提示
         $this->saveLog(0, $id);
         $this->error(L('EDIT_ERROR'));
     }
 }
 public function setUp()
 {
     parent::setUp();
     //Remap translation group for home pages
     Translatable::disable_locale_filter();
     $default = $this->objFromFixture('Page', 'home');
     $defaultFR = $this->objFromFixture('Page', 'home_fr');
     $defaultFR->addTranslationGroup($default->ID, true);
     Translatable::enable_locale_filter();
     $this->origLocaleRoutingEnabled = Config::inst()->get('MultilingualRootURLController', 'UseLocaleURL');
     Config::inst()->update('MultilingualRootURLController', 'UseLocaleURL', false);
     $this->origDashLocaleEnabled = Config::inst()->get('MultilingualRootURLController', 'UseDashLocale');
     Config::inst()->update('MultilingualRootURLController', 'UseDashLocale', false);
     $this->origAcceptLanguage = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
     $_SERVER['HTTP_ACCEPT_LANGUAGE'] = 'en-US,en;q=0.5';
     $this->origCookieLocale = Cookie::get('language');
     Cookie::force_expiry('language');
     $this->origCurrentLocale = Translatable::get_current_locale();
     Translatable::set_current_locale('en_US');
     $this->origLocale = Translatable::default_locale();
     Translatable::set_default_locale('en_US');
     $this->origi18nLocale = i18n::get_locale();
     i18n::set_locale('en_US');
     $this->origAllowedLocales = Translatable::get_allowed_locales();
     Translatable::set_allowed_locales(array('en_US', 'fr_FR'));
     MultilingualRootURLController::reset();
 }
예제 #26
0
파일: test.php 프로젝트: rhrn/apirn
 public function action_index()
 {
     $view = View::factory('test/index');
     $apirn = json_decode(Cookie::get('apirn_1'));
     $view->name = $apirn->name;
     $this->template->content = (string) $view;
 }
예제 #27
0
 function update()
 {
     $this->_upload();
     $name = $this->getActionName();
     $model = D($name);
     if (false === $model->create()) {
         $this->error($model->getError());
     }
     $map['id'] = $_POST['parent_id'];
     $level = $model->where($map)->getField('area_type');
     if (!isset($level)) {
         $model->area_type = 0;
     } else {
         $model->area_type = $level + 1;
     }
     // 更新数据
     $list = $model->save();
     if (false !== $list) {
         //成功提示
         $this->assign('jumpUrl', Cookie::get('_currentUrl_'));
         $this->success('编辑成功!');
     } else {
         //错误提示
         $this->error('编辑失败!');
     }
 }
예제 #28
0
 /**
  * Checks POSTed data for CSRF token validity
  */
 static function detect()
 {
     $CSRF = !isset($_POST[self::$_cookieKey]) || !Cookie::exists(self::$_cookieKey) || $_POST[self::$_cookieKey] !== Cookie::get(self::$_cookieKey);
     if (!POST_REQUEST && $CSRF) {
         Cookie::set(self::$_cookieKey, md5(time() + rand()), Cookie::SESSION);
     }
 }
예제 #29
0
파일: base.php 프로젝트: Hinton/langify
 public function before()
 {
     parent::before();
     // Borrowed from userguide
     if (isset($_GET['lang'])) {
         $lang = $_GET['lang'];
         // Make sure the translations is valid
         $translations = Kohana::message('langify', 'translations');
         if (in_array($lang, array_keys($translations))) {
             // Set the language cookie
             Cookie::set('langify_language', $lang, Date::YEAR);
         }
         // Reload the page
         $this->request->redirect($this->request->uri());
     }
     // Set the translation language
     I18n::$lang = Cookie::get('langify_language', Kohana::config('langify')->lang);
     // Borrowed from Vendo
     // Automaticly load a view class based on action.
     $view_name = $this->view_prefix . Request::current()->action();
     if (Kohana::find_file('classes', strtolower(str_replace('_', '/', $view_name)))) {
         $this->view = new $view_name();
         $this->view->set('version', $this->version);
     }
 }
 public function addDoc()
 {
     $course_id = $_POST['course_id'];
     $zhang_name = $_POST['zhang_name'];
     $usertype = Cookie::get('usertype');
     $upload = new UploadFile($_POST['file']);
     $upload->allowExts = array('zip', 'rar', 'gz');
     $upload->savePath = './../Public/Uploads/document/';
     if (!$upload->upload()) {
         $this->error($upload->getErrorMsg());
     } else {
         $info = $upload->getUploadFileInfo();
     }
     $zhang = M('zhang');
     $zhang->create();
     $zhang->course_id = $course_id;
     $zhang->zhang_name = $zhang_name;
     $zhang->file = $info[0]['savename'];
     $result = $zhang->add();
     $this->assign("jumpUrl", "__APP__/Document/teacherindex/id/{$course_id}");
     if ($result) {
         $this->success("添加成功!");
     } else {
         $this->error($result->getErrorMsg());
     }
 }