Project

General

Profile

« Previous | Next » 

Revision 883

Added by thorn almost 16 years ago

added redirect-type (301/302) to menu_link

View differences:

index.php
55 55

  
56 56
// redirect menu-link
57 57
$this_page_id = PAGE_ID;
58
if(version_compare(phpversion(), '4.3', '>=')) $php43 = TRUE; else $php43 = FALSE;
58 59
$query_this_module = $database->query("SELECT module, block FROM ".TABLE_PREFIX."sections WHERE page_id = '$this_page_id' AND module = 'menu_link'");
59 60
if($query_this_module->numRows() == 1) { // This is a menu_link. Get link of target-page and redirect
60 61
	// get target_page_id
61 62
	$table = TABLE_PREFIX.'mod_menu_link';
62
	$query_tpid = $database->query("SELECT target_page_id, anchor, extern FROM $table WHERE page_id = '$this_page_id'");
63
	$query_tpid = $database->query("SELECT * FROM $table WHERE page_id = '$this_page_id'");
63 64
	if($query_tpid->numRows() == 1) {
64 65
		$res=$query_tpid->fetchRow();
65 66
		$target_page_id = $res['target_page_id'];
67
		$r_type = $res['redirect_type'];
66 68
		$anchor = $res['anchor'];
67 69
		$extern = $res['extern'];
68 70
		if($anchor != '0') $anchor = ''.$anchor;
69 71
		else $anchor = FALSE;
72
		// set redirect-type
73
		if($r_type=='301') {
74
			if($php43) @header('HTTP/1.1 301 Moved Permanently', TRUE, 301);
75
			else @header('HTTP/1.1 301 Moved Permanently');
76
		}
70 77
		if($target_page_id == -1) {
71 78
			if($extern!='') {
72 79
				header("Location: $extern".($anchor?'#'.$anchor:''));
......
78 85
			if($query_link->numRows() == 1) {
79 86
				$res=$query_link->fetchRow();
80 87
				$target_page_link = $res['link'];
81
				// redirect
82 88
				header('Location: '.WB_URL.PAGES_DIRECTORY.$target_page_link.PAGE_EXTENSION.($anchor?'#'.$anchor:''));
83 89
				exit;
84 90
			}

Also available in: Unified diff