Exemplo n.º 1
0
 public function content()
 {
     global $dbh, $postvar, $getvar, $instance;
     $version_info = main::latest_version();
     $current_version = $version_info['THT'];
     $new_version_download = $version_info['THT_DL'];
     $running_version = $dbh->config('version');
     $install_check = $this->checkDir(INC . "../install/");
     $conf_check = $this->checkPerms(INC . "/conf.inc.php");
     if ($current_version == $running_version) {
         $updatemsg = "<span style='color:green'>Up-To-Date</span>";
         $upgrademsg = "";
     } else {
         $updatemsg = "<span style='color:red'>Upgrade Avaliable</span>";
         $upgrademsg = "<div class='warn'><img src='../themes/icons/error.png' alt='' /> There is a new version ({$current_version}) avaliable! <a href = '" . $new_version_download . "' target = '_blank'>Please download it here</a> and upgrade!</div>";
     }
     unset($current_version);
     unset($running_version);
     $stats['VERSION'] = $dbh->config('version');
     $stats['THEME'] = $dbh->config('theme');
     $stats['CENABLED'] = main::cleaninteger($dbh->config('cenabled'));
     $stats['SVID'] = main::cleaninteger($dbh->config('show_version_id'));
     $stats['SENABLED'] = main::cleaninteger($dbh->config('senabled'));
     $stats['DEFAULT'] = $dbh->config('default_page');
     $stats['EMETHOD'] = $dbh->config('emailmethod');
     $stats['SIGNENABLE'] = main::cleaninteger($dbh->config('general'));
     $stats['MULTI'] = main::cleaninteger($dbh->config('multiple'));
     $stats['UPDATE'] = $updatemsg;
     $stats['UPG_BOX'] = $upgrademsg;
     $stats_box = style::replaceVar('tpl/admin/home/stats.tpl', $stats);
     $content = '<strong>Welcome to your Admin Dashboard!</strong><br />Welcome to the dashboard of your Admin Control Panel. In this area you can do the tasks that you need to complete such as manage servers, create packages, manage users.<br />
             Here, you can also change the look and feel of your THT Installation. If you require any help, be sure to ask at the <a href="http://thehostingtool.com/forum" title="THT Community is the official stop for THT Support, THT Modules, Developer Center and more! Visit our growing community now!" class="tooltip">THT Community</a><br /><br />' . $stats_box . '<br />' . $install_check . $conf_check . '</div></div>';
     echo $content;
     if ($_POST) {
         $dbh->update("admin_notes", array("notes" => $postvar['admin_notes']), array("id", "=", "1"));
         main::errors("Settings Updated!");
         main::done();
     }
     $notes_data = $dbh->select("admin_notes", array("id", "=", "1"));
     $notepad_array['NOTEPAD'] = $notes_data['notes'];
     $content_notepad = style::replaceVar('tpl/admin/home/notepad.tpl', $notepad_array);
     echo '<br />';
     echo main::table('Admin Notepad', $content_notepad, 'auto', 'auto');
     $news = main::sub("<strong>Add the THT RSS Feed!</strong>", '<a href="http://thehostingtool.com/forum/syndication.php?fid=2" target="_blank" class="tooltip" title="Add the THT RSS Feed!"><img src="<URL>themes/icons/feed.png" /></a>');
     $rss_feed = @file_get_contents("http://thehostingtool.com/forum/syndication.php?fid=2&limit=3");
     if ($rss_feed !== false) {
         $xml = new SimpleXMLElement($rss_feed);
         foreach ($xml->channel->item as $item) {
             $newsitem_array['title'] = $item->title;
             $newsitem_array['author'] = "THT";
             $newsitem_array['link'] = $item->link;
             $newsitem_array['TIME'] = main::convertdate("n/d/Y", strtotime($item->pubDate));
             $newsitem_array['SUMMARY'] = $item->description;
             $news .= style::replaceVar('tpl/admin/home/news-item.tpl', $newsitem_array);
         }
     }
     echo "<br />";
     echo main::table('THT News & Updates', $news);
 }
Exemplo n.º 2
0
 private function TerminateClient($client)
 {
     global $dbh, $postvar, $getvar, $instance;
     if (!$postvar['submitreason']) {
         $client_uname = main::uname($client['id']);
         $reason_array['WARNTEXT'] = 'CAUTION: If you proceed, the account "' . $client_uname . '" will be completely and irrevocably removed from the server and THT.<br><br>Why are you terminating this account? Leave blank if you just feel like terminating them.';
         $reason_array['ACTION'] = 'terminating';
         $reason_array['ACTIONBUTT'] = 'Terminate Client';
         $clientview_array['BOX'] = "";
         $clientview_array['CONTENT'] = style::replaceVar("tpl/admin/clients/reason.tpl", $reason_array);
         return $clientview_array;
     } else {
         $command = server::terminate($client['id'], $postvar['reason']);
         if ($command == true) {
             //Terminated
             main::done();
         } else {
             main::errors($command);
         }
     }
 }
Exemplo n.º 3
0
 public function content()
 {
     global $dbh, $postvar, $getvar, $instance;
     switch ($getvar['sub']) {
         default:
             if ($_POST) {
                 check::empty_fields();
                 foreach ($postvar as $key => $value) {
                     $broke = explode("_", $key);
                     if ($broke[0] == "pages") {
                         $postvar['perms'][$broke[1]] = $value;
                     }
                 }
                 if (!main::errors()) {
                     $staff_query = $dbh->select("staff", array("user", "=", $postvar['user']), 0, "1", 1);
                     if (!check::email($postvar['email'])) {
                         main::errors("Your email is the wrong format or is already in use by another staff member or client.");
                     } elseif ($postvar['pass'] != $postvar['conpass']) {
                         main::errors("Passwords don't match!");
                     } elseif ($dbh->num_rows($staff_query) >= 1) {
                         main::errors("That account already exists!");
                     } else {
                         if ($postvar['perms']) {
                             foreach ($postvar['perms'] as $key => $value) {
                                 if ($n) {
                                     $perms .= ",";
                                 }
                                 if ($value == "1") {
                                     $perms .= $key;
                                 }
                                 $n++;
                             }
                         }
                         $salt = crypto::salt();
                         $password = crypto::passhash($postvar['pass'], $salt);
                         $staff_insert = array("user" => $postvar['user'], "name" => $postvar['name'], "email" => $postvar['email'], "password" => $password, "salt" => $salt, "perms" => $perms, "tzadjust" => $postvar['tzones']);
                         $dbh->insert("staff", $staff_insert);
                         main::errors("Account added!");
                     }
                 }
             }
             $acpnav_query = $dbh->select("acpnav", array("link", "!=", "home"), array("id", "ASC"), 0, 1);
             $add_staff_member_array['PAGES'] = '<table width="100%" border="0" cellspacing="0" cellpadding="1">';
             while ($acpnav_data = $dbh->fetch_array($acpnav_query)) {
                 $add_staff_member_array['PAGES'] .= '<tr><td width="30%" align="left">' . $acpnav_data['visual'] . ':</td><td><input name="pages_' . $acpnav_data['id'] . '" id="pages_' . $acpnav_data['id'] . '" type="checkbox" value="1" /></td></tr>';
             }
             $add_staff_member_array['PAGES'] .= '<tr><td width="30%" align="left">Paid Configuration:</td><td><input name="pages_paid" id="pages_paid" type="checkbox" value="1" /></td></tr>';
             $add_staff_member_array['PAGES'] .= '<tr><td width="30%" align="left">P2H Forums:</td><td><input name="pages_p2h" id="pages_p2h" type="checkbox" value="1" /></td></tr>';
             $add_staff_member_array['PAGES'] .= "</table>";
             $add_staff_member_array['TZADJUST'] = main::tzlist();
             echo style::replaceVar("tpl/admin/staff/add-staff-member.tpl", $add_staff_member_array);
             break;
         case "edit":
             if (isset($getvar['do'])) {
                 $staff_data = $dbh->select("staff", array("id", "=", $getvar['do']));
                 if (!$staff_data["user"]) {
                     echo "That account doesn't exist!";
                 } else {
                     if ($_POST) {
                         check::empty_fields();
                         foreach ($postvar as $key => $value) {
                             $broke = explode("_", $key);
                             if ($broke[0] == "pages") {
                                 $postvar['perms'][$broke[1]] = $value;
                             }
                         }
                         if (!main::errors()) {
                             if (!check::email($postvar['email'], $getvar['do'], "staff")) {
                                 main::errors("Your email is the wrong format or is already in use by another staff member or client.");
                             } else {
                                 if ($postvar['perms']) {
                                     foreach ($postvar['perms'] as $key => $value) {
                                         if ($n) {
                                             $perms .= ",";
                                         }
                                         if ($value == "1") {
                                             $perms .= $key;
                                         }
                                         $n++;
                                     }
                                 }
                                 $staff_update = array("email" => $postvar['email'], "name" => $postvar['name'], "perms" => $perms, "tzadjust" => $postvar['tzones'], "user" => $postvar['user']);
                                 $dbh->update("staff", $staff_update, array("id", "=", $getvar['do']));
                                 //Staff account edit complete
                                 main::done();
                             }
                         }
                     }
                     $edit_staff_member_array['USER'] = $staff_data['user'];
                     $edit_staff_member_array['EMAIL'] = $staff_data['email'];
                     $edit_staff_member_array['NAME'] = $staff_data['name'];
                     $edit_staff_member_array['TZADJUST'] = main::tzlist($staff_data['tzadjust']);
                     $acpnav_query = $dbh->select("acpnav", array("link", "!=", "home"), array("id", "ASC"), 0, 1);
                     $edit_staff_member_array['PAGES'] = '<table width="100%" border="0" cellspacing="0" cellpadding="1">';
                     while ($acpnav_data = $dbh->fetch_array($acpnav_query)) {
                         if (!main::checkPerms($acpnav_data['id'], $staff_data['id'])) {
                             $checked = 'checked="checked"';
                         }
                         $edit_staff_member_array['PAGES'] .= '<tr><td width="30%" align="left">' . $acpnav_data['visual'] . ':</td><td><input name="pages_' . $acpnav_data['id'] . '" id="pages_' . $acpnav_data['id'] . '" type="checkbox" value="1" ' . $checked . '/></td></tr>' . "\n";
                         $checked = NULL;
                     }
                     if (substr_count($staff_data['perms'], "paid") == '1') {
                         $paid_check = 'checked="checked"';
                     }
                     if (substr_count($staff_data['perms'], "p2h") == '1') {
                         $p2h_check = 'checked="checked"';
                     }
                     $edit_staff_member_array['PAGES'] .= '<tr><td width="30%" align="left">Paid Configuration:</td><td><input name="pages_paid" id="pages_paid" type="checkbox" value="1" ' . $paid_check . '/></td></tr>' . "\n";
                     $edit_staff_member_array['PAGES'] .= '<tr><td width="30%" align="left">P2H Forums:</td><td><input name="pages_p2h" id="pages_p2h" type="checkbox" value="1" ' . $p2h_check . '/></td></tr>' . "\n";
                     $edit_staff_member_array['PAGES'] .= "</table>";
                     echo style::replaceVar("tpl/admin/staff/edit-staff-member.tpl", $edit_staff_member_array);
                 }
             } else {
                 $staff_query = $dbh->select("staff");
                 if ($dbh->num_rows($staff_query) == 0) {
                     echo "There are no staff accounts to edit!";
                 } else {
                     echo "<ERRORS>";
                     while ($staff_data = $dbh->fetch_array($staff_query)) {
                         echo main::sub("<strong>" . $staff_data['user'] . "</strong>", '<a href="?page=staff&sub=edit&do=' . $staff_data['id'] . '"><img src="' . URL . 'themes/icons/pencil.png"></a>');
                     }
                 }
             }
             break;
         case "delete":
             $staff_query = $dbh->select("staff");
             if ($getvar['do'] && $dbh->num_rows($staff_query) > 1) {
                 $dbh->delete("staff", array("id", "=", $getvar['do']));
                 main::errors("Staff Account Deleted!");
             } elseif ($getvar['do']) {
                 main::errors("Theres only one staff account!");
             }
             if ($dbh->num_rows($staff_query) == 0) {
                 echo "There are no staff accounts to edit!";
             } else {
                 $staff_query = $dbh->select("staff");
                 //This pulls the current staff list after deletion.
                 echo "<ERRORS>";
                 while ($staff_data = $dbh->fetch_array($staff_query)) {
                     echo main::sub("<strong>" . $staff_data['user'] . "</strong>", '<a href="?page=staff&sub=delete&do=' . $staff_data['id'] . '"><img src="' . URL . 'themes/icons/delete.png"></a>');
                 }
             }
             break;
     }
 }
Exemplo n.º 4
0
 public function acpPage()
 {
     global $dbh, $postvar, $getvar, $instance;
     switch ($getvar['do']) {
         default:
             if ($_POST) {
                 check::empty_fields(array("prefix"));
                 if (!main::errors()) {
                     $forumcon = $dbh->connect($postvar['hostname'], $postvar['username'], $postvar['password'], $postvar['database']);
                     if (is_string($forumcon)) {
                         main::errors($forumcon);
                     } else {
                         $forums_params = $this->forumdata($postvar['forumname']);
                         if ($forums_params['id']) {
                             main::errors("This forum name has already been used! Please choose a new one.<br>");
                         } else {
                             $p2h_insert = array("forumname" => $postvar['forumname'], "username" => $postvar['username'], "password" => $postvar['password'], "forumdb" => $postvar['database'], "hostname" => $postvar['hostname'], "prefix" => $postvar['prefix'], "forumtype" => $postvar['forum'], "url" => $postvar['url']);
                             $dbh->insert("p2h", $p2h_insert);
                             main::errors("Your forum has been added!<br>");
                         }
                     }
                 }
             }
             $manage_forums_array['CONTENT'] = style::replaceVar("tpl/admin/p2h/add-forum.tpl");
             break;
         case "edit":
             $forums_params = $this->forumdata();
             if ($dbh->num_rows($forums_params) == 0) {
                 $manage_forums_array['CONTENT'] = "There are no forums to edit!<br>";
             } else {
                 if ($getvar['id']) {
                     if ($_POST) {
                         check::empty_fields(array("password"));
                         if (!main::errors()) {
                             $forumcon = $dbh->connect($postvar['hostname'], $postvar['username'], $postvar['password'], $postvar['database']);
                             if (is_string($forumcon)) {
                                 main::errors($forumcon);
                             } else {
                                 $forums_params = $this->forumdata($getvar['id']);
                                 if (!$forums_params['id']) {
                                     main::errors("This forum name does not exist.<br>");
                                 } else {
                                     $p2h_update = array("forumname" => $postvar['forumname'], "username" => $postvar['username'], "forumdb" => $postvar['database'], "hostname" => $postvar['hostname'], "prefix" => $postvar['prefix'], "url" => $postvar['url']);
                                     $dbh->update("p2h", $p2h_update, array("id", "=", $getvar['id']));
                                     if ($postvar['password']) {
                                         $dbh->update("p2h", array("password" => $postvar['password']), array("id", "=", $getvar['id']));
                                     }
                                     main::errors("Forum Edited!<br>");
                                 }
                             }
                         }
                     }
                     $forumdata = $this->forumdata($getvar['id']);
                     if (!$forumdata['id']) {
                         main::done();
                     }
                     $edit_forum_array['HOST'] = $forumdata['hostname'];
                     $edit_forum_array['NAME'] = $forumdata['forumname'];
                     $edit_forum_array['URL'] = $forumdata['url'];
                     $manage_forums_array['CONTENT'] = style::replaceVar("tpl/admin/p2h/edit-forum.tpl", $edit_forum_array);
                 } else {
                     $manage_forums_array['CONTENT'] .= "<ERRORS>";
                     while ($forums_params_data = $dbh->fetch_array($forums_params)) {
                         $manage_forums_array['CONTENT'] .= main::sub("<strong>" . $forums_params_data['forumname'] . "</strong>", '<a href="?page=type&type=p2h&sub=forums&do=edit&id=' . $forums_params_data['id'] . '"><img src="' . URL . 'themes/icons/pencil.png"></a>');
                     }
                 }
             }
             break;
         case "delete":
             $forums_params = $this->forumdata();
             if ($dbh->num_rows($forums_params) == 0) {
                 $manage_forums_array['CONTENT'] = "There are no forums to delete!<br>";
             } else {
                 if ($getvar['id']) {
                     $dbh->delete("p2h", array("id", "=", $getvar['id']));
                     main::errors("Forum deleted!<br>");
                     $forums_params = $this->forumdata();
                 }
                 $manage_forums_array['CONTENT'] .= "<ERRORS>";
                 while ($forums_params_data = $dbh->fetch_array($forums_params)) {
                     $manage_forums_array['CONTENT'] .= main::sub("<strong>" . $forums_params_data['forumname'] . "</strong>", '<a href="?page=type&type=p2h&sub=forums&do=delete&id=' . $forums_params_data['id'] . '"><img src="' . URL . 'themes/icons/delete.png"></a>');
                 }
             }
             break;
         case "config":
             if ($_POST) {
                 check::empty_fields(array("password"));
                 if (!main::errors()) {
                     if (!is_numeric($postvar['p2hwarndate']) || !($postvar['p2hwarndate'] < 28)) {
                         main::errors("The P2H Warn date must be a number less than 28.<br>");
                     } else {
                         $dbh->updateConfig("p2hwarndate", $postvar['p2hwarndate']);
                         main::errors("Configuration updated.<br>");
                     }
                 }
             }
             $forum_config_array['WARNDATE'] = $dbh->config("p2hwarndate");
             $manage_forums_array['CONTENT'] = style::replaceVar("tpl/admin/p2h/forum-config.tpl", $forum_config_array);
             break;
     }
     echo style::replaceVar("tpl/admin/p2h/manage-forums.tpl", $manage_forums_array);
 }
Exemplo n.º 5
0
 public function content()
 {
     global $dbh, $postvar, $getvar, $instance;
     switch ($getvar['sub']) {
         default:
             if ($_POST['add']) {
                 $no_check_array = array("resellerport", "welcome", "nstmp", "passtoo", "resellerid");
                 check::empty_fields($no_check_array);
                 if (!main::errors()) {
                     $servers_insert = array("ip" => $postvar['ip'], "resellerport" => $postvar['resellerport'], "port" => $postvar['port'], "nameservers" => $postvar['nameservers'], "name" => $postvar['name'], "host" => $postvar['host'], "user" => $postvar['user'], "accesshash" => $postvar['hash'], "type" => $postvar['type'], "dnstemplate" => $postvar['nstmp'], "welcome" => $postvar['welcome'], "pass" => $postvar['pass'], "reseller_id" => $postvar['resellerid'], "https" => $postvar['https'], "apiport" => $postvar['apiport']);
                     $dbh->insert("servers", $servers_insert);
                     main::errors("Server has been added!");
                 }
             }
             if ($_POST['addtype'] || $_POST['add']) {
                 $serverfile = server::createServer(0, $postvar['type']);
                 $server_fields = $serverfile->acp_form();
                 $add_server_array['SERVER_FIELDS'] = $server_fields;
                 $add_server_array['TYPE'] = $postvar['type'];
                 echo style::replaceVar("tpl/admin/servers/add-server.tpl", $add_server_array);
                 break;
             }
             $files = main::folderFiles(INC . "/servers/");
             foreach ($files as $value) {
                 include INC . "/servers/" . $value;
                 $fname = explode(".", $value);
                 $stype = new $fname[0]();
                 $values[] = array($stype->name, $fname[0]);
             }
             $server_type_array['TYPE'] = main::dropDown("type", $values, 0);
             echo style::replaceVar("tpl/admin/servers/server-type.tpl", $server_type_array);
             break;
         case "view":
             if (isset($getvar['do'])) {
                 $servers_query = $dbh->select("servers", array("id", "=", $getvar['do']), 0, 0, 1);
                 if ($dbh->num_rows($servers_query) == 0) {
                     echo "That server doesn't exist!";
                 } else {
                     if ($_POST) {
                         check::empty_fields();
                         if (!main::errors()) {
                             $servers_update = array("name" => $postvar['name'], "host" => $postvar['host'], "reseller_id" => $postvar['resellerid'], "user" => $postvar['user'], "pass" => $postvar['pass'], "accesshash" => $postvar['hash'], "port" => $postvar['port'], "resellerport" => $postvar['resellerport'], "nameservers" => $postvar['nameservers'], "ip" => $postvar['ip'], "dnstemplate" => $postvar['nstmp'], "welcome" => $postvar['welcome'], "https" => $postvar['https'], "apiport" => $postvar['apiport']);
                             $dbh->update("servers", $servers_update, array("id", "=", $getvar['do']), 1);
                             //Server edit complete
                             main::done();
                         }
                     }
                     $servers_data = $dbh->fetch_array($servers_query);
                     $serverfile = server::createServer(0, $servers_data['type']);
                     $server_fields = $serverfile->acp_form($getvar['do']);
                     $edit_server_array['NAME'] = $servers_data['name'];
                     $edit_server_array['HOST'] = $servers_data['host'];
                     $edit_server_array['SERVERIP'] = $servers_data['ip'];
                     $edit_server_array['RESELLERPORT'] = $servers_data['resellerport'];
                     $edit_server_array['PORT'] = $servers_data['port'];
                     $edit_server_array['NAMESERVERS'] = $servers_data['nameservers'];
                     $edit_server_array['SERVER_FIELDS'] = $server_fields;
                     echo style::replaceVar("tpl/admin/servers/edit-server.tpl", $edit_server_array);
                 }
             } else {
                 $servers_query = $dbh->select("servers");
                 if ($dbh->num_rows($servers_query) == 0) {
                     echo "There are no servers to view!";
                 } else {
                     echo "<ERRORS>";
                     while ($servers_data = $dbh->fetch_array($servers_query)) {
                         echo main::sub("<strong>" . $servers_data['name'] . "</strong>", '<a href="?page=servers&sub=view&do=' . $servers_data['id'] . '"><img src="' . URL . 'themes/icons/magnifier.png"></a>');
                     }
                 }
             }
             break;
         case "delete":
             if ($getvar['do']) {
                 $dbh->delete("servers", array("id", "=", $getvar['do']));
                 main::errors("Server Deleted!");
             }
             $servers_query = $dbh->select("servers");
             if ($dbh->num_rows($servers_query) == 0) {
                 echo "There are no servers to delete!";
             } else {
                 echo "<ERRORS>";
                 while ($servers_data = $dbh->fetch_array($servers_query)) {
                     echo main::sub("<strong>" . $servers_data['name'] . "</strong>", '<a href="?page=servers&sub=delete&do=' . $servers_data['id'] . '"><img src="' . URL . 'themes/icons/delete.png"></a>');
                 }
             }
             break;
         case "test":
             if (isset($getvar["do"])) {
                 $result = server::testConnection($getvar["do"]);
                 if ($result === true) {
                     echo '<div style="text-align:center;padding-top:10px;">' . style::notice(true, "Connected to the server successfully!") . "</div>";
                 } else {
                     echo '<div style="text-align:center;">' . style::notice(false, "Couldn't connect to the server...") . "</div>";
                     echo '<strong>Error:</strong><pre>' . (string) $result . '</pre>';
                 }
             } else {
                 $servers_query = $dbh->select("servers");
                 if ($dbh->num_rows($servers_query) == 0) {
                     echo "There are no servers to view!";
                 } else {
                     echo "Caution: Some servers are set to automatically ban the IP address of this server (" . $_SERVER['SERVER_ADDR'] . ") after a certain number of failed logins.<br />";
                     while ($servers_data = $dbh->fetch_array($servers_query)) {
                         echo main::sub("<strong>" . $servers_data['name'] . "</strong>", '<a href="?page=servers&sub=test&do=' . $servers_data['id'] . '"><img src="' . URL . 'themes/icons/server_chart.png"></a>');
                     }
                 }
             }
             break;
         case "status":
             $server_status_array['EXTRA'] = '';
             if (!main::canRun('shell_exec')) {
                 $server_status_array['EXTRA'] = 'Some statistics could not be provided because shell_exec has been disabled.<br>';
             }
             $server = $_SERVER['HTTP_HOST'];
             $server_status_array['OS'] = php_uname();
             $server_status_array['DISTRO'] = '';
             if (php_uname('s') == 'Linux') {
                 $distro = main::getLinuxDistro();
                 if ($distro) {
                     $server_status_array['DISTRO'] = '<tr><td><strong>Linux Distro:</strong></td><td> ' . $distro . ' </td></tr>';
                 }
             }
             $server_status_array['SOFTWARE'] = getenv('SERVER_SOFTWARE');
             $server_status_array['PHP_VERSION'] = phpversion();
             $server_status_array['MYSQL_VERSION'] = '';
             $mysqlVersion = $dbh->version();
             if ($mysqlVersion) {
                 $server_status_array['MYSQL_VERSION'] = '<tr><td><strong>MySQL Version:</strong><br><br></td><td> ' . $mysqlVersion . ' <br><br></td></tr>';
             }
             $server_status_array['SERVER'] = $server;
             echo style::replaceVar('tpl/admin/servers/server-status.tpl', $server_status_array);
             break;
         case "phpinfo":
             echo server::show_phpinfo();
             break;
     }
 }
Exemplo n.º 6
0
 public function content()
 {
     global $dbh, $postvar, $getvar, $instance;
     switch ($getvar['sub']) {
         default:
             if ($_POST) {
                 check::empty_fields();
                 if (!main::errors()) {
                     $subdomains_insert = array("domain" => $postvar['domain'], "server" => $postvar['server']);
                     $dbh->insert("subdomains", $subdomains_insert);
                     main::errors("Subdomain domain has been added!");
                 }
             }
             $servers_query = $dbh->select("servers");
             if ($dbh->num_rows($servers_query) == 0) {
                 echo "There are no servers, you need to add a server first!";
                 return;
             }
             while ($servers_data = $dbh->fetch_array($servers_query)) {
                 $values[] = array($servers_data['name'], $servers_data['id']);
             }
             $add_subdomain_array['SERVER'] = main::dropDown("server", $values);
             echo style::replaceVar("tpl/admin/subdomains/add-subdomain.tpl", $add_subdomain_array);
             break;
         case "edit":
             if (isset($getvar['do'])) {
                 $subdomains_data = $dbh->select("subdomains", array("id", "=", $getvar['do']));
                 if (!$subdomains_data['id']) {
                     echo "That subdomain domain doesn't exist!";
                 } else {
                     if ($_POST) {
                         check::empty_fields();
                         if (!main::errors()) {
                             $subdomains_update = array("domain" => $postvar['domain'], "server" => $postvar['server']);
                             $dbh->update("subdomains", $subdomains_update, array("id", "=", $getvar['do']));
                             //Subdomain added
                             main::done();
                         }
                     }
                     $edit_subdomain_array['DOMAIN'] = $subdomains_data['domain'];
                     $servers_query = $dbh->select("servers");
                     while ($servers_data = $dbh->fetch_array($servers_query)) {
                         $values[] = array($servers_data['name'], $servers_data['id']);
                     }
                     $edit_subdomain_array['SERVER'] = main::dropDown("server", $values, $servers_data['server']);
                     echo style::replaceVar("tpl/admin/subdomains/edit-subdomain.tpl", $edit_subdomain_array);
                 }
             } else {
                 $subdomains_query = $dbh->select("subdomains");
                 if ($dbh->num_rows($subdomains_query) == 0) {
                     echo "There are no subdomain domains to edit!";
                 } else {
                     echo "<ERRORS>";
                     while ($subdomains_data = $dbh->fetch_array($subdomains_query)) {
                         echo main::sub("<strong>" . $subdomains_data['domain'] . "</strong>", '<a href="?page=sub&sub=edit&do=' . $subdomains_data['id'] . '"><img src="' . URL . 'themes/icons/pencil.png"></a>');
                     }
                 }
             }
             break;
         case "delete":
             if (isset($getvar['do'])) {
                 $dbh->delete("subdomains", array("id", "=", $getvar['do']));
                 main::errors("Subdomain Deleted!");
             }
             $subdomains_query = $dbh->select("subdomains");
             if ($dbh->num_rows($subdomains_query) == 0) {
                 echo "There are no subdomain domains to delete!";
             } else {
                 echo "<ERRORS>";
                 while ($subdomains_data = $dbh->fetch_array($subdomains_query)) {
                     echo main::sub("<strong>" . $subdomains_data['domain'] . "</strong>", '<a href="?page=sub&sub=delete&do=' . $subdomains_data['id'] . '"><img src="' . URL . 'themes/icons/delete.png"></a>');
                 }
             }
             break;
     }
 }
Exemplo n.º 7
0
 public function content()
 {
     global $dbh, $postvar, $getvar, $instance;
     switch ($getvar['sub']) {
         default:
             if ($_POST['add']) {
                 $no_check_array = array("admin", "groupid", "sendwelcome", "welcomesubject", "welcomebody");
                 check::empty_fields($no_check_array);
                 $ZserverID = $postvar['server'];
                 unset($where);
                 $where[] = array("id", "=", $ZserverID, "AND");
                 $where[] = array("type", "=", "zpanel");
                 $servers_query = $dbh->select("servers", $where, 0, 0, 1);
                 if ($dbh->num_rows($servers_query) == 1) {
                     $zpanel_srv = 1;
                 }
                 //Hack to make sure the Group ID isn't 0 on ZPanel
                 if ($zpanel_srv && ($postvar["groupid"] == 0 || $postvar["backend"] == 0)) {
                     main::errors(" ZPanel server packages must include a Group ID for the package and the a backend package ID that's greater than 0. See the info bubbles for help.");
                 }
                 if ($postvar["monthly"] && !is_numeric($postvar["monthly"]) || $postvar["signup"] && !is_numeric($postvar["signup"])) {
                     main::errors("Please enter a positive number for the cost or posts fields.");
                 }
                 if (!main::errors()) {
                     $not_additional_array = array("add", "name", "backend", "description", "type", "server", "admin", "groupid", "sendwelcome", "welcomesubject", "welcomebody", $GLOBALS['csrf']['input-name']);
                     foreach ($postvar as $key => $value) {
                         if (!in_array($key, $not_additional_array)) {
                             if ($n) {
                                 $additional .= ",";
                             }
                             $additional .= $key . "=" . str_replace(array(" ", ","), array("", "."), $value);
                             $n++;
                         }
                     }
                     $packages_insert = array("name" => $postvar['name'], "backend" => $postvar['backend'], "description" => $postvar['description'], "type" => $postvar['type'], "server" => $postvar['server'], "admin" => $postvar['admin'], "is_hidden" => $postvar['hidden'], "is_disabled" => $postvar['disabled'], "additional" => $additional, "reseller" => $postvar['reseller'], "groupid" => $postvar['groupid'], "send_email" => $postvar['sendwelcome'], "email_subject" => $postvar['welcomesubject'], "email_body" => $postvar['welcomebody']);
                     $dbh->insert("packages", $packages_insert);
                     main::errors("Package has been added!<br>");
                 }
             }
             if ($_POST['packserver'] || $_POST['add']) {
                 $servers_data = $dbh->select("servers", array("id", "=", $postvar['server']), 0, "1");
                 $serverfile = server::createServer(0, $servers_data['type']);
                 $package_fields = $serverfile->acp_packages_form();
                 $add_package_array['TYPE_FORM'] = type::acpPadd($postvar['type']);
                 $add_package_array['TYPE'] = $postvar['type'];
                 $add_package_array['PACKAGES_FIELDS'] = $package_fields;
                 $add_package_array['SERVER'] = $postvar['server'];
                 echo style::replaceVar("tpl/admin/packages/add-package.tpl", $add_package_array);
                 break;
             }
             $servers_query = $dbh->select("servers");
             if ($dbh->num_rows($servers_query) == 0) {
                 echo "There are no servers, you need to add a server first!";
                 return;
             }
             while ($servers_data = $dbh->fetch_array($servers_query)) {
                 $values[] = array($servers_data['name'], $servers_data['id']);
             }
             $p2h_query = $dbh->select("p2h");
             $p2h_data = $dbh->num_rows($p2h_query);
             if ($p2h_data != "0") {
                 $package_server_array['P2HOPTION'] = '<option value="p2h">Post 2 Host</option>';
             } else {
                 $package_server_array['P2HOPTION'] == "";
             }
             $package_server_array['SERVER'] = main::dropDown("server", $values);
             echo "This will only add the package to THT, not create the package on the backend for you.<br><br>";
             echo style::replaceVar("tpl/admin/packages/package-server.tpl", $package_server_array);
             break;
         case "edit":
             if (isset($getvar['do'])) {
                 $packages_query = $dbh->select("packages", array("id", "=", $getvar['do']), 0, 0, 1);
                 if ($dbh->num_rows($packages_query) == 0) {
                     echo "That package doesn't exist!";
                 } else {
                     if ($_POST) {
                         $no_check_array = array("admin", "groupid", "sendwelcome", "welcomesubject", "welcomebody");
                         check::empty_fields($no_check_array);
                         $ZserverID = $postvar['server'];
                         unset($where);
                         $where[] = array("id", "=", $ZserverID, "AND");
                         $where[] = array("type", "=", "zpanel");
                         $servers_query = $dbh->select("servers", $where, 0, 0, 1);
                         if ($dbh->num_rows($servers_query) == 1) {
                             $zpanel_srv = 1;
                         }
                         //Hack to make sure the Group ID isn't 0 on ZPanel
                         if ($zpanel_srv && ($postvar["groupid"] == 0 || $postvar["backend"] == 0)) {
                             main::errors(" ZPanel server packages must include a Group ID for the package and the a backend package ID that's greater than 0. See the info bubbles for help.");
                         }
                         if ($postvar["monthly"] && !is_numeric($postvar["monthly"]) || $postvar["signup"] && !is_numeric($postvar["signup"])) {
                             main::errors("Please enter a positive number for the cost or posts fields.");
                         }
                         if (!main::errors()) {
                             $not_additional_array = array("edit", "name", "backend", "description", "type", "server", "admin", "groupid", "sendwelcome", "welcomesubject", "welcomebody", $GLOBALS['csrf']['input-name']);
                             foreach ($postvar as $key => $value) {
                                 if (!in_array($key, $not_additional_array)) {
                                     if ($n) {
                                         $additional .= ",";
                                     }
                                     $additional .= $key . "=" . str_replace(array(" ", ","), array("", "."), $value);
                                     $n++;
                                 }
                             }
                             if ($postvar['sendwelcome'] && (!$postvar['welcomesubject'] || !$postvar['welcomebody'])) {
                                 $serverid = $postvar['server'];
                                 $server_type_data = $dbh->select("servers", array("id", "=", $serverid));
                                 $server_type = $server_type_data['type'];
                                 if ($server_type == "zpanel") {
                                     include INC . "/servers/" . $server_type . ".php";
                                     $server = new $server_type();
                                     $server_subject_def = server::email_subject;
                                     $server_body_def = server::email_body;
                                     if (!$postvar['welcomesubject']) {
                                         $postvar['welcomesubject'] = $server_subject_def;
                                     }
                                     if (!$postvar['welcomebody']) {
                                         $postvar['welcomebody'] = $server_body_def;
                                     }
                                 }
                             }
                             $packages_update = array("name" => $postvar['name'], "backend" => $postvar['backend'], "description" => $postvar['description'], "server" => $postvar['server'], "admin" => $postvar['admin'], "additional" => $additional, "reseller" => $postvar['reseller'], "is_hidden" => $postvar['hidden'], "is_disabled" => $postvar['disabled'], "type" => $postvar['type'], "groupid" => $postvar['groupid'], "send_email" => $postvar['sendwelcome'], "email_subject" => $postvar['welcomesubject'], "email_body" => $postvar['welcomebody']);
                             $dbh->update("packages", $packages_update, array("id", "=", $getvar['do']));
                             //Package edit complete.
                             main::done();
                         }
                     }
                     $packages_data = $dbh->fetch_array($packages_query);
                     $edit_package_array['BACKEND'] = $packages_data['backend'];
                     $edit_package_array['DESCRIPTION'] = $packages_data['description'];
                     $edit_package_array['NAME'] = $packages_data['name'];
                     $edit_package_array['URL'] = $dbh->config("url");
                     $edit_package_array['ID'] = $packages_data['id'];
                     if ($packages_data['admin'] == 1) {
                         $edit_package_array['ADMIN_CHECKED'] = 'checked="checked"';
                     } else {
                         $edit_package_array['ADMIN_CHECKED'] = "";
                     }
                     if ($packages_data['reseller'] == 1) {
                         $edit_package_array['RESELLER_CHECKED'] = 'checked="checked"';
                     } else {
                         $edit_package_array['RESELLER_CHECKED'] = "";
                     }
                     if ($packages_data['is_hidden'] == 1) {
                         $edit_package_array['HIDDEN_CHECKED'] = 'checked="checked"';
                     } else {
                         $edit_package_array['HIDDEN_CHECKED'] = "";
                     }
                     if ($packages_data['is_disabled'] == 1) {
                         $edit_package_array['DISABLED_CHECKED'] = 'checked="checked"';
                     } else {
                         $edit_package_array['DISABLED_CHECKED'] = "";
                     }
                     $serverfile = server::createServer($getvar['do']);
                     $package_fields = $serverfile->acp_packages_form($getvar['do']);
                     $edit_package_array['PACKAGES_FIELDS'] = $package_fields;
                     $p2h_query = $dbh->select("p2h");
                     $p2h_data = $dbh->num_rows($p2h_query);
                     $edit_package_array['TYPE'] = $packages_data['type'];
                     $additional = $packages_data['additional'];
                     $edit_package_array['TYPE_FORM'] = type::acpPedit($packages_data['type'], $additional, $packages_data['type']);
                     if ($packages_data['type'] == "p2h" && $p2h_data == "0") {
                         $edit_package_array['TYPE_FORM'] = "";
                     }
                     $servers_query = $dbh->select("servers");
                     while ($servers_data = $dbh->fetch_array($servers_query)) {
                         $values[] = array($servers_data['name'], $servers_data['id']);
                     }
                     $edit_package_array['SERVER'] = $packages_data['server'];
                     echo "This will only edit the package on THT, not edit the package on the backend for you.<br><br>";
                     echo style::replaceVar("tpl/admin/packages/edit-package.tpl", $edit_package_array);
                 }
             } else {
                 $packages_query = $dbh->select("packages");
                 if ($dbh->num_rows($packages_query) == 0) {
                     echo "There are no packages to edit!";
                 } else {
                     echo "<ERRORS>";
                     while ($packages_data = $dbh->fetch_array($packages_query)) {
                         echo main::sub("<strong>" . $packages_data['name'] . "</strong>", '<a href="?page=packages&sub=edit&do=' . $packages_data['id'] . '"><img src="' . URL . 'themes/icons/pencil.png"></a>');
                         $n++;
                     }
                 }
             }
             break;
         case "delete":
             if ($getvar['do']) {
                 $dbh->delete("packages", array("id", "=", $getvar['do']));
                 main::errors("Package has been Deleted.<br>");
             }
             $packages_query = $dbh->select("packages");
             if ($dbh->num_rows($packages_query) == 0) {
                 echo "There are no packages to delete.";
             } else {
                 echo "<ERRORS>This will only delete the package on THT, not delete the package on the backend for you.<br><br>";
                 while ($packages_data = $dbh->fetch_array($packages_query)) {
                     echo main::sub("<strong>" . $packages_data['name'] . "</strong>", '<a href="?page=packages&sub=delete&do=' . $packages_data['id'] . '"><img src="' . URL . 'themes/icons/delete.png"></a>');
                     $n++;
                 }
             }
             break;
     }
 }
Exemplo n.º 8
0
function acp()
{
    global $dbh, $postvar, $getvar, $instance;
    ob_start();
    if ($_SESSION['clogged'] || $_SESSION['cuser']) {
        session_destroy();
        main::redirect("?page=home");
    }
    if (!$getvar['page']) {
        $getvar['page'] = "home";
    }
    $page = $dbh->select("acpnav", array("link", "=", $getvar['page']));
    // "Hack" to get the credits and tickets page looking nicer
    switch ($getvar["page"]) {
        case "credits":
            $header = "Credits";
            break;
        default:
            if ($page['visual'] == "Tickets" && $getvar['mode'] == 'ticketsall') {
                $header = "All Tickets";
            } else {
                $header = $page['visual'];
            }
            break;
    }
    $link = "pages/" . $getvar['page'] . ".php";
    $staff_data = $dbh->select("staff", array("id", "=", $_SESSION['user']));
    $user_perms = $staff_data['perms'];
    if (substr_count($user_perms, "paid") == '1') {
        $nopaid = '1';
    }
    if (substr_count($user_perms, "p2h") == '1') {
        $nop2h = '1';
    }
    if (!file_exists($link)) {
        $html = "<strong>THT Fatal Error:</strong> That page doesn't exist.";
    } elseif (!main::checkPerms($page['id']) && !$nopaid && !$nop2h && $user_perms) {
        $html = "You don't have access to this page.";
    } elseif ($getvar['page'] == "type" && $getvar['type'] == "paid" && $nopaid) {
        $html = "You don't have access to this page.";
    } elseif ($getvar['page'] == "type" && $getvar['type'] == "p2h" && $nop2h) {
        $html = "You don't have access to this page.";
    } else {
        include $link;
        $content = new page();
        // Main Side Bar HTML
        $nav = "Sidebar Menu";
        $sub = $dbh->select("acpnav", 0, array("id", "ASC"));
        while ($row = $dbh->fetch_array($sub)) {
            if (main::checkPerms($row['id'])) {
                $sidebarlink_array['IMGURL'] = $row['icon'];
                $sidebarlink_array['LINK'] = "?page=" . $row['link'];
                $sidebarlink_array['VISUAL'] = $row['visual'];
                $sidebar_array['LINKS'] .= style::replaceVar("tpl/sidebar-link.tpl", $sidebarlink_array);
            }
        }
        // Types Navbar
        /*
         * When Working on the navbar, to make a spacer use this:
         * $sidebar_array['LINKS'] .= style::replaceVar("tpl/spacer.tpl");
         */
        foreach ($instance->packtypes as $key => $value) {
            if ($key == "paid" && $nopaid != "1" || $key == "p2h" && $nop2h != "1" || $key != "paid" && $key != "p2h") {
                if ($instance->packtypes[$key]->acpNav) {
                    foreach ($instance->packtypes[$key]->acpNav as $key2 => $value) {
                        $sidebarlink_array['IMGURL'] = $value[2];
                        $sidebarlink_array['LINK'] = "?page=type&type=" . $key . "&sub=" . $value[1];
                        $sidebarlink_array['VISUAL'] = $value[0];
                        $sidebar_array['LINKS'] .= style::replaceVar("tpl/sidebar-link.tpl", $sidebarlink_array);
                        if ($getvar['page'] == "type" && $getvar['type'] == $key && $getvar['sub'] == $value[1]) {
                            define("SUB", $value[3]);
                            $header = $value[3];
                            $getvar['myheader'] = $value[3];
                        }
                    }
                }
            }
        }
        $sidebarlink_array['IMGURL'] = "information.png";
        $sidebarlink_array['LINK'] = "?page=credits";
        $sidebarlink_array['VISUAL'] = "Credits";
        $sidebar_array['LINKS'] .= style::replaceVar("tpl/sidebar-link.tpl", $sidebarlink_array);
        $sidebarlink_array['IMGURL'] = "delete.png";
        $sidebarlink_array['LINK'] = "?page=logout";
        $sidebarlink_array['VISUAL'] = "Logout";
        $sidebar_array['LINKS'] .= style::replaceVar("tpl/sidebar-link.tpl", $sidebarlink_array);
        $sidebar = style::replaceVar("tpl/sidebar.tpl", $sidebar_array);
        //Page Sidebar
        if ($content->navtitle) {
            $subnav = $content->navtitle;
            foreach ($content->navlist as $key => $value) {
                $sub_sidebarlink_array['IMGURL'] = $value[1];
                $sub_sidebarlink_array['LINK'] = "?page=" . $getvar['page'] . "&sub=" . $value[2];
                $sub_sidebarlink_array['VISUAL'] = $value[0];
                $sub_sidebar_array['LINKS'] .= style::replaceVar("tpl/sidebar-link.tpl", $sub_sidebarlink_array);
            }
            $subsidebar = style::replaceVar("tpl/sidebar.tpl", $sub_sidebar_array);
        }
        if ($getvar['sub'] && $getvar['page'] != "type") {
            foreach ($content->navlist as $key => $value) {
                if ($value[2] == $getvar['sub']) {
                    if (!$value[0]) {
                        define("SUB", $getvar['page']);
                        $header = $getvar['page'];
                    } else {
                        define("SUB", $value[0]);
                        $header = $value[0];
                    }
                }
            }
        }
        if ($getvar['sub'] == "delete" && isset($getvar['do']) && !$_POST && !$getvar['confirm']) {
            foreach ($postvar as $key => $value) {
                $warning_array['HIDDEN'] .= '<input name="' . $key . '" type="hidden" value="' . $value . '" />';
            }
            $warning_array['HIDDEN'] .= " ";
            $html = style::replaceVar("tpl/warning.tpl", $warning_array);
        } elseif ($getvar['sub'] == "delete" && isset($getvar['do']) && $_POST && !$getvar['confirm']) {
            if ($postvar['yes']) {
                foreach ($getvar as $key => $value) {
                    if ($i) {
                        $i = "&";
                    } else {
                        $i = "?";
                    }
                    $url .= $i . $key . "=" . $value;
                }
                $url .= "&confirm=1";
                main::redirect($url);
            } elseif ($postvar['no']) {
                main::done();
            }
        } else {
            if (isset($getvar['sub'])) {
                ob_start();
                $content->content();
                $html = ob_get_contents();
                // Retrieve the HTML
                ob_clean();
                // Flush the HTML
            } elseif ($content->navlist) {
                $html .= $content->description();
                // First, we gotta get the page description.
                $html .= "<br /><br />";
                // Break it up
                // Now we should prepend some stuff here
                $subsidebar2 .= "<strong>Page Submenu</strong><div class='break'></div>";
                $subsidebar2 .= $subsidebar;
                // Done, now output it in a sub() table
                $html .= main::sub($subsidebar2, NULL);
                // Initial implementation, add the SubSidebar(var) into the description, basically append it
            } else {
                ob_start();
                $content->content();
                $html = ob_get_contents();
                // Retrieve the HTML
                ob_clean();
                // Flush the HTML
            }
        }
    }
    $staffuser = $dbh->staff($_SESSION['user']);
    define("SUB", $header);
    define("INFO", '<b>Welcome back, ' . strip_tags($staffuser['name']) . '</b><br />' . SUB);
    echo '<div id="left">';
    echo main::table($nav, $sidebar);
    if ($content->navtitle) {
        echo "<br />";
        echo main::table($subnav, $subsidebar);
    }
    echo '</div>';
    echo '<div id="right">';
    echo main::table($header, $html);
    echo '</div>';
    $html_buff = ob_get_contents();
    ob_clean();
    return $html_buff;
}
Exemplo n.º 9
0
function client()
{
    global $dbh, $postvar, $getvar, $instance;
    ob_start();
    // Stop the output buffer
    if (!$getvar['page']) {
        $getvar['page'] = "home";
    }
    $page = $dbh->select("clientnav", array("link", "=", $getvar['page']), array("id", "ASC"));
    $header = $page['visual'];
    $link = "pages/" . $getvar['page'] . ".php";
    if (!file_exists($link)) {
        $html = "That page doesn't exist.";
    } else {
        if (preg_match("/[\\.*]/", $getvar['page']) == 0) {
            include $link;
            $content = new page();
            // Main Side Bar HTML
            $nav = "Sidebar";
            if (!$dbh->config("delacc")) {
                $clientnav_query = $dbh->select("clientnav", array("link", "!=", "delete"), array("id", "ASC"), 0, 1);
            } else {
                $clientnav_query = $dbh->select("clientnav", 0, array("id", "ASC"), 0, 1);
            }
            while ($clientnav_data = $dbh->fetch_array($clientnav_query)) {
                $sidebar_link_array['IMGURL'] = $clientnav_data['icon'];
                $sidebar_link_array['LINK'] = "?page=" . $clientnav_data['link'];
                $sidebar_link_array['VISUAL'] = $clientnav_data['visual'];
                $sidebar_array['LINKS'] .= style::replaceVar("tpl/sidebar-link.tpl", $sidebar_link_array);
            }
            // Types Navbar
            $client = $dbh->client($_SESSION['cuser']);
            $packtype = $instance->packtypes[type::packagetype($client['pid'])];
            if ($packtype->clientNav) {
                foreach ($packtype->clientNav as $key2 => $value) {
                    $sidebar_link_array['IMGURL'] = $value[2];
                    $sidebar_link_array['LINK'] = "?page=type&type=" . type::packagetype($client['pid']) . "&sub=" . $value[1];
                    $sidebar_link_array['VISUAL'] = $value[0];
                    $sidebar_array['LINKS'] .= style::replaceVar("tpl/sidebar-link.tpl", $sidebar_link_array);
                    if ($getvar['page'] == "type" && $getvar['type'] == type::packagetype($client['pid']) && $getvar['sub'] == $value[1]) {
                        define("SUB", $value[3]);
                        $header = $value[3];
                        $getvar['myheader'] = $value[3];
                    }
                }
            }
            $sidebar_link_array['IMGURL'] = "delete.png";
            $sidebar_link_array['LINK'] = "?page=logout";
            $sidebar_link_array['VISUAL'] = "Logout";
            $sidebar_array['LINKS'] .= style::replaceVar("tpl/sidebar-link.tpl", $sidebar_link_array);
            $sidebar = style::replaceVar("tpl/sidebar.tpl", $sidebar_array);
            //Page Sidebar
            if ($content->navtitle) {
                $subnav = $content->navtitle;
                foreach ($content->navlist as $key => $value) {
                    $sidebar_link_array['IMGURL'] = $value[1];
                    $sidebar_link_array['LINK'] = "?page=" . $getvar['page'] . "&sub=" . $value[2];
                    $sidebar_link_array['VISUAL'] = $value[0];
                    $sub_sidebar_array['LINKS'] .= style::replaceVar("tpl/sidebar-link.tpl", $sidebar_link_array);
                }
                $subsidebar = style::replaceVar("tpl/sidebar.tpl", $sub_sidebar_array);
            }
            if ($getvar['sub'] == "delete" && isset($getvar['do']) && !$_POST && !$getvar['confirm']) {
                foreach ($postvar as $key => $value) {
                    $warning_array['HIDDEN'] .= '<input name="' . $key . '" type="hidden" value="' . $value . '" />';
                }
                $warning_array['HIDDEN'] .= " ";
                $html = style::replaceVar("tpl/warning.tpl", $warning_array);
            } elseif ($getvar['sub'] == "delete" && isset($getvar['do']) && $_POST && !$getvar['confirm']) {
                if ($postvar['yes']) {
                    foreach ($getvar as $key => $value) {
                        if ($i) {
                            $i = "&";
                        } else {
                            $i = "?";
                        }
                        $url .= $i . $key . "=" . $value;
                    }
                    $url .= "&confirm=1";
                    main::redirect($url);
                } elseif ($postvar['no']) {
                    main::done();
                }
            } else {
                if (isset($getvar['sub'])) {
                    ob_start();
                    $content->content();
                    $html = ob_get_contents();
                    // Retrieve the HTML
                    ob_clean();
                    // Flush the HTML
                } elseif ($content->navlist) {
                    if ($content->description()) {
                        $html = $content->description() . "<br><br>";
                    }
                    $html .= "Select a sub-page from the sidebar.";
                } else {
                    ob_start();
                    $content->content();
                    $html = ob_get_contents();
                    // Retrieve the HTML
                    ob_clean();
                    // Flush the HTML
                }
            }
        }
    }
    if ($getvar['sub'] && $getvar['page'] != "type") {
        foreach ($content->navlist as $key => $value) {
            if ($value[2] == $getvar['sub']) {
                define("SUB", $value[0]);
                $header = $value[0];
            }
        }
    }
    $staffuser = $dbh->client($_SESSION['cuser']);
    define("SUB", $header);
    define("INFO", '<b>Welcome back, ' . $staffuser['user'] . '</b><br />' . SUB);
    echo '<div id="left">';
    echo main::table($nav, $sidebar);
    if ($content->navtitle) {
        echo "<br />";
        echo main::table($subnav, $subsidebar);
    }
    echo '</div>';
    echo '<div id="right">';
    echo main::table($header, $html);
    echo '</div>';
    $html_buff = ob_get_contents();
    ob_clean();
    return $html_buff;
}