Ejemplo n.º 1
0
    function submit_paypal_post()
    {
        global $dbh, $postvar, $getvar, $instance;
        echo "<form action=" . $this->paypal_url . " method='post' name='frm'>";
        foreach ($this->fields as $a => $b) {
            if ($a == "amount") {
                if ($b == "0") {
                    $user_data = $dbh->select("users", array("id", "=", $_SESSION['cuser']));
                    $signup_date = date("m-d-Y", $user_data['signup']);
                    if ($signup_date == date("m-d-Y")) {
                        $noemail = "1";
                    }
                    invoice::set_paid($getvar['iid'], $noemail);
                    main::redirect("../client/?page=invoices");
                    exit;
                }
            }
            echo "<input type='hidden' name='" . $a . "' value='" . $b . "'>";
        }
        echo '</form>
		<script language="JavaScript">
		document.frm.submit();
		</script>';
        exit;
    }
Ejemplo n.º 2
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);
     }
 }
Ejemplo n.º 3
0
        }
    }
}
closedir($handle);
//Define the Admin directory
if (!defined("ADMINDIR")) {
    $admin_dir = find_admin_dir("../");
    define("ADMINDIR", $admin_dir);
}
if (INSTALL == 1) {
    $session_timeout = $dbh->config("session_timeout") * 60;
    //Make minutes into seconds.
    if ($session_timeout) {
        if (time() - $session_timeout > $_SESSION['time'] && $_SESSION['time']) {
            session_destroy();
            main::redirect("./");
        }
        //Keep it alive when there's activity.
        $_SESSION['time'] = time();
    }
    define("THEME", $dbh->config("theme"));
    // Set the default theme
    // Sets the URL THT is located at
    if ($_SERVER["HTTPS"]) {
        // HTTPS support
        define("URL", str_replace("http://", "https://", $dbh->config("url")));
    } else {
        define("URL", $dbh->config("url"));
    }
    define("NAME", $dbh->config("name"));
    // Sets the name of the website
Ejemplo n.º 4
0
             $data['zip'] = $postvar['zip'];
             $data['country'] = $postvar['country'];
             $data['phone'] = $postvar['phone'];
             $data['tzones'] = $postvar['tzones'];
             $data['coupon'] = $postvar['coupon'];
             $data['package'] = $getvar['package'];
             $data['domsub'] = $getvar['domsub'];
             $data['additional'] = $additional;
             $data['subdomain'] = $subdomain;
             $response = server::signup($data);
             if ($response === true) {
                 //class_server adds an invoice for paid accounts.  Do we have one to pay?
                 $invoice = check::ispaid($getvar['package'], $postvar['username']);
                 //It's not false and has to be > 0 if it returns something.
                 if ($invoice) {
                     main::redirect("../client/?page=invoices&iid=" . $invoice);
                     exit;
                 }
             }
             if ($response === false) {
                 $response = "An unknown error has orrured.  Please contact your system administrator.";
             }
             //It's not redirecting to the payment page, so we display the finishing text.
             $order_finished_array['FINISHEDTEXT'] = $response;
             $step5 = 1;
             $maincontent = style::replaceVar("tpl/order/order-finished.tpl", $order_finished_array);
         }
     }
 }
 if (!$step5 && is_numeric($getvar['package']) && !strpos($getvar['package'], ".") && ($getvar['domsub'] == "dom" || $getvar['domsub'] == "sub")) {
     if ($postvar['tzones']) {
Ejemplo n.º 5
0
<?php

//////////////////////////////
// The Hosting Tool Reworked
// Index Page
// By Reworked Scripts (Original Script by http://thehostingtool.com)
// Released under the GNU-GPL
//////////////////////////////
define("INC", "includes");
include INC . "/compiler.php";
$page = $dbh->config('default_page');
if ($page != "") {
    main::redirect($page);
}
Ejemplo n.º 6
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);
 }
Ejemplo n.º 7
0
 public function done()
 {
     global $dbh, $postvar, $getvar, $instance;
     foreach ($getvar as $key => $value) {
         if ($key != "do") {
             if ($var_seperator) {
                 $var_seperator = "&";
             } else {
                 $var_seperator = "?";
             }
             $url .= $var_seperator . $key . "=" . $value;
         }
     }
     main::redirect($url);
 }
Ejemplo n.º 8
0
 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;
     }
 }
Ejemplo n.º 9
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;
     }
 }
Ejemplo n.º 10
0
 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);
         }
     }
 }
Ejemplo n.º 11
0
function acp()
{
    global $dbh, $postvar, $getvar, $instance;
    ob_start();
    if ($_SESSION['clogged'] || $_SESSION['cuser']) {
        session_destroy();
        main::redirect("?page=home");
    }
    if (!$getvar['page']) {
        $getvar['page'] = "home";
    }
    $page = $dbh->select("acpnav", array("link", "=", $getvar['page']));
    // "Hack" to get the credits and tickets page looking nicer
    switch ($getvar["page"]) {
        case "credits":
            $header = "Credits";
            break;
        default:
            if ($page['visual'] == "Tickets" && $getvar['mode'] == 'ticketsall') {
                $header = "All Tickets";
            } else {
                $header = $page['visual'];
            }
            break;
    }
    $link = "pages/" . $getvar['page'] . ".php";
    $staff_data = $dbh->select("staff", array("id", "=", $_SESSION['user']));
    $user_perms = $staff_data['perms'];
    if (substr_count($user_perms, "paid") == '1') {
        $nopaid = '1';
    }
    if (substr_count($user_perms, "p2h") == '1') {
        $nop2h = '1';
    }
    if (!file_exists($link)) {
        $html = "<strong>THT Fatal Error:</strong> That page doesn't exist.";
    } elseif (!main::checkPerms($page['id']) && !$nopaid && !$nop2h && $user_perms) {
        $html = "You don't have access to this page.";
    } elseif ($getvar['page'] == "type" && $getvar['type'] == "paid" && $nopaid) {
        $html = "You don't have access to this page.";
    } elseif ($getvar['page'] == "type" && $getvar['type'] == "p2h" && $nop2h) {
        $html = "You don't have access to this page.";
    } else {
        include $link;
        $content = new page();
        // Main Side Bar HTML
        $nav = "Sidebar Menu";
        $sub = $dbh->select("acpnav", 0, array("id", "ASC"));
        while ($row = $dbh->fetch_array($sub)) {
            if (main::checkPerms($row['id'])) {
                $sidebarlink_array['IMGURL'] = $row['icon'];
                $sidebarlink_array['LINK'] = "?page=" . $row['link'];
                $sidebarlink_array['VISUAL'] = $row['visual'];
                $sidebar_array['LINKS'] .= style::replaceVar("tpl/sidebar-link.tpl", $sidebarlink_array);
            }
        }
        // Types Navbar
        /*
         * When Working on the navbar, to make a spacer use this:
         * $sidebar_array['LINKS'] .= style::replaceVar("tpl/spacer.tpl");
         */
        foreach ($instance->packtypes as $key => $value) {
            if ($key == "paid" && $nopaid != "1" || $key == "p2h" && $nop2h != "1" || $key != "paid" && $key != "p2h") {
                if ($instance->packtypes[$key]->acpNav) {
                    foreach ($instance->packtypes[$key]->acpNav as $key2 => $value) {
                        $sidebarlink_array['IMGURL'] = $value[2];
                        $sidebarlink_array['LINK'] = "?page=type&type=" . $key . "&sub=" . $value[1];
                        $sidebarlink_array['VISUAL'] = $value[0];
                        $sidebar_array['LINKS'] .= style::replaceVar("tpl/sidebar-link.tpl", $sidebarlink_array);
                        if ($getvar['page'] == "type" && $getvar['type'] == $key && $getvar['sub'] == $value[1]) {
                            define("SUB", $value[3]);
                            $header = $value[3];
                            $getvar['myheader'] = $value[3];
                        }
                    }
                }
            }
        }
        $sidebarlink_array['IMGURL'] = "information.png";
        $sidebarlink_array['LINK'] = "?page=credits";
        $sidebarlink_array['VISUAL'] = "Credits";
        $sidebar_array['LINKS'] .= style::replaceVar("tpl/sidebar-link.tpl", $sidebarlink_array);
        $sidebarlink_array['IMGURL'] = "delete.png";
        $sidebarlink_array['LINK'] = "?page=logout";
        $sidebarlink_array['VISUAL'] = "Logout";
        $sidebar_array['LINKS'] .= style::replaceVar("tpl/sidebar-link.tpl", $sidebarlink_array);
        $sidebar = style::replaceVar("tpl/sidebar.tpl", $sidebar_array);
        //Page Sidebar
        if ($content->navtitle) {
            $subnav = $content->navtitle;
            foreach ($content->navlist as $key => $value) {
                $sub_sidebarlink_array['IMGURL'] = $value[1];
                $sub_sidebarlink_array['LINK'] = "?page=" . $getvar['page'] . "&sub=" . $value[2];
                $sub_sidebarlink_array['VISUAL'] = $value[0];
                $sub_sidebar_array['LINKS'] .= style::replaceVar("tpl/sidebar-link.tpl", $sub_sidebarlink_array);
            }
            $subsidebar = style::replaceVar("tpl/sidebar.tpl", $sub_sidebar_array);
        }
        if ($getvar['sub'] && $getvar['page'] != "type") {
            foreach ($content->navlist as $key => $value) {
                if ($value[2] == $getvar['sub']) {
                    if (!$value[0]) {
                        define("SUB", $getvar['page']);
                        $header = $getvar['page'];
                    } else {
                        define("SUB", $value[0]);
                        $header = $value[0];
                    }
                }
            }
        }
        if ($getvar['sub'] == "delete" && isset($getvar['do']) && !$_POST && !$getvar['confirm']) {
            foreach ($postvar as $key => $value) {
                $warning_array['HIDDEN'] .= '<input name="' . $key . '" type="hidden" value="' . $value . '" />';
            }
            $warning_array['HIDDEN'] .= " ";
            $html = style::replaceVar("tpl/warning.tpl", $warning_array);
        } elseif ($getvar['sub'] == "delete" && isset($getvar['do']) && $_POST && !$getvar['confirm']) {
            if ($postvar['yes']) {
                foreach ($getvar as $key => $value) {
                    if ($i) {
                        $i = "&";
                    } else {
                        $i = "?";
                    }
                    $url .= $i . $key . "=" . $value;
                }
                $url .= "&confirm=1";
                main::redirect($url);
            } elseif ($postvar['no']) {
                main::done();
            }
        } else {
            if (isset($getvar['sub'])) {
                ob_start();
                $content->content();
                $html = ob_get_contents();
                // Retrieve the HTML
                ob_clean();
                // Flush the HTML
            } elseif ($content->navlist) {
                $html .= $content->description();
                // First, we gotta get the page description.
                $html .= "<br /><br />";
                // Break it up
                // Now we should prepend some stuff here
                $subsidebar2 .= "<strong>Page Submenu</strong><div class='break'></div>";
                $subsidebar2 .= $subsidebar;
                // Done, now output it in a sub() table
                $html .= main::sub($subsidebar2, NULL);
                // Initial implementation, add the SubSidebar(var) into the description, basically append it
            } else {
                ob_start();
                $content->content();
                $html = ob_get_contents();
                // Retrieve the HTML
                ob_clean();
                // Flush the HTML
            }
        }
    }
    $staffuser = $dbh->staff($_SESSION['user']);
    define("SUB", $header);
    define("INFO", '<b>Welcome back, ' . strip_tags($staffuser['name']) . '</b><br />' . SUB);
    echo '<div id="left">';
    echo main::table($nav, $sidebar);
    if ($content->navtitle) {
        echo "<br />";
        echo main::table($subnav, $subsidebar);
    }
    echo '</div>';
    echo '<div id="right">';
    echo main::table($header, $html);
    echo '</div>';
    $html_buff = ob_get_contents();
    ob_clean();
    return $html_buff;
}
Ejemplo n.º 12
0
 public function completeinstall($mod_dir)
 {
     global $dbh, $postvar, $getvar, $instance;
     if ($mod_dir) {
         if (self::is_mod_installed($mod_dir)) {
             echo "This module is already installed.  Please uninstall the module first before reinstalling it.";
             return;
         }
         $mod_dir_full = INC . "/automod/" . $mod_dir;
         $mod_files = INC . "/automod/" . $mod_dir . "/root";
         $mod_xml_file = $mod_dir_full . "/install.xml";
         if (is_file($mod_xml_file)) {
             //Let's set some variables - First the basics.
             $module_data = self::get_mod_xml($mod_xml_file);
             $header_data = $module_data['header'];
             $actions_data = $module_data['action-group'];
             $author_data = $module_data['header']['author-group']['author'];
             //Values that every module should have.
             $mod_name = $header_data['projname'];
             $mod_desc = $header_data['description'];
             $mod_license = $header_data['license'];
             $mod_version = $header_data['mod-version'];
             $mod_author = $author_data['realname'];
             $mod_homepage = $author_data['homepage'];
             $mod_projectpage = $author_data['projectpage'];
             $mod_support = $author_data['support'];
             $mod_thtversion = $author_data['thtversion'];
             $mod_updateurl = htmlentities($author_data['updateurl']);
             //Values that many modules have
             $mod_sql = $actions_data['sql'];
             $mod_uninstallsql = $actions_data['uninstallsql'];
             //We should check this to see if the user can remove the database entries made by the module and notify them if the uninstall SQL info isn't available.
             $mod_after_install = $actions_data['diy-instructions'];
             $mod_edits = $actions_data['open'];
             //Copy the root directory to the THT file structure.
             self::RecursiveCopy($mod_files, "..");
             //Install the SQL
             self::mysql_scary($mod_sql);
             //Edit the files
             self::modify_files($mod_edits, false, false, $mod_dir);
             //Add the mod to the AutoMod table.
             $automod_mods_insert = array("mod_install_dir" => $mod_dir, "mod_name" => $mod_name, "mod_version" => $mod_version, "mod_thtversion" => $mod_thtversion, "mod_descrip" => $mod_desc, "mod_author" => $mod_author, "mod_link" => $mod_homepage, "mod_projectpage" => $mod_projectpage, "mod_support" => $mod_support, "mod_license" => $mod_license, "mod_diy" => $mod_after_install, "mod_updateurl" => $mod_updateurl);
             $dbh->insert("automod_mods", $automod_mods_insert);
             //Redirect the user to the view mod page.
             $mod_data = self::module_data($mod_dir);
             main::redirect("?page=automod&sub=added&view=" . $mod_data['id']);
         } else {
             echo "Cannot find the install.xml file.  Please make sure that " . $mod_xml_file . " exists.";
         }
     }
 }
Ejemplo n.º 13
0
 private function EditEmailTemplates()
 {
     global $dbh, $postvar, $getvar, $instance;
     if (main::isint($getvar['do'])) {
         if ($postvar['edittpl']) {
             check::empty_fields();
             if (!main::errors()) {
                 $dbh->update("templates", array("subject" => $postvar['subject']), array("id", "=", $getvar['do']));
                 $template_info = $dbh->select("templates", array("id", "=", $getvar['do']));
                 $tmpl_file_base = INC . "/tpl/email/" . $template_info['dir'] . "/" . $template_info['name'];
                 if (!is_writable($tmpl_file_base . ".tpl")) {
                     main::errors("In order to make changes to this file (" . $tmpl_file_base . ".tpl), please make it writable.");
                 } else {
                     $contents = stripslashes($postvar['emailcontent']);
                     if ($contents) {
                         $filetochangeOpen = fopen($tmpl_file_base . ".tpl", "w");
                         if (!fputs($filetochangeOpen, $contents)) {
                             main::errors("Could not write the template file, " . $tmpl_file_base . ".tpl");
                         }
                         fclose($filetochangeOpen);
                     }
                     if (!main::errors()) {
                         main::errors("Template edited!");
                     }
                 }
             }
         }
         $template_data = $dbh->select("templates", array("id", "=", $getvar['do']));
         if (!$template_data['id']) {
             $error_array['Error'] = "Template not found.";
             $error_array['Template ID'] = $getvar['do'];
             main::error($error_array);
         } else {
             $tmpl_file_base = INC . "/tpl/email/" . $template_data['dir'] . "/" . $template_data['name'];
             $tmpl_content_file = @file_get_contents($tmpl_file_base . ".tpl");
             $tmpl_descrip_file = @file_get_contents($tmpl_file_base . ".desc.tpl");
             if (!$tmpl_content_file && !$tmpl_descrip_file) {
                 $error_array['Error'] = "One of the template files don't exist.<br>";
                 $error_array['Template Locations'] = "<br>" . $tmpl_file_base . ".tpl<br>" . $tmpl_file_base . ".desc.tpl";
                 main::error($error_array);
             } else {
                 $edit_email_template_array['SUBJECT'] = $template_data['subject'];
                 $edit_email_template_array['DESCRIPTION'] = $tmpl_descrip_file;
                 $edit_email_template_array['TEMPLATE'] = $tmpl_content_file;
             }
         }
         echo style::replaceVar("tpl/admin/mail/edit-email-template.tpl", $edit_email_template_array);
         return;
     }
     if (main::isint($postvar['template'])) {
         main::redirect("?page=email&sub=templates&do=" . $postvar['template']);
     }
     $templates_query = $dbh->select("templates", 0, array("acpvisual", "ASC"));
     while ($templates_data = $dbh->fetch_array($templates_query)) {
         $values[] = array($templates_data['acpvisual'], $templates_data['id']);
     }
     $select_email_template_array['TEMPLATES'] = main::dropDown("template", $values, 0, 1);
     echo style::replaceVar("tpl/admin/mail/select-email-template.tpl", $select_email_template_array);
 }
Ejemplo n.º 14
0
 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);
     }
 }
Ejemplo n.º 15
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);
     }
 }
Ejemplo n.º 16
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");
     }
 }
Ejemplo n.º 17
0
 private function LoginAsClient($client)
 {
     global $dbh, $postvar, $getvar, $instance;
     session_destroy();
     session_start();
     $_SESSION['clogged'] = 1;
     $_SESSION['cuser'] = $client['id'];
     main::redirect("../client");
 }
Ejemplo n.º 18
0
function client()
{
    global $dbh, $postvar, $getvar, $instance;
    ob_start();
    // Stop the output buffer
    if (!$getvar['page']) {
        $getvar['page'] = "home";
    }
    $page = $dbh->select("clientnav", array("link", "=", $getvar['page']), array("id", "ASC"));
    $header = $page['visual'];
    $link = "pages/" . $getvar['page'] . ".php";
    if (!file_exists($link)) {
        $html = "That page doesn't exist.";
    } else {
        if (preg_match("/[\\.*]/", $getvar['page']) == 0) {
            include $link;
            $content = new page();
            // Main Side Bar HTML
            $nav = "Sidebar";
            if (!$dbh->config("delacc")) {
                $clientnav_query = $dbh->select("clientnav", array("link", "!=", "delete"), array("id", "ASC"), 0, 1);
            } else {
                $clientnav_query = $dbh->select("clientnav", 0, array("id", "ASC"), 0, 1);
            }
            while ($clientnav_data = $dbh->fetch_array($clientnav_query)) {
                $sidebar_link_array['IMGURL'] = $clientnav_data['icon'];
                $sidebar_link_array['LINK'] = "?page=" . $clientnav_data['link'];
                $sidebar_link_array['VISUAL'] = $clientnav_data['visual'];
                $sidebar_array['LINKS'] .= style::replaceVar("tpl/sidebar-link.tpl", $sidebar_link_array);
            }
            // Types Navbar
            $client = $dbh->client($_SESSION['cuser']);
            $packtype = $instance->packtypes[type::packagetype($client['pid'])];
            if ($packtype->clientNav) {
                foreach ($packtype->clientNav as $key2 => $value) {
                    $sidebar_link_array['IMGURL'] = $value[2];
                    $sidebar_link_array['LINK'] = "?page=type&type=" . type::packagetype($client['pid']) . "&sub=" . $value[1];
                    $sidebar_link_array['VISUAL'] = $value[0];
                    $sidebar_array['LINKS'] .= style::replaceVar("tpl/sidebar-link.tpl", $sidebar_link_array);
                    if ($getvar['page'] == "type" && $getvar['type'] == type::packagetype($client['pid']) && $getvar['sub'] == $value[1]) {
                        define("SUB", $value[3]);
                        $header = $value[3];
                        $getvar['myheader'] = $value[3];
                    }
                }
            }
            $sidebar_link_array['IMGURL'] = "delete.png";
            $sidebar_link_array['LINK'] = "?page=logout";
            $sidebar_link_array['VISUAL'] = "Logout";
            $sidebar_array['LINKS'] .= style::replaceVar("tpl/sidebar-link.tpl", $sidebar_link_array);
            $sidebar = style::replaceVar("tpl/sidebar.tpl", $sidebar_array);
            //Page Sidebar
            if ($content->navtitle) {
                $subnav = $content->navtitle;
                foreach ($content->navlist as $key => $value) {
                    $sidebar_link_array['IMGURL'] = $value[1];
                    $sidebar_link_array['LINK'] = "?page=" . $getvar['page'] . "&sub=" . $value[2];
                    $sidebar_link_array['VISUAL'] = $value[0];
                    $sub_sidebar_array['LINKS'] .= style::replaceVar("tpl/sidebar-link.tpl", $sidebar_link_array);
                }
                $subsidebar = style::replaceVar("tpl/sidebar.tpl", $sub_sidebar_array);
            }
            if ($getvar['sub'] == "delete" && isset($getvar['do']) && !$_POST && !$getvar['confirm']) {
                foreach ($postvar as $key => $value) {
                    $warning_array['HIDDEN'] .= '<input name="' . $key . '" type="hidden" value="' . $value . '" />';
                }
                $warning_array['HIDDEN'] .= " ";
                $html = style::replaceVar("tpl/warning.tpl", $warning_array);
            } elseif ($getvar['sub'] == "delete" && isset($getvar['do']) && $_POST && !$getvar['confirm']) {
                if ($postvar['yes']) {
                    foreach ($getvar as $key => $value) {
                        if ($i) {
                            $i = "&";
                        } else {
                            $i = "?";
                        }
                        $url .= $i . $key . "=" . $value;
                    }
                    $url .= "&confirm=1";
                    main::redirect($url);
                } elseif ($postvar['no']) {
                    main::done();
                }
            } else {
                if (isset($getvar['sub'])) {
                    ob_start();
                    $content->content();
                    $html = ob_get_contents();
                    // Retrieve the HTML
                    ob_clean();
                    // Flush the HTML
                } elseif ($content->navlist) {
                    if ($content->description()) {
                        $html = $content->description() . "<br><br>";
                    }
                    $html .= "Select a sub-page from the sidebar.";
                } else {
                    ob_start();
                    $content->content();
                    $html = ob_get_contents();
                    // Retrieve the HTML
                    ob_clean();
                    // Flush the HTML
                }
            }
        }
    }
    if ($getvar['sub'] && $getvar['page'] != "type") {
        foreach ($content->navlist as $key => $value) {
            if ($value[2] == $getvar['sub']) {
                define("SUB", $value[0]);
                $header = $value[0];
            }
        }
    }
    $staffuser = $dbh->client($_SESSION['cuser']);
    define("SUB", $header);
    define("INFO", '<b>Welcome back, ' . $staffuser['user'] . '</b><br />' . SUB);
    echo '<div id="left">';
    echo main::table($nav, $sidebar);
    if ($content->navtitle) {
        echo "<br />";
        echo main::table($subnav, $subsidebar);
    }
    echo '</div>';
    echo '<div id="right">';
    echo main::table($header, $html);
    echo '</div>';
    $html_buff = ob_get_contents();
    ob_clean();
    return $html_buff;
}