当前位置: 首页>>代码示例>>PHP>>正文


PHP uri::segment方法代码示例

本文整理汇总了PHP中uri::segment方法的典型用法代码示例。如果您正苦于以下问题:PHP uri::segment方法的具体用法?PHP uri::segment怎么用?PHP uri::segment使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在uri的用法示例。


在下文中一共展示了uri::segment方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: view

 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');
 }
开发者ID:soremi,项目名称:tutornavi,代码行数:35,代码来源:news.php

示例2: __construct

 public function __construct()
 {
     parent::__construct();
     if (!config::item('news_blog', 'news') && uri::segment(1) != 'news') {
         router::redirect('news/' . utf8::substr(uri::getURI(), 5));
     }
 }
开发者ID:soremi,项目名称:tutornavi,代码行数:7,代码来源:blog.php

示例3: delete

 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']);
 }
开发者ID:soremi,项目名称:tutornavi,代码行数:25,代码来源:blocked.php

示例4: delete

 public function delete()
 {
     // Get URI vars
     $fieldID = (int) uri::segment(7);
     // Delete custom field
     $this->deleteField('pages', 'pages_data', 0, $fieldID);
 }
开发者ID:soremi,项目名称:tutornavi,代码行数:7,代码来源:pages.php

示例5: render

 public function render()
 {
     if (!$this->links) {
         throw new Kohana_User_Exception("Navbar not implemented correctly", "Links have not been set. Please call <code>&#36;navbar->set_links({&#36;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;
         }
     }
 }
开发者ID:sydlawrence,项目名称:SocialFeed,代码行数:29,代码来源:Navbar.php

示例6: delete

 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);
 }
开发者ID:soremi,项目名称:tutornavi,代码行数:9,代码来源:pictures.php

示例7: click

 public function click()
 {
     $bannerID = (int) uri::segment(3);
     if ($bannerID && $bannerID > 0) {
         loader::model('banners/banners');
         $this->banners_model->updateClicks($bannerID);
     }
     exit;
 }
开发者ID:soremi,项目名称:tutornavi,代码行数:9,代码来源:banners.php

示例8: __construct

 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();
     }
 }
开发者ID:soremi,项目名称:tutornavi,代码行数:56,代码来源:session.php

示例9: confirm

 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');
 }
开发者ID:soremi,项目名称:tutornavi,代码行数:11,代码来源:connect.php

示例10: index

 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;
 }
开发者ID:soremi,项目名称:tutornavi,代码行数:12,代码来源:captcha.php

示例11: delete

 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);
 }
开发者ID:soremi,项目名称:tutornavi,代码行数:13,代码来源:users.php

示例12: css

 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;
 }
开发者ID:soremi,项目名称:tutornavi,代码行数:13,代码来源:load.php

示例13: submit

 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');
 }
开发者ID:soremi,项目名称:tutornavi,代码行数:50,代码来源:report.php

示例14: cities

 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);
 }
开发者ID:soremi,项目名称:tutornavi,代码行数:14,代码来源:geo.php

示例15: checkout

 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);
     }
 }
开发者ID:soremi,项目名称:tutornavi,代码行数:15,代码来源:plans.php


注:本文中的uri::segment方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。