Esempio n. 1
0
 public function content()
 {
     global $dbh, $postvar, $getvar, $instance;
     $client_data = $dbh->client($_SESSION['cuser']);
     $packages_data = $dbh->select("packages", array("id", "=", $client_data['pid']));
     $view_package_array['USER'] = $client_data['user'];
     $view_package_array['SIGNUP'] = main::convertdate("n/d/Y", $client_data['signup']);
     $view_package_array['DOMAIN'] = $client_data['domain'];
     $view_package_array['PACKAGE'] = $packages_data['name'] . " <a href = '?page=upgrade'>Change</a>";
     $view_package_array['DESCRIPTION'] = $packages_data['description'];
     if ($_POST) {
         if (crypto::passhash($postvar['currentpass'], $client_data['salt']) == $client_data['password']) {
             if ($postvar['newpass'] == $postvar['cpass']) {
                 $cmd = main::changeClientPassword($client_data['id'], $postvar['newpass']);
                 if ($cmd === true) {
                     main::errors("Details updated!");
                 } else {
                     main::errors((string) $cmd);
                 }
             } else {
                 main::errors("Your passwords don't match!");
             }
         } else {
             main::errors("Your current password wasn't correct!");
         }
     }
     echo style::replaceVar("tpl/client/view-package.tpl", $view_package_array);
 }
Esempio n. 2
0
 public function content()
 {
     global $dbh, $postvar, $getvar, $instance;
     if ($_POST) {
         check::empty_fields();
         if (!main::errors()) {
             $user = $dbh->staff($_SESSION['user']);
             if (!$user['password']) {
                 main::errors("Wrong username!?");
             } else {
                 if (crypto::passhash($postvar['old'], $user['salt']) == $user['password']) {
                     if ($postvar['new'] != $postvar['confirm']) {
                         main::errors("Your passwords don't match!");
                     } else {
                         $salt = crypto::salt();
                         $newpass = crypto::passhash($postvar['new'], $salt);
                         $update_staff = array("password" => $newpass, "salt" => $salt);
                         $dbh->update("staff", $update_staff, array("id", "=", $_SESSION['user']));
                         main::errors("Password changed!");
                     }
                 } else {
                     main::errors("Your old password was wrong!");
                 }
             }
         }
     }
     echo style::replaceVar("tpl/admin/change-admin-password.tpl");
 }
Esempio n. 3
0
 public function content()
 {
     global $dbh, $postvar, $getvar, $instance;
     if (!$dbh->config("delacc")) {
         die('This feature has been disabled.');
     } else {
         if ($_POST) {
             $user = $_SESSION['cuser'];
             $pass = $postvar['password'];
             $client = $dbh->client($user);
             unset($where);
             $where[] = array("is_paid", "=", "0", "AND");
             $where[] = array("uid", "=", $user);
             $balance_query = $dbh->select("invoices", $where, 0, "1", 1);
             if ($dbh->num_rows($balance_query) != 0) {
                 main::errors("You can't close your account with an outstanding balance.  Please contact an administrator for assistance or pay any unpaid invoices.");
             }
             if (crypto::passhash($pass, $client['salt']) == $client['password']) {
                 if (server::terminate($client['id'], "", 1)) {
                     main::errors("Your account has been cancelled successfully.");
                     session_destroy();
                 } else {
                     main::errors("Your account wasn't cancelled.  Please try again or contact your system administrator.");
                 }
             } else {
                 main::errors("The password entered is incorrect.");
             }
         }
         echo style::replaceVar("tpl/client/delete-account.tpl");
     }
 }
Esempio n. 4
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);
 }
Esempio n. 5
0
 public function content()
 {
     global $dbh, $postvar, $getvar, $instance;
     if ($dbh->config('alerts')) {
         $announcements_array['ALERTS'] = $dbh->config('alerts');
         echo style::replaceVar('tpl/client/announcements.tpl', $announcements_array);
     } else {
         echo 'No Announcements Available';
     }
 }
Esempio n. 6
0
 public function conf_perms()
 {
     if (is_writable(INC . "/conf.inc.php")) {
         if (main::perms(INC . "/conf.inc.php", 0444)) {
             main::errors("Configuration File made unwritable.");
         } else {
             main::errors("Failed to make the configuration file unwritable.");
         }
     } else {
         main::errors("Configuration File is already unwritable.");
     }
     echo style::replaceVar('tpl/admin/system/perms-tools.tpl');
 }
Esempio n. 7
0
 public function content()
 {
     global $dbh, $postvar, $getvar, $instance;
     $cats_query = $dbh->select("cats");
     if (!$dbh->num_rows($cats_query)) {
         echo "There are no knowledge base categories or articles!";
     } else {
         if ($getvar['cat']) {
             $cats_data = $dbh->select("cats", array("id", "=", $getvar['cat']));
             if (!$cats_data['id']) {
                 echo "That category doesn't exist!";
             } else {
                 echo main::sub('<img src="<ICONDIR>arrow_rotate_clockwise.png"><a href="?page=kb">Return To Category Selection</a>', '');
                 $articles_query = $dbh->select("articles", array("catid", "=", $getvar['cat']), 0, 0, 1);
                 if (!$dbh->num_rows($articles_query)) {
                     echo "There are no articles in this category!";
                 } else {
                     while ($articles_data = $dbh->fetch_array($articles_query)) {
                         $article_box_array['NAME'] = $articles_data['name'];
                         $article_box_array['ID'] = $articles_data['id'];
                         echo style::replaceVar("tpl/kb/article-box.tpl", $article_box_array);
                     }
                 }
             }
             return;
         }
         if ($getvar['art']) {
             $articles_data = $dbh->select("articles", array("id", "=", $getvar['art']));
             if (!$articles_data['id']) {
                 echo "That article doesn't exist!";
             } else {
                 $view_article_array['NAME'] = $articles_data['name'];
                 $view_article_array['CONTENT'] = $articles_data['content'];
                 $view_article_array['CATID'] = $articles_data['catid'];
                 echo style::replaceVar("tpl/kb/view-article.tpl", $view_article_array);
             }
             return;
         }
         //Show this by default.
         while ($cats_data = $dbh->fetch_array($cats_query)) {
             $category_box_array['NAME'] = $cats_data['name'];
             $category_box_array['DESCRIPTION'] = $cats_data['description'];
             $category_box_array['ID'] = $cats_data['id'];
             echo style::replaceVar("tpl/kb/category-box.tpl", $category_box_array);
         }
     }
 }
Esempio n. 8
0
function writeconfig($host, $user, $pass, $db, $pre, $true)
{
    $conftemp_array['HOST'] = addcslashes($host, '\\\'');
    $conftemp_array['USER'] = addcslashes($user, '\\\'');
    $conftemp_array['PASS'] = addcslashes($pass, '\\\'');
    $conftemp_array['DB'] = addcslashes($db, '\\\'');
    $conftemp_array['PRE'] = addcslashes($pre, '\\\'');
    $conftemp_array['TRUE'] = $true;
    $tpl = style::replaceVar("../install/includes/tpl/conf-inc-temp.tpl", $conftemp_array);
    $link = INC . "/conf.inc.php";
    if (is_writable($link)) {
        file_put_contents($link, $tpl);
        return true;
    } else {
        return false;
    }
}
Esempio n. 9
0
 public function import()
 {
     global $dbh, $postvar, $getvar, $instance;
     if (!$_POST) {
         $servers_query = $dbh->select("servers", array("type", "=", "zpanel"), 0, 0, 1);
         while ($servers_data = $dbh->fetch_array($servers_query)) {
             $values[] = array($servers_data['name'], $servers_data['id']);
         }
         $zpanel_array['DROPDOWN'] = main::dropdown("server", $values);
         echo style::replaceVar("tpl/admin/import/zpanel.tpl", $zpanel_array);
     } elseif ($_POST) {
         $postvar['server'] = $postvar['server'];
         //Hack to make sure we post the 'server' field as it doesn't post if it's empty.
         check::empty_fields();
         if (main::errors()) {
             echo "<ERRORS>";
         } else {
             $n = 0;
             include INC . "/servers/zpanel.php";
             $zpanel = new zpanel($postvar['server']);
             $zpanel_accounts = $zpanel->listaccs($postvar['server']);
             foreach ($zpanel_accounts as $zpanel_data) {
                 $packages_data = $dbh->select("packages", array("backend", "=", $zpanel_data['package']));
                 $users_data = $dbh->select("users", array("user", "=", $zpanel_data['user']));
                 if (!$packages_data['id']) {
                     $packages_insert = array("name" => $zpanel_data['package'], "backend" => $zpanel_data['package'], "description" => "Imported from ZPanel: " . $zpanel_data['package'], "type" => "free", "server" => $postvar['server'], "admin" => "1");
                     $dbh->insert("packages", $packages_insert);
                 }
                 $new_packages_data = $dbh->select("packages", array("backend", "=", $zpanel_data['package']));
                 if (!$users_data['id']) {
                     $salt = crypto::salt();
                     $newpass = crypto::passhash(rand(), $salt);
                     $users_insert = array("user" => $zpanel_data['user'], "zpanel_uid" => $zpanel_data['user'], "email" => $zpanel_data['user'], "password" => $zpanel_data['user'], "salt" => $zpanel_data['user'], "signup" => $zpanel_data['user'], "status" => $zpanel_data['user'], "domain" => $zpanel_data['user'], "pid" => $zpanel_data['user']);
                     $dbh->insert("users", $users_insert);
                     $dbh->insert("users_bak", $users_insert);
                     $n++;
                 }
             }
             echo $n . " Accounts have been imported";
         }
     }
 }
Esempio n. 10
0
 public function content()
 {
     global $dbh, $postvar, $getvar, $instance;
     unset($where);
     $where[] = array("reply", "=", "0", "AND");
     $where[] = array("userid", "=", $_SESSION['cuser']);
     $all_tickets_query = $dbh->select("tickets", $where, 0, 0, 1);
     $client_home_array['TICKETS'] = $dbh->num_rows($all_tickets_query);
     unset($where);
     $where[] = array("reply", "=", "0", "AND");
     $where[] = array("status", "=", "1", "AND");
     $where[] = array("userid", "=", $_SESSION['cuser']);
     $open_tickets_query = $dbh->select("tickets", $where, 0, 0, 1);
     $client_home_array['OPENTICKETS'] = $dbh->num_rows($open_tickets_query);
     unset($where);
     $where[] = array("reply", "=", "0", "AND");
     $where[] = array("status", "=", "3", "AND");
     $where[] = array("userid", "=", $_SESSION['cuser']);
     $closed_tickets_query = $dbh->select("tickets", $where, 0, 0, 1);
     $client_home_array['CLOSEDTICKETS'] = $dbh->num_rows($closed_tickets_query);
     unset($where);
     $where[] = array("uid", "=", $_SESSION['cuser'], "AND");
     $where[] = array("message", "LIKE", "Login%");
     $log_data = $dbh->select("logs", $where, array("id", "DESC"), "1");
     if ($log_data['logtime']) {
         $client_home_array['LASTDATE'] = main::convertdate("n/d/Y", $log_data['logtime']);
         $client_home_array['LASTTIME'] = main::convertdate("g:i a", $log_data['logtime']);
         $client_home_array['LASTLOGIN'] = $client_home_array['LASTDATE'] . " at " . $client_home_array['LASTTIME'];
     } else {
         $client_home_array['LASTLOGIN'] = "******";
     }
     $client_data = $dbh->client($_SESSION['cuser']);
     $client_home_array['DATE'] = main::convertdate("n/d/Y", $client_data['signup']);
     $client_home_array['EMAIL'] = $client_data['email'];
     $client_home_array['ALERTS'] = $dbh->config('alerts');
     $client_home_array['UNAME'] = $client_data['user'];
     $packages_data = $dbh->select("packages", array("id", "=", $client_data['pid']));
     $client_home_array['PACKAGE'] = $packages_data['name'];
     unset($where);
     $where[] = array("uid", "=", $client_data['id'], "AND");
     $where[] = array("is_paid", "=", "0");
     $invoices_query = $dbh->select("invoices", $where, 0, 0, 1);
     $client_home_array['INVOICES'] = $dbh->num_rows($invoices_query);
     unset($where);
     $where[] = array("uid", "=", $client_data['id'], "AND");
     $where[] = array("message", "LIKE", "Suspended (%");
     $suspended_data = $dbh->select("logs", $where, array("id", "DESC"), "1");
     switch ($client_data['status']) {
         default:
             $client_home_array['STATUS'] = "Other";
             break;
         case "1":
             $client_home_array['STATUS'] = "Active";
             break;
         case "2":
             $client_home_array['STATUS'] = "Suspended";
             $suspended_message = str_replace(")", "", $suspended_data['message']);
             $suspended_message = str_replace("Suspended (", "", $suspended_message);
             $client_home_array['STATUS_REASON'] = "<br><br><b>Suspended for:</b> " . $suspended_message;
             break;
         case "4":
             $client_home_array['STATUS'] = "Awaiting Payment";
             break;
         case "5":
             $client_home_array['STATUS'] = "Awaiting Email Confirmation";
             break;
         case "9":
             $client_home_array['STATUS'] = "Cancelled";
             break;
     }
     if (!$client_home_array['STATUS_REASON']) {
         $client_home_array['STATUS_REASON'] = "";
     }
     $typename = type::packagetype($client_data['pid']);
     $type_instance = $instance->packtypes[$typename];
     if (method_exists($type_instance, "clientBox")) {
         $box = $type_instance->clientBox();
         $client_home_array['BOX'] = main::sub($box[0], $box[1]);
     } else {
         $clienthome_array['BOX'] = "";
     }
     if ($dbh->config('alerts')) {
         $client_home_array['ALERTS'] = "<font size = '3'><b>Announcements:</b></font><br><font size = '2'>" . $dbh->config('alerts') . "</font><br><hr size = '1' noshade'><br>";
     } else {
         $client_home_array['ALERTS'] = "";
     }
     echo style::replaceVar("tpl/client/client-home.tpl", $client_home_array);
 }
Esempio n. 11
0
 public function content()
 {
     global $dbh, $postvar, $getvar, $instance;
     $client = $dbh->client($_SESSION['cuser']);
     $edit_account_array['USER'] = $client['user'];
     $edit_account_array['EMAIL'] = $client['email'];
     $edit_account_array['DOMAIN'] = $client['domain'];
     $edit_account_array['FIRSTNAME'] = $client['firstname'];
     $edit_account_array['LASTNAME'] = $client['lastname'];
     $edit_account_array['ADDRESS'] = $client['address'];
     $edit_account_array['CITY'] = $client['city'];
     $edit_account_array['STATE'] = $client['state'];
     $edit_account_array['ZIP'] = $client['zip'];
     $edit_account_array['PHONE'] = $client['phone'];
     $edit_account_array['TZADJUST'] = main::tzlist($client['tzadjust']);
     $edit_account_array['DISP'] = "<div>";
     $edit_account_array['COUNTRY'] = main::countries(1, $client['country']) . '<a title="Your country." class="tooltip"><img src="<ICONDIR>information.png" /></a>';
     if ($_POST) {
         if (!check::email($postvar['email'], $_SESSION['cuser'])) {
             main::errors("Your email is the wrong format!");
         }
         if (!check::state($postvar['state'])) {
             main::errors("Please enter a valid state!");
         }
         if (!check::address($postvar['address'])) {
             main::errors("Please enter a valid address!");
         }
         if (!check::phone($postvar['phone'])) {
             main::errors("Please enter a valid phone number!");
         }
         if (!check::zip($postvar['zip'])) {
             main::errors("Please enter a valid zip/postal code!");
         }
         if (!check::city($postvar['city'])) {
             main::errors("Please enter a valid city!");
         }
         if (!check::firstname($postvar['firstname'])) {
             main::errors("Please enter a valid first name!");
         }
         if (!check::lastname($postvar['lastname'])) {
             main::errors("Please enter a valid time last name!");
         }
         if (!main::errors()) {
             if ($postvar['country']) {
                 $country_q = "";
             }
             $users_update = array("email" => $postvar['email'], "state" => $postvar['state'], "address" => $postvar['address'], "phone" => $postvar['phone'], "zip" => $postvar['zip'], "city" => $postvar['city'], "tzadjust" => $postvar['tzones'], "firstname" => $postvar['firstname'], "lastname" => $postvar['lastname'], "country" => $postvar['country']);
             $dbh->update("users", $users_update, array("id", "=", $_SESSION['cuser']));
             if ($postvar['change']) {
                 $client = $dbh->client($_SESSION['cuser']);
                 if (crypto::passhash($postvar['currentpass'], $client['salt']) == $client['password']) {
                     if ($postvar['newpass'] === $postvar['cpass']) {
                         $cmd = main::changeClientPassword($_SESSION['cuser'], $postvar['newpass']);
                         if ($cmd === true) {
                             main::errors("Details updated!");
                         } else {
                             main::errors((string) $cmd);
                         }
                     } else {
                         main::errors("Your passwords don't match!");
                     }
                 } else {
                     main::errors("Your current password is incorrect.");
                 }
             } else {
                 $edit_account_array['DISP'] = "<div style=\"display:none;\">";
                 main::errors("Details updated!");
             }
         }
     }
     echo style::replaceVar("tpl/client/edit-account.tpl", $edit_account_array);
 }
Esempio n. 12
0
                $serverfile = server::createServer($server_type);
                $can_create_subs = $serverfile->subdomains;
                if ($can_create_subs == false) {
                    $maincontent = main::table("Subdomain Error", "Sorry, but the server for this package doesn't allow subdomains to be used without a unique domain present on the account.  If you'd like to\n                                                                   use a domain, please go back and select the domain option.");
                } else {
                    $subdomains_query = $dbh->select("subdomains", array("server", "=", $server_type), array("subdomain", "ASC"), 0, 1);
                    while ($subdomains_data = $dbh->fetch_array($subdomains_query)) {
                        $subdomains[] = array($subdomains_data['domain'], $subdomains_data['domain']);
                    }
                    if ($postvar['csub2']) {
                        $subtld = $postvar['csub2'];
                    } else {
                        $subtld = $subdomains[0]['domain'];
                    }
                    $subdomain_array['SUBDOMTLDLIST'] = main::dropdown("csub2", $subdomains, $subtld);
                    $order_form_array['DOMORSUB'] = style::replaceVar("tpl/order/subdomain.tpl", $subdomain_array);
                }
            }
        }
    }
    //Spit out the page
    if (!$maincontent) {
        $maincontent = style::replaceVar("tpl/order/order-form.tpl", $order_form_array);
    }
    echo '<div>';
    echo $maincontent;
    echo '</div>';
}
echo '</div>';
echo style::get("footer.tpl");
include INC . "/output.php";
Esempio n. 13
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;
     }
 }
Esempio n. 14
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;
     }
 }
Esempio n. 15
0
 public function search()
 {
     global $dbh, $postvar, $getvar, $instance;
     if ($_SESSION['logged']) {
         $type = $getvar['type'];
         $value = $getvar['value'];
         if ($getvar['num']) {
             $show = $getvar['num'];
         } else {
             $show = 10;
         }
         if ($getvar['page'] != 1) {
             $lower = $getvar['page'] * $show;
             $lower = $lower - $show;
             $upper = $lower + $show;
         } else {
             $lower = 0;
             $upper = $show;
         }
         $users_query = $dbh->select("users", array($type, "LIKE", "%" . $value . "%"), array($type, "ASC"), $lower . ", " . $upper, 1);
         if ($dbh->num_rows($users_query) == 0) {
             echo "No clients found!";
         } else {
             while ($users_data = $dbh->fetch_array($users_query)) {
                 if ($n != $show) {
                     $client = $dbh->client($users_data['id']);
                     $client_search_box_array['ID'] = $client['id'];
                     $client_search_box_array['USER'] = $client['user'];
                     $client_search_box_array['DOMAIN'] = $client['domain'];
                     $client_search_box_array['URL'] = URL;
                     switch ($client['status']) {
                         case "1":
                             $client_search_box_array['TEXT'] = "Suspend";
                             $client_search_box_array['FUNC'] = "sus";
                             $client_search_box_array['IMG'] = "exclamation.png";
                             break;
                         case "2":
                             $client_search_box_array['TEXT'] = "Unsuspend";
                             $client_search_box_array['FUNC'] = "unsus";
                             $client_search_box_array['IMG'] = "accept.png";
                             break;
                         case "3":
                             $client_search_box_array['TEXT'] = "Validate";
                             $client_search_box_array['FUNC'] = "none";
                             $client_search_box_array['IMG'] = "user_suit.png";
                             break;
                         case "4":
                             $client_search_box_array['TEXT'] = "Awaiting Payment";
                             $client_search_box_array['FUNC'] = "none";
                             $client_search_box_array['IMG'] = "money.png";
                             break;
                         case "5":
                             $client_search_box_array['TEXT'] = "Awaiting Email Confirmation";
                             $client_search_box_array['FUNC'] = "none";
                             $client_search_box_array['IMG'] = "email.png";
                             break;
                         default:
                             $client_search_box_array['TEXT'] = "Other Status";
                             $client_search_box_array['FUNC'] = "none";
                             $client_search_box_array['IMG'] = "help.png";
                             break;
                     }
                     echo style::replaceVar("tpl/admin/clients/client-search-box.tpl", $client_search_box_array);
                     $n++;
                 }
             }
             echo '<div class="break"></div>';
             echo '<div align="center">';
             $num = $dbh->num_rows($users_query);
             $pages = ceil($num / $show);
             echo "Page";
             for ($i; $i != $pages + 1; $i += 1) {
                 echo ' <a href="Javascript: page(\'' . $i . '\')">' . $i . '</a>';
             }
             echo '</div>';
         }
     }
 }
Esempio n. 16
0
 public function acpPedit($type, $values, $origtype)
 {
     global $dbh, $postvar, $getvar, $instance;
     $usingtype = $type;
     $type = $instance->packtypes[$type];
     if ($type->acpForm) {
         if ($usingtype != $origtype) {
             foreach ($type->acpForm as $key => $value) {
                 $type_form_array['NAME'] = $value[0] . ":";
                 $type_form_array['FORM'] = $value[1];
                 $html .= style::replaceVar("tpl/type-form.tpl", $type_form_array);
             }
         } else {
             $values = explode(",", $values);
             foreach ($values as $key => $value) {
                 $me = explode("=", $value);
                 $cform[$me[0]] = $me[1];
             }
             foreach ($type->acpForm as $value) {
                 $type_form_array['NAME'] = $value[0] . ":";
                 $hit = explode("/>", $value[1]);
                 $default = "";
                 if (stripos($value[1], "</select>") === false) {
                     $default = ' value="' . $cform[$value[2]] . '" />';
                 }
                 $type_form_array['FORM'] = $hit[0] . $default;
                 $html .= style::replaceVar("tpl/type-form.tpl", $type_form_array);
             }
         }
         return $html;
     }
 }
Esempio n. 17
0
 public function clientPage()
 {
     global $dbh, $postvar, $getvar, $instance;
     if (is_numeric($getvar['remove'])) {
         coupons::remove_p2h_coupon($getvar['remove']);
         main::redirect("?page=type&type=p2h&sub=forums");
         exit;
     }
     if ($_POST['submitaddcoupon']) {
         if (!$postvar['addcoupon']) {
             main::errors("Please enter a coupon code.");
         } else {
             $coupcode = $postvar['addcoupon'];
             $pack_data = main::uidtopack();
             $packid = $pack_data['packages']['id'];
             $multi_coupons = $dbh->config("multicoupons");
             $coupon_info = coupons::coupon_data($coupcode);
             $coupid = $coupon_info['id'];
             $use_coupon = coupons::use_coupon($coupid, $packid);
             if (!$use_coupon) {
                 if (!$multi_coupons) {
                     main::errors("Coupon code entered was invalid or you're already using a coupon.");
                 } else {
                     main::errors("Coupon code entered was invalid.");
                 }
             } else {
                 main::redirect("?page=type&type=p2h&sub=forums");
             }
         }
     }
     $userid = $_SESSION['cuser'];
     $client = $dbh->client($userid);
     $forum = type::additional($client['pid'], 'forum');
     $user = type::userAdditional($client['id']);
     $fdetails = $this->forumdata($forum);
     $this->con = $this->forumCon($forum);
     $posts = $this->checkMonthly($fdetails['forumtype'], $user['fuser'], $fdetails['prefix']);
     $total_posts = coupons::totalposts($userid);
     $p2h_payments = $dbh->select("coupons_p2h", array("uid", "=", $userid));
     $package_info = main::uidtopack($userid);
     $user_posts = $this->userposts($package_info['packages']['id'], $package_info['user_data']['id']);
     $monthly = $this->getMonthly($client['pid']);
     if (empty($p2h_payments)) {
         $p2h_pay_array = array("uid" => $userid, "amt_paid" => $user_posts, "txn" => $package_info['uadditional']['fuser'], "datepaid" => time(), "gateway" => $package_info['additional']['forum']);
         $dbh->insert("coupons_p2h", $p2h_pay_array);
         $p2h_payments = $dbh->select("coupons_p2h", array("uid", "=", $userid));
     }
     $amt_paid = $p2h_payments['amt_paid'];
     $txn = $p2h_payments['txn'];
     $datepaid = $p2h_payments['datepaid'];
     $gateway = $p2h_payments['gateway'];
     $amt_paid = explode(",", $amt_paid);
     $txn = explode(",", $txn);
     $datepaid = explode(",", $datepaid);
     $gateway = explode(",", $gateway);
     for ($i = 0; $i < count($amt_paid); $i++) {
         if ($txn[$i] == $package_info['uadditional']['fuser']) {
             if ($amt_paid[$i] != $user_posts) {
                 $reload = 1;
             }
             $amt_paid[$i] = $user_posts;
             $datepaid[$i] = time();
         }
         $p2h_data = $dbh->select("p2h", array("id", "=", $gateway[$i]));
         $transaction_list_array['PAIDAMOUNT'] = main::s($amt_paid[$i], " Post");
         $transaction_list_array['TXN'] = $txn[$i];
         $transaction_list_array['PAIDDATE'] = main::convertdate("n/d/Y", $datepaid[$i]);
         $transaction_list_array['GATEWAY'] = str_replace(",", "", $p2h_data['forumname']);
         $invoice_transactions_array['TXNS'] .= style::replaceVar("tpl/invoices/transaction-list.tpl", $transaction_list_array);
         $paidamts = $paidamts . "," . $amt_paid[$i];
         $paidtxn = $paidtxn . "," . $txn[$i];
         $paiddate = $paiddate . "," . $datepaid[$i];
         $paidgateway = $paidgateway . "," . $gateway[$i];
     }
     $paidamts = substr($paidamts, 1, strlen($paidamts));
     $paidtxn = substr($paidtxn, 1, strlen($paidtxn));
     $paiddate = substr($paiddate, 1, strlen($paiddate));
     $paidgateway = substr($paidgateway, 1, strlen($paidgateway));
     $p2h_pay_array = array("amt_paid" => $paidamts, "txn" => $paidtxn, "datepaid" => $paiddate, "gateway" => $paidgateway);
     $where[] = array("uid", "=", $userid);
     $dbh->update("coupons_p2h", $p2h_pay_array, $where);
     if ($reload) {
         main::redirect("?page=type&type=p2h&sub=forums");
     }
     $invoice_transactions_array['TOTALPAID'] = main::s($total_posts, " Post");
     $posts_array['TRANSACTIONS'] = style::replaceVar("tpl/invoices/invoice-transactions.tpl", $invoice_transactions_array);
     $pack_monthly = $package_info['additional']['monthly'];
     $coupon_total = $pack_monthly - coupons::get_discount("p2hmonthly", $pack_monthly, $userid);
     $balance = max(0, $monthly - $total_posts);
     unset($where);
     $where[] = array("user", "=", $_SESSION['cuser'], "AND");
     $where[] = array("disabled", "=", "0");
     $coupons_used_query = $dbh->select("coupons_used", $where, array("id", "ASC"), 0, 1);
     while ($coupons_used_data = $dbh->fetch_array($coupons_used_query)) {
         $valid_coupon = coupons::check_expire($coupons_used_data['coupcode']);
         if ($valid_coupon) {
             $multipost_text = main::s($coupons_used_data['p2hmonthlydisc'], " Post");
             $coupons_list_array['COUPONAMOUNT'] = $multipost_text;
             $coupons_list_array['COUPCODE'] = $coupons_used_data['coupcode'];
             $coupons_list_array['REMOVE'] = $balance == 0 ? "" : '(<a href = "?page=type&type=p2h&sub=forums&remove=' . $coupons_used_data['id'] . '">Remove</a>)';
             $posts_array['COUPONSLIST'] .= style::replaceVar("tpl/client/coupons/coupons-list.tpl", $coupons_list_array);
         }
     }
     if (!$posts_array['COUPONSLIST']) {
         $posts_array['COUPONSLIST'] = "<tr><td></td><td align = 'center'>None</td></tr>";
     }
     if ($total_posts >= $monthly) {
         $postedcolour = "#779500";
     } else {
         $postedcolour = "#FF7800";
     }
     if ($balance == "0") {
         $posts_array['ADDCOUPONS'] = "";
         $posts_array['PAIDSTATUS'] = "<font color = '#779500'>Paid</font>";
     } else {
         $posts_array['ADDCOUPONS'] = style::replaceVar("tpl/client/coupons/add-coupons.tpl");
         $posts_array['PAIDSTATUS'] = "<font color = '#FF7800'>Unpaid</font>";
     }
     $posts_array['POSTEDCOLOUR'] = $postedcolour;
     $posts_array['BASEAMOUNT'] = main::s($pack_monthly, " Post");
     $posts_array['COUPONTOTAL'] = main::s($coupon_total, " Post");
     $posts_array['USERPOSTED'] = main::s(str_replace("-", "−", $total_posts), " Post");
     $posts_array['TOTALAMOUNT'] = main::s($balance, " Post");
     echo style::replaceVar("tpl/client/coupons/posts.tpl", $posts_array);
 }
Esempio n. 18
0
 public function content()
 {
     global $dbh, $postvar, $getvar, $instance;
     echo style::replaceVar("tpl/admin/credits.tpl");
 }
Esempio n. 19
0
 public function content()
 {
     global $dbh, $postvar, $getvar, $instance;
     if (main::isint(str_replace("P2H-", "", $getvar['view']))) {
         //Display the invoice
         if (substr_count($getvar['view'], "P2H-")) {
             $p2hid = str_replace("P2H-", "", $getvar['view']);
             $userid = $dbh->select("users", array("id", "=", $p2hid));
             $userid = $userid['id'];
             $userdata = coupons::admin_userdata($userid);
         } else {
             $invoiceid = $getvar['view'];
             $invoice_data_top = $dbh->select("invoices", array("id", "=", $invoiceid));
             $pid = $invoice_data_top['pid'];
             $userid = $invoice_data_top['uid'];
             $uidtopack = main::uidtopack($userid, $pid);
             if (!$pid) {
                 $dbh->update("invoices", array("pid" => $uidtopack['pid']), array("id", "=", $invoice_data_top['id']));
             }
             $userdata = coupons::admin_userdata($userid);
         }
         if ($_POST['submitaddcoupon']) {
             if (!$postvar['addcoupon']) {
                 main::errors("Please enter a coupon code.");
             } else {
                 $coupcode = $postvar['addcoupon'];
                 $user = main::uname($userid);
                 $pack_data = main::uidtopack($userid, $pid);
                 $packid = $pack_data['packages']['id'];
                 $multi_coupons = $dbh->config("multicoupons");
                 if ($p2hid) {
                     $monthly = $pack_data['additional']['monthly'];
                     $monthly = coupons::get_discount("p2hmonthly", $monthly, $userid);
                     $total_posted = coupons::totalposts($userid);
                     $amt_owed = max(0, $monthly - $total_posted);
                 } else {
                     $invoice_info = $dbh->select("invoices", array("id", "=", $invoiceid));
                     if ($invoice_info['pid'] != $pack_data['pid']) {
                         $pack_data = upgrade::pidtobak($invoice_info['pid'], $invoice_info["uid"]);
                     }
                     $total_paid = coupons::totalpaid($invoiceid);
                     $amt_owed = max(0, $invoice_info['amount'] - $total_paid);
                 }
                 if ($amt_owed == 0) {
                     main::errors("The user's balance is already paid in full, so you can't add another coupon.");
                 } else {
                     $coupon_info = coupons::coupon_data($coupcode);
                     $coupid = $coupon_info['id'];
                     $use_coupon = coupons::use_coupon($coupid, $packid, $invoiceid, $userid);
                     if (!$use_coupon) {
                         if (!$multi_coupons) {
                             main::errors("Coupon code entered was invalid or user is already using a coupon.  You can give them a credit instead.");
                         } else {
                             main::errors("Coupon code entered was invalid or the user is already using this coupon.");
                         }
                     } else {
                         main::redirect("?page=invoices&view=" . $getvar['view']);
                     }
                 }
             }
         }
         if ($_POST['submitcredit']) {
             $postvar['credit'] = str_replace(array(" ", ","), array("", "."), $postvar['credit']);
             if (!is_numeric($postvar['credit'])) {
                 main::errors("Please enter the amount to be credited or debited.");
             } else {
                 if ($postvar['creditreason']) {
                     $creditreason = $postvar['creditreason'];
                     $creditreason = ' <a title="' . $creditreason . '" class="tooltip"><img src="<URL>themes/icons/information.png"></a>';
                     $creditreason = str_replace(",", "", $creditreason);
                     //Can't have commas, no way no how!  ;)  lol  We need to be able to explode(",", $invoice_info['txn']);
                 }
                 if ($p2hid) {
                     $credit_fee = $postvar['credit'];
                 } else {
                     $credit_fee = main::addzeros($postvar['credit']);
                 }
                 if ($credit_fee != 0) {
                     if (substr_count($credit_fee, "-")) {
                         $creditfee_lable = "CHARGE";
                     } else {
                         $creditfee_lable = "CREDIT";
                     }
                     $packinfo = main::uidtopack($userid, $pid);
                     if (!$packinfo['user_data']['pid'] && !$p2hid) {
                         $packinfo = upgrade::pidtobak($pid, $userid);
                     }
                     $monthly = $packinfo['additional']['monthly'];
                     if ($p2hid) {
                         $amt_owed = max(0, $monthly - coupons::totalposts($userid));
                     } else {
                         $amt_owed = max(0, $monthly - coupons::totalpaid($invoiceid));
                     }
                     if ($amt_owed == 0 && $creditfee_lable == "CREDIT") {
                         main::errors("The user's balance is already paid in full, so you can't add a credit.");
                     } else {
                         if ($p2hid) {
                             $p2h_info = $dbh->select("coupons_p2h", array("uid", "=", $userid));
                             if ($p2h_info['datepaid']) {
                                 $comma = ",";
                             }
                             $datepaid = $p2h_info['datepaid'] . $comma . time();
                             $txn = $p2h_info['txn'] . $comma . $creditfee_lable . $creditreason;
                             $amt_paid = $p2h_info['amt_paid'] . $comma . $credit_fee;
                             $gateway = $p2h_info['gateway'] . $comma . "INTERNAL";
                             $update_coupons_p2h = array("datepaid" => $datepaid, "txn" => $txn, "amt_paid" => $amt_paid, "gateway" => $gateway);
                             $dbh->update("coupons_p2h", $update_coupons_p2h, array("uid", "=", $userid), "1");
                         } else {
                             $invoice_info = $dbh->select("invoices", array("id", "=", $invoiceid));
                             if ($invoice_info['pid'] != $packinfo['pid']) {
                                 $pack_info = upgrade::pidtobak($invoice_info['pid'], $invoice_info["uid"]);
                             }
                             if ($invoice_info['datepaid']) {
                                 $comma = ",";
                             }
                             $datepaid = $invoice_info['datepaid'] . $comma . time();
                             $txn = $invoice_info['txn'] . $comma . $creditfee_lable . $creditreason;
                             $amt_paid = $invoice_info['amt_paid'] . $comma . $credit_fee;
                             $gateway = $invoice_info['gateway'] . $comma . "INTERNAL";
                             $update_invoices = array("datepaid" => $datepaid, "txn" => $txn, "amt_paid" => $amt_paid, "gateway" => $gateway);
                             $dbh->update("invoices", $update_invoices, array("id", "=", $invoiceid), "1");
                         }
                         main::redirect("?page=invoices&view=" . $getvar['view']);
                     }
                 }
             }
         }
         if ($_POST['submitpayarrange']) {
             $invoice_info = $dbh->select("invoices", array("id", "=", $invoiceid));
             $duedate = $invoice_info['due'];
             $days_modify = $postvar['days'];
             $days_modify = $days_modify * 24 * 60 * 60;
             if ($postvar['addsub'] == "add") {
                 $new_due_date = $duedate + $days_modify;
             } else {
                 $new_due_date = $duedate - $days_modify;
             }
             $dbh->update("invoices", array("due" => $new_due_date), array("id", "=", $invoiceid), "1");
             main::redirect("?page=invoices&view=" . $getvar['view']);
         }
         if ($p2hid) {
             $p2h_info = $dbh->select("users", array("id", "=", $p2hid));
         } else {
             $invoice_info = $dbh->select("invoices", array("id", "=", $invoiceid));
         }
         if (empty($invoice_info) && empty($p2h_info)) {
             main::redirect("?page=invoices");
             exit;
         }
         if ($getvar['deleteinv']) {
             if ($postvar['yes']) {
                 if ($p2hid) {
                     $dbh->delete("coupons_p2h", array("uid", "=", $userid), "1");
                     main::redirect("?page=invoices&view=" . $getvar['view']);
                 } else {
                     $dbh->delete("invoices", array("id", "=", $invoiceid), "1");
                     main::redirect("?page=invoices");
                 }
             } elseif ($postvar['no']) {
                 main::redirect("?page=invoices&view=" . $getvar['view']);
             } else {
                 $warning_array['HIDDEN'] = "<input type = 'hidden' name = 'confirm' value = 'confirm'>";
                 echo style::replaceVar("tpl/warning.tpl", $warning_array);
                 $warning_page = '1';
             }
         }
         if ($userdata['removed'] == 1) {
             $upackage = $dbh->select("users_bak", array("id", "=", $userid));
         } else {
             $upackage = $dbh->select("users", array("id", "=", $userid));
         }
         if (!$p2hid) {
             $package = $dbh->select("packages", array("id", "=", $invoice_info['pid']));
         } else {
             $package = $dbh->select("packages", array("id", "=", $upackage['pid']));
         }
         $monthly = type::additional($package['id']);
         $subtotal = $monthly['monthly'];
         if (is_numeric($getvar['remove'])) {
             $remove_id = $getvar['remove'];
             if ($p2hid) {
                 coupons::remove_p2h_coupon($remove_id, $userid);
             } else {
                 coupons::remove_coupon($remove_id, $package['id'], $invoice_info['id'], $userid);
             }
             main::redirect("?page=invoices&view=" . $getvar['view']);
             exit;
         }
         if ($p2hid) {
             $due = date("m/t/Y");
             $created = date("m/1/Y");
             $p2h = $instance->packtypes["p2h"];
             $monthly_with_disc = coupons::get_discount("p2hmonthly", $subtotal, $userid);
             $total_posts = $p2h->userposts($package['id'], $p2hid);
             $total_paid = coupons::totalposts($userid);
             if (empty($total_paid)) {
                 $total_paid = 0;
             }
             if (empty($total_posts)) {
                 $total_posts = 0;
             }
             $acct_balance = max(0, $monthly_with_disc - $total_paid);
             $view_invoice_array['BASEAMOUNT'] = $invoice_info['amount'] != $subtotal ? main::s($invoice_info['amount'], " Post") . " (Package price: " . main::s($subtotal, " Post") . ")" : main::s($invoice_info['amount'], " Post");
             $view_invoice_array['COUPONTOTAL'] = main::s($subtotal - $monthly_with_disc, " Post");
             $invoice_transactions_array['TOTALAMOUNT'] = main::s($acct_balance, " Post");
             $invoice_transactions_array['TOTALPAID'] = main::s($total_paid, " Post");
             $admin_ops_array['TOTALAMT'] = main::s($acct_balance, " Post");
             $admin_ops_array['DELRESET'] = "Reset";
             $admin_ops_modify_array['CREDIT'] = $acct_balance;
             $admin_ops_modify_array['CURRSYMBOL'] = "";
             $admin_ops_modify_array['POSTS'] = " Posts";
         } else {
             $created = $invoice_info['created'];
             $thirty_days = 30 * 24 * 60 * 60;
             $orig_due = $created + $thirty_days;
             if ($getvar['resetpayarange']) {
                 $dbh->update("invoices", array("due" => $orig_due), array("id", "=", $invoiceid), "1");
                 main::redirect("?page=invoices&view=" . $invoiceid);
             }
             if (main::convertdate("n/d/Y", $invoice_info['due']) != main::convertdate("n/d/Y", $created + $thirty_days)) {
                 $due_text = " (Originally " . main::convertdate("n/d/Y", $orig_due) . ") - <a href = '?page=invoices&view=" . $invoiceid . "&resetpayarange=1'>Reset</a>";
             }
             $due = main::convertdate("n/d/Y", $invoice_info['due']);
             $created = main::convertdate("n/d/Y", $created);
             $total_paid_real = coupons::totalpaid($invoiceid);
             if ($total_paid_real < 0) {
                 $total_paid = "0.00";
             } else {
                 $total_paid = $total_paid_real;
             }
             $acct_balance = $invoice_info['amount'] - $total_paid_real;
             $acct_balance = main::addzeros($acct_balance);
             if ($acct_balance < 0) {
                 $acct_balance = "0.00";
             }
             if ($acct_balance == 0 && $invoice_info['is_paid'] == '0') {
                 $dbh->update("invoices", array("is_paid" => "1"), array("id", "=", $invoice_info['id']), "1");
                 unset($where);
                 $where[] = array("id", "=", $invoice_info['uid'], "AND");
                 $where[] = array("status", "=", "4");
                 $dbh->update("users", array("status" => "1"), $where, "1");
                 unset($where);
                 $where[] = array("id", "=", $invoice_info['uid'], "AND");
                 $where[] = array("status", "=", "4");
                 $dbh->update("users", array("status" => "1"), $where, "1");
                 main::redirect("?page=invoices&view=" . $invoiceid);
             }
             if ($acct_balance > 0 && $invoice_info['is_paid'] == '1') {
                 $dbh->update("invoices", array("is_paid" => "0"), array("id", "=", $invoice_info['id']), "1");
                 main::redirect("?page=invoices&view=" . $invoiceid);
             }
             $view_invoice_array['BASEAMOUNT'] = $invoice_info['amount'] != $subtotal ? main::money($invoice_info['amount']) . " (Package price: " . main::money($subtotal) . ")" : main::money($invoice_info['amount']);
             $view_invoice_array['COUPONTOTAL'] = main::money($subtotal - coupons::get_discount("paid", $subtotal, $userid));
             $invoice_transactions_array['TOTALAMOUNT'] = main::money($acct_balance);
             $invoice_transactions_array['TOTALPAID'] = main::money($total_paid);
             $admin_ops_array['TOTALAMT'] = main::money($acct_balance);
             $admin_ops_array['DELRESET'] = "Delete";
             $admin_ops_modify_array['CREDIT'] = $acct_balance;
             $admin_ops_modify_array['CURRSYMBOL'] = main::money($acct_balance, "", 1) . " ";
             $admin_ops_modify_array['POSTS'] = "";
         }
         $view_invoice_array['ID'] = $getvar['view'];
         $view_invoice_array['DUE'] = $due . $due_text;
         $view_invoice_array['PACKDUE'] = $due;
         $view_invoice_array['CREATED'] = $created;
         $view_invoice_array['UNAME'] = $userdata['user'];
         $view_invoice_array['FNAME'] = $userdata['firstname'];
         $view_invoice_array['LNAME'] = $userdata['lastname'];
         $view_invoice_array['ADDRESS'] = $userdata['address'];
         $view_invoice_array['CITY'] = $userdata['city'];
         $view_invoice_array['STATE'] = $userdata['state'];
         $view_invoice_array['ZIP'] = $userdata['zip'];
         $view_invoice_array['COUNTRY'] = strtoupper($userdata['country']);
         $view_invoice_array['DOMAIN'] = $upackage['domain'];
         $view_invoice_array['PACKAGE'] = $package['name'];
         $view_invoice_array['STATUS'] = $acct_balance == 0 ? "<font color = '#779500'>Paid</font>" : "<font color = '#FF7800'>Unpaid</font>";
         if ($invoice_info['changed_plan'] && $invoice_info['hadcoupons']) {
             $coupon_list = explode(",", $invoice_info['hadcoupons']);
             $coupon_values = explode(",", $invoice_info['couponvals']);
             if ($coupon_list) {
                 for ($i = 0; $i < count($coupon_list); $i++) {
                     $coupons_list_array['COUPONAMOUNT'] = main::money($coupon_values[$i]);
                     $coupons_list_array['COUPCODE'] = $coupon_list[$i];
                     $coupons_list_array['REMOVE'] = "";
                     $view_invoice_array['COUPONSLIST'] .= style::replaceVar("tpl/invoices/coupons-list.tpl", $coupons_list_array);
                     $coup_total = $coup_total + $coupon_values[$i];
                 }
                 $view_invoice_array['COUPONTOTAL'] = main::money(min($subtotal, $coup_total));
             }
         } else {
             unset($where);
             $where[] = array("user", "=", $userid, "AND");
             $where[] = array("disabled", "=", "0");
             $coupons_query = $dbh->select("coupons_used", $where, array("id", "ASC"), 0, 1);
             while ($coupons_used_fetch = $dbh->fetch_array($coupons_query)) {
                 $valid_coupon = coupons::check_expire($coupons_used_fetch['coupcode'], $userid);
                 if ($valid_coupon) {
                     if ($p2hid) {
                         $coupamt = main::s($coupons_used_fetch['p2hmonthlydisc'], " Post");
                     } else {
                         $coupamt = main::money($coupons_used_fetch['paiddisc']);
                     }
                     $coupons_list_array['COUPONAMOUNT'] = $coupamt;
                     $coupons_list_array['COUPCODE'] = $coupons_used_fetch['coupcode'];
                     $coupons_list_array['REMOVE'] = $userdata['removed'] == 1 ? "" : '(<a href = "?page=invoices&view=' . $getvar['view'] . '&remove=' . $coupons_used_fetch['id'] . '">Remove</a>)';
                     $view_invoice_array['COUPONSLIST'] .= style::replaceVar("tpl/invoices/coupons-list.tpl", $coupons_list_array);
                 }
             }
         }
         if (!$view_invoice_array['COUPONSLIST']) {
             $view_invoice_array['COUPONSLIST'] = "<tr><td></td><td align = 'center'>None</td></tr>";
         }
         if ($p2hid) {
             $p2h_payments = $dbh->select("coupons_p2h", array("uid", "=", $userid));
             $package_info = main::uidtopack($userid);
             if (empty($p2h_payments)) {
                 $p2h_pay_array = array("uid" => $userid, "amt_paid" => $total_posts, "txn" => $package_info['uadditional']['fuser'], "datepaid" => time(), "gateway" => $package_info['additional']['forum']);
                 $dbh->insert("coupons_p2h", $p2h_pay_array);
                 $p2h_payments = $dbh->select("coupons_p2h", array("uid", "=", $userid));
             }
             $amt_paid = $p2h_payments['amt_paid'];
             $txn = $p2h_payments['txn'];
             $datepaid = $p2h_payments['datepaid'];
             $gateway = $p2h_payments['gateway'];
         } else {
             $amt_paid = $invoice_info['amt_paid'];
             $txn = $invoice_info['txn'];
             $datepaid = $invoice_info['datepaid'];
             $gateway = $invoice_info['gateway'];
         }
         $amt_paid = explode(",", $amt_paid);
         $txn = explode(",", $txn);
         $datepaid = explode(",", $datepaid);
         $gateway = explode(",", $gateway);
         $remnum = 1;
         for ($i = 0; $i < count($amt_paid); $i++) {
             unset($remtxn);
             if ($gateway[$i] == "INTERNAL" && !$userdata['removed']) {
                 $remtxn = ' <a href = "?page=invoices&view=' . $getvar['view'] . '&remtxn=' . $remnum . '">[Delete]</a>';
             }
             if ($txn[$i] == $package_info['uadditional']['fuser']) {
                 if ($amt_paid[$i] != $total_posts) {
                     $reload = 1;
                 }
                 $amt_paid[$i] = $total_posts;
                 $datepaid[$i] = time();
             }
             $paid_this = $paid_this + $amt_paid[$i];
             if ($p2hid) {
                 $transaction_list_array['PAIDAMOUNT'] = main::s(str_replace("-", "−", $amt_paid[$i]), " Post") . $remtxn;
             } else {
                 $transaction_list_array['PAIDAMOUNT'] = main::money($amt_paid[$i]) . $remtxn;
             }
             $transaction_list_array['TXN'] = $txn[$i];
             $transaction_list_array['PAIDDATE'] = main::convertdate("n/d/Y", $datepaid[$i]);
             $transaction_list_array['GATEWAY'] = $gateway[$i];
             $invoice_transactions_array['TXNS'] .= style::replaceVar("tpl/invoices/transaction-list.tpl", $transaction_list_array);
             if ($getvar['remtxn'] != $i + 1) {
                 $paidamts = $paidamts . "," . $amt_paid[$i];
                 $paidtxn = $paidtxn . "," . $txn[$i];
                 $paiddate = $paiddate . "," . $datepaid[$i];
                 $paidgateway = $paidgateway . "," . $gateway[$i];
             }
             $remnum++;
         }
         if ($p2hid) {
             $paidamts = substr($paidamts, 1, strlen($paidamts));
             $paidtxn = substr($paidtxn, 1, strlen($paidtxn));
             $paiddate = substr($paiddate, 1, strlen($paiddate));
             $paidgateway = substr($paidgateway, 1, strlen($paidgateway));
             $p2h_pay_array = array("amt_paid" => $paidamts, "txn" => $paidtxn, "datepaid" => $paiddate, "gateway" => $paidgateway);
             unset($where);
             $where[] = array("uid", "=", $userid);
             $dbh->update("coupons_p2h", $p2h_pay_array, $where);
             if ($getvar['remtxn'] || $reload) {
                 main::redirect("?page=invoices&view=" . $getvar['view']);
             }
         } else {
             if ($getvar['remtxn']) {
                 $paidamts = substr($paidamts, 1, strlen($paidamts));
                 $paidtxn = substr($paidtxn, 1, strlen($paidtxn));
                 $paiddate = substr($paiddate, 1, strlen($paiddate));
                 $paidgateway = substr($paidgateway, 1, strlen($paidgateway));
                 $update_invoices = array("amt_paid" => $paidamts, "txn" => $paidtxn, "datepaid" => $paiddate, "gateway" => $paidgateway);
                 $dbh->update("invoices", $update_invoices, array("id", "=", $invoiceid), "1");
                 main::redirect("?page=invoices&view=" . $invoiceid);
             }
         }
         if ($invoice_info['amt_paid'] || $p2hid) {
             $view_invoice_array['TRANSACTIONS'] = style::replaceVar("tpl/invoices/invoice-transactions.tpl", $invoice_transactions_array);
         }
         $addsub[] = array("Add", "add");
         $addsub[] = array("Subtract", "subtract");
         $days[] = array("1 Day", "1");
         for ($num = 2; $num < 31; $num++) {
             $days[] = array($num . " Days", $num);
         }
         $payment_arrangments_array['ADDSUB'] = main::dropDown("addsub", $addsub, "add", 0);
         $payment_arrangments_array['DAYS'] = main::dropDown("days", $days, 1, 0);
         if ($userdata['removed'] == 1) {
             $admin_ops_array['MODIFYFUNCS'] = '
                     <tr>
                      <td align="center" colspan = "2"><font color = "#FF0055"><strong>The owner of this invoice has been dismembered.  Er... I mean the member who owned this invoice has been removed.</strong></font></td>
                     </tr>';
         } else {
             if (!$p2hid) {
                 $admin_ops_modify_array['PAYARRANGE'] = style::replaceVar("tpl/admin/invoices/payment-arrangments.tpl", $payment_arrangments_array);
             } else {
                 $admin_ops_modify_array['PAYARRANGE'] = "";
             }
             $admin_ops_array['MODIFYFUNCS'] = style::replaceVar("tpl/admin/invoices/admin-ops-modify.tpl", $admin_ops_modify_array);
             if ($invoice_info['changed_plan']) {
                 $admin_ops_array['MODIFYFUNCS'] .= '
                     <tr>
                      <td align="center" colspan = "2"><font color = "#FF0055"><strong>The owner of this invoice has upgraded their account and this is an invoice from an old account.</strong></font></td>
                     </tr>';
             }
         }
         $view_invoice_array['TRANSACTIONS'] .= style::replaceVar("tpl/admin/invoices/admin-ops.tpl", $admin_ops_array);
         if (!$warning_page) {
             echo style::replaceVar("tpl/invoices/view-invoice.tpl", $view_invoice_array);
         }
     } else {
         //Display the invoice list
         //Status search
         $showstatus = "all";
         if ($postvar['submitstatus']) {
             $showstatus = $postvar['status'];
         }
         //End ststus search
         //Type search
         $showtype = "all";
         if ($postvar['submittype']) {
             $showtype = $postvar['invtype'];
         }
         //End type search
         $users[] = array("All", "all");
         $users[] = array("Orphans", "orphans");
         $users_query = $dbh->select("users", 0, array("user", "ASC"));
         while ($users_data = $dbh->fetch_array($users_query)) {
             $users[] = array($users_data['user'], $users_data['id']);
         }
         //User search
         $users_default = "all";
         if ($postvar['submitusers']) {
             $users_default = $postvar['users'];
             if ($users_default != "all" && $users_default != "orphans") {
                 $show_user = array("uid", "=", $users_default);
                 $show_p2h_user_where = array("id", "=", $users_default, "AND");
                 $username = main::uname($users_default);
                 $for_user = "******" . $username;
             }
         }
         //End user search
         $num_invoices = 0;
         $num_paid = 0;
         $num_unpaid = 0;
         $total_unpaid = 0;
         if ($showtype == "all" || $showtype == "p2h") {
             $p2h_query = $dbh->select("packages", array("type", "=", "p2h"), 0, 0, 1);
             while ($p2h_data = $dbh->fetch_array($p2h_query)) {
                 $show_p2h_user_where[] = array("pid", "=", $p2h_data['id']);
                 $user_query = $dbh->select("users", $show_p2h_user_where, 0, 0, 1);
                 while ($user_data = $dbh->fetch_array($user_query)) {
                     unset($user_show);
                     unset($orphaned);
                     $user_show = main::uname($user_data["id"]);
                     if (!$user_show) {
                         $user_show = '<font color = "FF0055">ORPHANED</font>';
                         $orphaned = 1;
                     }
                     if ($orphaned && $users_default == "orphans" || $users_default != "orphans") {
                         $pack_info = main::uidtopack($user_data['id']);
                         $p2h = $instance->packtypes["p2h"];
                         $monthly = $pack_info['additional']['monthly'];
                         $monthly_with_disc = coupons::get_discount("p2hmonthly", $monthly, $user_data['id']);
                         $userposts = coupons::totalposts($user_data['id']);
                         $invoice_list_item_array['ID'] = "P2H-" . $user_data['id'];
                         $invoice_list_item_array['USERFIELD'] = '<td width="100" align="center">' . $user_show . '</td>';
                         $invoice_list_item_array['DUE'] = main::convertdate("n/d/Y", mktime(date("H"), date("i"), date("s"), date("n"), date("t"), date("Y")));
                         $invoice_list_item_array['CREATED'] = main::convertdate("n/d/Y", mktime(date("H"), date("i"), date("s"), date("n"), 1, date("Y")));
                         $invoice_list_item_array['AMOUNT'] = main::s($monthly, " Post");
                         $invoice_list_item_array['AMTPAID'] = main::s($userposts, " Post");
                         if ($showstatus == "unpaid" || $showstatus == "all") {
                             if ($monthly_with_disc - $userposts > 0) {
                                 $pulled = 1;
                                 $invoice_list_item_array["PAID"] = "<font color = '#FF7800'>Unpaid</font>";
                                 $admin_page_array['LIST'] .= style::replaceVar("tpl/invoices/invoice-list-item.tpl", $invoice_list_item_array);
                             }
                         }
                         if ($showstatus == "paid" || $showstatus == "all" && !$pulled) {
                             if ($monthly_with_disc - $userposts <= 0) {
                                 $invoice_list_item_array["PAID"] = "<font color = '#779500'>Paid</font>";
                                 $admin_page_array['LIST'] .= style::replaceVar("tpl/invoices/invoice-list-item.tpl", $invoice_list_item_array);
                             }
                         }
                         if ($monthly_with_disc - $userposts > 0) {
                             $total_unpaid = $total_unpaid + 1;
                         }
                         $pulled = 0;
                         $num_invoices = $num_invoices + 1;
                     }
                 }
             }
         }
         if ($showtype == "all" || $showtype == "paid") {
             $invoices_query = $dbh->select("invoices", $show_user, array("id", "DESC"), 0, 1);
             while ($invoices_data = $dbh->fetch_array($invoices_query)) {
                 unset($user_show);
                 unset($orphaned);
                 unset($invoice_locked);
                 $user_show = main::uname($invoices_data["uid"]);
                 if (!$user_show) {
                     $user_show = '<font color = "FF0055">ORPHANED</font>';
                     $orphaned = 1;
                 }
                 if ($orphaned && $users_default == "orphans" || $users_default != "orphans") {
                     $pack_info = main::uidtopack($invoices_data["uid"], $invoices_data['pid']);
                     if (!$invoices_data['pid']) {
                         $dbh->update("invoices", array("pid" => $pack_info['user_data']['pid']), array("id", "=", $invoices_data['id']));
                         $invoices_data['pid'] = $pack_info['user_data']['pid'];
                     }
                     if ($invoices_data['pid'] != $pack_info['user_data']['pid']) {
                         $pack_info = upgrade::pidtobak($invoices_data['pid'], $invoices_data["uid"]);
                     }
                     $invoice_list_item_array['ID'] = $invoices_data['id'];
                     $invoice_list_item_array['USERFIELD'] = '<td width="100" align="center">' . $user_show . '</td>';
                     $invoice_list_item_array['DUE'] = main::convertdate("n/d/Y", $invoices_data['due']);
                     $invoice_list_item_array['CREATED'] = main::convertdate("n/d/Y", $invoices_data['created']);
                     $total_paid_real = coupons::totalpaid($invoices_data['id']);
                     $invoice_list_item_array['AMOUNT'] = main::money($invoices_data['amount']);
                     $invoice_list_item_array['AMTPAID'] = main::money($total_paid_real);
                     if ($showstatus == "unpaid" || $showstatus == "all") {
                         if ($invoices_data["is_paid"] == 0) {
                             $pulled = 1;
                             $invoice_list_item_array["PAID"] = "<font color = '#FF7800'>Unpaid</font>" . $invoice_locked;
                             $admin_page_array['LIST'] .= style::replaceVar("tpl/invoices/invoice-list-item.tpl", $invoice_list_item_array);
                         }
                     }
                     if ($showstatus == "paid" || $showstatus == "all" && !$pulled) {
                         if ($invoices_data["is_paid"] == 1) {
                             $invoice_list_item_array["PAID"] = "<font color = '#779500'>Paid</font>" . $invoice_locked;
                             $admin_page_array['LIST'] .= style::replaceVar("tpl/invoices/invoice-list-item.tpl", $invoice_list_item_array);
                         }
                     }
                     if ($invoices_data["is_paid"] == 0) {
                         $total_unpaid = $total_unpaid + 1;
                     }
                     $pulled = 0;
                     $num_invoices = $num_invoices + 1;
                 }
             }
         }
         if (!$admin_page_array['LIST']) {
             $admin_page_array['LIST'] = "<tr>\n<td colspan = '7' align = 'center'>There are not currently any invoices to show.</td>\n</tr>";
         }
         $statusopts[] = array("All", "all");
         $statusopts[] = array("Unpaid", "unpaid");
         $statusopts[] = array("Paid", "paid");
         $typeopts[] = array("All", "all");
         $typeopts[] = array("P2H", "p2h");
         $typeopts[] = array("Paid", "paid");
         $admin_page_array['USERS'] = main::dropDown("users", $users, $users_default, 0);
         $admin_page_array['TYPEOPTS'] = main::dropDown("invtype", $typeopts, $showtype, 0);
         $admin_page_array['STATUSOPTS'] = main::dropDown("status", $statusopts, $showstatus, 0);
         $admin_page_array['FORUSER'] = $for_user;
         $admin_page_array['NUM'] = $num_invoices;
         $admin_page_array['NUMPAID'] = $num_invoices - $total_unpaid;
         $admin_page_array['NUMUNPAID'] = $total_unpaid;
         echo style::replaceVar("tpl/admin/invoices/admin-page.tpl", $admin_page_array);
     }
 }
Esempio n. 20
0
 public function content()
 {
     global $dbh, $postvar, $getvar, $instance;
     if (is_numeric($getvar['dellogid'])) {
         $dbh->delete("logs", array("id", "=", $getvar['dellogid']), "1");
         main::errors("Log entry deleted.");
     }
     if (is_numeric($getvar['removeall'])) {
         if ($getvar['confirm'] != '1') {
             main::errors("Are you sure you wish to remove ALL log entries?   <a href = '?page=logs&removeall=" . $getvar['removeall'] . "&confirm=1'>Yes</a>    |    <a href = '?page=logs'>No</a>");
         } else {
             $dbh->delete("logs", 0, 0, 1);
             main::thtlog("Logs Cleared", "All Logs were removed.", $_SESSION['user'], "", "staff");
             main::redirect("?page=logs");
         }
     }
     if (is_numeric($getvar['logid'])) {
         $loginfo = $dbh->select("logs", array("id", "=", $getvar['logid']));
         $admin_log_view_array['MESSAGE'] = $loginfo['message'];
         echo style::replaceVar("tpl/admin/logs/admin-log-view.tpl", $admin_log_view_array);
     } else {
         $per_page = $getvar['limit'];
         $start = $getvar['start'];
         if (!$postvar['show']) {
             $show = $getvar['show'];
         } else {
             $show = $postvar['show'];
             $start = 0;
         }
         if (!$show) {
             $show = "all";
         }
         if (!$per_page) {
             $per_page = 10;
         }
         if (!$start) {
             $start = 0;
         }
         if ($show != "all") {
             $logs_query = $dbh->select("logs", array("logtype", "=", $show), array("logtime", "DESC"), $start . ", " . $per_page, 1);
         } else {
             $logs_query = $dbh->select("logs", 0, array("logtime", "DESC"), $start . ", " . $per_page, 1);
         }
         $all_logs_query = $dbh->select("logs");
         $num_logs = $dbh->num_rows($all_logs_query);
         $pages = ceil($num_logs / $per_page);
         if ($num_logs == 0) {
             $admin_logs_list_array['LOGS'] = "";
             $admin_logs_list_array['PAGING'] = "";
             main::errors("No logs found.");
         } else {
             while ($logs_data = $dbh->fetch_array($logs_query)) {
                 $message_data = explode("<", substr($logs_data['message'], 0, 100));
                 $admin_log_item_array['USER'] = $logs_data['loguser'];
                 $admin_log_item_array['DATE'] = main::convertdate("n/d/Y", $logs_data['logtime']);
                 $admin_log_item_array['TIME'] = main::convertdate("g:i A", $logs_data['logtime']);
                 $admin_log_item_array['MESSAGE'] = $message_data[0];
                 $admin_log_item_array['LOGID'] = $logs_data['id'];
                 $admin_logs_list_array['LOGS'] .= style::replaceVar("tpl/admin/logs/admin-log-item.tpl", $admin_log_item_array);
             }
         }
         if ($start != 0) {
             $back_page = $start - $per_page;
             $admin_logs_list_array['PAGING'] = '<a href="?page=logs&show=' . $show . '&start=' . $back_page . '&limit=' . $per_page . '">BACK</a>&nbsp;';
         }
         for ($i = 1; $i <= $pages; $i++) {
             $start_link = $per_page * ($i - 1);
             if ($start_link == $start) {
                 $admin_logs_list_array['PAGING'] .= '&nbsp;<b>' . $i . '</b>&nbsp;';
             } else {
                 $admin_logs_list_array['PAGING'] .= '&nbsp;<a href="?page=logs&show=' . $show . '&start=' . $start_link . '&limit=' . $per_page . '">' . $i . '</a>&nbsp;';
             }
         }
         if (($start + $per_page) / $per_page < $pages && $pages != 1) {
             $next_page = $start + $per_page;
             $admin_logs_list_array['PAGING'] .= '&nbsp;<a href="?page=logs&show=' . $show . '&start=' . $next_page . '&limit=' . $per_page . '">NEXT</a>';
         }
         $shown = array();
         $log_type_values[] = array("Show All", "all");
         $logs_query = $dbh->select("logs", 0, array("logtype", "ASC"), 0, 1);
         while ($logs_data = $dbh->fetch_array($logs_query)) {
             if (!in_array($logs_data['logtype'], $shown)) {
                 $log_type_values[] = array($logs_data['logtype'], $logs_data['logtype']);
                 $shown[] = $logs_data['logtype'];
             }
         }
         $admin_logs_list_array['SHOW_TYPE'] = main::dropdown("show", $log_type_values);
         echo style::replaceVar("tpl/admin/logs/admin-logs-list.tpl", $admin_logs_list_array);
     }
 }
Esempio n. 21
0
 public function content()
 {
     global $dbh, $postvar, $getvar, $instance;
     if (!automod::checkDir(INC . "/automod")) {
         main::errors("Please create the /includes/automod directory and make it writable.");
     }
     if (!automod::checkPerms(INC . "/automod")) {
         main::errors("Please make the /includes/automod directory writable.  (0777)");
     }
     switch ($getvar['sub']) {
         case "added":
             $mods_exist = $dbh->select("automod_mods", 0, array("mod_name", "ASC"));
             $mods_exist = $dbh->num_rows($mods_exist);
             if ($mods_exist > 0) {
                 if (is_numeric($getvar['view'])) {
                     $mod_vals = automod::module_data($getvar['view']);
                     if (automod::installed_tht_is_reworked()) {
                         $THT_VERS = $dbh->config("version") . " Reworked";
                     } else {
                         $THT_VERS = $dbh->config("version");
                     }
                     $mod_vals['mod_thtversion'] = str_replace("rework3d", "Reworked", strtolower($mod_vals['mod_thtversion']));
                     $mod_vals['mod_thtversion'] = str_replace("reworked", "Reworked", strtolower($mod_vals['mod_thtversion']));
                     $viewmod_array['ID'] = $mod_vals['id'];
                     $viewmod_array['NAME'] = $mod_vals['mod_name'];
                     $viewmod_array['MODVERSION'] = $mod_vals['mod_version'];
                     $viewmod_array['VERSION'] = $THT_VERS;
                     $viewmod_array['THTVERSION'] = $mod_vals['mod_thtversion'];
                     $viewmod_array['LICENSE'] = $mod_vals['mod_license'];
                     $viewmod_array['AUTHOR'] = $mod_vals['mod_author'];
                     $viewmod_array['SUPPORT'] = $mod_vals['mod_support'];
                     $viewmod_array['AUTHLINK'] = $mod_vals['mod_link'];
                     $viewmod_array['PROJWEB'] = $mod_vals['mod_projectpage'];
                     $viewmod_array['RECOMMENDATIONS'] = automod::recommendations();
                     $viewmod_array['DESCRIPTION'] = nl2br($mod_vals['mod_descrip']);
                     $viewmod_array['DIY'] = $mod_vals['mod_diy'];
                     echo style::replaceVar("tpl/automod/view-module.tpl", $viewmod_array);
                 } else {
                     $mod_query = $dbh->select("automod_mods", 0, array("mod_name", "ASC"));
                     while ($mod_vals = $dbh->fetch_array($mod_query)) {
                         $listmods_array['ID'] = $mod_vals['id'];
                         $listmods_array['NAME'] = $mod_vals['mod_name'];
                         unset($elipses);
                         if (strlen($mod_vals['mod_descrip']) > 250) {
                             $elipses = " <b>...</b>";
                         }
                         $listmods_array['DESCRIPTION'] = nl2br(htmlentities(substr($mod_vals['mod_descrip'], 0, 250)) . $elipses);
                         echo style::replaceVar("tpl/automod/list-modules.tpl", $listmods_array);
                     }
                 }
             } else {
                 echo "No modules installed.";
             }
             break;
         case "install":
             if ($getvar['install']) {
                 //Install a module
                 if ($getvar['confirm'] == '1') {
                     automod::completeinstall($getvar['install']);
                 } else {
                     automod::install_mod($getvar['install']);
                 }
             } elseif ($getvar['reminstall']) {
                 //Remove a module's directory
                 $reminstall = $getvar['reminstall'];
                 if ($postvar['confirm']) {
                     if ($postvar['yes']) {
                         automod::rmfulldir(INC . "/automod/" . $reminstall);
                         main::redirect("?page=automod&sub=install");
                     } else {
                         main::redirect("?page=automod&sub=install");
                     }
                 } else {
                     $warning_array['HIDDEN'] = "<input type = 'hidden' name = 'confirm' value = 'confirm'>";
                     echo style::replaceVar("tpl/warning.tpl", $warning_array);
                 }
             } else {
                 //Add a module to be installed
                 automod::processaddmod();
             }
             break;
         case "uninstall":
             $mods_exist = $dbh->select("automod_mods", 0, array("mod_name", "ASC"));
             $mods_exist = $dbh->num_rows($mods_exist);
             if ($mods_exist > 0) {
                 if (is_numeric($getvar['uninstall'])) {
                     if ($getvar['confirm'] == '1') {
                         if (!$postvar['remove'] && !$postvar['rename']) {
                             $mode = '1';
                         }
                         if ($postvar['remove'] && $postvar['rename']) {
                             $mode = '2';
                         }
                         if ($postvar['remove'] && !$postvar['rename']) {
                             $mode = '3';
                         }
                         if (!$postvar['remove'] && $postvar['rename']) {
                             $mode = '4';
                         }
                         automod::completeuninstall($getvar['uninstall'], $mode);
                     } else {
                         automod::uninstall_mod($getvar['uninstall']);
                     }
                 } else {
                     $mod_query = $dbh->select("automod_mods", 0, array("mod_name", "ASC"));
                     while ($mod_vals = $dbh->fetch_array($mod_query)) {
                         $listmods_array['ID'] = $mod_vals['id'];
                         $listmods_array['NAME'] = $mod_vals['mod_name'];
                         unset($elipses);
                         if (strlen($mod_vals['mod_descrip']) > 250) {
                             $elipses = " <b>...</b>";
                         }
                         $listmods_array['DESCRIPTION'] = nl2br(htmlentities(substr($mod_vals['mod_descrip'], 0, 250)) . $elipses);
                         echo style::replaceVar("tpl/automod/list-modules.tpl", $listmods_array);
                     }
                 }
             } else {
                 echo "No modules installed.";
             }
             break;
         case "updates":
             automod::updates_check();
             break;
     }
 }
Esempio n. 22
0
 public function _customf()
 {
     global $dbh, $postvar, $getvar, $instance;
     echo style::replaceVar("tpl/admin/order-form/top.tpl");
     $orderfields_query = $dbh->select("orderfields", 0, array("sortorder", "ASC"));
     if ($dbh->num_rows($orderfields_query) == 0) {
         echo "<center>" . style::notice(false, "You don't have any custom fields defined!") . "</center>";
         return;
     }
     echo '<div id="sortableDiv">';
     while ($arr = $dbh->fetch_array($orderfields_query)) {
         unset($order_field_box_array);
         $order_field_box_array["ID"] = $arr["id"];
         $order_field_box_array["TITLE"] = htmlspecialchars($arr["title"]);
         $order_field_box_array["DESCRIPTION"] = htmlspecialchars($arr["description"]);
         if ($arr["required"] == 1) {
             $order_field_box_array["REQ"] = "<span style=\"color: red;\">*</span>";
             $order_field_box_array["REQC"] = " checked=\"yes\"";
         } else {
             $order_field_box_array["REQ"] = "";
         }
         // A lame solution but I don't feel like solving this problem at 5 AM...
         $selected = array(false, false, false, false, false, false, false);
         switch ($arr["type"]) {
             case "text":
                 $selected[0] = true;
                 break;
             case "password":
                 $selected[1] = true;
                 break;
             case "checkbox":
                 $selected[2] = true;
                 break;
             case "select":
                 $selected[3] = true;
                 break;
             case "tel":
                 $selected[4] = true;
                 break;
             case "url":
                 $selected[5] = true;
                 break;
             case "email":
                 $selected[6] = true;
                 break;
             case "range":
                 $selected[7] = true;
                 break;
         }
         $value = array('id' => 'cfield-field-typelist-' . $arr["id"], 'class' => 'cfield-field cfield-field-' . $arr["id"] . ' cfield-field-typelist');
         $extra = array(array('text' => '--- Standard ---', 'value' => 'standard', 'disabled' => true), array('text' => 'Text', 'value' => 'text', 'selected' => $selected[0]), array('text' => 'Password', 'value' => 'password', 'selected' => $selected[1]), array('text' => 'Checkbox', 'value' => 'checkbox', 'selected' => $selected[2]), array('text' => 'Select Box', 'value' => 'select', 'selected' => $selected[3]), array('text' => '--- HTML5 ---', 'value' => 'html5', 'disabled' => true), array('text' => 'Telephone #', 'value' => 'tel', 'selected' => $selected[4]), array('text' => 'URL', 'value' => 'url', 'selected' => $selected[5]), array('text' => 'Email', 'value' => 'email', 'selected' => $selected[6]), array('text' => 'Range', 'value' => 'range', 'selected' => $selected[7]));
         $order_field_box_array["TYPELIST"] = style::createInput('select', 'cfield-field-typelist-' . $arr["id"], '', $value, $extra);
         $order_field_box_array["DEFAULTVALUE"] = htmlspecialchars($arr["default"]);
         $order_field_box_array["REGEX"] = htmlspecialchars($arr["regex"]);
         echo style::replaceVar("tpl/admin/order-form/order-field-box.tpl", $order_field_box_array);
     }
     echo '</div>';
     echo style::replaceVar("tpl/admin/order-form/bottom.tpl");
 }
Esempio n. 23
0
    } else {
        $pagegen = '';
    }
    if ($dbh->config("show_version_id") == 1) {
        $version = $dbh->config("version");
    } else {
        $version = '';
    }
    if (FOLDER != "install") {
        $navbar_query = $dbh->select("navbar", 0, array("sortorder", "ASC"));
        while ($navbar_data = $dbh->fetch_array($navbar_query)) {
            $navigation_link_array['ID'] = "nav_" . $navbar_data['name'];
            $navigation_link_array['LINK'] = $navbar_data['link'];
            $navigation_link_array['ICON'] = $navbar_data['icon'];
            $navigation_link_array['NAME'] = $navbar_data['visual'];
            $navigation .= style::replaceVar("tpl/navigation-link.tpl", $navigation_link_array);
        }
    }
}
/**********************************************************************/
$page_data = preg_replace("/<THT TITLE>/si", NAME . " :: " . PAGE . " - " . SUB, $page_data);
$page_data = preg_replace("/<NAME>/si", NAME, $page_data);
$page_data = preg_replace("/<CSS>/si", self::css(), $page_data);
$page_data = preg_replace("/<JAVASCRIPT>/si", self::javascript(), $page_data);
$page_data = preg_replace("/<WYSIWYG_EDITOR>/si", "<URL>includes/tinymce/tinymce.min.js", $page_data);
$page_data = preg_replace("/<WYSIWYG_PLUGS>/si", "advlist autolink autoresize hr link searchreplace table", $page_data);
$page_data = preg_replace("/<WYSIWYG_LANG>/si", "", $page_data);
$page_data = preg_replace("/<MENU>/si", $navigation, $page_data);
$page_data = preg_replace("/<URL>/si", URL, $page_data);
$page_data = preg_replace("/<AJAX>/si", URL . "includes/ajax.php", $page_data);
$page_data = preg_replace("/<IMG>/si", URL . "themes/" . THEME . "/images/", $page_data);
Esempio n. 24
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;
     }
 }
Esempio n. 25
0
    unset($sql);
    require $link;
    if (isset($sql)) {
        $db = new db();
    }
}
$disable = false;
if ($sql['install'] == 'true') {
    if (!writeconfig($sql['host'], $sql['user'], $sql['pass'], $sql['db'], $sql['pre'], "false")) {
        $array['ANYTHING'] = "Your {$link} isn't writeable or does not exist! Please CHMOD it to 666 and make sure it exists!";
        $disable = true;
    } else {
        $array['ANYTHING'] = "Since you've already ran the installer, your config has been re-written to the \"not installed\" state. If you are upgrading, this is normal.";
    }
}
if (!file_exists($link)) {
    $array["ANYTHING"] = "Your {$link} file doesn't exist! Please create it as a blank file and CHMOD it to 666!";
    $disable = true;
} elseif (!is_writable($link)) {
    $array["ANYTHING"] = "Your {$link} isn't writeable! Please CHMOD it to 666!";
    $disable = true;
}
echo $style->get("header.tpl");
if ($disable) {
    echo '<script type="text/javascript">$(function(){$(".twobutton").attr("disabled", "true");$("#method").attr("disabled", "true");});</script>';
}
$array["GENERATED_URL"] = generateSiteUrl();
echo $style->replaceVar("tpl/install/install.tpl", $array);
echo $style->get("footer.tpl");
include LINK . "output.php";
#Output it
Esempio n. 26
0
 public function acpPage()
 {
     global $dbh, $postvar, $getvar, $instance;
     if ($_POST) {
         check::empty_fields(array("password", "paypalsandemail"));
         if (!main::errors()) {
             if (is_numeric($postvar['susdays']) && is_numeric($postvar['termdays'])) {
                 $dbh->updateConfig("suspensiondays", $postvar['susdays']);
                 $dbh->updateConfig("terminationdays", $postvar['termdays']);
                 $dbh->updateConfig("currency", $postvar['currency']);
                 $dbh->updateConfig("currency_format", $postvar['currency_format']);
                 $dbh->updateConfig("paypalemail", $postvar['paypalemail']);
                 $dbh->updateConfig("paypalmode", $postvar['paypalmode']);
                 $dbh->updateConfig("paypalsandemail", $postvar['paypalsandemail']);
                 main::errors("Values have been updated!");
             } else {
                 main::errors("Please enter a valid value!");
             }
         }
     }
     $currency_values[] = array("Pound Sterling", "GBP");
     $currency_values[] = array("US Dollars", "USD");
     $currency_values[] = array("Australian Dollars", "AUD");
     $currency_values[] = array("Canadian Dollars", "CAD");
     $currency_values[] = array("Euros", "EUR");
     $currency_values[] = array("Yen", "JPY");
     $currency_values[] = array("New Zealand Dollar", "NZD");
     $currency_values[] = array("Swiss Franc", "CHF");
     $currency_values[] = array("Hong Kong Dollar", "HKD");
     $currency_values[] = array("Singapore Dollar", "SGD");
     $currency_values[] = array("Swedish Krona", "SEK");
     $currency_values[] = array("Danish Krone", "DKK");
     $currency_values[] = array("Polish Zloty", "PLN");
     $currency_values[] = array("Norwegian Krone", "NOK");
     $currency_values[] = array("Hungarian Forint", "HUF");
     $currency_values[] = array("Czech Koruna", "CZK");
     $currency_values[] = array("Israeli Shekel", "ILS");
     $currency_values[] = array("Mexican Peso", "MXN");
     $paypal_values[] = array("Live", "live");
     $paypal_values[] = array("Sandbox", "sandbox");
     $currency_format_values[] = array("1,000.99", ".");
     $currency_format_values[] = array("1 000,99", ",");
     $paid_configuration_array['CURRENCY'] = main::dropDown("currency", $currency_values, $dbh->config("currency"));
     $paid_configuration_array['CURRENCY_FORMAT'] = main::dropDown("currency_format", $currency_format_values, $dbh->config("currency_format"));
     $paid_configuration_array['PAYPALMODE'] = main::dropDown("paypalmode", $paypal_values, $dbh->config("paypalmode"));
     $paid_configuration_array['PAYPALSANDEMAIL'] = $dbh->config("paypalsandemail");
     $paid_configuration_array['SUSDAYS'] = $dbh->config("suspensiondays");
     $paid_configuration_array['TERDAYS'] = $dbh->config("terminationdays");
     $paid_configuration_array['PAYPALEMAIL'] = $dbh->config("paypalemail");
     echo style::replaceVar("tpl/admin/paid-configuration.tpl", $paid_configuration_array);
 }
Esempio n. 27
0
 private function ChangePassword($client)
 {
     global $dbh, $postvar, $getvar, $instance;
     $change_password_array['MSG'] = "This will change the user's password in THT and the control panel.<br><br>";
     if ($_POST) {
         if (empty($postvar['passwd'])) {
             main::errors('A password was not provided.');
         } else {
             $command = main::changeClientPassword($client['id'], $postvar['passwd']);
             if ($command === true) {
                 main::errors('Password changed!');
             } else {
                 main::errors($command);
             }
         }
     }
     $clientview_array['BOX'] = "";
     $clientview_array['CONTENT'] = style::replaceVar("tpl/admin/clients/change-password.tpl", $change_password_array);
     return $clientview_array;
 }
Esempio n. 28
0
 public function content()
 {
     global $dbh, $postvar, $getvar, $instance;
     $upackinfo = main::uidtopack();
     $currentpack = $upackinfo['user_data']['pid'];
     $packsid = $postvar['packs'];
     if (!$packsid) {
         $packsid = $getvar['package'];
     }
     unset($where);
     if (is_numeric($packsid)) {
         $where[] = array("id", "=", $packsid, "AND");
     } else {
         $where[] = array("is_hidden", "=", "0", "AND");
     }
     $where[] = array("is_disabled", "=", "0", "AND");
     $where[] = array("id", "!=", $currentpack);
     $packages_order[] = array("type", "ASC");
     $packages_order[] = array("name", "ASC");
     $packages_query = $dbh->select("packages", $where, $packages_order, 0, 1);
     $upgrade_array['PACK'] = "";
     while ($packages_data = $dbh->fetch_array($packages_query)) {
         $additional = type::additional($packages_data['id']);
         $monthly = $additional['monthly'];
         $signup = $additional['signup'];
         unset($info);
         if ($packages_data['type'] == "p2h") {
             $info = "[Signup Posts: " . $signup . ", Monthly Posts: " . $monthly . "] ";
             $contribution = "<strong>Signup Posts:</strong> " . $signup . "<br><strong>Monthly Posts:</strong> " . $monthly;
         } elseif ($packages_data['type'] == "paid") {
             $info = "[" . main::money($monthly) . "] ";
             $contribution = main::money($monthly);
         } else {
             $contribution = "Free";
         }
         $packages[] = array("[" . $packages_data['type'] . "] " . $info . $packages_data['name'], $packages_data['id']);
         if ($packsid && $packsid == $packages_data['id']) {
             $prorate = upgrade::prorate($packages_data['id'], $postvar['coupon']);
             $package_array['DISABLED'] = "";
             if ($prorate == "inelegible") {
                 main::errors("You are currently not elegible for the plan selected because you do not have enough posts.<br><br>");
                 $package_array['DISABLED'] = "disabled";
             }
             if ($prorate == "owe") {
                 main::errors("You have outstanding charges on your account and can only upgrade your paid package.  Your charges are outstanding!  Keep up the good work.  lol<br><br>");
                 $package_array['DISABLED'] = "disabled";
             }
             if ($prorate == "oweposts") {
                 main::errors("You still owe your required monthly posts and can only upgrade to a paid plan until you finish your posting quota.  Our forum is a lot of fun, so come join us!  =)<br><br>");
                 $package_array['DISABLED'] = "disabled";
             }
             if ($prorate == "next" || $prorate == "check next") {
                 main::errors("If you choose this package, you'll be upgraded at the start of your next billing cycle.  If you do not wish to wait, please contact us.<br><br>");
                 $next_month = 1;
             }
             if (is_numeric($prorate) && $prorate > 0) {
                 $contribution .= " (You pay only <font color = '#FF0055'>" . main::money($prorate) . "</font> more today to upgrade.)";
             }
             if ($prorate == "check" || $prorate == "check next" || $prorate == "check now") {
                 $fuser = $postvar['fuser'];
                 $fpass = $postvar['fpass'];
                 $forum_credentials_array['FUSER'] = $fuser;
                 $forum_credentials_array['FPASS'] = $fpass;
                 $package_array['FORUMINFO'] = style::replaceVar("tpl/upgrade/forum-credentials.tpl", $forum_credentials_array);
             } else {
                 if ($packages_data['type'] == "p2h") {
                     $fuser = $upackinfo['uadditional']['fuser'];
                     $fpass = $upackinfo['uadditional']['fpass'];
                     $no_fcheck = 1;
                 }
                 $package_array['FORUMINFO'] = "";
             }
             $coupon_entry_array['COUPCODE'] = "";
             $coupon_entry_array['COUPTEXT'] = "";
             $coupon_entry_array['COUPCODEVALID'] = "";
             if ($packages_data['type'] == "p2h" && $prorate != "owe") {
                 //Paid users can enter them when they pay the invoice and free users don't need coupons.
                 $coupcode = $postvar['coupon'];
                 $validcoupon = $postvar['validcoupon'];
                 if ($postvar['addcoupon']) {
                     $uname = main::uname($_SESSION['cuser']);
                     if ($coupcode) {
                         $response = coupons::validate_coupon($coupcode, "orders", $uname, $packsid);
                         if ($response) {
                             $coup_data = coupons::coupon_data($coupcode);
                             $discount = $coup_data['p2hinitdisc'];
                             $multi_coupons = $dbh->config("multicoupons");
                             if ($multi_coupons) {
                                 $discount = $discount + upgrade::get_init_discount();
                             }
                             $total_posts = coupons::totalposts($_SESSION['cuser'], $packages_data['id']) + $discount;
                             if ($total_posts < $signup) {
                                 $error = 1;
                                 main::errors("You are currently not elegible for the plan selected because you do not have enough posts.<br><br>");
                                 $package_array['DISABLED'] = "disabled";
                                 $coupon_entry_array['COUPCODEVALID'] = "";
                             } else {
                                 $prorate = upgrade::prorate($packages_data['id'], $coupcode);
                                 if ($prorate == "next" || $prorate == "check next" || $prorate == "inelegible") {
                                     //We know they're eligible or they wouldn't be at this stage.  It just doesn't check existing coupons.
                                     main::errors("If you choose this package, you'll be upgraded at the start of your next billing cycle.  If you do not wish to wait, please contact us.<br><br>");
                                     $next_month = 1;
                                 } else {
                                     unset($_SESSION['errors']);
                                 }
                                 $package_array['DISABLED'] = "";
                                 $coupon_entry_array['COUPCODEVALID'] = $coupcode;
                             }
                             $coupon_entry_array['COUPTEXT'] = $response;
                             $coupon_entry_array['COUPCODE'] = $coupcode;
                         } else {
                             $coupon_entry_array['COUPTEXT'] = "<font color = '#FF0055'>The code entered was invalid.</font>";
                             $coupon_entry_array['COUPCODEVALID'] = "invalid";
                         }
                     } else {
                         $coupon_entry_array['COUPTEXT'] = "<font color = '#FF0055'>The code entered was invalid.</font>";
                         $coupon_entry_array['COUPCODEVALID'] = "invalid";
                     }
                 } else {
                     $coupon_entry_array['COUPTEXT'] = "";
                     $coupon_entry_array['COUPCODE'] = $coupcode;
                     $coupon_entry_array['COUPCODEVALID'] = $validcoupon;
                 }
                 $package_array['COUPONS'] = style::replaceVar("tpl/upgrade/coupon-entry.tpl", $coupon_entry_array);
             } else {
                 $package_array['COUPONS'] = "";
             }
             $package_array['CONTRIBUTION'] = $contribution;
             $package_array['PACKID'] = $packages_data['id'];
             $package_array['PACKNAME'] = $packages_data['name'];
             $package_array['PACKDESC'] = $packages_data['description'];
             $package_array['ADMIN'] = $packages_data['admin'] == "1" ? "Yes" : "No";
             $package_array['RESELLER'] = $packages_data['reseller'] == "1" ? "Yes" : "No";
             $package_array['SERVER'] = $packages_data['server'] != $upackinfo['packages']['server'] ? "Yes" : "No";
             $package_array['TYPE'] = $packages_data['type'] == "p2h" ? strtoupper($packages_data['type']) : ucfirst($packages_data['type']);
             if ($postvar['submitchange']) {
                 //Someone cheated and modified the code to re-enable the button.  This stops all that.
                 if ($package_array['DISABLED'] == "disabled") {
                     main::redirect("?page=upgrade");
                     return;
                 }
                 if ((!$fuser || !$fpass) && $packages_data['type'] == "p2h" && !$no_fcheck) {
                     $error = 1;
                     main::errors("Please enter your forum username and password to continue.<br><br>");
                 }
                 if ($fuser && $fpass && $packages_data['type'] == "p2h" && !$no_fcheck) {
                     $p2h = $instance->packtypes["p2h"];
                     $response = $p2h->checkSignup($fuser, $fpass, $postvar['packs'], $postvar['validcoupon']);
                     switch ($response) {
                         case "3":
                             $error = 1;
                             main::errors("The username, " . $fuser . ", does not exist.<br><br>");
                             break;
                         case "4":
                             $error = 1;
                             main::errors("Invalid password.<br><br>");
                             break;
                         default:
                             //We add this now so the post checks can use it and it also tacks it to the user's account for future reference.
                             $new_additional = "fuser="******",fpass=0";
                             $dbh->update("users", array("additional" => $new_additional), array("id", "=", $upackinfo['user_data']['id']), "1");
                             break;
                     }
                 }
                 if (!$error) {
                     if ($validcoupon && $validcoupon != "invalid") {
                         $coup_data = coupons::coupon_data($validcoupon);
                         $discount = $coup_data['p2hinitdisc'];
                         $db_coupcode = $validcoupon;
                     }
                     $multi_coupons = $dbh->config("multicoupons");
                     if ($multi_coupons) {
                         $discount = $discount + upgrade::get_init_discount();
                     }
                     if ($packages_data['type'] == "p2h") {
                         $total_posts = coupons::totalposts($_SESSION['cuser'], $packages_data['id']) + $discount;
                         if ($total_posts < $signup) {
                             $error = 1;
                             main::errors("You are currently not elegible for the plan selected because you do not have enough posts.<br><br>");
                         }
                     }
                     if (!$error) {
                         //The user is elegible to upgrade and all checks have passed.
                         if ($packages_data['admin']) {
                             $admin = 1;
                         }
                         if ($packages_data['server'] != $upackinfo['packages']['server']) {
                             $different_server = 1;
                         }
                         //Flag meaning:
                         //
                         //IMMEDIATE UPGRADE FLAGS
                         //
                         //0 - Upgrade is immediate.
                         //5 - If admin approves the upgrade, then the upgrade will be immediate.
                         //
                         //6 - If admin approves the upgrade, then the new account will be created on the new server and the
                         //    admin will know that they are moving to a new server so they can manually close the old account
                         //    when they're ready.
                         //
                         //7 - The new account on the new server will be immediately created and the admin will be notified that
                         //    the user is switching servers.
                         //
                         //NEXT MONTH UPGRADE FLAGS
                         //
                         //1 - Cron will upgrade them next month.
                         //2 - If admin approves this, then it will be set to 1 for cron to upgrade them next month.
                         //3 - The admin will be notified that the user wishes to be upgraded and if they approve it,
                         //    then an account on the new server will be created so they can migrate to the new server.
                         //    the admin can opt to switch the account over before next month if they both agree and the
                         //    switch will be made in the admin area manually.
                         //
                         //4 - Cron will create a new account on the new server next month and inform the admin that the
                         //    user is changing to the new server.
                         //
                         if ($next_month) {
                             $flags = "1";
                             if ($admin) {
                                 $flags = "2";
                                 if ($different_server) {
                                     $flags = "3";
                                 }
                             } else {
                                 if ($different_server) {
                                     $flags = "4";
                                 }
                             }
                         } else {
                             $flags = "0";
                             if ($admin) {
                                 $flags = "5";
                                 if ($different_server) {
                                     $flags = "6";
                                 }
                             } else {
                                 if ($different_server) {
                                     $flags = "7";
                                 }
                             }
                         }
                         $pending_upgrade = $dbh->select("upgrade", array("uid", "=", $_SESSION['cuser']));
                         //When the upgrade is finished, the entry is removed.
                         if ($pending_upgrade['id']) {
                             $upgrade_update = array("uid" => $_SESSION['cuser'], "newpack" => $packsid, "flags" => $flags, "created" => time(), "coupcode" => $db_coupcode);
                             $dbh->update("upgrade", $upgrade_update, array("id", "=", $pending_upgrade['id']), "1");
                         } else {
                             $upgrade_insert = array("uid" => $_SESSION['cuser'], "newpack" => $packsid, "flags" => $flags, "created" => time(), "coupcode" => $db_coupcode);
                             $dbh->insert("upgrade", $upgrade_insert);
                         }
                         $pending_upgrade = $dbh->select("upgrade", array("uid", "=", $_SESSION['cuser']));
                         $response = upgrade::do_upgrade($pending_upgrade['id'], "Init");
                         if ($response === false) {
                             echo "Your upgrade could not be completed as dialed.  Please check with your admin and try your upgrade again later.  The following tones are for the deaf community in hopes that they'll be able to hear again.  BEEEEEEEEEEEEEEEEEEEEEEEEP!!!!!!!!";
                         } else {
                             echo $response;
                         }
                         return;
                     }
                 }
             }
         }
     }
     if ($packsid) {
         $upgrade_array['PACK'] = style::replaceVar("tpl/upgrade/package.tpl", $package_array);
     } else {
         $select_package_array['PACKS'] = main::dropDown("packs", $packages, '', 0);
         $upgrade_array['PACK'] = style::replaceVar("tpl/upgrade/select-package.tpl", $select_package_array);
     }
     echo style::replaceVar("tpl/upgrade/upgrade.tpl", $upgrade_array);
     $page_shown = 1;
     //The page doesn't show if they refresh it after the upgrade since the loop checks if they're upgrading to the same package they are on and fails if they are.
     if (!$page_shown) {
         main::redirect("?page=upgrade");
     }
 }
Esempio n. 29
0
 private function EditTemplate($tpl, $ext)
 {
     global $dbh, $postvar, $getvar, $instance;
     $filetochange = INC . "/../themes/" . $dbh->config('theme') . "/" . $tpl . "." . $ext;
     if ($_POST) {
         file_put_contents($filetochange, stripslashes(str_replace(array("&lt;IMG>", "-%-INFO-%-"), array("<IMG>", "%INFO%"), $postvar['contents'])));
         main::errors($tpl . '.' . $ext . ' Modified.');
     }
     $tpl_editor_array['CONTENT'] = str_replace(array("<IMG>", "%INFO%"), array("&lt;IMG>", "-%-INFO-%-"), htmlentities(file_get_contents($filetochange)));
     if (is_writable($filetochange)) {
         $tpl_editor_array['NOTICE'] = '';
     } else {
         $tpl_editor_array['NOTICE'] = style::notice(false, "In order to make changes to this file, please make it writable.");
     }
     return style::replaceVar('tpl/admin/lof/' . $tpl . '-editor.tpl', $tpl_editor_array);
 }
Esempio n. 30
0
 public function sub($left, $right)
 {
     $sub_table_array['LEFT'] = $left;
     $sub_table_array['RIGHT'] = $right;
     if (file_exists(INC . "../themes/" . THEME . "/tpl/sub-table.tpl")) {
         $tbl = style::replaceVar("../themes/" . THEME . "/tpl/sub-table.tpl", $sub_table_array);
     } else {
         $tbl = style::replaceVar("tpl/sub-table.tpl", $sub_table_array);
     }
     return $tbl;
 }