本文整理匯總了PHP中type::additional方法的典型用法代碼示例。如果您正苦於以下問題:PHP type::additional方法的具體用法?PHP type::additional怎麽用?PHP type::additional使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類type
的用法示例。
在下文中一共展示了type::additional方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: ViewClient
private function ViewClient($client)
{
global $dbh, $postvar, $getvar, $instance;
$client_details_array['DATE'] = main::convertdate("n/d/Y", $client['signup']);
$client_details_array['EMAIL'] = $client['email'];
$client_details_array['UPGRADEINFO'] = "";
$existing_upgrade = $dbh->select("upgrade", array("uid", "=", $client['id']));
$all_packs_query = $dbh->select("packages", array("is_disabled", "=", "0"), array("type", "ASC"), 0, 1);
while ($all_packs_data = $dbh->fetch_array($all_packs_query)) {
$additional = type::additional($all_packs_data['id']);
$monthly = $additional['monthly'];
$signup = $additional['signup'];
unset($info);
if ($all_packs_data['type'] == "p2h") {
$info = "[Signup Posts: " . $signup . ", Monthly Posts: " . $monthly . "] ";
} elseif ($all_packs_data['type'] == "paid") {
$info = "[" . main::money($monthly) . "] ";
}
$packages[] = array("[" . $all_packs_data['type'] . "] " . $info . $all_packs_data['name'], $all_packs_data['id']);
if ($existing_upgrade && $existing_upgrade['newpack'] == $all_packs_data['id']) {
if ($all_packs_data['admin']) {
$admin = " after you approve them";
}
if ($existing_upgrade['flags'] && $existing_upgrade['flags'] < 5) {
$next_cycle = " next billing cycle";
}
$client_details_array['UPGRADEINFO'] = "NOTE: This user is slated for an upgrade to \"" . $all_packs_data['name'] . "\"" . $next_cycle . $admin . ".<br><br>";
}
}
$client_details_array['PACKAGE'] = main::dropdown("newpackage", $packages, $client['pid']);
$client_details_array['USER'] = $client['user'];
$client_details_array['DOMAIN'] = $client['domain'];
$client_details_array['CLIENTIP'] = $client['ip'];
$client_details_array['FIRSTNAME'] = $client['firstname'];
$client_details_array['LASTNAME'] = $client['lastname'];
$client_details_array['ADDRESS'] = $client['address'];
$client_details_array['CITY'] = $client['city'];
$client_details_array['STATE'] = $client['state'];
$client_details_array['ZIP'] = $client['zip'];
$client_details_array['COUNTRY'] = strtolower($client['country']);
$client_details_array['FULLCOUNTRY'] = main::country_code_to_country($client['country']);
$client_details_array['PHONE'] = $client['phone'];
unset($where);
$where[] = array("uid", "=", $client['id'], "AND");
$where[] = array("is_paid", "=", "0");
$invoices_query = $dbh->select("invoices", $where, 0, 0, 1);
$client_details_array['INVOICES'] = $dbh->num_rows($invoices_query);
switch ($client['status']) {
default:
$client_details_array['STATUS'] = "Other";
break;
case "1":
$client_details_array['STATUS'] = "Active";
break;
case "2":
$client_details_array['STATUS'] = "Suspended";
break;
case "3":
$client_details_array['STATUS'] = "Awaiting Validation";
break;
case "4":
$client_details_array['STATUS'] = "Awaiting Payment";
break;
case "5":
$client_details_array['STATUS'] = "Awaiting Email Confirmation";
break;
case "9":
$client_details_array['STATUS'] = "Cancelled";
break;
}
$class = type::packagetype($client['pid']);
$packtype = $instance->packtypes[$class];
if (method_exists($packtype, "acpBox")) {
$box = $packtype->acpBox();
$clientview_array['BOX'] = main::sub($box[0], $box[1]);
} else {
$clientview_array['BOX'] = "";
}
$clientview_array['CONTENT'] = style::replaceVar("tpl/admin/clients/client-details.tpl", $client_details_array);
return $clientview_array;
}
示例2: do_upgrade
public function do_upgrade($upgradeid, $mode, $no_errors_out = 0)
{
global $dbh, $postvar, $getvar, $instance;
//$mode
//
//Init - When the upgrade info is added, we call this function.
//Update - When cron or an admin does something with this function, we check to see if various tasks are ready to be performed.
//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.
//
$upgrade_data = $dbh->select("upgrade", array("id", "=", $upgradeid));
$userid = $upgrade_data['uid'];
$newpack = $upgrade_data['newpack'];
$flags = $upgrade_data['flags'];
$created = $upgrade_data['created'];
$coupcode = $upgrade_data['coupcode'];
$user_data = main::uidtopack($userid);
$current_pack_type = $user_data['packages']['type'];
$current_pack_name = $user_data['packages']['name'];
$current_pack_id = $user_data['packages']['id'];
$user_info = $dbh->select("users", array("id", "=", $userid));
$user_email = $user_info['email'];
$username = $user_info['user'];
$new_plan_data = $dbh->select("packages", array("id", "=", $newpack));
$newpack_name = $new_plan_data['name'];
$new_plan_additional = type::additional($newpack);
$new_server_data = $dbh->select("servers", array("id", "=", $new_plan_data['server']));
$new_server_name = $new_server_data['name'];
$old_server_data = $dbh->select("servers", array("id", "=", $user_data['packages']['server']));
$old_server_name = $old_server_data['name'];
switch ($flags) {
case "0":
$upgrade = 1;
break;
case "1":
$upgrade_today = self::upgrade_today($current_pack_type, $userid);
if ($upgrade_today) {
$upgrade = 1;
}
break;
case "2":
if ($mode = "Init") {
$admin_approval = 1;
} else {
//If its already the day for the upgrade, then we can do the upgrade now.
$upgrade_today = self::upgrade_today($current_pack_type, $userid);
if ($upgrade_today) {
$upgrade = 1;
}
if (!$upgrade) {
$dbh->update("upgrade", array("flags" => "1"), array("id", "=", $upgradeid), "1");
}
}
break;
case "3":
if ($mode = "Init") {
$admin_approval = 1;
$new_server = 1;
} else {
//If its already the day for the upgrade, then we can do the upgrade now.
$upgrade_today = self::upgrade_today($current_pack_type, $userid);
if ($upgrade_today) {
$upgrade = 1;
$new_server = 1;
}
if (!$upgrade) {
$dbh->update("upgrade", array("flags", "=", "4"), array("id", "=", $upgradeid), "1");
}
}
break;
case "4":
//If its already the day for the upgrade, then we can do the upgrade now.
$upgrade_today = self::upgrade_today($current_pack_type, $userid);
if ($upgrade_today) {
$upgrade = 1;
$new_server = 1;
$admin_inform = 1;
//.........這裏部分代碼省略.........
示例3: content
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 = ",";
//.........這裏部分代碼省略.........
示例4: uidtopack
public function uidtopack($userid = "", $pid = "")
{
global $dbh, $postvar, $getvar, $instance;
if (!$userid) {
$userid = $_SESSION['cuser'];
}
$userdata = $dbh->select("users", array("id", "=", $userid));
if (empty($userdata)) {
$package_data['removed'] = 1;
if (!$pid) {
$backup = "_bak";
$userdata = $dbh->select("users_bak", array("id", "=", $userid));
} else {
$package_data = array_merge($package_data, upgrade::pidtobak($pid, $userid));
return $package_data;
}
} else {
$package_data['removed'] = 0;
}
if (!$pid) {
$pid = $userdata['pid'];
}
$packageinfo = $dbh->select("packages", array("id", "=", $pid));
$additional = type::additional($pid);
$uadditional = self::userAdditional($userdata['id'], $backup);
$package_data['user_data'] = $userdata;
$package_data['packages'] = $packageinfo;
$package_data['additional'] = $additional;
$package_data['uadditional'] = $uadditional;
return $package_data;
}
示例5: userposts
public function userposts($packid, $uid)
{
global $dbh, $postvar, $getvar, $instance;
if ($postvar['fuser']) {
$fuser = $postvar['fuser'];
} else {
$user = type::userAdditional($uid);
$fuser = $user['fuser'];
}
$forum = type::additional($packid, 'forum');
if (!$forum) {
$client = $dbh->client();
$forum = type::additional($client['pid'], 'forum');
}
if (!$forum) {
//As a last resort, we assume the user doesn't have any posts as we couldn't connect to the DB using their current package's
//details or the one for upgrading to. This stops fatal errors as well.
return 0;
}
$fdetails = $this->forumdata($forum);
$this->con = $this->forumCon($forum);
$posts = $this->checkMonthly($fdetails['forumtype'], $fuser, $fdetails['prefix']);
return $posts;
}
示例6: content
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.
//.........這裏部分代碼省略.........
示例7: cron
public function cron()
{
global $dbh, $postvar, $getvar, $instance;
$packages_query = $dbh->select("packages", array("type" => "paid"), 0, 0, 1);
$packages_num_rows = $dbh->num_rows($packages_query);
//Do we have paid packages?
if ($packages_num_rows) {
while ($packages_data = $dbh->fetch_array($packages_query)) {
$i++;
//Do we have multiple packages and aren't on the last one?
if ($packages_data < $i) {
//Did we already pull one package? If so, we don't set the flag for the parenthesis.
if ($pulled_one) {
$where[] = array("pid", "=", $packages_data['id'], "OR");
//We are on the first listing of the paid packages, so we set the flag for the opening parenthesis and mark it that we pulled one already.
} else {
$where[] = array("pid", "=", $packages_data['id'], "OR", 1);
$pulled_one = 1;
}
} else {
//Are we on the last listing of paid listings? If so, we close the parenthesis by setting that flag.
if ($pulled_one) {
$where[] = array("pid", "=", $packages_data['id'], "", 1);
//We only had one listing, so we don't use parenthesis and we don't use "OR."
} else {
$where[] = array("pid", "=", $packages_data['id']);
}
}
//So we can later grab the package's information without needing to repull this data.
$packages_info[$packages_data['id']] = $packages_data;
}
$time = time();
//Look at every last invoice.
$invoices_query = $dbh->select("invoices");
while ($invoices_data = $dbh->fetch_array($invoices_query)) {
$uid = $invoices_data['uid'];
$client = $dbh->client($uid);
//Skip this invoice if it belongs to a user marked as a free user.
if ($client['freeuser']) {
continue;
}
//If the invoice is older than 30 days and we haven't issued a new invoice yet... (This makes sure the user is still on the package
//before issuing a new invoice for it.)
if ($time > $invoices_data['created'] + 2592000 && !in_array($uid, $invoiced_to) && $invoices_data['pid'] == $client['pid']) {
$pack_additional = type::additional($client['pid']);
$amount = coupons::get_discount("paid", $pack_additional['monthly'], $client['user']);
invoice::create($uid, $amount, $time, "Your hosting package invoice for this billing cycle. Package: " . $packages_info[$client['pid']]['name']);
$invoiced_to[] = $uid;
//Track what clients have been sent a new invoice.
}
$lastmonth = $time - 2592000;
$suspenddays = $dbh->config('suspensiondays');
$terminationdays = $suspenddays + $dbh->config('terminationdays');
$suspendseconds = $suspenddays * 24 * 60 * 60;
$terminateseconds = $dbh->config('terminationdays') * 24 * 60 * 60;
//If we have an unpaid bill that's greater than $0 and it's past it's due date...
if ($invoices_data['due'] < $time and $invoices_data['is_paid'] == 0 && $invoices_data['amount'] > 0) {
//If we have a bill that's overdue by $terminationdays + $suspenddays, then we terminate the account...
if ($time - $suspendseconds - $terminateseconds > $invoices_data['due']) {
server::terminate($uid, "Your account was overdue for more than " . $terminationdays . " days.");
$checked_term = 1;
//If we have a bill that's overdue by $suspenddays and the client is active, then we suspend them...
//Just an FYI, if I start(ed) charging for this script, check The Pirate Bay for this script as I always upload my payware stuff there since I know not everyone can afford to pay me.
} elseif ($time - $suspendseconds > $invoices_data['due'] && $client['status'] == '1') {
server::suspend($uid, "Your account is overdue. Please log in and pay your invoice to bring your account out of suspension.");
}
}
}
//If the user does not have an invoice yet and never had one, this will create one for them. The portion above
//handles creating NEW invoices. (It checks for outdated ones and such.)
$users_query = $dbh->select("users", $where, 0, 0, 1);
while ($users_data = $dbh->fetch_array($users_query)) {
//Skip this user if its marked as a free user.
if ($users_data['freeuser']) {
continue;
}
$invoice_data = $dbh->select("invoices", array("pid", "=", $users_data['pid']));
if (!$invoice_data['id']) {
$monthly = type::additional($users_data['pid']);
$amount = $monthly['monthly'];
$amount = coupons::get_discount("paid", $amount, $users_data['id']);
invoice::create($users_data['id'], $amount, $time + 30 * 24 * 60 * 60, "Your hosting package invoice for this billing cycle. Package: " . $packages_info[$users_data['pid']]['name']);
// Create Invoice +30 Days
}
}
}
}
示例8: validate_coupon
public function validate_coupon($coupcode, $areaused, $uname, $package)
{
global $dbh, $postvar, $getvar, $instance;
$userid = main::userid($uname);
$coupon_info = self::coupon_data($coupcode);
if (empty($coupon_info)) {
return false;
}
if ($coupon_info['expiredate'] != "99/99/9999") {
$today = time();
$coupon_expiry = explode("/", $coupon_info['expiredate']);
$expiry_time = mktime(date("H"), date("i"), date("s"), ltrim($coupon_expiry[0]), ltrim($coupon_expiry[1]), $coupon_expiry[2]);
if ($today >= $expiry_time) {
return false;
}
}
if ($coupon_info['area'] != "both" && $coupon_info['area'] != $areaused) {
return false;
}
if ($coupon_info['user'] != "all" && $coupon_info['user'] != $uname) {
return false;
}
if ($coupon_info['packages'] != "all") {
$available_packs = explode(",", $coupon_info['packages']);
if (!in_array($package, $available_packs)) {
return false;
}
}
if ($coupon_info['limited']) {
$coupons_used_query = $dbh->select("coupons_used", array("coupcode", "=", $coupcode), 0, 0, 1);
$coupons_used_rows = $dbh->num_rows($coupons_used_query);
if ($coupons_used_rows >= $coupon_info['limited']) {
return false;
}
}
$coupon_used = self::user_coupon_data($userid, 0, $coupcode);
if (!empty($coupon_used) && $coupon_used['disabled'] != '2') {
return false;
}
//All checks passed.
//
//Brok
// en
// Eng
// lish
// lol
$package_type = type::packagetype($package);
$package_info = type::additional($package);
$package_monthly = $package_info['monthly'];
$package_p2hinit = $package_info['signup'];
$paidtype = $coupon_info['paidtype'];
$p2hinittype = $coupon_info['p2hinittype'];
$p2hmonthlytype = $coupon_info['p2hmonthlytype'];
$coupon_info['paiddisc'] = self::percent_to_value("paid", $paidtype, $coupon_info['paiddisc'], $package_monthly);
$coupon_info['p2hinitdisc'] = self::percent_to_value("p2h", $p2hinittype, $coupon_info['p2hinitdisc'], $package_p2hinit);
$coupon_info['p2hmonthlydisc'] = self::percent_to_value("p2h", $p2hmonthlytype, $coupon_info['p2hmonthlydisc'], $package_monthly);
if ($package_type == "paid") {
if ($coupon_info['paiddisc'] >= $package_monthly) {
$coupon_text = "Free ";
} else {
$they_pay = $package_monthly - $coupon_info['paiddisc'];
$currency = main::money($they_pay);
$coupon_text = "Only pay " . $currency . " ";
$pay_per_month = "/month";
}
} else {
$init_required = $package_p2hinit - $coupon_info['p2hinitdisc'];
$monthly_required = $package_monthly - $coupon_info['p2hmonthlydisc'];
if ($init_required > 1) {
$s = "s";
}
if ($monthly_required > 1) {
$s2 = "s";
}
if ($coupon_info['p2hinitdisc'] >= $package_p2hinit) {
$coupon_p2hdisc = "0 Posts";
} else {
$coupon_p2hdisc = $init_required . " Post" . $s . " required";
}
if ($coupon_info['p2hmonthlydisc'] >= $package_monthly) {
$coupon_p2hmonth = "0 Posts";
} else {
$coupon_p2hmonth = $monthly_required . " Post" . $s2 . " required";
}
if ($coupon_info['p2hinitdisc'] > 0 && $coupon_info['p2hmonthlydisc'] > 0) {
$coupon_text = $coupon_p2hdisc . " to sign up and " . $coupon_p2hmonth . " for the month";
} else {
if ($coupon_info['p2hinitdisc'] > 0) {
$coupon_text = $coupon_p2hdisc . " to sign up";
$no_goodfor = "1";
//YOU! lol Good for nothing? lol
} else {
$coupon_text = $coupon_p2hmonth . " for the month";
}
}
}
if ($coupon_info['goodfor'] == "life") {
$coupon_text .= $pay_per_month . " for the lifetime of the account.";
}
if ($coupon_info['goodfor'] == "current") {
//.........這裏部分代碼省略.........
示例9: content
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);
//.........這裏部分代碼省略.........
示例10: signup
public function signup($data)
{
global $dbh, $postvar, $getvar, $instance;
$domain = $data['domain'];
$username = $data['username'];
$password = $data['password'];
$user_email = $data['user_email'];
$firstname = $data['firstname'];
$lastname = $data['lastname'];
$address = $data['address'];
$city = $data['city'];
$state = $data['state'];
$zip = $data['zip'];
$country = $data['country'];
$phone = $data['phone'];
$tzones = $data['tzones'];
$coupon = $data['coupon'];
$package = $data['package'];
$domsub = $data['domsub'];
$additional = $data['additional'];
$subdomain = empty($data['subdomain']) ? 0 : $data['subdomain'];
//Let's make sure we're actually receiving an integer as a string.
if (!is_numeric($package) || strpos($package, ".") !== false) {
return "The package specified is invalid.";
}
//Check to see if we have a valid domain type.
if ($domsub != "dom" && $domsub != "sub") {
return "The domain/subdomain type is unspecified in the URL.";
}
if ($domsub == "dom") {
$cdom = $domain;
} else {
$csub2 = $domain;
$csub = $subdomain;
}
unset($where);
$where[] = array("id", "=", $package, "AND");
$where[] = array("is_disabled", "=", "0");
$packages_data = $dbh->select("packages", $where);
if (!$packages_data['id']) {
return "This package is disabled or doesn't exist.";
}
$package_server = $packages_data['server'];
if ($domsub == "dom") {
$use_dom = $cdom;
}
if ($domsub == "sub") {
unset($where);
$where[] = array("server", "=", $package_server, "AND");
$where[] = array("domain", "=", $csub2);
$subdomains_data = $dbh->select("subdomains", $where, 0, "1");
if (!$subdomains_data['id']) {
return "The chosen domain for your subdomain is not in the allowed list of domains.";
}
$use_dom = $csub . "." . $csub2;
}
if ($coupon && $packages_data['type'] != 'free') {
$coupon_response = coupons::validate_coupon($coupon, "orders", $username, $package);
if (!$coupon_response) {
return "Please enter a valid coupon.";
} else {
$coupon_info = coupons::coupon_data($coupon);
}
}
$packtype_instance = $instance->packtypes[$packages_data['type']];
if (method_exists($packtype_instance, "signup")) {
$packtype_signup = $packtype_instance->signup();
//If this gives any response, it means it failed to validate the signup.
if ($packtype_signup) {
return $packtype_signup;
}
}
$server_package_name = type::packageBackend($package);
$serverfile = self::createServer($package);
$packages_data = $dbh->select("packages", array("id", "=", $package));
$extra['firstname'] = $firstname;
$extra['lastname'] = $lastname;
$extra['address'] = $address;
$extra['city'] = $city;
$extra['state'] = $state;
$extra['zip'] = $zip;
$extra['country'] = strtoupper($country);
$extra['phone'] = $phone;
$server_response = $serverfile->signup(type::packageserver($package), $packages_data['reseller'], $username, $user_email, $password, $use_dom, $server_package_name, $extra, $use_dom);
if ($server_response !== true) {
return $server_response;
} else {
$time = time();
$ip = $_SERVER['REMOTE_ADDR'];
$salt = crypto::salt();
$password_hash = crypto::passhash($password, $salt);
if ($packages_data['admin'] == "1") {
$status = "3";
} else {
if ($packages_data['type'] == "paid") {
$status = "4";
} else {
$status = "1";
}
}
//.........這裏部分代碼省略.........