public function rel($relativeUri) { $relativeUri = $relativeUri instanceof uri ? $relativeUri : uri::fromString(strval($relativeUri)); $rel = new uri(); $rel->setPath(array_merge($this->_uri->getPath(), $relativeUri->getPath())); return $rel; }
function & _fetch(&$counter, $params) { $result =& parent :: _fetch($counter, $params); $uri = new uri($_SERVER['PHP_SELF']); foreach($result as $key => $data) { $nav_uri = new uri($data['url']); if ($uri->get_host() != $nav_uri->get_host()) continue; if(is_integer($res = $uri->compare_path($nav_uri))) { if($res >= 0) { $result[$key]['in_path'] = true; $params['path'] = $data['path']; $result[$key]['items'] = $this->_fetch(&$counter, $params); } if($res == 0) $result[$key]['selected'] = true; } } return $result; }
function & _fetch(&$counter, $params) { $result =& parent :: _fetch($counter, $params); $uri = new uri($_SERVER['PHP_SELF']); //we're trimming trailing slashes: thus /root/about == /root/about/ $uri->set_path(rtrim($uri->get_path(), '/')); foreach($result as $key => $data) { $nav_uri = new uri($data['url']); $nav_uri->set_path(rtrim($nav_uri->get_path(), '/')); if ($uri->get_host() != $nav_uri->get_host()) continue; if(is_integer($res = $uri->compare_path($nav_uri))) { if($res >= 0) $result[$key]['in_path'] = true; if($res == 0) $result[$key]['selected'] = true; } } return $result; }
function _compare_with_url($url) { $uri = new uri($_SERVER['PHP_SELF']); //we're trimming trailing slashes: thus /root/about == /root/about/ $uri->set_path(rtrim($uri->get_path(), '/')); $nav_uri = new uri($url); $nav_uri->set_path(rtrim($nav_uri->get_path(), '/')); if ($uri->get_host() != $nav_uri->get_host()) { return false; } return $uri->compare_path($nav_uri); }
public function render() { if (!$this->links) { throw new Kohana_User_Exception("Navbar not implemented correctly", "Links have not been set. Please call <code>$navbar->set_links({$links})</code>"); } else { if ($this->view) { return $this->render_to_view($this->view); } else { $html = ""; $i = 0; foreach ($this->links as $link) { $class = ""; if (str_replace("site", "", url::current()) == $link->seoURL || url::current() == $link->seoURL || uri::segment(1) == $link->seoURL) { $class .= "selected"; } if ($i == 0) { $class .= " first"; } if ($i == count($this->links) - 1) { $class .= " last"; } $html .= '<li class="' . $class . '" id="menu0' . ($i + 1) . '"><a href="' . url::site() . $link->seoURL . '" class="' . $class . '">' . $link->title . '</a></li>'; $i++; } # $html .= "</ul>"; return $html; } } }
public function __construct() { parent::__construct(); if (!config::item('news_blog', 'news') && uri::segment(1) != 'news') { router::redirect('news/' . utf8::substr(uri::getURI(), 5)); } }
public function delete() { // Get URI vars $slugID = urldecode(utf8::trim(uri::segment(4))); // Do we have a slug ID? if ($slugID == '') { error::show404(); } // Get user if (!($user = $this->users_model->getUser($slugID)) || !$user['active'] || !$user['verified']) { error::show404(); } elseif ($user['user_id'] == session::item('user_id')) { router::redirect($user['slug']); } // Does user exist? if (!($blocked = $this->users_blocked_model->getUser($user['user_id'], true))) { view::setError(__('no_blocked_user', 'users_blocked')); router::redirect('users/blocked'); } // Delete blocked user $this->users_blocked_model->deleteBlockedUser(session::item('user_id'), $user['user_id']); // Success view::setInfo(__('user_unblocked', 'users_blocked')); router::redirect(input::get('page') ? 'users/blocked' : $user['slug']); }
public function view() { // Get URI vars $newsID = (int) uri::segment(3); // Get news entry if (!$newsID || !($news = $this->news_model->getEntry($newsID, 'in_view')) || !$news['active']) { error::show404(); } // Do we have views enabled? if (config::item('news_views', 'news')) { // Update views counter $this->news_model->updateViews($newsID); } // Load ratings if (config::item('news_rating', 'news') == 'stars') { // Load votes model loader::model('comments/votes'); // Get votes $news['user_vote'] = $this->votes_model->getVote('news', $newsID); } elseif (config::item('news_rating', 'news') == 'likes') { // Load likes model loader::model('comments/likes'); // Get likes $news['user_vote'] = $this->likes_model->getLike('news', $newsID); } // Assign vars view::assign(array('newsID' => $newsID, 'news' => $news)); // Set title view::setTitle($news['data_title']); // Set meta tags view::setMetaDescription($news['data_meta_description']); view::setMetaKeywords($news['data_meta_keywords']); // Load view view::load('news/view'); }
function &_fetch(&$counter, $params) { $result =& parent::_fetch($counter, $params); $uri = new uri($_SERVER['PHP_SELF']); foreach ($result as $key => $data) { if (is_integer($res = $uri->compare_path(new uri($data['url'])))) { if ($res >= 0) { $result[$key]['in_path'] = true; } if ($res == 0) { $result[$key]['selected'] = true; } } } return $result; }
/** * Returns the formatted html * * html example * e.g <h1>{TITLE}</h1><h2>{DATE}</h2><h3>by {AUTHOR}</h3>{IMAGE}{TEXT}<div class="spacer"> </div> * * @param array $options Options for the rendering array('count', 'date_format','image' = array($width,$height), 'word_count', 'html') * @return string $html Formatted HTML */ public function render_summary($options = null, $feedpost_options = null) { $array = array('per_page' => 5, 'pagination' => 'classic', 'template' => 'feed', 'html' => '{FEEDPOSTS}{PAGINATION}'); if (!$options) { $config = Kohana::config_load('zest'); $options = $config['feed.summary']; } $array = arr::overwrite($array, $options); $uri = uri::instance(); $page = $uri->segment('page', 1); $feedposts = ""; $posts = $this->get_posts($array['per_page'], ($page - 1) * $array['per_page']); foreach ($posts as $post) { $feedposts .= $post->render_summary($feedpost_options); } $pagination = new Pagination(array('uri_segment' => 'page', 'total_items' => count($this->get_posts()), 'items_per_page' => $array['per_page'], 'style' => $array['pagination'])); if ($array['template'] != '') { $html = zest::template_to_html('snippets/' . $array['template']); } else { $html = $array['html']; } $html = str_replace("{RSS_LINK}", $this->get_rss(), $html); $html = str_replace("{FEEDPOSTS}", $feedposts, $html); $html = str_replace("{PAGINATION}", $pagination, $html); $html = str_replace("{FEED_LINK}", $this->get_url(), $html); return $html; }
function &_fetch(&$counter, $params) { $result =& parent::_fetch($counter, $params); $requested_uri = new uri($_SERVER['REQUEST_URI']); $nav_uri = new uri(); foreach ($result as $key => $data) { $nav_uri->parse($data['url']); if ($requested_uri->compare_path($nav_uri) === 0) { $result[$key]['selected'] = true; if ($nav_uri->get_query_item('action') !== $requested_uri->get_query_item('action')) { $result[$key]['selected'] = false; } } } return $result; }
function &_fetch(&$counter, $params) { $result =& parent::_fetch($counter, $params); $uri = new uri($_SERVER['PHP_SELF']); foreach ($result as $key => $data) { if ($uri->compare($data['url'], $url_rest, $query_match)) { if ($url_rest >= 0) { $result[$key]['in_path'] = true; } if ($url_rest == 0) { $result[$key]['selected'] = true; } } } return $result; }
public function delete() { // Get URI vars $fieldID = (int) uri::segment(7); // Delete custom field $this->deleteField('pages', 'pages_data', 0, $fieldID); }
public function delete() { // Get URI vars $typeID = (int) uri::segment(6); $fieldID = (int) uri::segment(7); $typeID = $typeID == 0 || $typeID == 1 ? $typeID : 0; // Delete custom field $this->deleteField('pictures', 'pictures_' . ($typeID == 1 ? 'albums_' : '') . 'data', $typeID, $fieldID); }
public function click() { $bannerID = (int) uri::segment(3); if ($bannerID && $bannerID > 0) { loader::model('banners/banners'); $this->banners_model->updateClicks($bannerID); } exit; }
public function __construct() { parent::__construct(); $authID = session::item('auth_id'); $userID = session::item('user_id'); $ipaddress = substr(input::ipaddress(), 0, 15); $useragent = substr(input::useragent(), 0, 255); $user = array(); if ($authID && ($user = $this->getSession($authID, $userID, $ipaddress, $useragent))) { if ($user['active_date'] < date_helper::now() - 60 * $this->timeout) { $this->saveSession($authID, $userID, $ipaddress, $useragent); if (isset($user['user_id']) && $user['user_id']) { $this->saveLastvisit($user['user_id']); } } } else { $cookie = cookie::item('sessdata'); $cookie = $cookie ? @json_decode($cookie, true) : array(); if ($cookie && is_array($cookie)) { $userID = isset($cookie['user_id']) ? $cookie['user_id'] : ''; $email = isset($cookie['email']) ? $cookie['email'] : ''; $passhash = isset($cookie['passhash']) ? $cookie['passhash'] : ''; if ($userID && is_numeric($userID) && $userID > 0) { if ($user = $this->getUser($userID, false, false)) { $newPasshash = $this->generatePasshash($email, $user['password']); if ($user['active'] && $user['verified'] && strcmp($email, $user['email']) == 0 && strcmp($passhash, $newPasshash) == 0) { $authID = $this->saveSession(0, $user['user_id'], $ipaddress, $useragent); $this->saveLastvisit($user['user_id']); } else { $user = array(); } } } } } if (!$user || !isset($user['user_id']) || !$user['user_id'] || !$this->createUserSession($user)) { $userID = 0; if (!$user) { $authID = $this->saveSession(0, $userID, $ipaddress, $useragent); } $this->createGuestSession(); } session::set('auth_id', $authID); session::set('user_id', $userID); // Is the site offline? if (!input::isCP() && !config::item('site_online', 'system') && !session::permission('site_access_offline', 'system') && uri::getURI() != 'site/offline' && uri::segment(1) != 'load') { router::redirect('site/offline'); } elseif (input::isCP() && !session::permission('site_access_cp', 'system') && (uri::getURI() != 'cp' && uri::getURI() != 'cp/users/login' && uri::getURI() != 'cp/users/login/license')) { router::redirect('cp/users/login'); } if (!input::isCP() && $this->isLoggedin() && session::permission('site_access_cp', 'system') && uri::segment(1) != 'load' && input::demo(0, '', session::item('user_id'))) { $this->logout(); view::setInfo('For the purposes of this demo you may not use front end of the site under the administrator account. As such we have now logged you out.<br/>Feel free ' . html_helper::anchor('users/signup', 'register on the site') . ' to test user end functionality or ' . html_helper::anchor('users/login', 'login') . ' using your existing account details if you have one already.'); router::redirect(); } }
public function confirm() { $class = uri::segment(4); $action = uri::segment(5) == 'signup' ? 'signup' : 'login'; $service = $this->users_authentication_model->getService($class); if ($service) { loader::library('authentication/' . uri::segment(4), $service['settings'], 'users_authentication_' . $class . '_model'); $this->{'users_authentication_' . $class . '_model'}->confirm($action); } router::redirect('users/login'); }
/** * Confirm reset password * * @access public * @return Response */ public function action_send_reset_password_mail() { // Already logged in Auth::check() and Response::redirect('member'); Util_security::check_method('POST'); Util_security::check_csrf(); $form = $this->form_resend_password(); $val = $form->validation(); if (!$val->run()) { Session::set_flash('error', $val->show_errors()); $this->action_resend_password(); return; } $post = $val->validated(); $message = term('site.password') . 'のリセット方法をメールで送信しました。'; if (!($member_auth = Model_MemberAuth::get4email($post['email']))) { Session::set_flash('message', $message); Response::redirect(conf('login_uri.site')); return; } $member = Model_Member::check_authority($member_auth->member_id); $error_message = ''; $is_transaction_rollback = false; try { $maildata = array(); DB::start_transaction(); $token = Model_MemberPasswordPre::save_with_token($member_auth->member_id, $post['email']); DB::commit_transaction(); $mail = new Site_Mail('memberResendPassword'); $mail->send($post['email'], array('to_name' => $member->name, 'register_url' => sprintf('%s?token=%s', uri::create('member/recover/reset_password'), $token))); Session::set_flash('message', $message); Response::redirect(conf('login_uri.site')); } catch (EmailValidationFailedException $e) { Util_Toolkit::log_error('send mail error: ' . __METHOD__ . ' validation error'); $error_message = 'メール送信エラー'; } catch (EmailSendingFailedException $e) { Util_Toolkit::log_error('send mail error: ' . __METHOD__ . ' sending error'); $error_message = 'メール送信エラー'; } catch (\Database_Exception $e) { $is_transaction_rollback = true; $error_message = \Site_Controller::get_error_message($e, true); } catch (FuelException $e) { $is_transaction_rollback = true; $error_message = $e->getMessage(); } if ($error_message) { if ($is_transaction_rollback && DB::in_transaction()) { DB::rollback_transaction(); } Session::set_flash('error', $error_message); } $this->action_resend_password(); }
public function index() { $service = config::item('default_captcha', 'security'); $settings = config::item('default_captcha_settings', 'security'); // Load library $captcha = loader::library('captcha', $settings, null); if (uri::segment(3) == 'reload') { $captcha->create(); } echo $captcha->render(); exit; }
function path($key = null, $default = null) { $path = self::$path; if (!$path) { $path = url::strip_query(self::raw()); $path = (array) str::split($path, '/'); self::$path = $path; } if ($key === null) { return $path; } return a::get($path, $key, $default); }
public function delete() { // Get URI vars $typeID = (int) uri::segment(6); $fieldID = (int) uri::segment(7); // Get user type if (!$typeID || !($type = $this->users_types_model->getType($typeID))) { view::setError(__('no_type', 'users_types')); router::redirect('cp/userstypes'); } // Delete profile question $this->deleteField('users', 'users_data_' . $type['keyword'], $typeID, $fieldID); }
public function css() { // echo 123; // exit; $template = strtolower(uri::segment(3)); if ($template != 'cp' && !in_array($template, config::item('templates', 'core', 'keywords'))) { error::show404(); } $output = $this->getStylesheets($template, $template == 'cp' ? true : false); codebreeder::setHeader('Content-Type: text/css'); echo $output; exit; }
/** * @param string $url * * @return Request */ private function getRequest($url) { if ($this->baseUri && substr($url, 0, 1) != '/') { throw new \InvalidArgumentException(sprintf("Invalid uri '%s' with baseUri '%s'", $url, $this->baseUri->get(false))); } if ($this->baseUri && $url) { $uri = clone $this->baseUri; $uri->setPath($uri->getPath() . $url); } else { $uri = $url instanceof Uri ? $url : new Uri($url); } return new Request($uri); }
public function submit() { // Does user have permission to submit reports? if (!session::permission('reports_post', 'reports')) { view::setError(__('no_action', 'system')); view::load('system/elements/blank', array('autoclose' => true)); return false; } $resource = uri::segment(3); $itemID = uri::segment(4); if (!$resource || !($resourceID = config::item('resources', 'core', $resource, 'resource_id')) || !config::item('resources', 'core', $resource, 'report')) { view::setError(__('resource_invalid', 'system')); view::load('system/elements/blank', array('autoclose' => true)); return false; } if (!$itemID || !is_numeric($itemID) || $itemID < 0) { view::setError(__('item_invalid', 'reports')); view::load('system/elements/blank', array('autoclose' => true)); return false; } // Does this item exist? if (!($userID = $this->reports_model->getUserID($resource, $itemID))) { view::setError(__('item_invalid', 'reports')); view::load('system/elements/blank', array('autoclose' => true)); return false; } // Did we report this already? if ($this->reports_model->isReported($resourceID, $itemID)) { view::setError(__('report_exists', 'reports')); view::load('system/elements/blank', array('autoclose' => true)); return false; } // Get subjects $subjects = array(); $data = $this->reports_subjects_model->getSubjects(false, true); foreach ($data as $subject) { $subjects[$subject['subject_id']] = $subject['name']; } $subjects = $subjects ? array('' => __('select', 'system')) + $subjects : $subjects; // Assign vars view::assign(array('subjects' => $subjects)); // Process form values if (input::post('do_submit_report')) { $this->_submitReport($resource, $resourceID, $userID, $itemID, $subjects); } // Set title view::setTitle(__('report_submit', 'reports')); // Load view view::load('report/index'); }
public function cities() { $stateID = uri::segment(3); $data = array(); if (input::post('title') == 'any') { $data[''] = __('any', 'system', array(), array(), false); } else { $data[''] = __('select', 'system', array(), array(), false); } foreach (geo_helper::getCities($stateID) as $id => $name) { $data[$id . ' '] = $name; } view::ajaxResponse($data); }
public function checkout() { // Get URI vars $planID = (int) uri::segment(4); $gatewayID = uri::segment(5); // Get plan if (!$planID || !($plan = $this->plans_model->getPlan($planID, false)) || !$plan['active']) { view::setError(__('no_plan', 'billing_plans')); router::redirect('billing/plans'); } $retval = $this->process($gatewayID, session::item('user_id'), 'plans', $planID, $plan['name'], $plan['price'], '', 'billing/plans'); if (!$retval) { router::redirect('billing/plans/payment/' . $planID); } }
public static function get_by_url() { static $instance; if (empty($instance)) { $uri = uri::instance(); $page = $uri->segment(1); $page = ORM::factory('page')->where(array('seoURL' => $page, 'status_id' => 2))->find(); if ($page->id > 0) { $instance = $page; } else { $instance = null; } } return $instance; }
public function _index($showroom, $sub_tool = FALSE) { $url_array = uri::url_array(); list($page_name, $first_node, $item) = $url_array; $page_name = $this->get_page_name($page_name, 'showroom', $showroom->id); # parse the params. $params = explode('|', $showroom->params); $primary = new View("public_showroom/display/wrapper"); # what is the url asking for? if ('get' == $url_array['0'] or empty($first_node)) { # if empty, display default category $primary->items = empty($showroom->home_cat) ? '(Home Category not set)' : self::items_category($page_name, $showroom, (int) $showroom->home_cat); } elseif (is_numeric($first_node)) { if ('0' == substr($first_node, 0, 1)) { $primary->item = self::item($page_name, $first_node, $item); } else { $primary->items = self::items_category($page_name, $showroom, $first_node); } } else { Event::run('system.404'); } # determine the category to highlight. $first_node = empty($first_node) ? $showroom->home_cat : $first_node; # how do we show the category list on every showroom page? $category_list = ''; if (!empty($params[0])) { if ('flat' == $params[0]) { # showing only root categories. $root_cats = ORM::factory('showroom_cat')->where(array('fk_site' => $this->site_id, 'showroom_id' => $showroom->id, 'local_parent' => $showroom->root_id))->orderby(array('lft' => 'asc'))->find_all(); $category_list = Tree::display_flat_tree('showroom', $root_cats, $page_name, $first_node); } else { $category_list = Tree::display_tree('showroom', $showroom->showroom_cats, $page_name, $first_node); } } $primary->categories = $category_list; # add custom javascript; $primary->global_readyJS(self::javascripts($showroom)); # admin js hack. if ($this->client->can_edit($this->site_id)) { $primary->global_readyJS(' $("#click_hook").click(function(){ $().add_toolkit_items("showroom"); }); '); } return $this->wrap_tool($primary, 'showroom', $showroom); }
/** * Returns a feedpost from the current url * * $param bool $unpublished Return unpublished posts too? * @return object|bool $post The feedpost generated by the url, or null if no feedpost found */ public static function get_by_url($unpublished = false) { $uri = uri::instance(); $feed = Feed_Model::get_by_url(); if ($feed && $feed->id > 0) { $post_id = $uri->segment(2); $post = ORM::factory('feedpost', $post_id); if (!$unpublished) { if ($post->status_id == 2) { return $post; } } else { return $post; } } return null; }
public function checkout() { // Get URI vars $packageID = (int) uri::segment(4); $gatewayID = uri::segment(5); // Get package if (!$packageID || !($package = $this->credits_model->getPackage($packageID)) || !$package['active']) { view::setError(__('no_package', 'billing_credits')); router::redirect('billing/credits'); } // Set package name $name = __('credits_info', 'billing_credits', array('%s' => $package['credits'])); $retval = $this->process($gatewayID, session::item('user_id'), 'credits', $packageID, $name, $package['price'], '', 'billing/credits'); if (!$retval) { router::redirect('billing/credits/payment/' . $packageID); } }