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


PHP common::Redirect方法代码示例

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


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

示例1: WhichPage

 /**
  * Determine a user's language preference and redirect them to the appropriate homepage if necessary
  * How do we differentiate between a user requesting the home page (to get the default language content) and a request that should be redirected?
  * 	... don't create any empty links (set $config['homepath'] to false)
  * 	... redirect all empty paths?
  *
  */
 function WhichPage($path)
 {
     global $config;
     $home_title = $config['homepath'];
     $config['homepath_key'] = false;
     $config['homepath'] = false;
     //only if homepage
     if (!empty($path)) {
         return $path;
     }
     //only if the homepage is translated
     $list = $this->GetList($config['homepath_key']);
     if (!$list) {
         common::Redirect(common::GetUrl($home_title));
         //dies
     }
     //only if user has language settings
     if (empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
         common::Redirect(common::GetUrl($home_title));
         //dies
     }
     //check for appropriate translation
     $langs = $this->RequestLangs();
     foreach ($langs as $lang => $importance) {
         if (isset($list[$lang])) {
             $title = common::IndexToTitle($list[$lang]);
             common::Redirect(common::GetUrl($title));
             //dies
         }
     }
     common::Redirect(common::GetUrl($home_title));
 }
开发者ID:rizub4u,项目名称:gpEasy-CMS,代码行数:39,代码来源:MultiLanguage.php

示例2: CheckSimilar

 /**
  * Redirect the request if the requested page closely matches an existing page
  * If it's just a difference of case, then the similarity will be 100%
  */
 function CheckSimilar()
 {
     global $config;
     $similar = $this->SimilarTitleArray($this->requested);
     reset($similar);
     $first_title = key($similar);
     $first_percent = current($similar);
     if ($config['auto_redir'] > 0 && $first_percent >= $config['auto_redir']) {
         common::Redirect($first_title);
     }
 }
开发者ID:rizub4u,项目名称:gpEasy-CMS,代码行数:15,代码来源:special_missing.php

示例3: CheckSimilar

 /**
  * Redirect the request if the requested page closely matches an existing page
  * If it's just a difference of case, then the similarity will be 100%
  *
  */
 function CheckSimilar()
 {
     global $config;
     $requested = trim($this->requested, '/');
     $similar = $this->SimilarTitleArray($requested);
     $first_title = key($similar);
     $first_percent = current($similar);
     if ($config['auto_redir'] > 0 && $first_percent >= $config['auto_redir']) {
         $redirect = common::GetUrl($first_title, http_build_query($_GET), false);
         common::Redirect($redirect);
     }
 }
开发者ID:barbrick,项目名称:gpEasy-CMS,代码行数:17,代码来源:special_missing.php

示例4: WhichPage

 public function WhichPage($path)
 {
     global $config;
     $home_title = $config['homepath'];
     $home_key = $config['homepath_key'];
     $config['homepath_key'] = false;
     $config['homepath'] = false;
     //only if homepage
     if (!empty($path) && $path !== $home_title) {
         return $path;
     }
     $translated_key = $this->WhichTranslation($home_key);
     if (!is_null($translated_key)) {
         $home_title = common::IndexToTitle($translated_key);
     }
     //redirect if needed
     if ($home_title != $path) {
         common::Redirect(common::GetUrl($home_title));
     }
 }
开发者ID:Typesetter,项目名称:Multi-Language,代码行数:20,代码来源:MultiLanguage.php

示例5: PostCommands

 /**
  * Run commands
  *
  */
 public function PostCommands()
 {
     global $page;
     $cmd = common::GetCommand();
     if (empty($cmd)) {
         //redirect to correct url if needed
         SimpleBlogCommon::UrlQuery($this->post_id, $expected_url, $query);
         $expected_url = str_replace('&', '&', $expected_url);
         //because of htmlspecialchars($cattitle)
         if ($page->requested != $expected_url) {
             $expected_url = common::GetUrl($expected_url, $query, false);
             common::Redirect($expected_url);
         }
         return;
     }
     switch ($cmd) {
         case 'Add Comment':
             $this->AddComment();
             break;
     }
 }
开发者ID:jozefkrz,项目名称:gpEasy-CMS,代码行数:25,代码来源:SimpleBlogPage.php

示例6: RunAdminScript

 /**
  * Find the requested admin script and execute it if the user has permissions to view it
  *
  */
 function RunAdminScript()
 {
     global $dataDir, $langmessage;
     //resolve request for /Admin_Theme_Content if the request is for /Admin_Theme_Conent/1234
     $parts = explode('/', $this->requested);
     do {
         $request_string = implode('/', $parts);
         $scriptinfo = false;
         $scripts = admin_tools::AdminScripts();
         if (isset($scripts[$request_string])) {
             $scriptinfo = $scripts[$request_string];
             if (admin_tools::HasPermission($request_string)) {
                 admin_display::OrganizeFrequentScripts($request_string);
                 gpOutput::ExecInfo($scriptinfo);
                 return;
             } else {
                 message($langmessage['not_permitted']);
                 $parts = array();
             }
         } elseif (count($scripts) > 0) {
             //check case
             $case_check = array_keys($scripts);
             $case_check = array_combine($case_check, $case_check);
             $case_check = array_change_key_case($case_check, CASE_LOWER);
             $lower = strtolower($request_string);
             if (isset($case_check[$lower])) {
                 $location = common::GetUrl($case_check[$lower], http_build_query($_GET), false);
                 common::Redirect($location);
             }
         }
         //these are here because they should be available to everyone
         switch ($request_string) {
             case 'Admin_Browser':
                 includeFile('admin/admin_browser.php');
                 new admin_browser();
                 return;
             case 'Admin_Preferences':
                 $this->label = $langmessage['Preferences'];
                 includeFile('admin/admin_preferences.php');
                 new admin_preferences();
                 return;
             case 'Admin_About':
                 $this->label = 'About gpEasy';
                 includeFile('admin/admin_about.php');
                 new admin_about();
                 return;
             case 'Admin_Finder':
                 if (admin_tools::HasPermission('Admin_Uploaded')) {
                     includeFile('thirdparty/finder/connector.php');
                     return;
                 }
                 break;
         }
         array_pop($parts);
     } while (count($parts));
     $this->AdminPanel();
 }
开发者ID:jdearaujo,项目名称:gpEasy-CMS,代码行数:61,代码来源:admin_display.php

示例7: ShowPage

 /**
  * Display a blog page with multiple blog posts
  *
  */
 public function ShowPage()
 {
     global $page;
     $per_page = SimpleBlogCommon::$data['per_page'];
     $page_num = 0;
     $expected_q = '';
     if (isset($_GET['page']) && is_numeric($_GET['page'])) {
         $page_num = (int) $_GET['page'];
         $expected_q = 'page=' . $page_num;
     }
     //redirect if the request isn't correct
     if ($page->requested != SimpleBlogCommon::$root_url) {
         $expected_url = common::GetUrl(SimpleBlogCommon::$root_url, $expected_q, false);
         common::Redirect($expected_url);
     }
     $start = $page_num * $per_page;
     $include_drafts = common::LoggedIn();
     $show_posts = SimpleBlogCommon::WhichPosts($start, $per_page, $include_drafts);
     $this->ShowPosts($show_posts);
     //pagination links
     echo '<p class="blog_nav_links">';
     if ($page_num > 0) {
         $html = common::Link('Special_Blog', '%s');
         echo gpOutput::GetAddonText('Blog Home', $html);
         echo '&nbsp;';
         $html = common::Link('Special_Blog', '%s', 'page=' . ($page_num - 1), 'class="blog_newer"');
         echo gpOutput::GetAddonText('Newer Entries', $html);
         echo '&nbsp;';
     }
     if (($page_num + 1) * $per_page < SimpleBlogCommon::$data['post_count']) {
         $html = common::Link('Special_Blog', '%s', 'page=' . ($page_num + 1), 'class="blog_older"');
         echo gpOutput::GetAddonText('Older Entries', $html);
     }
     echo '</p>';
 }
开发者ID:Typesetter,项目名称:Simple-Blog,代码行数:39,代码来源:SimpleBlog.php

示例8: __construct

 /**
  * Check the path of the img, return full path of image if the requested image is found
  *
  */
 function __construct()
 {
     global $dataDir;
     if (!isset($_GET['w']) || !isset($_GET['h']) || !isset($_GET['img'])) {
         self::Send404();
         //dies
     }
     $img = $_GET['img'];
     $height = $_GET['h'];
     $width = $_GET['w'];
     $index = $_GET['i'];
     if (!is_numeric($height) || !is_numeric($width)) {
         self::Send404();
         //dies
     }
     $img = gpFiles::NoNull($img);
     //check file path
     if (strpos($img, './') !== false || strpos($img, '%2f') !== false || strpos($img, '%2F') !== false) {
         return false;
     }
     //make sure the index is set
     gp_resized::SetIndex();
     if (!isset(self::$index[$index])) {
         self::Send404();
         //dies
     }
     //if the image has been renamed, redirect to the new name
     $index_img = self::$index[$index];
     if ($index_img != $img) {
         $path = common::GetDir('/include/image.php', false) . '?i=' . $index . '&w=' . $width . '&h=' . $height . '&img=' . rawurlencode($index_img);
         common::Redirect($path);
     }
     $info = self::ImageInfo($img, $width, $height);
     $folder = $dataDir . '/data/_resized/' . $info['index'];
     $full_path = $folder . '/' . $info['name'];
     //if it exists return true
     if (file_exists($full_path)) {
         header('Cache-Control: public, max-age=5184000');
         //60 days
         //attempt to send 304
         $stats = lstat($full_path);
         if ($stats) {
             common::Send304(common::GenEtag($stats['mtime'], $stats['size']));
         }
         header('Content-Transfer-Encoding: binary');
         header('Content-Type: ' . $info['ctype']);
         readfile($full_path);
         die;
     }
     //redirect to next largest image if available
     $usage = self::GetUsage($info['index']);
     foreach ($usage as $size => $data) {
         if (!$data['uses']) {
             continue;
         }
         list($use_width, $use_height) = explode('x', $size);
         if ($use_width >= $width && $use_height > $height || $use_width > $width && $use_height >= $height) {
             $path = common::GetDir('/include/image.php', false) . '?i=' . $index . '&w=' . $use_width . '&h=' . $use_height . '&img=' . rawurlencode($img);
             common::Redirect($path);
             //dies
         }
     }
     //redirect to full size image
     $original = common::GetDir('/data/_uploaded' . $img, false);
     common::Redirect($original);
     //dies
 }
开发者ID:VTAMAGNO,项目名称:gpEasy-CMS,代码行数:71,代码来源:image.php

示例9: EnableComponent

 /**
  * Re-enable components that were disabled because of fatal errors
  *
  */
 static function EnableComponent()
 {
     includeFile('admin/admin_errors.php');
     admin_errors::ClearError($_REQUEST['hash']);
     $title = common::WhichPage();
     common::Redirect(common::GetUrl($title, '', false));
 }
开发者ID:barbrick,项目名称:gpEasy-CMS,代码行数:11,代码来源:sessions.php

示例10: GetScriptInfo

 /**
  *
  * @static
  */
 static function GetScriptInfo(&$requested, $redirect = true)
 {
     global $dataDir, $gp_index, $gp_titles;
     $scripts['special_site_map']['script'] = '/include/special/special_map.php';
     $scripts['special_site_map']['class'] = 'special_map';
     $scripts['special_galleries']['script'] = '/include/special/special_galleries.php';
     $scripts['special_galleries']['class'] = 'special_galleries';
     $scripts['special_contact']['script'] = '/include/special/special_contact.php';
     $scripts['special_contact']['class'] = 'special_contact';
     $scripts['special_missing']['script'] = '/include/special/special_missing.php';
     $scripts['special_missing']['class'] = 'special_missing';
     $scripts['special_gpsearch']['script'] = '/include/special/special_search.php';
     $scripts['special_gpsearch']['class'] = 'special_gpsearch';
     //check for use of a index instead of a page title
     $translated = common::SpecialHref($requested);
     if ($translated != $requested) {
         $requested = $translated;
         if ($redirect) {
             $title = common::GetUrl($requested, http_build_query($_GET), false);
             common::Redirect($title);
         }
     }
     //get the script info
     $parts = explode('/', $requested);
     do {
         $requested = implode('/', $parts);
         if (isset($gp_index[$requested])) {
             $index = $gp_index[$requested];
             // Merge page data & script data if both exist
             if (isset($scripts[$index]) && isset($gp_titles[$index])) {
                 return array_merge($scripts[$index], $gp_titles[$index]);
             }
             if (isset($scripts[$index])) {
                 return $scripts[$index];
             }
             if (isset($gp_titles[$index])) {
                 return $gp_titles[$index];
             }
         }
         array_pop($parts);
     } while (count($parts));
     return false;
 }
开发者ID:Knuzen,项目名称:gpEasy-CMS,代码行数:47,代码来源:special.php

示例11: ShowPost

 /**
  * Output the html for a single blog post
  * Handle comment actions
  */
 function ShowPost($cmd)
 {
     global $langmessage, $page;
     $post = $this->GetPostContent($this->post_id);
     if ($post === false) {
         message($langmessage['OOPS']);
         return;
     }
     $commentSaved = false;
     switch ($cmd) {
         //redirect to correct url if needed
         case 'post':
             SimpleBlogCommon::UrlQuery($this->post_id, $expected_url, $query);
             $expected_url = str_replace('&amp;', '&', $expected_url);
             //because of htmlspecialchars($cattitle)
             if ($page->requested != $expected_url) {
                 $expected_url = common::GetUrl($expected_url, $query, false);
                 common::Redirect($expected_url, 301);
             }
             break;
             //close comments
         //close comments
         case 'closecomments':
             $this->CloseComments($this->post_id);
             break;
         case 'opencomments':
             $this->OpenComments($this->post_id);
             break;
             //commments
         //commments
         case 'Add Comment':
             if ($this->AddComment($this->post_id)) {
                 $commentSaved = true;
             } else {
                 echo '<div class="comment_container">';
                 $this->CommentForm($this->post_id, true);
                 echo '</div>';
                 return;
             }
             break;
         case 'delete_comment':
             $this->DeleteComment($this->post_id);
             break;
     }
     $post = $this->GetPostContent($this->post_id);
     if (!common::LoggedIn() && SimpleBlogCommon::AStrValue('drafts', $this->post_id)) {
         //How to make 404 page?
         message($langmessage['OOPS']);
         return;
     }
     $this->ShowPostContent($post, $this->post_id);
     $page->label = SimpleBlogCommon::Underscores($post['title']);
     //blog categories
     if (isset($post['categories']) && count($post['categories'])) {
         $temp = array();
         foreach ($post['categories'] as $catindex) {
             $title = SimpleBlogCommon::AStrValue('categories', $catindex);
             if (!$title) {
                 continue;
             }
             if (SimpleBlogCommon::AStrValue('categories_hidden', $catindex)) {
                 continue;
             }
             $temp[] = SimpleBlogCommon::CategoryLink($catindex, $title, $title);
         }
         if (count($temp)) {
             echo '<div class="category_container">';
             echo '<b>';
             echo gpOutput::GetAddonText('Categories');
             echo ':</b> ';
             echo implode(', ', $temp);
             echo '</div>';
         }
     }
     SimpleBlog::PostLinks($this->post_id);
     //comments
     if (SimpleBlogCommon::$data['allow_comments']) {
         echo '<div class="comment_container">';
         $this->ShowComments($this->post_id);
         if (!$commentSaved) {
             $this->CommentForm($this->post_id);
         }
         echo '</div>';
     }
 }
开发者ID:Bomberus,项目名称:gpEasy-CMS,代码行数:89,代码来源:SimpleBlog.php

示例12: WhichPage

 /**
  * Return the name of the page being requested based on $_SERVER['REQUEST_URI']
  * May also redirect the request
  *
  * @return string The title to display based on the request uri
  *
  */
 function WhichPage()
 {
     global $config, $gp_internal_redir, $gp_menu;
     if (isset($gp_internal_redir)) {
         return $gp_internal_redir;
     }
     $path = common::CleanRequest($_SERVER['REQUEST_URI']);
     $pos = strpos($path, '?');
     if ($pos !== false) {
         $path = substr($path, 0, $pos);
     }
     $path = gpPlugin::Filter('WhichPage', array($path));
     //redirect if an "external link" is the first entry of the main menu
     if (empty($path) && isset($gp_menu[$config['homepath_key']])) {
         $homepath_info = $gp_menu[$config['homepath_key']];
         if (isset($homepath_info['url'])) {
             common::Redirect($homepath_info['url'], 302);
         }
     }
     if (empty($path)) {
         return $config['homepath'];
     }
     if (isset($config['homepath']) && $path == $config['homepath']) {
         common::Redirect(common::GetUrl(''));
     }
     return $path;
 }
开发者ID:rizub4u,项目名称:gpEasy-CMS,代码行数:34,代码来源:common.php

示例13: SaveNew

 /**
  * Save a new blog post
  * @return bool
  *
  */
 function SaveNew()
 {
     global $langmessage, $gpAdmin;
     //use current data file or create new one
     SimpleBlogCommon::$data['post_index']++;
     $new_id = SimpleBlogCommon::$data['post_index'];
     //add new_id to list of indeces
     $str_index = SimpleBlogCommon::AStrToArray('str_index');
     array_unshift($str_index, $new_id);
     SimpleBlogCommon::$data['str_index'] = SimpleBlogCommon::AStrFromArray($str_index);
     //save to data file
     $post = array();
     if (!self::SavePost($new_id, $post)) {
         return false;
     }
     //redirect to new post
     $url = common::GetUrl('Admin_Blog', '', false);
     common::Redirect($url);
 }
开发者ID:jozefkrz,项目名称:gpEasy-CMS,代码行数:24,代码来源:Posts.php

示例14: RunAdminScript

 /**
  * Find the requested admin script and execute it if the user has permissions to view it
  *
  */
 function RunAdminScript()
 {
     global $dataDir, $langmessage;
     //resolve request for /Admin_Theme_Content if the request is for /Admin_Theme_Conent/1234
     $parts = explode('/', $this->requested);
     do {
         $request_string = implode('/', $parts);
         $scriptinfo = false;
         $scripts = admin_tools::AdminScripts();
         if (isset($scripts[$request_string])) {
             $scriptinfo = $scripts[$request_string];
             if (admin_tools::HasPermission($request_string)) {
                 if (isset($scriptinfo['addon'])) {
                     gpPlugin::SetDataFolder($scriptinfo['addon']);
                 }
                 admin_display::OrganizeFrequentScripts($request_string);
                 if (isset($scriptinfo['script'])) {
                     require $dataDir . $scriptinfo['script'];
                 }
                 if (isset($scriptinfo['class'])) {
                     new $scriptinfo['class']();
                 }
                 gpPlugin::ClearDataFolder();
                 return;
             } else {
                 message($langmessage['not_permitted']);
                 $parts = array();
             }
         } elseif (count($scripts) > 0) {
             //check case
             $case_check = array_keys($scripts);
             $case_check = array_combine($case_check, $case_check);
             $case_check = array_change_key_case($case_check, CASE_LOWER);
             $lower = strtolower($request_string);
             if (isset($case_check[$lower])) {
                 $location = common::GetUrl($case_check[$lower], '', false);
                 common::Redirect($location);
             }
         }
         //these are here because they should be available to everyone
         switch ($request_string) {
             case 'Admin_Browser':
                 includeFile('admin/admin_browser.php');
                 new admin_browser();
                 return;
             case 'Admin_Preferences':
                 includeFile('admin/admin_preferences.php');
                 new admin_preferences();
                 return;
             case 'Admin_About':
                 includeFile('admin/admin_about.php');
                 new admin_about();
                 return;
             case 'Admin_Finder':
                 includeFile('thirdparty/elfinder/connector.php');
                 return;
         }
     } while (array_pop($parts));
     $this->AdminPanel();
 }
开发者ID:rizub4u,项目名称:gpEasy-CMS,代码行数:64,代码来源:admin_display.php

示例15: GetScriptInfo

 /**
  *
  * @static
  */
 function GetScriptInfo(&$requested)
 {
     global $dataDir, $gp_index, $gp_titles;
     $scripts['special_site_map']['script'] = '/include/special/special_map.php';
     $scripts['special_site_map']['class'] = 'special_map';
     $scripts['special_galleries']['script'] = '/include/special/special_galleries.php';
     $scripts['special_galleries']['class'] = 'special_galleries';
     $scripts['special_contact']['script'] = '/include/special/special_contact.php';
     $scripts['special_contact']['class'] = 'special_contact';
     $scripts['special_missing']['script'] = '/include/special/special_missing.php';
     $scripts['special_missing']['class'] = 'special_missing';
     if (isset($gp_index[$requested])) {
         $index = $gp_index[$requested];
         if (isset($scripts[$index])) {
             return $scripts[$index];
         }
         if (isset($gp_titles[$index])) {
             return $gp_titles[$index];
         }
     }
     //resolve if the requested path matches a data index
     $title = common::IndexToTitle(strtolower($requested));
     if ($title) {
         $title = common::GetUrl($title, '', false);
         common::Redirect($title);
     }
     return false;
 }
开发者ID:rizub4u,项目名称:gpEasy-CMS,代码行数:32,代码来源:special.php


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