Set a new cookie
static public set ( string $key, string $value, integer $expires = 3600, string $domain = '/' ) : boolean | ||
$key | string | The name of the cookie |
$value | string | The cookie content |
$expires | integer | The number of seconds until the cookie expires |
$domain | string | The domain to set this cookie for. |
return | boolean | true: the cookie has been created, false: cookie creation failed |
public static function set($type, $id, $message) { $c = config::get('notes'); $c['name'] = "note-{$type}-{$id}"; $c['value'] = $message; cookie::set($c); }
/** * Tests cookie::set() * * @test * @dataProvider provider_set * @covers cookie::set * @param mixed $key key to use * @param mixed $value value to set * @param mixed $exp exp to set * @param boolean $expected Output for cookie::set() */ public function test_set($key, $value, $exp, $expected) { if (headers_sent()) { $this->markTestSkipped('Cannot test setting cookies as headers have already been sent'); } $this->assertSame($expected, cookie::set($key, $value, $exp)); }
/** * Methode : page de détail d'une user */ public function show($idQuete = false) { if (!$idQuete || !is_numeric($idQuete)) { return parent::redirect_erreur('quetes'); } cookie::set('UserFilesPath', url::base() . '../images/quetes/' . $idQuete); cookie::set('UserFilesAbsolutePath', DOCROOT . '../images/quetes/' . $idQuete); if (!cookie::get('UserFilesPath')) { return url::redirect('quetes/show/' . $idQuete); } if (!($quete = $this->quete->select(array('id_quete' => $idQuete), 1))) { return parent::redirect_erreur('quetes'); } if (!($module = Map_Model::instance()->select(array('module_map' => 'quete'), false))) { return url::redirect('regions?msg=' . urlencode(Kohana::lang('quete.no_module'))); } $this->script = array('js/lib/jquery.validate', 'js/lib/jquery.facebox', 'js/quetes'); $this->css = array('form', 'quete', 'facebox'); $this->template->titre = array(Kohana::lang('quete.all_quetes') => 'quetes', Kohana::lang('quete.show_title', ucfirst(mb_strtolower($quete->title))) => NULL); $this->template->button = TRUE; $this->template->navigation = parent::navigation($idQuete, 'id_quete', 'quetes'); $this->template->contenu = new View('formulaire/form'); $this->template->contenu->action = 'quetes/save'; $this->template->contenu->id = $idQuete; $this->template->contenu->formulaire = new View('quetes/show'); $this->template->contenu->formulaire->row = $quete; $this->template->contenu->formulaire->module = $module; $this->template->contenu->formulaire->bots = Map_Model::instance()->select(array('module_map' => 'fight'), false); $this->template->contenu->formulaire->quete = $this->quete->select(array('id_quete !=' => $idQuete)); }
/** * Methode : page de détail d'un article */ public function show($idActualite = FALSE) { if (!$idActualite || !is_numeric($idActualite)) { return parent::redirect_erreur('articles'); } cookie::set('UserFilesPath', url::base() . '../images/articles/' . $idActualite); cookie::set('UserFilesAbsolutePath', DOCROOT . '../images/articles/' . $idActualite); if (!cookie::get('UserFilesPath')) { return url::redirect('articles/show/' . $idActualite); } if (!($actualite = $this->acticles->select(array('id_article' => $idActualite), TRUE))) { return parent::redirect_erreur('articles'); } $actualiteCategories = $this->acticles->selectListeCategories(); $this->script = array('js/lib/jquery.validate', 'js/articles'); $this->css = array('form', 'article'); $this->template->titre = array(Kohana::lang('article.all_article') => 'articles', $actualite->title => NULL); $this->template->button = TRUE; $this->template->navigation = $this->acticles->navigation($idActualite, 'id_article', 'articles'); $this->template->navigationURL = 'articles/show'; $this->template->contenu = new View('formulaire/form'); $this->template->contenu->action = 'articles/save'; $this->template->contenu->id = $idActualite; $this->template->contenu->formulaire = new View('articles/show'); $this->template->contenu->formulaire->row = $actualite; $this->template->contenu->formulaire->actualiteCategories = $actualiteCategories; $this->template->contenu->formulaire->regions = Region_Model::instance()->listing_parent(); }
/** * On first session instance creation, sets up the driver and creates session. */ public function __construct() { $this->input = Input::instance(); // This part only needs to be run once if (self::$instance === NULL) { // Load config self::$config = Kohana::config('session'); // Makes a mirrored array, eg: foo=foo self::$protect = array_combine(self::$protect, self::$protect); // Configure garbage collection ini_set('session.gc_probability', (int) self::$config['gc_probability']); ini_set('session.gc_divisor', 100); ini_set('session.gc_maxlifetime', self::$config['expiration'] == 0 ? 86400 : self::$config['expiration']); // Create a new session $this->create(); if (self::$config['regenerate'] > 0 and $_SESSION['total_hits'] % self::$config['regenerate'] === 0) { // Regenerate session id and update session cookie $this->regenerate(); } else { // Always update session cookie to keep the session alive cookie::set(self::$config['name'], $_SESSION['session_id'], self::$config['expiration']); } // Close the session just before sending the headers, so that // the session cookie(s) can be written. Event::add('system.send_headers', array($this, 'write_close')); // Make sure that sessions are closed before exiting register_shutdown_function(array($this, 'write_close')); // Singleton instance self::$instance = $this; } Kohana::log('debug', 'Session Library initialized'); }
public function action_index() { $this->template->content = View::factory('admin/projects/create')->bind('post', $post)->bind('errors', $errors)->bind('associates', $assoc); $assoc = DB::query(Database::SELECT, 'SELECT id, name FROM associates ORDER BY name')->execute()->as_array('id', 'name'); // Add an option for "no associate" arr::unshift($assoc, 0, '- none -'); $post = Validate::factory($_POST)->filter(TRUE, 'trim')->rule('title', 'not_empty')->rule('title', 'regex', array('/^[\\pL\\pP\\s]{4,255}$/iu'))->rule('associate_id', 'not_empty')->rule('associate_id', 'in_array', array(array_keys($assoc)))->rule('completed', 'not_empty')->rule('completed', 'date')->rule('website', 'regex', array('#^https?://.+$#')); if ($post->check($errors)) { if (empty($post['associate_id'])) { // Make the associate NULL $post['associate_id'] = NULL; // Use only the title for the slug $post['slug'] = url::title($post['title']); } else { // Use the title with associate for the slug $post['slug'] = url::title($post['title']) . '/with/' . url::title($assoc[$post['associate_id']]); } if (empty($post['website'])) { // Make the website value NULL $post['website'] = NULL; } // Get the values of the array $values = $post->as_array(); // Convert the completed date into a timestamp $values['completed'] = strtotime($values['completed']); $query = DB::query(Database::INSERT, 'INSERT INTO projects (title, associate_id, completed, website, slug) VALUES (:values)')->bind(':values', $values)->execute(); // Set a cookie message cookie::set('message', 'Created new project with an ID of ' . $query); // Redirect back to the same page $this->request->redirect(url::site($this->request->uri)); } }
function index_action() { if (front::post('submit')) { if (!front::post('ballot')) { front::alert(lang('Please_select_vote')); return false; } if (config::get('checkip')) { $time=cookie::get('vttime'); if (time() -$time <config::get('timer') * 60) { front::alert(lang('You_have_voted')); return false; } } $bid=front::$post['bid']; if (is_array(front::$post['ballot'])) { $ids=implode(',',front::$post['ballot']); } else { $ids=front::$post['ballot']; } if(preg_match('/(select|union|and|\'|"|\))/i',$ids)){ exit('非法参数'); } if(preg_match('/(select|union|and|\'|"|\))/i',$bid)){ exit('非法参数'); } $where="id in($ids)"; $data='num=num+1'; $option=new option(); $option->rec_update($data,$where); $this->_table->rec_update($data,$bid); cookie::set('vttime',time(),time() +3600 * 24); front::alert(lang('Successful_vote')); } }
function remotelogin_action() { cookie::del('passinfo'); $this->view->loginfalse=cookie::get('loginfalse'.md5($_SERVER['REQUEST_URI'])); if (front::$args) { $user=new user(); $args = xxtea_decrypt(base64_decode(front::$args), config::get('cookie_password')); $user=$user->getrow(unserialize($args)); if (is_array($user)) { if ($user['groupid'] == '888') front::$isadmin=true; cookie::set('login_username',$user['username']); cookie::set('login_password',front::cookie_encode($user['password'])); session::set('username',$user['username']); require_once ROOT.'/celive/include/config.inc.php'; require_once ROOT.'/celive/include/celive.class.php'; $login=new celive(); $login->auth(); $GLOBALS['auth']->remotelogin($user['username'],$user['password']); $GLOBALS['auth']->check_login1(); front::$user=$user; }elseif (!is_array(front::$user) ||!isset(front::$isadmin)) { cookie::set('loginfalse'.md5($_SERVER['REQUEST_URI']),(int) cookie::get('loginfalse'.md5($_SERVER['REQUEST_URI'])) +1,time() +3600); event::log('loginfalse','失败 user='******'username']); front::flash('密码错误或不存在该管理员!'); front::refresh(url('admin/login',true)); } } $this->render(); }
public function write($id, $data) { $data = base64_encode($data); if (strlen($data) > 4048) { return FALSE; } return cookie::set($this->cookie_name, $data, Ko::config('session.expiration')); }
function __construct() { // Check and see if this is being run from the command line define('IS_CLI', 'cli' == PHP_SAPI); parent::__construct(); Footsteps::step(); $this->template->title = ucwords(router::$method); $this->session = Session::instance(); $this->template->robots = ''; if (router::$controller != 'page') { if (!Auth::instance()->logged_in() and !cookie::get('qaargh_visited', false, true)) { $this->session->set_flash('notice', 'It looks like this is your first time here. Click "home" to find out more about Q-Aargh!'); cookie::set(array('name' => 'qaargh_visited', 'value' => true, 'expire' => 31536000)); } } else { cookie::set(array('name' => 'qaargh_visited', 'value' => true, 'expire' => 31536000)); } try { $this->template->view = new View(strtolower(router::$controller . '/' . router::$method)); } catch (Exception $e) { $this->template->view = new View('error/missing_view'); } if (Auth::instance()->logged_in()) { $this->template->menu = new View('menu/logged_in'); } else { $this->template->menu = new View('menu/logged_out'); } // Handle built-in authorization if (array_key_exists(router::$method, $this->auth_required)) { // If it's in the array, you must at least be logged in. if (!Auth::instance()->logged_in()) { $this->session->set_flash('error', Kohana::lang('general.login_required')); url::redirect("/user/login"); } $authorized = false; // If it's *, then being logged in is enough if ('*' == $this->auth_required[router::$method]) { $authorized = true; } else { if (is_array($this->auth_required[router::$method])) { foreach ($this->auth_required[router::$method] as $right) { if (Auth::instance()->logged_in($right)) { $authorized = false; break; } } } else { if (Auth::instance()->logged_in($this->auth_required[router::$method])) { $authorized = false; } } } if (!$authorized) { $this->session->set_flash('error', Kohana::lang('general.insufficient_privileges')); url::redirect("/user"); } } }
public function write($id, $data) { $data = empty($this->encrypt) ? base64_encode($data) : $this->encrypt->encode($data); if (strlen($data) > 4048) { throw new LemonRuntimeException('Session (' . $id . ') data exceeds the 4KB limit, ignoring write.', 500); return FALSE; } return cookie::set($this->cookie_name, $data, Lemon::config('session.expiration')); }
public function write($id, $data) { $data = empty($this->encrypt) ? base64_encode($data) : $this->encrypt->encode($data); if (strlen($data) > 4048) { Kohana::log('error', 'Session (' . $id . ') data exceeds the 4KB limit, ignoring write.'); return FALSE; } return cookie::set($this->cookie_name, $data, Kohana::config('session.expiration')); }
public function action_set() { $value = array('time' => $time = microtime(TRUE), 'md5' => md5($time), 'uid' => uniqid()); $this->_cases['kohana'] = $value; foreach ($this->_cases as $name => $value) { // Set the cookie cookie::set($name, serialize($value)); } }
function index() { //判断用户是否是已经登录状态 $data = role::get_manager(); if ($data['id'] > 0) { $data['success'] = 'true'; $data['msg'] = 1; } else { $data['success'] = 'false'; $data['msg'] = 1; } $username = $this->input->post('username'); $password = $this->input->post('password'); $secode = $this->input->post('secode'); $remember = $this->input->post('remember'); $data['success'] = 'false'; //验证登录 $manager = role::log_in($username, $password); if (isset($manager['username'])) { //判断普通账号的状态、权限 if (!role::is_root($manager['username'])) { if ($manager['active'] != 1) { ulog::login($manager['id'], 1); $data['msg'] = Kohana::lang('o_global.account_was_locked'); } $actions = role::manager_actions($manager['id'], TRUE); if (count($actions) < 1) { ulog::login($manager['id'], 2); $data['msg'] = Kohana::lang('o_global.account_permission_enough'); } } //是否记录用户名 if ($remember == 1) { cookie::set('opococ_username', $username); } else { cookie::delete('opococ_username'); } //清除记录登录错误记录 //Session::instance()->delete('login_error_count'); //记入SESSION role::set_manager_session($manager); //记录日志 ulog::login($manager['id']); $data['success'] = 'true'; $data['msg'] = 1; /*if(empty($request_url)) { remind::set(Kohana::lang('o_global.login_success'), '/index', 'success'); } else { $request_url = url::base() . urldecode($request_url); remind::set(Kohana::lang('o_global.login_success'), $request_url, 'success'); }*/ } die(json_encode($data)); }
protected static function kill() { self::$user = null; // overwrite the token $token = str::random(); // the cookie is valid for 24 hours cookie::set('authFrontend', $token, 60 * 60 * 24); // restart the session s::restart(); }
/** * Nullify and unset a cookie. * * @param string cookie name * @param string URL path * @param string URL domain * @return boolean */ public static function delete($name, $path = NULL, $domain = NULL) { if (!isset($_COOKIE[$name])) { return FALSE; } // Delete the cookie from globals unset($_COOKIE[$name]); // Sets the cookie value to an empty string, and the expiration to 24 hours ago return cookie::set($name, '', -86400, $path, $domain, FALSE, FALSE); }
/** * 設置或讀取訂單信息 * @param $ary * @return array */ static function oInfo($ary = null) { if ($ary) { cookie::set('order', json_encode($ary)); } else { $oinfo = cookie::get('order'); $ary = json_decode($oinfo, true); !$ary && ($ary = array()); return $ary; } }
public function do_login(Validate $array, $field, array $errors) { if (empty($errors) and isset($array['username']) and isset($array['password'])) { $query = DB::query(Database::SELECT, 'SELECT password FROM users WHERE username = :username')->bind(':username', $array['username'])->execute(); if (sha1($array['password']) === $query->get('password')) { // User is authorized cookie::set('authorized', $array['username']); } else { // Invalid login $errors['username'] = '******'; } } return $errors; }
/** * 登录 */ public function login() { $cookie = cookie::get(COOKIE_KEY); if ($cookie) { redirect(url('admin', 'index')); return; } $username = $this->post('username'); $password = $this->post('password'); if ($username === 'ruanzhijun' && $password === 'ruanzhijun') { cookie::set(COOKIE_KEY, 1); redirect(url('admin', 'index')); return; } }
static function index() { //初始化工作 self::del_empty_file('gitkeep'); //1、删除空文件(github空目录) self::logo(); //2、生成logo图片 self::clean(); //3、删除模板编译文件 $tpl = smarty(); $head['title'] = 'Home'; $tpl->assign('head', $head); $tpl->assign('logo', '<img src="' . dc_url_create . 'eqphp_logo.png">'); cookie::set('frame_name', 'EQPHP'); $tpl->display('index'); }
public static function set($name, $value, $cookie = FALSE) { if (!$cookie) { $cookie = self::$config['cookie']; } $d = new DateTime(); $d->modify($cookie['expire']); $salt = self::salt(); $cookie['name'] = $name; $cookie['value'] = $salt; if (empty($cookie['expire'])) { $cookie['expire'] = '+1 hours'; } cookie::set($cookie); $t = db(self::$config['table'], NULL, self::$config['connection']); $t->insert(array('name' => $name, 'value' => $value, 'cookie' => $salt, 'expire' => $d->format('U'))); self::$table[$name] = $value; }
/** * 每页显示条数 调用样例见order/order.php $pagination_arr = array ( 0 => 20, 1 => 50, 2 => 100, 3 => 300, ); $per_page = controller_tool::per_page($pagination_arr); 或者 $per_page = controller_tool::per_page(); */ public static function per_page($pagination_arr = NULL) { $input = Input::instance(); $uri = URI::instance(); $segment = $uri->segment(1) . '_' . $uri->segment(2) . '_' . $uri->segment(3); //不带参数时给个默认值 if (empty($pagination_arr)) { $pagination_arr = Kohana::config('pagination.per_page'); } if (!is_null($input->get('per_page'))) { $per_page = intval($input->get('per_page')); cookie::set($segment . '_per_page', $per_page); } elseif (!is_null(cookie::get($segment . '_per_page'))) { $per_page = intval(cookie::get($segment . '_per_page')); } else { $per_page = $pagination_arr[0]; } return $per_page; }
public static function save_update_current() { if (true || !user::logged('admin')) { $session = Session::instance(); $visitor = ORM::factory('Visitor', $session->get('active_visitor')); $base = request::detect_uri(); $queries = isset($_GET) && !empty($_GET) ? '?' . http_build_query($_GET) : ''; $uri = request::detect_uri() . $queries; //substr($base, 1, strlen($base)) if ($visitor->loaded() && $uri == $visitor->page) { // This is just a reload of the current page. return; } if (!$visitor->loaded()) { $numvisits = cookie::get('numvisits'); if (!$numvisits) { $numvisits = 0; } cookie::set('numvisits', $numvisits + 1); $visitor->numvisits = $numvisits + 1; $visitor->start = time(); $visitor->referrer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : ''; $visitor->ip = isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : ''; $visitor->geolocation = 'todo'; } if (empty($visitor->client)) { $visitor->client = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : ''; } $visitor->page = $uri; if (user::logged()) { $visitor->user_id = user::get()->id; } $history = json_decode($visitor->history); if (!is_array($history)) { $history = array(); } $history[] = $uri; $visitor->history = json_encode($history); $visitor->time = time(); $visitor->save(); $session->set('active_visitor', $visitor->id); } }
static function viewable($model) { // Hide password protected albums until the correct password is entered, // unless the current user is an admin, or the albums owner. $model = item_Core::viewable($model); // If the user is an admin, don't hide anything anything. // If not, hide whatever is restricted by an album password // that the current user is not the owner of. if (!identity::active_user()->admin) { // Display items that are not in idcaches. $model->and_open()->join("albumpassword_idcaches", "items.id", "albumpassword_idcaches.item_id", "LEFT OUTER")->and_where("albumpassword_idcaches.item_id", "IS", NULL); // If in hide only mode, check and see if the current item is protected. // If it is, log the user in with the password to view it. if (module::get_var("albumpassword", "hideonly") == true) { $existing_cacheditem = ORM::factory("albumpassword_idcache")->where("item_id", "=", $model->id)->order_by("cache_id")->find_all(); if (count($existing_cacheditem) > 0) { $existing_cacheditem_password = ORM::factory("items_albumpassword")->where("id", "=", $existing_cacheditem[0]->password_id)->find_all(); if (cookie::get("g3_albumpassword") != $existing_cacheditem_password[0]->password) { cookie::set("g3_albumpassword", $existing_cacheditem_password[0]->password); cookie::set("g3_albumpassword_id", $existing_cacheditem_password[0]->id); $model->or_where("albumpassword_idcaches.password_id", "=", $existing_cacheditem_password[0]->id); } } } // ... Unless their password id corresponds with a valid password. $existing_password = ORM::factory("items_albumpassword")->where("password", "=", cookie::get("g3_albumpassword"))->find_all(); if (count($existing_password) > 0) { foreach ($existing_password as $one_password) { if (cookie::get("g3_albumpassword_id") != "") { if (cookie::get("g3_albumpassword_id") == $one_password->id) { $model->or_where("albumpassword_idcaches.password_id", "=", $one_password->id); } } else { $model->or_where("albumpassword_idcaches.password_id", "=", $one_password->id); } } } // Or the current user is the owner of the item. $model->or_where("items.owner_id", "=", identity::active_user()->id)->close(); } return $model; }
function into_action() { preg_match_all("/case=union&act=into&(.*)/isu",$_SERVER['QUERY_STRING'],$queryout); if(!empty($queryout[1][0])) { $userid = intval($queryout[1][0]); $r = $this->_union->getrow(array('userid'=>$userid)); if($r) { $time = time() -3600*24; $unionvisit = new union_visit(); $r_visit = $unionvisit->rec_select("userid=$userid AND visitip='".front::ip()."' AND visittime>$time",0,'*',' 1'); if(!$r_visit) { $rewardtype = union::getconfig('rewardtype'); $rewardnumber = union::getconfig('rewardnumber'); $user = $this->_user->getrow(array('userid'=>$userid)); $user['username']; switch($rewardtype) { case 'point': union::pointadd($user['username'],$rewardnumber,'union'); break; } $useridarr = array(); $useridarr['userid'] = $userid; $updatevisit = $this->_union->rec_update(array('visits'=>'[visits+1]'),$useridarr); if($this->_union->affected_rows()) { $useridarr['userid'] = $userid; $useridarr['visittime'] = time(); $useridarr['visitip'] = front::ip(); $useridarr['referer'] = $_SERVER['HTTP_REFERER']; if(preg_match('/select/i',$useridarr['referer']) || preg_match('/union/i',$useridarr['referer']) || preg_match('/"/i',$useridarr['referer']) ||preg_match('/\'/i',$useridarr['referer'])){ exit('非法参数'); } $unionvisit->rec_insert($useridarr); $union_visitid = $unionvisit->insert_id(); $cookietime = time() +union::getconfig('keeptime'); cookie::set('union_visitid',$union_visitid,$cookietime); cookie::set('union_userid',$userid,$cookietime); } } } } $url = union::getconfig('forward') ?union::getconfig('forward') : config::get('site_url'); header('location:'.$url); }
public function s($sponsor) { $userData = user::checkExist("user_accounts", "agent_id = '{$sponsor}' or username = '******'"); if ($userData == 1) { $getUserData = $this->db->select("user_accounts", "agent_id, username", "agent_id = '{$sponsor}' or username = '******'", "fetch"); $chkCookie = cookie::exists(COOKIE_SPONSOR_NAME); if ($chkCookie) { $cookieName = cookie::get(COOKIE_SPONSOR_NAME); if ($cookieName != $getUserData['agent_id']) { cookie::delete(COOKIE_SPONSOR_NAME); cookie::set(COOKIE_SPONSOR_NAME, $getUserData['agent_id'], COOKIE_EXPIRY); } } else { cookie::set(COOKIE_SPONSOR_NAME, $getUserData['agent_id'], COOKIE_EXPIRY); } } else { cookie::delete(COOKIE_SPONSOR_NAME); } redirect::to(BASE_PATH, TRUE); }
/** * Logs a user in. * * @param string username * @param string password * @param boolean enable auto-login * @return boolean */ public function _login($user, $password, $remember) { // Make sure we have a user object $user = $this->_get_object($user); // If the passwords match, perform a login if ($user->has_role('login') and $user->password === $password) { if ($remember === TRUE) { // Generate autologin token $token = sha1(uniqid('sprig-auth', TRUE)); // Save token to user data $user->values(array('autologin' => $token))->update(); // Save token cookie cookie::set('authautologin', $token, $this->config['lifetime']); } // Finish the login $this->complete_login($user); return TRUE; } // Login failed return FALSE; }
function downfile_action() { $base_url = config::get('base_url'); if(front::post('submit')) { if(!session::get('verify') ||front::post('verify')<>session::get('verify')) { front::flash(lang('验证码错误!')); return; }else { front::check_type(front::get('aid')); $aid=front::get('aid'); $name=archive_attachment($aid,'intro'); $path=archive_attachment($aid,'path'); if(!$name) $name=preg_replace('%(.*)[\\\\\/](.*)_\d+(\.[a-z]+)$%i','$2',$path); @cookie::set('allowdown',md5(url::create('attachment/downfile/aid/'.$aid.'/v/ce'))); if(!rank::arcget($aid,$this->view->usergroupid,'down')) $link="<p align='center'><a id='att' href='javascript:alert(\"未取得授权,无法下载!\");'><img src='{$base_url}/images/download.gif' alt='$name' border='0' /></a></p>"; else $link="<p align='center'><a id='att' href='".url::create('attachment/down/aid/'.$aid)."'><img src='{$base_url}/images/download.gif' alt='$name' border='0' /></a></p>"; echo $link; exit; } } }
/** * Logs a user in, based on the authautologin cookie. * * @return boolean */ public function auto_login() { if ($token = cookie::get('authautologin')) { // Load the token and user $token = ORM::factory('user_token', $token); if ($token->loaded and $token->user->loaded) { if ($token->user_agent === sha1(Kohana::$user_agent)) { // Save the token to create a new unique token $token->save(); // Set the new token cookie::set('authautologin', $token->token, $token->expires - time()); // Complete the login with the found data $this->complete_login($token->user); // Automatic login was successful return TRUE; } // Token is invalid $token->delete(); } } return FALSE; }
function add_photos() { $path = trim($this->input->post("path")); $parent_id = (int) $this->input->post("parent_id"); $parent = ORM::factory("item", $parent_id); if (!$parent->loaded) { throw new Exception("@todo BAD_ALBUM"); } batch::start(); cookie::set("add_photos_path", $path); $photo_count = 0; foreach (glob("{$path}/*.[Jj][Pp][Gg]") as $file) { set_time_limit(30); photo::create($parent, $file, basename($file), basename($file)); $photo_count++; } batch::stop(); if ($photo_count > 0) { log::success("content", "(scaffold) Added {$photo_count} photos", html::anchor("albums/{$parent_id}", "View album")); } url::redirect("scaffold"); }