public function __construct() { global $dbh, $postvar, $getvar, $instance; $this->acpForm[] = array("Signup Posts", '<input name="signup" type="text" id="signup" size="5" />', 'signup'); $this->acpForm[] = array("Monthly Posts", '<input name="monthly" type="text" id="monthly" size="5" />', 'monthly'); $this->orderForm[] = array("Forum Username", '<input name="type_fuser" type="text" id="type_fuser" />', 'fuser'); $this->orderForm[] = array("Forum Password", '<input name="type_fpass" type="password" id="type_fpass" />', 'fpass'); $p2h_query = $dbh->select("p2h"); while ($p2h_data = $dbh->fetch_array($p2h_query)) { $values[] = array($p2h_data['forumname'], $p2h_data['id']); } $this->acpForm[] = array("Forum", main::dropDown("forum", $values), 'forum'); $this->acpNav[] = array("P2H Forums", "forums", "lightning.png", "P2H Forums"); $this->clientNav[] = array("Forum Posting", "forums", "lightning.png", "Forum Posting"); }
public function content() { global $dbh, $postvar, $getvar, $instance; switch ($getvar['sub']) { case "tchoose": if ($_POST) { check::empty_fields(); if (!main::errors()) { foreach ($postvar as $key => $value) { $dbh->updateConfig($key, $value); } main::errors("Settings Updated!"); } } $folder = "../themes/"; if ($handle = opendir($folder)) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != ".." && $file != ".svn" && $file != "icons" && $file != "index.html" && $file != "flags") { $values[] = array($file, $file); } } } closedir($handle); $theme_settings_array['THEME'] = main::dropDown("theme", $values, $dbh->config("theme")); echo style::replaceVar("tpl/admin/lof/theme-settings.tpl", $theme_settings_array); break; case "tupload": // Theme Uploader echo "Here you can upload a theme of your choice to the installer. Please be sure that the theme is in .zip format.<br><br>"; if ($_POST) { $response = main::upload_theme(); echo $response . "<br><br>"; } echo style::replaceVar('tpl/admin/lof/theme-upload.tpl'); break; case "cssedit": echo $this->EditTemplate("style", "css"); break; case "tpledit": echo style::replaceVar('tpl/admin/lof/template-editor.tpl'); break; case "navedit": echo style::replaceVar("tpl/admin/lof/navedit/top.tpl"); $navbar_query = $dbh->select("navbar", 0, array("sortorder", "ASC")); while ($navbar_data = $dbh->fetch_array($navbar_query)) { $link_box_array['ID'] = $navbar_data['id']; $link_box_array['NAME'] = $navbar_data['visual']; $link_box_array['ICON'] = $navbar_data['icon']; $link_box_array['LINK'] = $navbar_data['link']; $links_array['LINKS'] .= style::replaceVar("tpl/admin/lof/navedit/link-box.tpl", $link_box_array); } echo style::replaceVar("tpl/admin/lof/navedit/links.tpl", $links_array); echo style::replaceVar("tpl/admin/lof/navedit/bottom.tpl"); break; case "editheader": echo $this->EditTemplate("header", "tpl"); break; case "editfooter": echo $this->EditTemplate("footer", "tpl"); break; case "ui-theme": if ($_POST) { check::empty_fields(); if (!main::errors()) { foreach ($postvar as $key => $value) { $dbh->updateConfig($key, $value); } main::errors("Settings Updated!"); } } $folder = INC . "/css/"; foreach (main::folderFiles($folder) as $file) { $files[] = array($file, $file); } $jquery_theme_changer_array['THEME'] = main::dropDown("ui-theme", $files, $dbh->config("ui-theme")); echo style::replaceVar('tpl/admin/lof/jquery-theme-changer.tpl', $jquery_theme_changer_array); break; } }
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); } }
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"); } }
public function content() { global $dbh, $postvar, $getvar, $instance; switch ($getvar['sub']) { default: if ($_POST) { check::empty_fields(); if (!main::errors()) { $subdomains_insert = array("domain" => $postvar['domain'], "server" => $postvar['server']); $dbh->insert("subdomains", $subdomains_insert); main::errors("Subdomain domain has been added!"); } } $servers_query = $dbh->select("servers"); if ($dbh->num_rows($servers_query) == 0) { echo "There are no servers, you need to add a server first!"; return; } while ($servers_data = $dbh->fetch_array($servers_query)) { $values[] = array($servers_data['name'], $servers_data['id']); } $add_subdomain_array['SERVER'] = main::dropDown("server", $values); echo style::replaceVar("tpl/admin/subdomains/add-subdomain.tpl", $add_subdomain_array); break; case "edit": if (isset($getvar['do'])) { $subdomains_data = $dbh->select("subdomains", array("id", "=", $getvar['do'])); if (!$subdomains_data['id']) { echo "That subdomain domain doesn't exist!"; } else { if ($_POST) { check::empty_fields(); if (!main::errors()) { $subdomains_update = array("domain" => $postvar['domain'], "server" => $postvar['server']); $dbh->update("subdomains", $subdomains_update, array("id", "=", $getvar['do'])); //Subdomain added main::done(); } } $edit_subdomain_array['DOMAIN'] = $subdomains_data['domain']; $servers_query = $dbh->select("servers"); while ($servers_data = $dbh->fetch_array($servers_query)) { $values[] = array($servers_data['name'], $servers_data['id']); } $edit_subdomain_array['SERVER'] = main::dropDown("server", $values, $servers_data['server']); echo style::replaceVar("tpl/admin/subdomains/edit-subdomain.tpl", $edit_subdomain_array); } } else { $subdomains_query = $dbh->select("subdomains"); if ($dbh->num_rows($subdomains_query) == 0) { echo "There are no subdomain domains to edit!"; } else { echo "<ERRORS>"; while ($subdomains_data = $dbh->fetch_array($subdomains_query)) { echo main::sub("<strong>" . $subdomains_data['domain'] . "</strong>", '<a href="?page=sub&sub=edit&do=' . $subdomains_data['id'] . '"><img src="' . URL . 'themes/icons/pencil.png"></a>'); } } } break; case "delete": if (isset($getvar['do'])) { $dbh->delete("subdomains", array("id", "=", $getvar['do'])); main::errors("Subdomain Deleted!"); } $subdomains_query = $dbh->select("subdomains"); if ($dbh->num_rows($subdomains_query) == 0) { echo "There are no subdomain domains to delete!"; } else { echo "<ERRORS>"; while ($subdomains_data = $dbh->fetch_array($subdomains_query)) { echo main::sub("<strong>" . $subdomains_data['domain'] . "</strong>", '<a href="?page=sub&sub=delete&do=' . $subdomains_data['id'] . '"><img src="' . URL . 'themes/icons/delete.png"></a>'); } } break; } }
public function content() { global $dbh, $postvar, $getvar, $instance; switch ($getvar['sub']) { default: if ($_POST['add']) { $no_check_array = array("resellerport", "welcome", "nstmp", "passtoo", "resellerid"); check::empty_fields($no_check_array); if (!main::errors()) { $servers_insert = array("ip" => $postvar['ip'], "resellerport" => $postvar['resellerport'], "port" => $postvar['port'], "nameservers" => $postvar['nameservers'], "name" => $postvar['name'], "host" => $postvar['host'], "user" => $postvar['user'], "accesshash" => $postvar['hash'], "type" => $postvar['type'], "dnstemplate" => $postvar['nstmp'], "welcome" => $postvar['welcome'], "pass" => $postvar['pass'], "reseller_id" => $postvar['resellerid'], "https" => $postvar['https'], "apiport" => $postvar['apiport']); $dbh->insert("servers", $servers_insert); main::errors("Server has been added!"); } } if ($_POST['addtype'] || $_POST['add']) { $serverfile = server::createServer(0, $postvar['type']); $server_fields = $serverfile->acp_form(); $add_server_array['SERVER_FIELDS'] = $server_fields; $add_server_array['TYPE'] = $postvar['type']; echo style::replaceVar("tpl/admin/servers/add-server.tpl", $add_server_array); break; } $files = main::folderFiles(INC . "/servers/"); foreach ($files as $value) { include INC . "/servers/" . $value; $fname = explode(".", $value); $stype = new $fname[0](); $values[] = array($stype->name, $fname[0]); } $server_type_array['TYPE'] = main::dropDown("type", $values, 0); echo style::replaceVar("tpl/admin/servers/server-type.tpl", $server_type_array); break; case "view": if (isset($getvar['do'])) { $servers_query = $dbh->select("servers", array("id", "=", $getvar['do']), 0, 0, 1); if ($dbh->num_rows($servers_query) == 0) { echo "That server doesn't exist!"; } else { if ($_POST) { check::empty_fields(); if (!main::errors()) { $servers_update = array("name" => $postvar['name'], "host" => $postvar['host'], "reseller_id" => $postvar['resellerid'], "user" => $postvar['user'], "pass" => $postvar['pass'], "accesshash" => $postvar['hash'], "port" => $postvar['port'], "resellerport" => $postvar['resellerport'], "nameservers" => $postvar['nameservers'], "ip" => $postvar['ip'], "dnstemplate" => $postvar['nstmp'], "welcome" => $postvar['welcome'], "https" => $postvar['https'], "apiport" => $postvar['apiport']); $dbh->update("servers", $servers_update, array("id", "=", $getvar['do']), 1); //Server edit complete main::done(); } } $servers_data = $dbh->fetch_array($servers_query); $serverfile = server::createServer(0, $servers_data['type']); $server_fields = $serverfile->acp_form($getvar['do']); $edit_server_array['NAME'] = $servers_data['name']; $edit_server_array['HOST'] = $servers_data['host']; $edit_server_array['SERVERIP'] = $servers_data['ip']; $edit_server_array['RESELLERPORT'] = $servers_data['resellerport']; $edit_server_array['PORT'] = $servers_data['port']; $edit_server_array['NAMESERVERS'] = $servers_data['nameservers']; $edit_server_array['SERVER_FIELDS'] = $server_fields; echo style::replaceVar("tpl/admin/servers/edit-server.tpl", $edit_server_array); } } else { $servers_query = $dbh->select("servers"); if ($dbh->num_rows($servers_query) == 0) { echo "There are no servers to view!"; } else { echo "<ERRORS>"; while ($servers_data = $dbh->fetch_array($servers_query)) { echo main::sub("<strong>" . $servers_data['name'] . "</strong>", '<a href="?page=servers&sub=view&do=' . $servers_data['id'] . '"><img src="' . URL . 'themes/icons/magnifier.png"></a>'); } } } break; case "delete": if ($getvar['do']) { $dbh->delete("servers", array("id", "=", $getvar['do'])); main::errors("Server Deleted!"); } $servers_query = $dbh->select("servers"); if ($dbh->num_rows($servers_query) == 0) { echo "There are no servers to delete!"; } else { echo "<ERRORS>"; while ($servers_data = $dbh->fetch_array($servers_query)) { echo main::sub("<strong>" . $servers_data['name'] . "</strong>", '<a href="?page=servers&sub=delete&do=' . $servers_data['id'] . '"><img src="' . URL . 'themes/icons/delete.png"></a>'); } } break; case "test": if (isset($getvar["do"])) { $result = server::testConnection($getvar["do"]); if ($result === true) { echo '<div style="text-align:center;padding-top:10px;">' . style::notice(true, "Connected to the server successfully!") . "</div>"; } else { echo '<div style="text-align:center;">' . style::notice(false, "Couldn't connect to the server...") . "</div>"; echo '<strong>Error:</strong><pre>' . (string) $result . '</pre>'; } } else { $servers_query = $dbh->select("servers"); if ($dbh->num_rows($servers_query) == 0) { echo "There are no servers to view!"; } else { echo "Caution: Some servers are set to automatically ban the IP address of this server (" . $_SERVER['SERVER_ADDR'] . ") after a certain number of failed logins.<br />"; while ($servers_data = $dbh->fetch_array($servers_query)) { echo main::sub("<strong>" . $servers_data['name'] . "</strong>", '<a href="?page=servers&sub=test&do=' . $servers_data['id'] . '"><img src="' . URL . 'themes/icons/server_chart.png"></a>'); } } } break; case "status": $server_status_array['EXTRA'] = ''; if (!main::canRun('shell_exec')) { $server_status_array['EXTRA'] = 'Some statistics could not be provided because shell_exec has been disabled.<br>'; } $server = $_SERVER['HTTP_HOST']; $server_status_array['OS'] = php_uname(); $server_status_array['DISTRO'] = ''; if (php_uname('s') == 'Linux') { $distro = main::getLinuxDistro(); if ($distro) { $server_status_array['DISTRO'] = '<tr><td><strong>Linux Distro:</strong></td><td> ' . $distro . ' </td></tr>'; } } $server_status_array['SOFTWARE'] = getenv('SERVER_SOFTWARE'); $server_status_array['PHP_VERSION'] = phpversion(); $server_status_array['MYSQL_VERSION'] = ''; $mysqlVersion = $dbh->version(); if ($mysqlVersion) { $server_status_array['MYSQL_VERSION'] = '<tr><td><strong>MySQL Version:</strong><br><br></td><td> ' . $mysqlVersion . ' <br><br></td></tr>'; } $server_status_array['SERVER'] = $server; echo style::replaceVar('tpl/admin/servers/server-status.tpl', $server_status_array); break; case "phpinfo": echo server::show_phpinfo(); break; } }
public function acpPage() { global $dbh, $postvar, $getvar, $instance; if ($_POST) { check::empty_fields(array("password", "paypalsandemail")); if (!main::errors()) { if (is_numeric($postvar['susdays']) && is_numeric($postvar['termdays'])) { $dbh->updateConfig("suspensiondays", $postvar['susdays']); $dbh->updateConfig("terminationdays", $postvar['termdays']); $dbh->updateConfig("currency", $postvar['currency']); $dbh->updateConfig("currency_format", $postvar['currency_format']); $dbh->updateConfig("paypalemail", $postvar['paypalemail']); $dbh->updateConfig("paypalmode", $postvar['paypalmode']); $dbh->updateConfig("paypalsandemail", $postvar['paypalsandemail']); main::errors("Values have been updated!"); } else { main::errors("Please enter a valid value!"); } } } $currency_values[] = array("Pound Sterling", "GBP"); $currency_values[] = array("US Dollars", "USD"); $currency_values[] = array("Australian Dollars", "AUD"); $currency_values[] = array("Canadian Dollars", "CAD"); $currency_values[] = array("Euros", "EUR"); $currency_values[] = array("Yen", "JPY"); $currency_values[] = array("New Zealand Dollar", "NZD"); $currency_values[] = array("Swiss Franc", "CHF"); $currency_values[] = array("Hong Kong Dollar", "HKD"); $currency_values[] = array("Singapore Dollar", "SGD"); $currency_values[] = array("Swedish Krona", "SEK"); $currency_values[] = array("Danish Krone", "DKK"); $currency_values[] = array("Polish Zloty", "PLN"); $currency_values[] = array("Norwegian Krone", "NOK"); $currency_values[] = array("Hungarian Forint", "HUF"); $currency_values[] = array("Czech Koruna", "CZK"); $currency_values[] = array("Israeli Shekel", "ILS"); $currency_values[] = array("Mexican Peso", "MXN"); $paypal_values[] = array("Live", "live"); $paypal_values[] = array("Sandbox", "sandbox"); $currency_format_values[] = array("1,000.99", "."); $currency_format_values[] = array("1 000,99", ","); $paid_configuration_array['CURRENCY'] = main::dropDown("currency", $currency_values, $dbh->config("currency")); $paid_configuration_array['CURRENCY_FORMAT'] = main::dropDown("currency_format", $currency_format_values, $dbh->config("currency_format")); $paid_configuration_array['PAYPALMODE'] = main::dropDown("paypalmode", $paypal_values, $dbh->config("paypalmode")); $paid_configuration_array['PAYPALSANDEMAIL'] = $dbh->config("paypalsandemail"); $paid_configuration_array['SUSDAYS'] = $dbh->config("suspensiondays"); $paid_configuration_array['TERDAYS'] = $dbh->config("terminationdays"); $paid_configuration_array['PAYPALEMAIL'] = $dbh->config("paypalemail"); echo style::replaceVar("tpl/admin/paid-configuration.tpl", $paid_configuration_array); }
public function content() { global $dbh, $postvar, $getvar, $instance; switch ($getvar['sub']) { default: if ($_POST['add']) { $no_check_array = array("admin", "groupid", "sendwelcome", "welcomesubject", "welcomebody"); check::empty_fields($no_check_array); $ZserverID = $postvar['server']; unset($where); $where[] = array("id", "=", $ZserverID, "AND"); $where[] = array("type", "=", "zpanel"); $servers_query = $dbh->select("servers", $where, 0, 0, 1); if ($dbh->num_rows($servers_query) == 1) { $zpanel_srv = 1; } //Hack to make sure the Group ID isn't 0 on ZPanel if ($zpanel_srv && ($postvar["groupid"] == 0 || $postvar["backend"] == 0)) { main::errors(" ZPanel server packages must include a Group ID for the package and the a backend package ID that's greater than 0. See the info bubbles for help."); } if ($postvar["monthly"] && !is_numeric($postvar["monthly"]) || $postvar["signup"] && !is_numeric($postvar["signup"])) { main::errors("Please enter a positive number for the cost or posts fields."); } if (!main::errors()) { $not_additional_array = array("add", "name", "backend", "description", "type", "server", "admin", "groupid", "sendwelcome", "welcomesubject", "welcomebody", $GLOBALS['csrf']['input-name']); foreach ($postvar as $key => $value) { if (!in_array($key, $not_additional_array)) { if ($n) { $additional .= ","; } $additional .= $key . "=" . str_replace(array(" ", ","), array("", "."), $value); $n++; } } $packages_insert = array("name" => $postvar['name'], "backend" => $postvar['backend'], "description" => $postvar['description'], "type" => $postvar['type'], "server" => $postvar['server'], "admin" => $postvar['admin'], "is_hidden" => $postvar['hidden'], "is_disabled" => $postvar['disabled'], "additional" => $additional, "reseller" => $postvar['reseller'], "groupid" => $postvar['groupid'], "send_email" => $postvar['sendwelcome'], "email_subject" => $postvar['welcomesubject'], "email_body" => $postvar['welcomebody']); $dbh->insert("packages", $packages_insert); main::errors("Package has been added!<br>"); } } if ($_POST['packserver'] || $_POST['add']) { $servers_data = $dbh->select("servers", array("id", "=", $postvar['server']), 0, "1"); $serverfile = server::createServer(0, $servers_data['type']); $package_fields = $serverfile->acp_packages_form(); $add_package_array['TYPE_FORM'] = type::acpPadd($postvar['type']); $add_package_array['TYPE'] = $postvar['type']; $add_package_array['PACKAGES_FIELDS'] = $package_fields; $add_package_array['SERVER'] = $postvar['server']; echo style::replaceVar("tpl/admin/packages/add-package.tpl", $add_package_array); break; } $servers_query = $dbh->select("servers"); if ($dbh->num_rows($servers_query) == 0) { echo "There are no servers, you need to add a server first!"; return; } while ($servers_data = $dbh->fetch_array($servers_query)) { $values[] = array($servers_data['name'], $servers_data['id']); } $p2h_query = $dbh->select("p2h"); $p2h_data = $dbh->num_rows($p2h_query); if ($p2h_data != "0") { $package_server_array['P2HOPTION'] = '<option value="p2h">Post 2 Host</option>'; } else { $package_server_array['P2HOPTION'] == ""; } $package_server_array['SERVER'] = main::dropDown("server", $values); echo "This will only add the package to THT, not create the package on the backend for you.<br><br>"; echo style::replaceVar("tpl/admin/packages/package-server.tpl", $package_server_array); break; case "edit": if (isset($getvar['do'])) { $packages_query = $dbh->select("packages", array("id", "=", $getvar['do']), 0, 0, 1); if ($dbh->num_rows($packages_query) == 0) { echo "That package doesn't exist!"; } else { if ($_POST) { $no_check_array = array("admin", "groupid", "sendwelcome", "welcomesubject", "welcomebody"); check::empty_fields($no_check_array); $ZserverID = $postvar['server']; unset($where); $where[] = array("id", "=", $ZserverID, "AND"); $where[] = array("type", "=", "zpanel"); $servers_query = $dbh->select("servers", $where, 0, 0, 1); if ($dbh->num_rows($servers_query) == 1) { $zpanel_srv = 1; } //Hack to make sure the Group ID isn't 0 on ZPanel if ($zpanel_srv && ($postvar["groupid"] == 0 || $postvar["backend"] == 0)) { main::errors(" ZPanel server packages must include a Group ID for the package and the a backend package ID that's greater than 0. See the info bubbles for help."); } if ($postvar["monthly"] && !is_numeric($postvar["monthly"]) || $postvar["signup"] && !is_numeric($postvar["signup"])) { main::errors("Please enter a positive number for the cost or posts fields."); } if (!main::errors()) { $not_additional_array = array("edit", "name", "backend", "description", "type", "server", "admin", "groupid", "sendwelcome", "welcomesubject", "welcomebody", $GLOBALS['csrf']['input-name']); foreach ($postvar as $key => $value) { if (!in_array($key, $not_additional_array)) { if ($n) { $additional .= ","; } $additional .= $key . "=" . str_replace(array(" ", ","), array("", "."), $value); $n++; } } if ($postvar['sendwelcome'] && (!$postvar['welcomesubject'] || !$postvar['welcomebody'])) { $serverid = $postvar['server']; $server_type_data = $dbh->select("servers", array("id", "=", $serverid)); $server_type = $server_type_data['type']; if ($server_type == "zpanel") { include INC . "/servers/" . $server_type . ".php"; $server = new $server_type(); $server_subject_def = server::email_subject; $server_body_def = server::email_body; if (!$postvar['welcomesubject']) { $postvar['welcomesubject'] = $server_subject_def; } if (!$postvar['welcomebody']) { $postvar['welcomebody'] = $server_body_def; } } } $packages_update = array("name" => $postvar['name'], "backend" => $postvar['backend'], "description" => $postvar['description'], "server" => $postvar['server'], "admin" => $postvar['admin'], "additional" => $additional, "reseller" => $postvar['reseller'], "is_hidden" => $postvar['hidden'], "is_disabled" => $postvar['disabled'], "type" => $postvar['type'], "groupid" => $postvar['groupid'], "send_email" => $postvar['sendwelcome'], "email_subject" => $postvar['welcomesubject'], "email_body" => $postvar['welcomebody']); $dbh->update("packages", $packages_update, array("id", "=", $getvar['do'])); //Package edit complete. main::done(); } } $packages_data = $dbh->fetch_array($packages_query); $edit_package_array['BACKEND'] = $packages_data['backend']; $edit_package_array['DESCRIPTION'] = $packages_data['description']; $edit_package_array['NAME'] = $packages_data['name']; $edit_package_array['URL'] = $dbh->config("url"); $edit_package_array['ID'] = $packages_data['id']; if ($packages_data['admin'] == 1) { $edit_package_array['ADMIN_CHECKED'] = 'checked="checked"'; } else { $edit_package_array['ADMIN_CHECKED'] = ""; } if ($packages_data['reseller'] == 1) { $edit_package_array['RESELLER_CHECKED'] = 'checked="checked"'; } else { $edit_package_array['RESELLER_CHECKED'] = ""; } if ($packages_data['is_hidden'] == 1) { $edit_package_array['HIDDEN_CHECKED'] = 'checked="checked"'; } else { $edit_package_array['HIDDEN_CHECKED'] = ""; } if ($packages_data['is_disabled'] == 1) { $edit_package_array['DISABLED_CHECKED'] = 'checked="checked"'; } else { $edit_package_array['DISABLED_CHECKED'] = ""; } $serverfile = server::createServer($getvar['do']); $package_fields = $serverfile->acp_packages_form($getvar['do']); $edit_package_array['PACKAGES_FIELDS'] = $package_fields; $p2h_query = $dbh->select("p2h"); $p2h_data = $dbh->num_rows($p2h_query); $edit_package_array['TYPE'] = $packages_data['type']; $additional = $packages_data['additional']; $edit_package_array['TYPE_FORM'] = type::acpPedit($packages_data['type'], $additional, $packages_data['type']); if ($packages_data['type'] == "p2h" && $p2h_data == "0") { $edit_package_array['TYPE_FORM'] = ""; } $servers_query = $dbh->select("servers"); while ($servers_data = $dbh->fetch_array($servers_query)) { $values[] = array($servers_data['name'], $servers_data['id']); } $edit_package_array['SERVER'] = $packages_data['server']; echo "This will only edit the package on THT, not edit the package on the backend for you.<br><br>"; echo style::replaceVar("tpl/admin/packages/edit-package.tpl", $edit_package_array); } } else { $packages_query = $dbh->select("packages"); if ($dbh->num_rows($packages_query) == 0) { echo "There are no packages to edit!"; } else { echo "<ERRORS>"; while ($packages_data = $dbh->fetch_array($packages_query)) { echo main::sub("<strong>" . $packages_data['name'] . "</strong>", '<a href="?page=packages&sub=edit&do=' . $packages_data['id'] . '"><img src="' . URL . 'themes/icons/pencil.png"></a>'); $n++; } } } break; case "delete": if ($getvar['do']) { $dbh->delete("packages", array("id", "=", $getvar['do'])); main::errors("Package has been Deleted.<br>"); } $packages_query = $dbh->select("packages"); if ($dbh->num_rows($packages_query) == 0) { echo "There are no packages to delete."; } else { echo "<ERRORS>This will only delete the package on THT, not delete the package on the backend for you.<br><br>"; while ($packages_data = $dbh->fetch_array($packages_query)) { echo main::sub("<strong>" . $packages_data['name'] . "</strong>", '<a href="?page=packages&sub=delete&do=' . $packages_data['id'] . '"><img src="' . URL . 'themes/icons/delete.png"></a>'); $n++; } } break; } }
private function edit_article() { global $dbh, $postvar, $getvar, $instance; $cats_query = $dbh->select("cats"); if (!$dbh->num_rows($cats_query)) { echo "You need to add a category before you add an article."; return; } if ($_POST['edit']) { check::empty_fields(); if (!main::errors()) { $articles_update = array("name" => $postvar['editname'], "content" => $postvar['editdescription'], "catid" => $postvar['catid']); $dbh->update("articles", $articles_update, array("id", "=", $getvar['id'])); main::errors("Article Edited!"); } } if ($getvar['del']) { $dbh->delete("articles", array("id", "=", $getvar['del'])); main::errors("Article Deleted!"); } if (main::isint($getvar['categoryid'])) { $show_cat[] = array("catid", "=", $getvar['categoryid']); } if (!main::isint($getvar['id'])) { $list_articles_array['BOXES'] = ""; $articles_query = $dbh->select("articles", $show_cat, 0, 0, 1); if ($dbh->num_rows($articles_query)) { while ($articles_data = $dbh->fetch_array($articles_query)) { $edit_article_box_array['NAME'] = $articles_data['name']; $edit_article_box_array['ID'] = $articles_data['id']; $list_articles_array['BOXES'] .= style::replaceVar("tpl/admin/kb/edit-article-box.tpl", $edit_article_box_array); } } echo style::replaceVar("tpl/admin/kb/list-articles.tpl", $list_articles_array); } else { $cats_query = $dbh->select("cats"); while ($cat = $dbh->fetch_array($cats_query)) { $values[] = array($cat['name'], $cat['id']); } $article_data = $dbh->select("articles", array("id", "=", $getvar['id']), 0, "1"); $edit_article_array['NAME'] = $article_data['name']; $edit_article_array['DESCRIPTION'] = $article_data['content']; $edit_article_array['DROPDOWN'] = main::dropDown("catid", $values, $article_data['catid']); echo style::replaceVar("tpl/admin/kb/edit-article.tpl", $edit_article_array); } }
public function content() { global $dbh, $postvar, $getvar, $instance; switch ($getvar['sub']) { default: if ($_POST) { $no_check_fields = array("last_tld_update", "otherdefault"); check::empty_fields($no_check_fields); if ($postvar['url'] && substr($postvar['url'], -1, 1) != "/") { $postvar['url'] = $postvar['url'] . "/"; } if ($postvar['default_page'] && $postvar['default_page'] == "-other-") { if (!$postvar['otherdefault']) { main::errors("Please enter the default directory to redirect to."); } else { if (is_dir("../" . $postvar['otherdefault'])) { $postvar['default_page'] = $postvar['otherdefault']; } else { main::errors("The default directory entered does not exist."); } } } if ($postvar['last_tld_update'] == "never") { $dbh->updateConfig("last_tld_update", "never"); } else { unset($postvar['last_tld_update']); } if (!main::errors()) { foreach ($postvar as $key => $value) { $dbh->updateConfig($key, $value); } main::errors("Settings Updated!"); } } $general_settings_array['NAME'] = $dbh->config("name"); $general_settings_array['URL'] = $dbh->config("url"); $general_settings_array['RECURL'] = $_SERVER['HTTP_HOST']; $values[] = array("Order Form", "order"); $values[] = array("Client Area", "client"); $values[] = array("Knowledge Base", "support"); $values[] = array("Other", "-other-"); if ($dbh->config('default_page') != ADMINDIR && $dbh->config('default_page') != "order" && $dbh->config('default_page') != "client") { $general_settings_array['DEFAULT_PAGE'] = main::dropDown("default_page", $values, "-other-"); $general_settings_array['OTHERDEFAULT'] = $dbh->config('default_page'); } else { $general_settings_array['OTHERDEFAULT'] = ""; $general_settings_array['DEFAULT_PAGE'] = main::dropDown('default_page', $values, $dbh->config('default_page')); } $IANA_queue_values[] = array("No", ""); $IANA_queue_values[] = array("Yes", "never"); $general_settings_array['QUEUE_IANA'] = main::dropDown("last_tld_update", $IANA_queue_values, $dbh->config("last_tld_update")); $general_settings_array['TLD_UPDATE_DAYS'] = $dbh->config("tld_update_days"); echo style::replaceVar("tpl/admin/settings/general-settings.tpl", $general_settings_array); break; case "security": //security settings if ($_POST) { check::empty_fields(); if (!check::email($postvar['email_for_cron'], 0, 0, 1)) { main::errors("Please verify that the email you're using for cron output is of a valid format."); } if (!main::errors()) { foreach ($postvar as $key => $value) { $dbh->updateConfig($key, $value); } main::errors("Settings Updated!"); } } $values[] = array("Yes", "1"); $values[] = array("No", "0"); $security_settings_array['SHOW_VERSION_ID'] = main::dropDown("show_version_id", $values, $dbh->config("show_version_id")); $security_settings_array['SHOW_PAGE_GENTIME'] = main::dropDown("show_page_gentime", $values, $dbh->config("show_page_gentime")); $security_settings_array['SHOW_FOOTER'] = main::dropDown("show_footer", $values, $dbh->config("show_footer")); $security_settings_array['SHOW_ERRORS'] = main::dropDown("show_errors", $values, $dbh->config("show_errors")); $security_settings_array['EMAIL_ON_CRON'] = main::dropDown("emailoncron", $values, $dbh->config("emailoncron")); $security_settings_array['EMAIL_FOR_CRON'] = $dbh->config("email_for_cron"); $security_settings_array['SESSION_TIMEOUT'] = $dbh->config("session_timeout"); echo style::replaceVar("tpl/admin/settings/security-settings.tpl", $security_settings_array); break; case "tos": if ($_POST) { check::empty_fields(); if (!main::errors()) { $dbh->updateConfig("tos", $postvar['tos']); main::errors("Settings Updated!"); } } $tos_array['TOS'] = $dbh->config("tos"); echo style::replaceVar("tpl/admin/settings/tos.tpl", $tos_array); break; case "signup": if ($_POST) { check::empty_fields(); if (!main::errors()) { foreach ($postvar as $key => $value) { $dbh->updateConfig($key, $value); } main::errors("Settings Updated!"); } } $values[] = array("Enabled", "1"); $values[] = array("Disabled", "0"); $signup_settings_array['MULTIPLE'] = main::dropDown("multiple", $values, $dbh->config("multiple")); $signup_settings_array['TLDONLY'] = main::dropDown("tldonly", $values, $dbh->config("tldonly")); $signup_settings_array['GENERAL'] = main::dropDown("general", $values, $dbh->config("general")); $signup_settings_array['MESSAGE'] = $dbh->config("message"); echo style::replaceVar("tpl/admin/settings/signup-settings.tpl", $signup_settings_array); break; case "client": if ($_POST) { $no_check_fields = array("alerts"); check::empty_fields($no_check_fields); if (!main::errors()) { foreach ($postvar as $key => $value) { $dbh->updateConfig($key, $value); } main::errors("Settings Updated!"); } } $values[] = array("Enabled", "1"); $values[] = array("Disabled", "0"); $client_area_settings_array['DELACC'] = main::dropDown("delacc", $values, $dbh->config("delacc")); $client_area_settings_array['ENABLED'] = main::dropDown("cenabled", $values, $dbh->config("cenabled")); $client_area_settings_array['ALERTS'] = $dbh->config("alerts"); echo style::replaceVar("tpl/admin/settings/client-area-settings.tpl", $client_area_settings_array); break; case "support": if ($_POST) { check::empty_fields(); if (!main::errors()) { foreach ($postvar as $key => $value) { $dbh->updateConfig($key, $value); } main::errors("Settings Updated!"); } } $values[] = array("Enabled", "1"); $values[] = array("Disabled", "0"); $support_settings_array['ENABLED'] = main::dropDown("senabled", $values, $dbh->config("senabled")); $support_settings_array['MESSAGE'] = $dbh->config("smessage"); echo style::replaceVar("tpl/admin/settings/support-settings.tpl", $support_settings_array); break; case "email": if ($_POST) { check::empty_fields(); if (!main::errors()) { foreach ($postvar as $key => $value) { $dbh->updateConfig($key, $value); } main::errors("Settings Updated!"); } } $values[] = array("PHP Mail", "php"); $values[] = array("SMTP", "smtp"); $email_settings_array['METHOD'] = main::dropDown("emailmethod", $values, $dbh->config("emailmethod"), 0); $email_settings_array['EMAILFROM'] = $dbh->config("emailfrom"); $email_settings_array['SMTP_HOST'] = $dbh->config("smtp_host"); $email_settings_array['SMTP_USER'] = $dbh->config("smtp_user"); $email_settings_array['SMTP_PASS'] = $dbh->config("smtp_password"); $email_settings_array['SMTP_PORT'] = $dbh->config("smtp_port"); echo style::replaceVar("tpl/admin/settings/email-settings.tpl", $email_settings_array); break; } }
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); }