コード例 #1
0
ファイル: view.php プロジェクト: cozylife/tht-reworked
 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);
 }
コード例 #2
0
ファイル: home.php プロジェクト: cozylife/tht-reworked
 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);
 }
コード例 #3
0
 public function create($uid, $amount, $due, $notes)
 {
     global $dbh, $postvar, $getvar, $instance;
     $client = $dbh->client($uid);
     $emailtemp = email::emailTemplate("new-invoice");
     $newinvoice_array['USER'] = $client['user'];
     $newinvoice_array['AMOUNT'] = main::addzeros($amount);
     $newinvoice_array['LINK'] = $dbh->config("url") . "/client/?page=invoices";
     $newinvoice_array['DUE'] = main::convertdate("n/d/Y", $due, $uid);
     $is_paid = $newinvoice_array['AMOUNT'] == "0.00" ? "1" : "0";
     email::send($client['email'], $emailtemp['subject'], $emailtemp['content'], $newinvoice_array);
     unset($where);
     $where[] = array("amount", "=", "0", "OR");
     $where[] = array("amount", "=", "0.00");
     $dbh->update("invoices", array("is_paid" => "1"), $where);
     //This way people won't see unpaid invoices for $0.
     $invoices_insert = array("uid" => $uid, "amount" => $amount, "created" => time(), "due" => $due, "notes" => $notes, "pay_now" => $amount, "is_paid" => $is_paid);
     $response = $dbh->insert("invoices", $invoices_insert);
     return $response;
 }
コード例 #4
0
ファイル: users.php プロジェクト: cozylife/tht-reworked
 private function ViewClient($client)
 {
     global $dbh, $postvar, $getvar, $instance;
     $client_details_array['DATE'] = main::convertdate("n/d/Y", $client['signup']);
     $client_details_array['EMAIL'] = $client['email'];
     $client_details_array['UPGRADEINFO'] = "";
     $existing_upgrade = $dbh->select("upgrade", array("uid", "=", $client['id']));
     $all_packs_query = $dbh->select("packages", array("is_disabled", "=", "0"), array("type", "ASC"), 0, 1);
     while ($all_packs_data = $dbh->fetch_array($all_packs_query)) {
         $additional = type::additional($all_packs_data['id']);
         $monthly = $additional['monthly'];
         $signup = $additional['signup'];
         unset($info);
         if ($all_packs_data['type'] == "p2h") {
             $info = "[Signup Posts: " . $signup . ", Monthly Posts: " . $monthly . "] ";
         } elseif ($all_packs_data['type'] == "paid") {
             $info = "[" . main::money($monthly) . "] ";
         }
         $packages[] = array("[" . $all_packs_data['type'] . "] " . $info . $all_packs_data['name'], $all_packs_data['id']);
         if ($existing_upgrade && $existing_upgrade['newpack'] == $all_packs_data['id']) {
             if ($all_packs_data['admin']) {
                 $admin = " after you approve them";
             }
             if ($existing_upgrade['flags'] && $existing_upgrade['flags'] < 5) {
                 $next_cycle = " next billing cycle";
             }
             $client_details_array['UPGRADEINFO'] = "NOTE: This user is slated for an upgrade to \"" . $all_packs_data['name'] . "\"" . $next_cycle . $admin . ".<br><br>";
         }
     }
     $client_details_array['PACKAGE'] = main::dropdown("newpackage", $packages, $client['pid']);
     $client_details_array['USER'] = $client['user'];
     $client_details_array['DOMAIN'] = $client['domain'];
     $client_details_array['CLIENTIP'] = $client['ip'];
     $client_details_array['FIRSTNAME'] = $client['firstname'];
     $client_details_array['LASTNAME'] = $client['lastname'];
     $client_details_array['ADDRESS'] = $client['address'];
     $client_details_array['CITY'] = $client['city'];
     $client_details_array['STATE'] = $client['state'];
     $client_details_array['ZIP'] = $client['zip'];
     $client_details_array['COUNTRY'] = strtolower($client['country']);
     $client_details_array['FULLCOUNTRY'] = main::country_code_to_country($client['country']);
     $client_details_array['PHONE'] = $client['phone'];
     unset($where);
     $where[] = array("uid", "=", $client['id'], "AND");
     $where[] = array("is_paid", "=", "0");
     $invoices_query = $dbh->select("invoices", $where, 0, 0, 1);
     $client_details_array['INVOICES'] = $dbh->num_rows($invoices_query);
     switch ($client['status']) {
         default:
             $client_details_array['STATUS'] = "Other";
             break;
         case "1":
             $client_details_array['STATUS'] = "Active";
             break;
         case "2":
             $client_details_array['STATUS'] = "Suspended";
             break;
         case "3":
             $client_details_array['STATUS'] = "Awaiting Validation";
             break;
         case "4":
             $client_details_array['STATUS'] = "Awaiting Payment";
             break;
         case "5":
             $client_details_array['STATUS'] = "Awaiting Email Confirmation";
             break;
         case "9":
             $client_details_array['STATUS'] = "Cancelled";
             break;
     }
     $class = type::packagetype($client['pid']);
     $packtype = $instance->packtypes[$class];
     if (method_exists($packtype, "acpBox")) {
         $box = $packtype->acpBox();
         $clientview_array['BOX'] = main::sub($box[0], $box[1]);
     } else {
         $clientview_array['BOX'] = "";
     }
     $clientview_array['CONTENT'] = style::replaceVar("tpl/admin/clients/client-details.tpl", $client_details_array);
     return $clientview_array;
 }
コード例 #5
0
ファイル: logs.php プロジェクト: cozylife/tht-reworked
 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);
     }
 }
コード例 #6
0
ファイル: invoices.php プロジェクト: cozylife/tht-reworked
 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);
     }
 }
コード例 #7
0
ファイル: home.php プロジェクト: cozylife/tht-reworked
 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);
 }
コード例 #8
0
ファイル: p2h.php プロジェクト: cozylife/tht-reworked
 private function checkMonthly($forum, $fuser, $prefix)
 {
     global $dbh, $postvar, $getvar, $instance;
     $nmonth = date("m");
     $nyear = date("y");
     $n = 0;
     switch ($forum) {
         case "ipb":
             $ipb_members_data = $dbh->select($prefix . "members", array("name", "=", $fuser), 0, 0, 0, $this->con);
             $ipb_posts_query = $dbh->select($prefix . "posts", array("author_name", "=", $ipb_members_data['members_display_name']), 0, 0, 1, $this->con);
             while ($ipb_posts_data = $dbh->fetch_array($ipb_posts_query)) {
                 $date = explode(":", main::convertdate("m:y", $ipb_posts_data['post_date']));
                 if ($nmonth == $date[0] && $nyear == $date[1]) {
                     $n++;
                 }
             }
             break;
         case "ipb3":
             $ipb3_members_data = $dbh->select($prefix . "members", array("name", "=", $fuser), 0, 0, 0, $this->con);
             $ipb3_posts_query = $dbh->select($prefix . "posts", array("author_name", "=", $ipb3_members_data['members_display_name']), 0, 0, 1, $this->con);
             while ($ipb3_posts_data = $dbh->fetch_array($ipb3_posts_query)) {
                 $date = explode(":", main::convertdate("m:y", $ipb3_posts_data['post_date']));
                 if ($nmonth == $date[0] && $nyear == $date[1]) {
                     $n++;
                 }
             }
             break;
         case "mybb":
             $mybb_posts_query = $dbh->select($prefix . "posts", array("username", "=", $fuser), 0, 0, 1, $this->con);
             while ($mybb_posts_data = $dbh->fetch_array($mybb_posts_query)) {
                 $date = explode(":", main::convertdate("m:y", $mybb_posts_data['dateline']));
                 if ($nmonth == $date[0] && $nyear == $date[1]) {
                     $n++;
                 }
             }
             break;
         case "phpbb":
             $phpbb_users_data = $dbh->select($prefix . "users", array("username", "=", $fuser), 0, 0, 0, $this->con);
             $phpbb_posts_query = $dbh->select($prefix . "posts", array("poster_id", "=", $phpbb_users_data['user_id']), 0, 0, 1, $this->con);
             while ($phpbb_posts_data = $dbh->fetch_array($phpbb_posts_query)) {
                 $date = explode(":", main::convertdate("m:y", $phpbb_posts_data['post_time']));
                 if ($nmonth == $date[0] && $nyear == $date[1]) {
                     $n++;
                 }
             }
             break;
         case "phpbb2":
             $phpbb2_users_data = $dbh->select($prefix . "users", array("username", "=", $fuser), 0, 0, 0, $this->con);
             $phpbb2_posts_query = $dbh->select($prefix . "posts", array("poster_id", "=", $phpbb2_users_data['user_id']), 0, 0, 1, $this->con);
             while ($phpbb2_posts_data = $dbh->fetch_array($phpbb2_posts_query)) {
                 $date = explode(":", main::convertdate("m:y", $phpbb2_posts_data['post_time']));
                 if ($nmonth == $date[0] && $nyear == $date[1]) {
                     $n++;
                 }
             }
             break;
         case "vb":
             $vb_post_query = $dbh->select($prefix . "post", array("username", "=", $fuser), 0, 0, 1, $this->con);
             while ($vb_post_data = $dbh->fetch_array($vb_post_query)) {
                 $date = explode(":", main::convertdate("m:y", $vb_post_data['dateline']));
                 if ($nmonth == $date[0] && $nyear == $date[1]) {
                     $n++;
                 }
             }
             break;
         case "smf":
             $smf_messages_query = $dbh->select($prefix . "messages", array("posterName", "=", $fuser), 0, 0, 1, $this->con);
             while ($smf_messages_data = $dbh->fetch_array($smf_messages_query)) {
                 $date = explode(":", main::convertdate("m:y", $smf_messages_data['posterTime']));
                 if ($nmonth == $date[0] && $nyear == $date[1]) {
                     $n++;
                 }
             }
             break;
         case "aef":
             $aef_users_data = $dbh->select($prefix . "users", array("username", "=", $fuser), 0, 0, 0, $this->con);
             $aef_posts_query = $dbh->select($prefix . "posts", array("poster_id", "=", $aef_users_data['id']), 0, 0, 1, $this->con);
             while ($aef_posts_data = $dbh->fetch_array($aef_posts_query)) {
                 $date = explode(":", main::convertdate("m:y", $aef_posts_data['ptime']));
                 if ($nmonth == $date[0] && $nyear == $date[1]) {
                     $n++;
                 }
             }
             break;
         case "drupal":
             $drupal_users_data = $dbh->select($prefix . "users", array("name", "=", $fuser), 0, "1", 0, $this->con);
             unset($where);
             $where[] = array("type", "=", "forum", "AND");
             $where[] = array("uid", "=", $drupal_users_data["uid"]);
             $drupal_node_query = $dbh->select($prefix . "node", $where, 0, 0, 1, $this->con);
             while ($drupal_node_data = $dbh->fetch_array($drupal_node_query)) {
                 $date = explode(":", main::convertdate("m:y", $drupal_node_data['created']));
                 if ($nmonth == $date[0] && $nyear == $date[1]) {
                     $n++;
                 }
                 unset($where);
                 $where[] = array("nid", "=", $drupal_node_data["nid"], "AND");
                 $where[] = array("uid", "=", $drupal_users_data["uid"]);
                 $drupal_comments_query = $dbh->select($prefix . "comments", $where, 0, 0, 1, $this->con);
                 unset($comments);
                 while ($drupal_comments_data = $dbh->fetch_array($drupal_comments_query)) {
                     $date = explode(":", main::convertdate("m:y", $drupal_comments_data['timestamp']));
                     if ($nmonth == $date[0] && $nyear == $date[1]) {
                         $n++;
                     }
                 }
             }
             break;
     }
     return $n;
 }
コード例 #9
0
ファイル: tickets.php プロジェクト: cozylife/tht-reworked
 public function content()
 {
     global $dbh, $postvar, $getvar, $instance;
     if ($getvar['mode'] == 'ticketsall') {
         $no_tickets_msg = "You currently have no tickets.";
         $view_mode_text = "<center><i><u><a href=\"?page=tickets\" title=\"View open tickets\">View open tickets</a></u></i></center>";
     } else {
         $where[] = array("status", "!=", "3", "AND");
         $no_tickets_msg = "You currently have no new tickets! <i><u><a href=\"?page=tickets&mode=ticketsall\" title=\"View all tickets.\">View all tickets</a></u></i>";
         $view_mode_text = "<center><i><u><a href=\"?page=tickets&mode=ticketsall\" title=\"View all tickets\">View all tickets</a></u></i></center>";
     }
     if (!$getvar['do']) {
         $where[] = array("reply", "=", "0");
         $tickets_query = $dbh->select("tickets", $where, array("time", "DESC"), 0, 1);
         if (!$dbh->num_rows($tickets_query)) {
             echo $no_tickets_msg;
         } else {
             if ($getvar['mode'] == 'ticketsall') {
                 echo "<div style=\"display: none;\" id=\"nun-tickets\">You currently have no tickets!</div>";
             } else {
                 echo "<div style=\"display: none;\" id=\"nun-tickets\">You currently have no new tickets!</div>";
             }
             $num_rows = $dbh->num_rows($tickets_query);
             echo style::replaceVar("tpl/admin/tickets/tickets-js.tpl", array('NUM_TICKETS' => $num_rows));
             while ($tickets_data = $dbh->fetch_array($tickets_query)) {
                 $ticket_view_box_array['TITLE'] = $tickets_data['title'];
                 $ticket_view_box_array['UPDATE'] = $this->lastUpdated($tickets_data['id']);
                 $ticket_view_box_array['STATUS'] = $tickets_data['status'];
                 $ticket_view_box_array['STATUSMSG'] = $this->status($tickets_data['status']);
                 $ticket_view_box_array['ID'] = $tickets_data['id'];
                 $ticket_view_box_array['URGENCYTEXT'] = $tickets_data['urgency'];
                 $ticket_view_box_array['URGENCY_CLASS'] = strtolower(str_replace(" ", "_", $tickets_data['urgency']));
                 echo style::replaceVar("tpl/admin/tickets/ticket-view-box.tpl", $ticket_view_box_array);
             }
             echo $view_mode_text;
         }
     } else {
         unset($where);
         $where[] = array("id", "=", $getvar['do'], "OR");
         $where[] = array("ticketid", "=", $getvar['do']);
         $tickets_query = $dbh->select("tickets", $where, array("time", "ASC"), 0, 1);
         if (!$dbh->num_rows($tickets_query)) {
             echo "That ticket doesn't exist!";
         } else {
             if ($_POST) {
                 check::empty_fields(array("admin"));
                 if (!main::errors()) {
                     $time = time();
                     $tickets_insert = array("title" => $postvar['title'], "content" => $postvar['content'], "time" => $time, "userid" => $_SESSION['user'], "reply" => "1", "ticketid" => $getvar['do'], "staff" => "1");
                     $dbh->insert("tickets", $tickets_insert);
                     main::errors("Reply has been added!");
                     $last_ticket_data = $dbh->select("tickets", array("time", "=", $time), 0, "1");
                     $tickets_data = $dbh->fetch_array($tickets_query);
                     $client = $dbh->staff($_SESSION['user']);
                     $user = $dbh->client($tickets_data['userid']);
                     $template = email::emailTemplate("ticket-staff-responded");
                     $clientresponse_array['TITLE'] = $tickets_data['title'];
                     $clientresponse_array['STAFF'] = $client['name'];
                     $clientresponse_array['CONTENT'] = $postvar['content'];
                     $clientresponse_array['LINK'] = $dbh->config("url") . "/client/?page=tickets&sub=view&do=" . $last_ticket_data['ticketid'];
                     email::send($user['email'], $template['subject'], $template['content'], $clientresponse_array);
                     main::redirect("?page=tickets&sub=view&do=" . $getvar['do']);
                 }
             }
             $tickets_data = $dbh->fetch_array($tickets_query);
             $view_ticket_array['AUTHOR'] = $this->determineAuthor($tickets_data['userid'], $tickets_data['staff']);
             $view_ticket_array['TIME'] = main::convertdate("n/d/Y - g:i A", $tickets_data['time']);
             $view_ticket_array['NUMREPLIES'] = $dbh->num_rows($tickets_query) - 1;
             $view_ticket_array['UPDATED'] = $this->lastUpdated($tickets_data['id']);
             $view_ticket_array['ORIG'] = $this->showReply($tickets_data['id']);
             $view_ticket_array['URGENCY'] = $tickets_data['urgency'];
             $view_ticket_array['STATUS'] = $this->status($tickets_data['status']);
             switch ($tickets_data['status']) {
                 case "1":
                     $view_ticket_array['STATUSCOLOR'] = "779500";
                     break;
                 case "2":
                     $view_ticket_array['STATUSCOLOR'] = "FF9500";
                     break;
                 case "3":
                     $view_ticket_array['STATUSCOLOR'] = "FF0000";
                     break;
                 default:
                     $view_ticket_array['STATUSCOLOR'] = "000000";
                     break;
             }
             $view_ticket_array['REPLIES'] = "";
             $n = 0;
             while ($reply = $dbh->fetch_array($tickets_query)) {
                 if (!$n) {
                     $view_ticket_array['REPLIES'] .= "<br /><b>Replies</b>";
                 }
                 $view_ticket_array['REPLIES'] .= $this->showReply($reply['id']);
                 $n++;
             }
             $view_ticket_array['ADDREPLY'] .= "<br /><b>Change Ticket Status</b>";
             $values[] = array("Open", 1);
             $values[] = array("On Hold", 2);
             $values[] = array("Closed", 3);
             $change_status_array['DROPDOWN'] = main::dropdown("status", $values, $tickets_data['status'], 0);
             $change_status_array['ID'] = $tickets_data['id'];
             $view_ticket_array['ADDREPLY'] .= style::replaceVar("tpl/tickets/change-status.tpl", $change_status_array);
             $view_ticket_array['ADDREPLY'] .= "<br /><b>Add Reply</b>";
             $add_reply_array['TITLE'] = "RE: " . $tickets_data['title'];
             $view_ticket_array['ADDREPLY'] .= style::replaceVar("tpl/tickets/add-reply.tpl", $add_reply_array);
             echo style::replaceVar("tpl/tickets/view-ticket.tpl", $view_ticket_array);
         }
     }
 }
コード例 #10
0
ファイル: invoices.php プロジェクト: cozylife/tht-reworked
 public function content()
 {
     global $dbh, $postvar, $getvar, $instance;
     if (is_numeric($getvar['view'])) {
         //Show the invoice
         unset($where);
         $where[] = array("uid", "=", $_SESSION['cuser'], "AND");
         $where[] = array("id", "=", $getvar['view']);
         $invoice_info_top = $dbh->select("invoices", $where);
         $pack_data_top = main::uidtopack();
         if (!$invoice_info_top['pid']) {
             $dbh->update("invoices", array("pid" => $pack_data_top['user_data']['pid']), array("id", "=", $invoice_info_top['id']));
             $invoice_info_top['pid'] = $pack_data_top['user_data']['pid'];
         }
         if ($_POST['submitaddcoupon']) {
             if (!$postvar['addcoupon']) {
                 main::errors("Please enter a coupon code or click the checkout button.");
             } else {
                 $coupcode = $postvar['addcoupon'];
                 $user = main::uname($_SESSION['cuser']);
                 $pack_data = main::uidtopack();
                 if ($invoice_info_top['pid'] != $pack_data['user_data']['pid']) {
                     $pack_data = upgrade::pidtobak($invoice_info_top['pid']);
                 }
                 $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, $getvar['view']);
                 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=invoices&view=" . $getvar['view']);
                 }
             }
         }
         unset($where);
         $where[] = array("uid", "=", $_SESSION['cuser'], "AND");
         $where[] = array("id", "=", $getvar['view']);
         $invoice_info = $dbh->select("invoices", $where);
         if (empty($invoice_info)) {
             main::redirect("?page=invoices");
             exit;
         }
         $package = $dbh->select("packages", array("id", "=", $invoice_info['pid']));
         $monthly = type::additional($package['id']);
         $subtotal = $monthly['monthly'];
         if (is_numeric($getvar['remove'])) {
             $remove_id = $getvar['remove'];
             $remove = coupons::remove_coupon($remove_id, $package['id'], $invoice_info['id'], $_SESSION['cuser']);
             main::redirect("?page=invoices&view=" . $invoice_info['id']);
             exit;
         }
         $total_paid_real = coupons::totalpaid($getvar['view']);
         if ($total_paid_real < 0) {
             $total_paid = "0.00";
         } else {
             $total_paid = $total_paid_real;
         }
         $acct_balance = coupons::get_discount("paid", $subtotal) - $total_paid_real;
         if ($acct_balance < 0) {
             $acct_balance = "0.00";
         }
         $acct_balance = main::addzeros($acct_balance);
         if ($acct_balance == 0 && $invoice_info['is_paid'] == '0') {
             $dbh->update("invoices", array("is_paid" => "1"), array("id", "=", $invoice_info['id']), "1");
             main::redirect("?page=invoices&view=" . $invoice_info['id']);
         }
         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=" . $invoice_info['id']);
         }
         if ($_POST['checkout']) {
             $postvar['paythis'] = str_replace(array(" ", ","), array("", "."), $postvar['paythis']);
             if (!is_numeric($postvar['paythis'])) {
                 main::errors("Please enter the amount you wish to pay today.");
             } else {
                 if ($postvar['paythis'] > $acct_balance || $acct_balance <= 0) {
                     main::errors("You can't pay more than you owe.  =)");
                 } else {
                     $dbh->update("invoices", array("pay_now" => $postvar['paythis']), array("id", "=", $getvar['view']));
                     main::redirect("?page=invoices&iid=" . $getvar['view']);
                     exit;
                 }
             }
         }
         $created = $invoice_info['created'];
         $thirty_days = 30 * 24 * 60 * 60;
         $orig_due = $created + $thirty_days;
         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) . ")";
         }
         $due = main::convertdate("n/d/Y", $invoice_info['due']);
         $client = $dbh->client($_SESSION['cuser']);
         $invoice_transactions_array['TOTALAMOUNT'] = main::money($acct_balance);
         $invoice_transactions_array['TOTALPAID'] = main::money($total_paid);
         $pay_invoice_array['TOTALAMT'] = main::money($acct_balance);
         $pay_invoice_array['PAYBALANCE'] = $acct_balance;
         $pay_invoice_array['CURRSYMBOL'] = main::money($acct_balance, "", 1);
         $pay_invoice_array['PACKID'] = $invoice_info['pid'];
         $pay_invoice_array['USER'] = $client['user'];
         $view_invoice_array['ID'] = $invoice_info['id'];
         $view_invoice_array['DUE'] = $due . $due_text;
         $view_invoice_array['PACKDUE'] = $due;
         $view_invoice_array['CREATED'] = main::convertdate("n/d/Y", $created);
         $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['BALANCE'] = main::money($acct_balance);
         $view_invoice_array['COUPONTOTAL'] = main::money($subtotal - coupons::get_discount("paid", $subtotal));
         $view_invoice_array['UNAME'] = $client['user'];
         $view_invoice_array['FNAME'] = $client['firstname'];
         $view_invoice_array['LNAME'] = $client['lastname'];
         $view_invoice_array['ADDRESS'] = $client['address'];
         $view_invoice_array['CITY'] = $client['city'];
         $view_invoice_array['STATE'] = $client['state'];
         $view_invoice_array['ZIP'] = $client['zip'];
         $view_invoice_array['COUNTRY'] = strtoupper($client['country']);
         $view_invoice_array['DOMAIN'] = $client['domain'];
         $view_invoice_array['PACKAGE'] = $package['name'];
         $view_invoice_array['STATUS'] = $invoice_info["is_paid"] == 1 ? "<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", "=", $client['id'], "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'], $client['id']);
                 if ($valid_coupon) {
                     $coupons_list_array['COUPONAMOUNT'] = main::money($coupons_used_fetch['paiddisc']);
                     $coupons_list_array['COUPCODE'] = $coupons_used_fetch['coupcode'];
                     $coupons_list_array['REMOVE'] = $invoice_info['is_paid'] == 1 ? "" : '(<a href = "?page=invoices&view=' . $invoice_info['id'] . '&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>";
             }
         }
         $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);
         $view_invoice_array['TRANSACTIONS'] = "";
         for ($i = 0; $i < count($amt_paid); $i++) {
             $paid_this = $paid_this + $amt_paid[$i];
             $transaction_list_array['PAIDAMOUNT'] = main::money($amt_paid[$i]);
             $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 ($invoice_info["is_paid"]) {
             if (!$invoice_info['amt_paid']) {
                 $invoice_transactions_array['TXNS'] = "<tr><td colspan = '4' align = 'center'><b>--- None ---</b></td></tr>";
             }
             $view_invoice_array['TRANSACTIONS'] = style::replaceVar("tpl/invoices/invoice-transactions.tpl", $invoice_transactions_array);
         } else {
             if ($invoice_info['amt_paid']) {
                 $view_invoice_array['TRANSACTIONS'] = style::replaceVar("tpl/invoices/invoice-transactions.tpl", $invoice_transactions_array);
             }
             $view_invoice_array['TRANSACTIONS'] .= style::replaceVar("tpl/client/invoices/pay-invoice.tpl", $pay_invoice_array);
         }
         echo style::replaceVar("tpl/invoices/view-invoice.tpl", $view_invoice_array);
     } else {
         //Show the list of invoices
         $pack_info = main::uidtopack();
         $invoices_query = $dbh->select("invoices", array("uid", "=", $_SESSION['cuser']), array("id", "DESC"), 0, 1);
         $client_page_array['LIST'] = "";
         while ($invoices_data = $dbh->fetch_array($invoices_query)) {
             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']);
             }
             $monthly = $pack_info['additional']['monthly'];
             $invoice_list_item_array['ID'] = $invoices_data['id'];
             $invoice_list_item_array['USERFIELD'] = "";
             $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']);
             $invoice_list_item_array["PAID"] = $invoices_data["is_paid"] == 1 ? "<font color = '#779500'>Paid</font>" : "<font color = '#FF7800'>Unpaid</font>";
             $invoice_list_item_array['AMOUNT'] = main::money($invoices_data['amount']);
             $invoice_list_item_array['AMTPAID'] = main::money(coupons::totalpaid($invoices_data['id']));
             $client_page_array['LIST'] .= style::replaceVar("tpl/invoices/invoice-list-item.tpl", $invoice_list_item_array);
         }
         $client_page_array['NUM'] = $dbh->num_rows($invoices_query);
         if ($client_page_array['NUM'] == 0) {
             $client_page_array['LIST'] = "<tr>\n<td colspan = '6' align = 'center'>You currently do not have any invoices.</td>\n</tr>";
         }
         echo style::replaceVar("tpl/client/invoices/client-page.tpl", $client_page_array);
     }
 }
コード例 #11
0
ファイル: tickets.php プロジェクト: cozylife/tht-reworked
 public function content()
 {
     global $dbh, $postvar, $getvar, $instance;
     switch ($getvar['sub']) {
         default:
             if ($_POST) {
                 check::empty_fields();
                 if (!main::errors()) {
                     $time = time();
                     $tickets_insert = array("title" => $postvar['title'], "content" => $postvar['content'], "urgency" => $postvar['urgency'], "time" => $time, "userid" => $_SESSION['cuser']);
                     $dbh->insert("tickets", $tickets_insert);
                     $last_ticket_data = $dbh->select("tickets", array("time", "=", $time), 0, "1");
                     $template = email::emailTemplate("new-ticket");
                     $newticket_array['TITLE'] = $postvar['title'];
                     $newticket_array['URGENCY'] = $postvar['urgency'];
                     $newticket_array['CONTENT'] = $postvar['content'];
                     $newticket_array['LINK'] = $dbh->config("url") . ADMINDIR . "/?page=tickets&sub=view&do=" . $last_ticket_data['id'];
                     email::staff($template['subject'], $template['content'], $newticket_array);
                     main::errors("Ticket has been added!");
                 }
             }
             echo style::replaceVar("tpl/client/tickets/add-ticket.tpl");
             break;
         case "view":
             if (is_numeric($getvar['deltid'])) {
                 $userid = $_SESSION['cuser'];
                 $tid = $getvar['deltid'];
                 unset($where);
                 $where[] = array("id", "=", $tid, "AND");
                 $where[] = array("userid", "=", $userid);
                 $user_check = $dbh->select("tickets", $where, 0, "1", 1);
                 $user_check_rows = $dbh->num_rows($user_check);
                 if ($user_check_rows == "0") {
                     echo "<font color = '#FF0000'>This ticket is not yours to delete or does not exist.</font><br>";
                 } else {
                     unset($where);
                     $where[] = array("id", "=", $tid, "OR");
                     $where[] = array("ticketid", "=", $tid);
                     $dbh->delete("tickets", $where);
                 }
             }
             if (!$getvar['do']) {
                 unset($where);
                 $where[] = array("userid", "=", $_SESSION['cuser'], "AND");
                 $where[] = array("reply", "=", "0");
                 $tickets_query = $dbh->select("tickets", $where, 0, 0, 1);
                 if (!$dbh->num_rows($tickets_query)) {
                     echo "You currently have no tickets!";
                 } else {
                     while ($tickets_data = $dbh->fetch_array($tickets_query)) {
                         $ticket_view_box_array['TITLE'] = $tickets_data['title'];
                         $ticket_view_box_array['UPDATE'] = $this->lastUpdated($tickets_data['id']);
                         $ticket_view_box_array['ID'] = $tickets_data['id'];
                         $ticket_view_box_array['STATUS'] = $tickets_data['status'];
                         $ticket_view_box_array['STATUSMSG'] = $this->status($tickets_data['status']);
                         echo style::replaceVar("tpl/client/tickets/ticket-view-box.tpl", $ticket_view_box_array);
                     }
                 }
             } else {
                 unset($where);
                 $where[] = array("id", "=", $getvar['do'], "OR");
                 $where[] = array("ticketid", "=", $getvar['do']);
                 $tickets_query = $dbh->select("tickets", $where, array("time", "ASC"), 0, 1);
                 if (!$dbh->num_rows($tickets_query)) {
                     echo "That ticket doesn't exist!";
                 } else {
                     if ($_POST) {
                         check::empty_fields();
                         if (!main::errors()) {
                             $time = time();
                             $tickets_insert = array("title" => $postvar['title'], "content" => $postvar['content'], "time" => $time, "userid" => $_SESSION['cuser'], "reply" => "1", "ticketid" => $getvar['do']);
                             $dbh->insert("tickets", $tickets_insert);
                             $last_ticket_data = $dbh->select("tickets", array("time", "=", $time), 0, "1");
                             $tickets_data = $dbh->fetch_array($tickets_query);
                             $client = $dbh->client($_SESSION['cuser']);
                             $template = email::emailTemplate("ticket-client-responded");
                             $newresponse_array['TITLE'] = $tickets_data['title'];
                             $newresponse_array['USER'] = $client['user'];
                             $newresponse_array['CONTENT'] = $postvar['content'];
                             $newresponse_array['LINK'] = $dbh->config("url") . ADMINDIR . "/?page=tickets&sub=view&do=" . $last_ticket_data['ticketid'];
                             email::staff($template['subject'], $template['content'], $newresponse_array);
                             main::redirect("?page=tickets&sub=view&do=" . $getvar['do']);
                         }
                     }
                     $tickets_data = $dbh->fetch_array($tickets_query);
                     $view_ticket_array['AUTHOR'] = $this->determineAuthor($tickets_data['userid'], $tickets_data['staff']);
                     $view_ticket_array['TIME'] = main::convertdate("n/d/Y - g:i A", $tickets_data['time']);
                     $view_ticket_array['NUMREPLIES'] = $dbh->num_rows($tickets_query) - 1;
                     $view_ticket_array['UPDATED'] = $this->lastUpdated($tickets_data['id']);
                     $view_ticket_array['ORIG'] = $this->showReply($tickets_data['id']);
                     $view_ticket_array['URGENCY'] = $tickets_data['urgency'];
                     $view_ticket_array['STATUS'] = $this->status($tickets_data['status']);
                     switch ($tickets_data['status']) {
                         case "1":
                             $view_ticket_array['STATUSCOLOR'] = "779500";
                             break;
                         case "2":
                             $view_ticket_array['STATUSCOLOR'] = "FF9500";
                             break;
                         case "3":
                             $view_ticket_array['STATUSCOLOR'] = "FF0000";
                             break;
                         default:
                             $view_ticket_array['STATUSCOLOR'] = "000000";
                             break;
                     }
                     $n = 0;
                     $view_ticket_array['REPLIES'] = "";
                     while ($reply = $dbh->fetch_array($tickets_query)) {
                         if (!$n) {
                             $view_ticket_array['REPLIES'] .= "<br /><b>Replies</b>";
                         }
                         $view_ticket_array['REPLIES'] .= $this->showReply($reply['id']);
                         $n++;
                     }
                     $view_ticket_array['ADDREPLY'] .= "<br /><b>Change Ticket Status</b>";
                     $values[] = array("Open", 1);
                     $values[] = array("On Hold", 2);
                     $values[] = array("Closed", 3);
                     $client_change_status_array['DROPDOWN'] = main::dropdown("status", $values, $tickets_data['status'], 0);
                     $client_change_status_array['ID'] = $tickets_data['id'];
                     $view_ticket_array['ADDREPLY'] .= style::replaceVar("tpl/tickets/change-status.tpl", $client_change_status_array);
                     $view_ticket_array['ADDREPLY'] .= "<br /><b>Add Reply</b>";
                     $add_reply_array['TITLE'] = "RE: " . $tickets_data['title'];
                     $view_ticket_array['ADDREPLY'] .= style::replaceVar("tpl/tickets/add-reply.tpl", $add_reply_array);
                     echo style::replaceVar("tpl/tickets/view-ticket.tpl", $view_ticket_array);
                 }
             }
             break;
     }
 }