deeemm-cms /includes/build_navigation.php

Language PHP Lines 160
MD5 Hash 642224e5dac17112901f0722a1a2da34 Estimated Cost $2,509 (why?)
Repository https://bitbucket.org/mpercy/deeemm-cms View Raw File View Project SPDX
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
<?php

defined( '_INDM' ) or die( 'POSSIBLE HACK ATTEMPT!' );


/*===========================================================================
Setup admin links
===========================================================================*/
if ($user == 'ADMIN'){

	if ($page == '' || !isset($page)) {
		$sql_query = mysql_query("SELECT * FROM `" . $db_table_prefix . "core_structure` WHERE `order` = 1");
		while($sql_result = mysql_fetch_array($sql_query)) {
			$page = $sql_result[table];
		}

		$sql_query = mysql_query("SELECT DISTINCT `id` FROM `" . $db_table_prefix . 'cat_' . $page . "` WHERE `order` = 1");
		while($sql_result = @mysql_fetch_array($sql_query)) {
			$id = $sql_result[id];
		}

	}

	//16-06-08
	//if $id not set get highest ranking page by order
	if ($id == '' || !isset($id)) {
		$sql_query = mysql_query("SELECT DISTINCT * FROM `" . $db_table_prefix . 'cat_' . $page . "` WHERE `order` > 0");
		while($sql_result = @mysql_fetch_array($sql_query)) {
			$id = $sql_result[id];
		}
	}

		$empty_normal_page_admin_href = "<A href='$default_url".$admin_dir.""."index.php?action=add'><img class='icon' title='Add' src='$default_url".$templates_dir."images/icons/article_add.gif'></A> <A href='$default_url".$admin_dir."index.php?action=add_link'><img class='icon' title='Add' src='$default_url".$templates_dir."images/icons/link_add.gif'></A>";
		$normal_page_admin_href = "<A href='$default_url".$admin_dir.""."index.php?action=add'><img class='icon' title='Add' src='$default_url".$templates_dir."images/icons/article_add.gif'></A> <A href='$default_url".$admin_dir."index.php?action=add_link'><img class='icon' title='Add' src='$default_url".$templates_dir."images/icons/link_add.gif'></A> <A href='$default_url".$admin_dir."index.php?page=$page&amp;id=$id&amp;action=edit'><img class='icon' title='Edit' src='$default_url"."$templates_dir"."images/icons/article_edit.gif'></A> <A href='$default_url".$admin_dir."index.php?page=$page&amp;id=$id&amp;action=delete' onClick=\"javascript:return confirm('[lan]delete_warning[/lan]')\"><img class='icon' title='Delete' src='$default_url".$templates_dir."images/icons/article_delete.gif'></A>";

		$empty_media_page_admin_href = "<A href='$default_url".$admin_dir.""."index.php?action=add_media'><img class='icon' title='Add' src='$default_url".$templates_dir."images/icons/image_add.gif'></A> ";
		$media_page_admin_href = "<A href='$default_url".$admin_dir.""."index.php?action=add_media'><img class='icon' title='Add' src='$default_url".$templates_dir."images/icons/image_add.gif'></A> <A href='$default_url".$admin_dir. "index.php?page=$page&amp;id=$id&amp;action=edit'><img class='icon' title='Edit' src='$default_url"."$templates_dir"."images/icons/image_edit.gif'></A> <A href='$default_url".$admin_dir. "index.php?page=$page&amp;id=$id&amp;action=delete' onClick=\"javascript:return confirm('[lan]delete_warning[/lan]')\"><img class='icon' title='Delete' src='$default_url".$templates_dir."images/icons/image_delete.gif'></A>";
		$media_library_image_edit = "<A href='$default_url".$admin_dir. "index.php?page=$page&amp;action=add_media'><img class='icon' title='Add' src='$default_url".$templates_dir."images/icons/image_add.gif'></A> <A href='$default_url" . $admin_dir. "index.php?page=$page&amp;action=edit_media&amp;id=$id'><img class='icon' title='Edit' src='$default_url"."$templates_dir"."images/icons/image_edit.gif'></A> <a href='$default_url" . $admin_dir. "index.php?page=$page&amp;id=$id&amp;action=delete' onClick=\"javascript:return confirm('[lan]delete_warning[/lan]')\"><img class='icon' title='Delete' src='$default_url".$templates_dir."images/icons/image_delete.gif'></A>&nbsp&nbsp&nbsp" . $lf;
		$media_library_index_edit = "<A href='$default_url".$admin_dir."index.php?page=$page&amp;action=add_media'><img class='icon' title='Add' src='$default_url".$templates_dir."images/icons/image_add.gif'></A>&nbsp&nbsp&nbsp" . $lf;
		$media_href = "<A href='$default_url".$admin_dir."index.php?page=$page&amp;action=add_media'><img class='icon' title='Add' src='$default_url".$templates_dir."images/icons/image_add.gif'></A>" . $lf;

//		$admin_nav = '<A href="'.$default_url.$admin_dir.'" title="Modify Admin Settings">[lan]admin[/lan]</A>';

		$list_article_edit = "<A href='$default_url".$admin_dir."index.php?page=$page&amp;action=add'><img class='icon' title='Add' src='$default_url".$templates_dir."images/icons/article_add.gif'></A> <A href='$default_url" . $admin_dir. "index.php?page=$page&amp;action=edit&amp;id=$id'><img class='icon' title='Edit' src='$default_url"."$templates_dir"."images/icons/article_edit.gif'></A> <a href='$default_url".$admin_dir. "index.php?page=$page&amp;id=$id&amp;action=delete' onClick=\"javascript:return confirm('[lan]delete_warning[/lan]')\"><img class='icon' title='Delete' src='$default_url".$templates_dir."images/icons/article_delete.gif'></A>" . $lf;
		$list_index_edit = "<A href='$default_url".$admin_dir."index.php?page=$page&amp;action=add'><img class='icon' title='Add' src='$default_url".$templates_dir."images/icons/article_add.gif'></A>" . $lf;

		$sitemap_category_edit = '';
		$sitemap_subcategory_edit = '';

}

/*===========================================================================
Create main menu categories links from table array
===========================================================================*/
foreach($all_tables as $value){

	//get main menu item data
	$sql_query = mysql_query("SELECT * FROM `" . $db_table_prefix . "core_structure` WHERE `table` = '$value' ORDER BY `order`");
	while($sql_result = mysql_fetch_array($sql_query)) {
		$type = $sql_result[type];
		$category = $sql_result[category_lan_ . $language];
		$tool_tip = $sql_result[tool_tip_lan_ . $language];
		$display_in_sitemap = $sql_result[display_in_sitemap];
	}

	//get highest order page
	$sql_query = mysql_query("SELECT * FROM `" . $db_table_prefix . 'cat_' . "$value` WHERE `id` > 0 ORDER BY `order` LIMIT 1");
	if($sql_result = mysql_fetch_array($sql_query)){
		$nav_id = $sql_result[id];
		$page_exists = TRUE;
	} else {
		$page_exists = FALSE;
	}

	if (isset($display_in_sitemap) && $display_in_sitemap <> ''){


		switch ($type) {

			//suppress sub menus if list type
			case 'list';
			if($page_exists){
				$navmenu .= "<li><A href='$default_url"."index.php?page=$value' title='".$tool_tip."'>".$category.$navigation_seperator."</a>";
			} ELSE {
				$navmenu .= "<li><A href='$default_url"."index.php?page=messagebox&amp;message=no_data' title='".$tool_tip."'>".$category.$navigation_seperator."</a>";
			}
			break;


			//suppress sub menus if media type
			case 'media';
			if($page_exists){
				$navmenu .= "<li><A href='$default_url"."index.php?page=$value' title='".$tool_tip."'>".$category.$navigation_seperator."</a>";
			} ELSE {
				$navmenu .= "<li><A href='$default_url"."index.php?page=messagebox&amp;message=no_media' title='".$tool_tip."'>".$category.$navigation_seperator."</a>";
			}
			break;


			case 'normal';
			//get top link
			$sql_query = mysql_query("SELECT * FROM `" . $db_table_prefix . 'cat_' . "$value` WHERE `id` > 0 ORDER BY `order` LIMIT 1");
			if($page_exists){
				//if page is link type, display link
				if (isset($sql_result[link_url]) && $sql_result[link_url] <> '') {
					$navmenu .= "<li><a href='$sql_result[link_url]' title='" . $sql_result[tool_tip_lan_ . $language] . "'>".$category.$navigation_seperator."</a>";
				} else {
					$nav_id = $sql_result[id];
					$navmenu .= "<li><a href='$default_url"."index.php?page=$value&amp;id=$nav_id' title='".$tool_tip."'>".$category.$navigation_seperator."</a>";
				}

			} else {
				//no data
				$navmenu .= "<li><A href='$default_url"."index.php?page=messagebox&amp;message=no_data' title='".$tool_tip."'>".$category.$navigation_seperator."</a>";
			}

			//get sub menu data from database and create array of sub menu categories
			$sub_tables = '';
			$sql_query = mysql_query("SELECT * FROM `" . $db_table_prefix . 'cat_' . "$value` WHERE `parent` = '$value' ORDER BY `order`");
			while($sql_result = mysql_fetch_array($sql_query)){
				$sub_tables[] .= $sql_result[category];
			}

			//if array has more than one category create a sub menu item for it
			if (count($sub_tables) > 1){
				$navmenu .= "<ul>";
				foreach($sub_tables as $sub_value){
					$sql_query = mysql_query("SELECT * FROM `" . $db_table_prefix . 'cat_' . "$value` WHERE `category` = '$sub_value'");
					while($sql_result = mysql_fetch_array($sql_query)){
						if (isset($sql_result[link_url]) && $sql_result[link_url] <> '') {
							$navmenu .= "<li><a href='$sql_result[link_url]' title='" . $sql_result[tool_tip_lan_ . $language] . "'>" . $sql_result[title_lan_ . $language] . "</a></li>";
						} else {
							$navmenu .= "<li><a href='$default_url"."index.php?page=$sql_result[parent]&amp;id=$sql_result[id]' title='" . $sql_result[tool_tip_lan_ . $language] . "'>" . $sql_result[title_lan_ . $language] . "</a></li>";
						}
					}
				}
				$navmenu .= "</ul>";
			}
			break;

		}//endif $display_in_sitemap
	}//end select $type
	$navmenu .= "</li>";
}


//Add log in/out link if enabled
if ($conf[login_link_enabled]) {
	if ($logged_in == true) {
		$navmenu .= "<li><A href='$default_url"."index.php?page=logout' title='Log Out'>Log Out".$navigation_seperator."</a></li>";
	} else  {
		$navmenu .= "<li><A href='$default_url"."index.php?page=login' title='Log In'>Log In".$navigation_seperator."</a></li>";
	}
}


//$navmenu .= "<li>$admin_nav"."</li>";

?>
Back to Top