Code: Select all
default: {
$class->data_output("1");
} break;Anybody know how to fix this?
Moderator: General Moderators
Code: Select all
default: {
$class->data_output("1");
} break;If you mean show data_output()duk wrote:show please the rest of the code...
Code: Select all
function data_output($action_id) {
global $links, $admin_access, $table_o, $tr_o, $td_o, $td_c, $tr_c, $table_c;
if ($action_id == "1") {
if (isset($admin_access)) {
openPanel(message("7"));
echo $table_o;
foreach($links as $link) {
echo $tr_o.$td_o."<a href='{$link}'>$link_name</a><br />".$td_c.$tr_c;
}
echo $table_c;
} else {
openPanel(message("8"));
echo $table_o.$tr_o.$td_o;
// message("2")
echo "You are not logged in.<br />";
echo $td_c.$tr_c.$table_c;
}
closePanel();
}
if ($action_id == "2") {
if ($_POST['login']) {
if (isset($admin_access)) {
if ($_POST['user_name'] == "Fractal") {
if ($_POST['user_pass'] == "test") {
openPanel(message("9"));
set_status("1");
echo $table_o.$tr_o.$td_o.message("5").$td_c.$tr_c.$table_c;
} else {
openPanel(message("10"));
echo $table_o.$tr_o.$td_o.message("4").$td_c.$tr_c.$table_c;
}
} else {
openPanel(message("11"));
echo $table_o.$tr_o.$td_o.message("3").$td_c.$tr_c.$table_c;
}
} else {
openPanel(message("9"));
echo "<form action='?action=login' method='POST'>\n";
echo $table_o;
echo $tr_o.$td_o.message("13").$td_c.$td_o."<input type='text' name='user_name'><br />".$td_c.$tr_c;
echo $tr_o.$td_o.message("14").$td_c.$td_o."<input type='password' name='user_pass'><br />".$td_c.$tr_c;
echo $tr_o.$td_o."<input type='submit' name='login' value='".message("15")."'><br />".$td_c.$tr_c;
echo $table.c;
echo "</form>\n";
}
} else {
openPanel(message("12"));
echo $table_o.$tr_o.$td_o.message("1").$td_c.$tr_c.$table_c."<br /><br />\n";
echo "<form action='?action=login' method='POST'>\n";
echo $table_o;
echo $tr_o.$td_o.message("13").$td_c.$td_o."<input type='text' name='user_name'><br />".$td_c.$tr_c;
echo $tr_o.$td_o.message("14").$td_c.$td_o."<input type='password' name='user_pass'><br />".$td_c.$tr_c;
echo $tr_o.$td_o."<input type='submit' name='login' value='".message("15")."'><br />".$td_c.$tr_c;
echo $table.c;
echo "</form>\n";
}
closePanel();
}
if ($action_id == "3") {
global $admin_access, $table_o, $tr_o, $td_o, $td_c, $tr_c, $table_c;
if (isset($admin_access)) {
openPanel(message("16"));
// set_status("2");
echo $table_o.$tr_o.$td_o.message("6").$td_c.$tr_c.$table_c;
} else {
openPanel(message(8));
echo $table_o.$tr_o.$td_o.message("2").$td_c.$tr_c.$table_c;
}
closePanel();
}
}Code: Select all
default: {
$class->data_output("1");
} break;Code: Select all
<style type='text/css'>
a { text-decoration: none; color: orange; }
a:hover { color: #888; }
td { background-color: #CCC; color: #888; }
td.panel { border-color: #AAA; color: #888; }
</style>Code: Select all
<?php
ob_start();
$lclass = "adminPanel";
function __autoload($lclass)
{
if (!class_exists($lclass, false)) {
trigger_error("Unable to load class: ".$lclass, E_USER_WARNING."\n");
} elseif (class_exists($lclass)) {
$admin = new $lclass();
} else {
trigger_error("Class ".$lclass." can and cannot be found.<br />\n");
}
}
$links = array(
1 => 'admin_test.php?action=',
2 => 'admin_test.php?action=login&',
3 => 'admin_test.php?action=logout&',
);
$link_name = array(
'admin_test.php?action=', 'Home',
'admin_test.php?action=login&', 'Login',
'admin_test.php?action=logout&', 'Logout',
);
$admin_access = $_COOKIE['admin_access'];
$table_o = "<table width='100%' cellpadding='0' cellspacing='0'>\n";
$tr_o = "<tr>";
$td_o = "<td>";
$td_c = "</td>";
$tr_c = "</tr>\n";
$table_c = "</table>\n";
switch($_GET['action']) {
case "login": {
$admin->data_output("2");
} break;
case "logout": {
$admin->data_output("3");
} break;
default: {
$admin->data_output("1");
} break;
}
class adminPanel {
var $admin_access;
function message($messno) {
if ($messno == "1") return $this->data_output("You are already logged in.<br />");
if ($messno == "2") return $this->data_output("You are not logged in.<br />");
if ($messno == "3") return $this->data_output("The username you entered was incorrect.<br />");
if ($messno == "4") return $this->data_output("The password you entered was incorrect.<br />");
if ($messno == "5") return $this->data_output("You have logged in successfully.<br />");
if ($messno == "6") return $this->data_output("You have logged out successfully.<br />");
if ($messno == "7") return $this->data_output("Administration - Home<br />");
if ($messno == "8") return $this->data_output("Administration - Error 2<br />");
if ($messno == "9") return $this->data_output("Administration - Login<br />");
if ($messno == "10") return $this->data_output("Administration - Error 4<br />");
if ($messno == "11") return $this->data_output("Administration - Error 3<br />");
if ($messno == "12") return $this->data_output("Administration - Error 1<br />");
if ($messno == "13") return $this->data_output("Username<br />");
if ($messno == "14") return $this->data_output("Password<br />");
if ($messno == "15") return $this->data_output("Login<br />");
if ($messno == "16") return $this->data_output("Administration - Logout<br />");
}
function set_status($statusno) {
if ($statusno == "1") { /* Set Cookie */ }
if ($statusno == "2") { /* Destroy Cookie */ }
}
function data_output($action_id) {
global $links, $admin_access, $table_o, $tr_o, $td_o, $td_c, $tr_c, $table_c;
if ($action_id == "1") {
if (isset($admin_access)) {
openPanel(message("7"));
echo $table_o;
foreach($links as $link) {
echo $tr_o.$td_o."<a href='{$link}'>$link_name</a><br />".$td_c.$tr_c;
}
echo $table_c;
} else {
openPanel(message("8"));
echo $table_o.$tr_o.$td_o;
// message("2")
echo "You are not logged in.<br />";
echo $td_c.$tr_c.$table_c;
}
closePanel();
}
if ($action_id == "2") {
if ($_POST['login']) {
if (isset($admin_access)) {
if ($_POST['user_name'] == "Fractal") {
if ($_POST['user_pass'] == "test") {
openPanel(message("9"));
set_status("1");
echo $table_o.$tr_o.$td_o.message("5").$td_c.$tr_c.$table_c;
} else {
openPanel(message("10"));
echo $table_o.$tr_o.$td_o.message("4").$td_c.$tr_c.$table_c;
}
} else {
openPanel(message("11"));
echo $table_o.$tr_o.$td_o.message("3").$td_c.$tr_c.$table_c;
}
} else {
openPanel(message("9"));
echo "<form action='?action=login' method='POST'>\n";
echo $table_o;
echo $tr_o.$td_o.message("13").$td_c.$td_o."<input type='text' name='user_name'><br />".$td_c.$tr_c;
echo $tr_o.$td_o.message("14").$td_c.$td_o."<input type='password' name='user_pass'><br />".$td_c.$tr_c;
echo $tr_o.$td_o."<input type='submit' name='login' value='".message("15")."'><br />".$td_c.$tr_c;
echo $table.c;
echo "</form>\n";
}
} else {
openPanel(message("12"));
echo $table_o.$tr_o.$td_o.message("1").$td_c.$tr_c.$table_c."<br /><br />\n";
echo "<form action='?action=login' method='POST'>\n";
echo $table_o;
echo $tr_o.$td_o.message("13").$td_c.$td_o."<input type='text' name='user_name'><br />".$td_c.$tr_c;
echo $tr_o.$td_o.message("14").$td_c.$td_o."<input type='password' name='user_pass'><br />".$td_c.$tr_c;
echo $tr_o.$td_o."<input type='submit' name='login' value='".message("15")."'><br />".$td_c.$tr_c;
echo $table.c;
echo "</form>\n";
}
closePanel();
}
if ($action_id == "3") {
global $admin_access, $table_o, $tr_o, $td_o, $td_c, $tr_c, $table_c;
if (isset($admin_access)) {
openPanel(message("16"));
// set_status("2");
echo $table_o.$tr_o.$td_o.message("6").$td_c.$tr_c.$table_c;
} else {
openPanel(message(8));
echo $table_o.$tr_o.$td_o.message("2").$td_c.$tr_c.$table_c;
}
closePanel();
}
}
function openPanel($title) {
echo "<table width='100%' cellpadding='0' cellspacing='1'>\n";
echo "<tr><td class='panel'>".$title."</td></tr>\n";
echo "<tr><td class='panel'>";
}
function closePanel() {
echo "</td></tr>\n";
echo "</table>\n";
}
}
?>Code: Select all
switch($_GET['action']) {
case "login":
$admin->data_output("2");
break;
case "logout":
$admin->data_output("3");
break;
default:
$admin->data_output("1");
break;
}Code: Select all
if (!class_exists($lclass, false)) {
trigger_error("Unable to load class: ".$lclass, E_USER_WARNING."\n");
}
$admin = new $lclass();Code: Select all
$this->openPanel('foo');That's good to know, I'll change all the functions called to $this->[function_name]([title]); and see what happens.feyd wrote:to call a function (method) that is apart of the object, you must use $this, e.g.Code: Select all
$this->openPanel('foo');
Code: Select all
andCode: Select all
tags where appropriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
Ok, well it worked, but it's having real issues echoing it where it's supposed to be. As if it's echoing where the message function is located.
[url=http://img133.imageshack.us/my.php?image=error2ba.gif]Design Appearence[/url]
The updated code below (Removed function set_status() { } in the code below)Code: Select all
function message($messno) {
if ($messno == "1") echo "You are already logged in.<br />";
if ($messno == "2") echo "You are not logged in.<br />";
if ($messno == "3") echo "The username you entered was incorrect.<br />";
if ($messno == "4") echo "The password you entered was incorrect.<br />";
if ($messno == "5") echo "You have logged in successfully.<br />";
if ($messno == "6") echo "You have logged out successfully.<br />";
if ($messno == "7") echo "Administration - Home<br />";
if ($messno == "8") echo "Administration - Error 2<br />";
if ($messno == "9") echo "Administration - Login<br />";
if ($messno == "10") echo "Administration - Error 4<br />";
if ($messno == "11") echo "Administration - Error 3<br />";
if ($messno == "12") echo "Administration - Error 1<br />";
if ($messno == "13") echo "Username<br />";
if ($messno == "14") echo "Password<br />";
if ($messno == "15") echo "Login<br />";
if ($messno == "16") echo "Administration - Logout<br />";
}
function data_output($action_id) {
global $links, $admin_access, $table_o, $tr_o, $td_o, $td_c, $tr_c, $table_c;
if ($action_id == "1") {
if (isset($admin_access)) {
$this->openPanel($this->message("7"));
echo $table_o;
foreach($links as $link) {
echo $tr_o.$td_o."<a href='{$link}'>$link_name</a><br />".$td_c.$tr_c;
}
echo $table_c;
} else {
$this->openPanel($this->message("8"));
echo $table_o.$tr_o.$td_o;
echo $this->message("2");
// echo "You are not logged in.<br />";
echo $td_c.$tr_c.$table_c;
}
$this->closePanel();
}
if ($action_id == "2") {
if ($_POST['login']) {
if (isset($admin_access)) {
if ($_POST['user_name'] == "Phathom") {
if ($_POST['user_pass'] == "r0c3s") {
$this->openPanel($this->message("9"));
$this->set_status("1");
echo $table_o.$tr_o.$td_o.$this->message("5").$td_c.$tr_c.$table_c;
} else {
$this->openPanel($this->message("10"));
echo $table_o.$tr_o.$td_o.$this->message("4").$td_c.$tr_c.$table_c;
}
} else {
$this->openPanel($this->message("11"));
echo $table_o.$tr_o.$td_o.$this->message("3").$td_c.$tr_c.$table_c;
}
} else {
$this->openPanel($this->message("9"));
echo "<form action='?action=login' method='POST'>\n";
echo $table_o;
echo $tr_o.$td_o.$this->message("13").$td_c.$td_o."<input type='text' name='user_name'><br />".$td_c.$tr_c;
echo $tr_o.$td_o.$this->message("14").$td_c.$td_o."<input type='password' name='user_pass'><br />".$td_c.$tr_c;
echo $tr_o.$td_o."<input type='submit' name='login' value='".$this->message("15")."'><br />".$td_c.$tr_c;
echo $table.c;
echo "</form>\n";
}
} else {
$this->openPanel($this->message("12"));
echo $table_o.$tr_o.$td_o.$this->message("1").$td_c.$tr_c.$table_c."\n";
echo "<form action='?action=login' method='POST'>\n";
echo $table_o;
echo $tr_o.$td_o.$this->message("13").$td_c.$td_o."<input type='text' name='user_name'><br />".$td_c.$tr_c;
echo $tr_o.$td_o.$this->message("14").$td_c.$td_o."<input type='password' name='user_pass'><br />".$td_c.$tr_c;
echo $tr_o.$td_o."<input type='submit' name='login' value='".$this->message("15")."'><br />".$td_c.$tr_c;
echo $table.c;
echo "</form>\n";
}
$this->closePanel();
}
if ($action_id == "3") {
global $admin_access, $table_o, $tr_o, $td_o, $td_c, $tr_c, $table_c;
if (isset($admin_access)) {
$this->openPanel($this->message("16"));
$this->set_status("2");
echo $table_o.$tr_o.$td_o.$this->message("6").$td_c.$tr_c.$table_c;
} else {
$this->openPanel($this->message(8));
echo $table_o.$tr_o.$td_o.$this->message("2").$td_c.$tr_c.$table_c;
}
$this->closePanel();
}
}Code: Select all
andCode: Select all
tags where appropriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]