From be4f83cd2a17a0ec05f5bce50c91befaafaa6e0c Mon Sep 17 00:00:00 2001 From: jhunkeler Date: Sun, 20 Dec 2009 18:38:08 +0000 Subject: Test. git-svn-id: http://svn.3rd-infantry-division.org/testing/branches/Bayonet CMS v2@376 c5b2fb0a-d05d-0410-98c8-828840a80ff6 --- admin/admin_functions.php | 164 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 164 insertions(+) create mode 100644 admin/admin_functions.php (limited to 'admin/admin_functions.php') diff --git a/admin/admin_functions.php b/admin/admin_functions.php new file mode 100644 index 0000000..83392a1 --- /dev/null +++ b/admin/admin_functions.php @@ -0,0 +1,164 @@ +. + */ + +if(!defined("ADMIN_FILE")) +{ + die("Access denied."); + return; +} + +function is_loggedin() +{ + $id = session_id(); + if($id == "") + { + header("location: index.php"); + return false; + } + return true; +} + +function login() +{ + global $db; + + if(isset($_SESSION['username']) || isset($_SESSION['password'])) + { + return true; + } + + if(isset($_POST['processed'])) + { + $username = addslashes($_POST['username']); + $password = addslashes($_POST['password']); + $password = crypt(md5($password),'iamnotadirtywhorebitch'); + $result = $db->Query("SELECT * FROM bayonet_users WHERE username = '$username' AND password = '$password' LIMIT 1"); + $rows = $db->Rows($result); + $row = $db->Fetch($result); + + if($rows > 0) + { + $_SESSION['username'] = stripslashes($username); + $_SESSION['password'] = stripslashes($password); + $_SESSION['level'] = $row['level']; + return true; + } + else + { + ReportError("Login incorrect."); + + //NOT CORRECT LOGIN, DEFAULT TO LOGIN PAGE + echo ""; + + return false; + } + + } + else + { + echo "
\n"; + //OpenTable(); + echo ""; + echo "
\n + \n + \n + \n + \n + \n +
Administrative Login
Username
Password
\n"; + //CloseTable(); + echo "
"; + echo "
\n"; + return false; + } +} + +function logout() +{ + session_unset(); + session_destroy(); + + echo ""; +} + +/** + * CompileAdmin() + * + * because we want to have a horizontal display of options, we need to have + * the data separated by arrays. the data is processed into single tables, and is + * echoed in realtime. we checked to make sure they were arrays, but there is no + * checking to make sure the data passed is not malicious in nature. + * + * @param mixed $head + * @param mixed $body + * @return + */ +function CompileAdmin($head,$body) +{ + /*if we were not passed arrays, then say goodbye*/ + if(!is_array($head) || !is_array($body)) + { + echo "must be array\n"; + return; + } + + echo ""; + +$num = 1; + foreach($body as $td) + { + if($num==1){ + echo ""; + } + echo "\n"; + if($num%6 == 0){ + echo ""; + $num=0; + } + $num++; + } + echo "
$td
\n"; +} + +/** + * OpenTable() + * + * The administration OpenTable() function requires an argument to define + * the header title. It may be wise to replace the standard OpenTable() function + * with this one... that's alot of code to unfuck though. + * + * @param mixed $title + * @return + */ +function OpenTable_Ex($title) +{ + echo "
{$title}
"; +} + +/** + * CloseTable() + * + * @return + */ +function CloseTable_Ex() +{ + echo "
"; +} + +?> \ No newline at end of file -- cgit