Location: PHPKode > projects > Nitrotech > nitrotech/admin/includes/admin_functions.php
<?php

//lets see if they are an admin
if(!$admin)
{
	die("Hacking attempt");
}

function admin_header($type)
{
	global $root, $table, $site_data, $page_name, $header_started;

	$style = get_userinfo('style');

	if($type != 'simple')
    {
    	include($root . "admin/includes/header.php");
    }
}

function admin_footer($type)
{
	global $root, $table;

	$style = get_userinfo('style');

	if($type != 'simple')
    {
    	include($root . "admin/includes/footer.php");
    }
}

function check_admin($level)
{
	$userlevel = get_userinfo('level');
	if($level != $userlevel)
    {
    	die("You are unautorised to view the admin panel");
    }
}


function move_item($db_id, $db_table, $way)
{
	global $table, $root;
    if($way == 'up')
    {
	    $query1 = "SELECT * FROM " . $table[$db_table];
	    $result1 = mysql_query($query1);
	    if (!$result1)
	    {
	       message("Could not successfully run query ($query1) from DB: " . mysql_error(), 'die');
	    }

	    while($row1 = mysql_fetch_assoc($result1))
	    {
	            $query2 = "SELECT * FROM " . $table[$db_table] . " WHERE id='". $db_id ."'";
	            $result2 = mysql_query($query2);
	            if (!$result2)
	            {
	               message("Could not successfully run query ($query2) from DB: " . mysql_error(), 'die');
	            }
                $sort2 = mysql_result($result2,0,"sort_id");
                if($sort2 == ($row1['sort_id'] + 1))
                {
                	$sort2 = $sort2 - 1;
                    $sort = $row1['sort_id'] + 1;
	                 $query3 = "UPDATE " . $table[$db_table] . " SET sort_id = '" . $sort2 . "' WHERE id = '" . $db_id . "'";
	                 $result3 = mysql_query($query3);
	                 if (!$result3)
	                 {
	                    message("Could not successfully run query ($query3) from DB: " . mysql_error(), 'die');
	                 }
	                 $query4 = "UPDATE " . $table[$db_table] . " SET sort_id = '" . $sort . "' WHERE id = '" . $row1['id'] . "'";
	                 $result4 = mysql_query($query4);
	                 if (!$result4)
	                 {
	                    message("Could not successfully run query ($query4) from DB: " . mysql_error(), 'die');
	                 }
                     message("Move successful", 'message');
                }
                else if($sort2 < '2')
                {
                	message("You cannot move this up anymore", 'message');
                }
        }
	    unset($query1);
	    unset($result1);
	    unset($query2);
	    unset($result2);
	    unset($query3);
	    unset($result3);
	    unset($query4);
	    unset($result4);
    }
    else
    {
	    $query1 = "SELECT * FROM " . $table[$db_table];
	    $result1 = mysql_query($query1);
	    if (!$result1)
	    {
	       message("Could not successfully run query ($query1) from DB: " . mysql_error(), 'die');
	    }
        $num1 = mysql_numrows($result1);

	    while($row1 = mysql_fetch_assoc($result1))
	    {
	            $query2 = "SELECT * FROM " . $table[$db_table] . " WHERE id='". $db_id ."'";
	            $result2 = mysql_query($query2);
	            if (!$result2)
	            {
	               message("Could not successfully run query ($query2) from DB: " . mysql_error(), 'die');
	            }
                $sort2 = mysql_result($result2,0,"sort_id");
                if($sort2 == ($row1['sort_id'] - 1))
                {
                	$sort2 = $sort2 + 1;
                    $sort = $row1['sort_id'] - 1;
	                 $query3 = "UPDATE " . $table[$db_table] . " SET sort_id = '" . $sort2 . "' WHERE id = '" . $db_id . "'";
	                 $result3 = mysql_query($query3);
	                 if (!$result3)
	                 {
	                    message("Could not successfully run query ($query3) from DB: " . mysql_error(), 'die');
	                 }
	                 $query4 = "UPDATE " . $table[$db_table] . " SET sort_id = '" . $sort . "' WHERE id = '" . $row1['id'] . "'";
	                 $result4 = mysql_query($query4);
	                 if (!$result4)
	                 {
	                    message("Could not successfully run query ($query4) from DB: " . mysql_error(), 'die');
	                 }
                     message("Move successful", 'message');
                }
                else if($sort2 == $num1)
                {
                	message("You cannot move this down anymore", 'message');
                }
        }
	    unset($query1);
	    unset($result1);
	    unset($query2);
	    unset($result2);
	    unset($query3);
	    unset($result3);
	    unset($query4);
	    unset($result4);
    }
}

?>
Return current item: Nitrotech