Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)

Paste

Pasted as PHP by Shock ( 17 years ago )
<?php
/*-------------------------------------------------------+
| PHP-Fusion Content Management System
| Copyright (C) 2002 - 2008 Nick Jones
| http://www.php-fusion.co.uk/
+--------------------------------------------------------+
| Filename: weblinks.php
| Author: Nick Jones (Digitanium)
+--------------------------------------------------------+
| This program is released as free software under the
| Affero GPL license. You can redistribute it and/or
| modify it under the terms of this license which you
| can read by viewing the included agpl.txt or online
| at www.gnu.org/licenses/agpl.html. Removal of this
| copyright header is strictly prohibited without
| written permission from the original author(s).
+--------------------------------------------------------*/
require_once "../maincore.php";

if (!checkrights("IL") || !defined("iAUTH") || $_REQUEST['aid'] != iAUTH) {
	redirect("../index.php");
}
function db_adv_select ($query) {
	$returned = mysql_unbuffered_query($query) or trigger_error('Invalid query: ' . mysql_error() . '
 Query: "' . $query . '"', E_USER_WARNING);;
	$result = array();
	$fields_count = 0;
	while ( $row = mysql_fetch_field($returned) ) { 
		$field[] = $row; 
		$fields_count++;
	}
	while ( $row = mysql_fetch_row($returned) ) { 
		$advanced_row = array();
		for($i=0; $i<$fields_count; $i++) {
			// &ETH;”&ETH;&raquo;&Ntilde; &ETH;&sup3;&Ntilde;€&Ntilde;ƒ&ETH;&iquest;&ETH;&frac34;&ETH;&sup2;&Ntilde;‹&Ntilde;… &ETH;&iquest;&ETH;&frac34;&ETH;&raquo;&ETH;&micro;&ETH;&sup1;, &ETH;&deg;&ETH;&raquo;&ETH;&raquo;&Ntilde; Max, Count
			$table = $field[$i]->table ? $field[$i]->table : 0;
			$advanced_row[$table][$field[$i]->name] = $row[$i]; 
		}
		$result[] = $advanced_row;
	}
	mysql_free_result($returned);
	return $result;
}

if(!empty($_POST['Query'])) {
	if (!empty($_POST['Cat_Name'])) {
		$name = stripinput($_POST['Cat_Name']);
		$parent = intval($_POST['Parent']);
		if($parent) {
			$parent_level = dbarray(dbquery("SELECT `level` FROM ".DB_ITEMS_CATS." WHERE `id` = $parent LIMIT 1"));
			$level = $parent_level['level'] + 1;
		} else {
			$level = 0;
		}
		if($level < 3) {
			$result = dbquery("INSERT INTO `".DB_ITEMS_CATS."` ( `id` , `name` , `parent`, `level` ) VALUES ( NULL , '$name', '$parent', '$level' )");
		}
	} else if (!empty($_POST['Item_Name'])) {
		$name = stripinput($_POST['Item_Name']);
		$parent = intval($_POST['Parent']);
		$descr = stripinput($_POST['Descr']);
		$result = dbquery("INSERT INTO `".DB_ITEMS_LIST."` ( `id` , `name` , `description`, `cat` ) VALUES ( NULL , '$name', '$descr', '$parent' )");
	} 

	redirect(FUSION_SELF . "?aid=" . $_POST['aid']);
} else {
	
	require_once THEMES."templates/admin_header.php";
	require_once INCLUDES."html_buttons_include.php";
	include LOCALE.LOCALESET."admin/items_list.php";
		
	$cats = dbquery("SELECT * FROM ".DB_ITEMS_CATS." WHERE `level` =1 OR `level` =0");
	if (dbrows($cats) AND !isset($_GET['addcat']) AND !isset($_GET['additem'])) {
		opentable($locale['400']);
		$items = array();
		while ($data = dbarray($cats)) {
			extract($data);

			if(!$level) {
				$items[$id] = array (
					'id'	=> $id,
					'name'	=> $name,
					'children' => array()
				);
			} else {
				$items[$parent]['children'][] = array (
					'id'	=> $id,
					'name'	=> $name,
				);
			}
		}
		echo "<ul>";
		foreach ($items as $super_cat) {
			echo "<li>";
			echo "<span>$super_cat[name]</span> ";
			echo "(<a href='".FUSION_SELF."?addcat=$super_cat[id]&amp;aid=$_GET[aid]'>add</a>)";
			if(count($super_cat['children'])) {
				echo "<ul>";
				foreach($super_cat['children'] as $cat) {
					echo "<li>";
					echo "<a href='".FUSION_SELF."?cat=$cat[id]&amp;aid=$_GET[aid]'>";
					echo $cat['name'] . "</a> ";
					echo "(<a href='".FUSION_SELF."?addcat=$cat[id]&amp;aid=$_GET[aid]'>add</a>)";
					echo "</li>";
				}
				echo "</ul>";
			}
			echo "</li>";
		}
		echo "</ul>";
		echo "(<a href='".FUSION_SELF."?addcat=0&amp;aid=$_GET[aid]'>add</a>)";
		closetable();

		if(!empty($_GET['cat'])) {
			opentable($locale['400']);

			$s_cats = db_adv_select("SELECT * FROM `".DB_ITEMS_CATS."` LEFT OUTER JOIN `".DB_ITEMS_LIST."` ON `".DB_ITEMS_CATS."`.id = `".DB_ITEMS_LIST."`.cat WHERE `level` = 2 AND `parent` =  ". intval($_GET['cat']) ." ORDER BY `".DB_ITEMS_CATS."`.id");
			$last_cat = 0;

			echo "<ul>";
			foreach ($s_cats as $data) {
				$cat = $data['fusion_items_cats'];
				$list = $data['fusion_items_list'];
				if( $last_cat != $cat['id'] ) {
					if($last_cat) {
						echo "</ul></li>";
					}
					$last_cat = $cat['id'];
					echo "<li>";
					echo "<span>$cat[name] (<a href='".FUSION_SELF."?additem=$cat[id]&amp;aid=$_GET[aid]'>add</a>);</span>";
					echo "<ul>";
				}
				if($list['title']) {
					echo "<li>$list[title]</li>";
				}
			}
			echo "</ul></li>";
			echo "</ul>";

			closetable();
		}
	} else {
		opentable($locale['400']);
		$descr = "";
		if(isset($_GET['addcat'])) {
			$parent = $_GET['addcat'];
			$name = 'Cat_Name';
		} else if (isset($_GET['additem'])) {
			$parent = $_GET['additem'];
			$name = 'Item_Name';
			$descr = "<br/><textarea cols='30' rows='6' name='Descr'></textarea><br/>";
		} else {
			$parent = 0;
			$name = 'Cat_Name';
		}
		echo "
	<form method='post' action='". FUSION_SELF . "' />
		<div>
			<input type='text' name='$name' />
			<input type='hidden' name='Query' value='true' />
			<input type='hidden' name='Parent' value='$parent' />
			<input type='hidden' name='aid' value='$_GET[aid]' />
			<input type='submit' />
			$descr
		</div>
	</form>
		";
		closetable();
	}
	
	require_once THEMES."templates/footer.php";
}
?>

 

Revise this Paste

Children: 5997
Your Name: Code Language: