/* This software is developed & licensed by Dreamcost.com.
Unauthorized distribution, sales, or use of any of the code, in part or in whole, is
strictly prohibited and will be prosecuted to the full extent of the law. */
// CHECKOUT A FREE ORDER, CREATE ORDER AND ACTIVATE SUBSCRIPTION
function free_checkout($account_id,$setup_amount,$amount,$name,$address,$zip,$session_ip,$sess,$attr,$attrname,$value) {
$order_id = next_order_id();
create_order_record("1",$order_id,$account_id,$billing_id,$sess,$attr,$attrname,$value);
create_domain_record("1","Y",$order_id,$account_id,$billing_id,$session_ip);
member_type_update($account_id,$session_ip);
delete_sessions($session_ip);
// SEND THE ADMIN NEW ORDER EMAIL
if (setup("email_2") == Y) {
send_mail("2",$account_id,"",$order_id,"");
}
// SEND THE CUSTOMER NEW ORDER EMAIL
if (setup("email_12") == Y) {
send_mail("12",$account_id,"",$order_id,"");
}
// update the authentication for this order
$f[order_id] = $order_id;
global $path;
unset($API_ACTION);
$API_ACTION = 'auth_order';
include ($path . 'auth.api.php');
// Show the order approved page
include($path . "member_order_approved.html");
}
// GENERATE PAY BY CHECK FORM FOR RECURRING CHARGES
function check_recurr($amount)
{
include($path . "member_check_recurr.html");
}
// GENERATE PAYMENT FORMS AFTER CHECKOUT
function redirect_checkout($redirect_type,$account_id,$setup_amount,$amount,$name,$address,$zip,$session_ip,$sess,$attr,$attrname,$value) {
global $form, $message, $path;
$order_id = next_order_id();
create_order_record("0",$order_id,$account_id,$billing_id,$sess,$attr,$attrname,$value);
create_domain_record("0","Y",$order_id,$account_id,$billing_id,$session_ip);
delete_sessions($session_ip);
// SEND THE ADMIN NEW ORDER EMAIL
if (setup("email_2") == Y) {
send_mail("2",$account_id,"",$order_id,"");
}
// SEND THE CUSTOMER NEW ORDER EMAIL
if (setup("email_12") == Y) {
send_mail("12",$account_id,"",$order_id,"");
}
$form = generate_redirect($redirect_type, $amount, $order_id);
include($path . "member_order_redirect_approved.html");
}
// GENERATE PAY BY CHECK FORM
function check_checkout($account_id,$setup_amount,$amount,$name,$address,$zip,$session_ip,$sess,$attr,$attrname,$value) {
global $billed_amount, $form, $path, $message;
$order_id = next_order_id();
create_order_record("0",$order_id,$account_id,$billing_id,$sess,$attr,$attrname,$value);
create_domain_record("0","Y",$order_id,$account_id,$billing_id,$session_ip);
member_type_update($account_id,$session_ip);
delete_sessions($session_ip);
// SEND THE ADMIN NEW ORDER EMAIL
if (setup("email_2") == Y) {
send_mail("2",$account_id,"",$order_id,"");
}
// SEND THE CUSTOMER NEW ORDER EMAIL
if (setup("email_12") == Y) {
send_mail("12",$account_id,"",$order_id,"");
}
include($path . "member_order_check_approved.html");
}
// GENERATE PAYMENT FORMS FOR RECURRING CHARGES
function redirect_recurr($redirect_type,$subscription_id,$amount) {
$form = generate_redirect_recurr($redirect_type, $amount, $subscription_id);
global $path;
include($path . "member_payment_recurr3.html");
}
// ATTEMPT TO BILL THE CARD (AT CHECKOUT)
function card_checkout($account_id,$setup_amount,$amount,$cc_num,$cc_exp,$name,$address,$zip,$session_ip,$sess,$attr,$attrname,$value) {
$gateway = setup("gateway");
if($gateway == 0) {
if(identify($cc_num) == 'N')
{
$rt[result] = "3";
}
else
{
$rt[result] = "1";
}
}
elseif(!check_order_attempt($account_id)) {
$rt[result] = "3";
order_attempt($account_id);
} else {
$rt = card_1($account_id,$name,$address,$zip,$cc_num,$cc_exp,$amount);
order_attempt($account_id);
}
if ($rt[RESULT]=="1" || $rt[RESULT]=="") { $ret="member_order_error.html"; }
if($rt[RESULT] > "1" || $rt[RESULT] < "0") { $ret="member_order_declined.html"; send_failed_order_notice($account_id);}
//if (((($rt[result]=="1") || ($rt[result]=="5") || ($rt[result]=="4") || ($rt[result]=="25")))) {
if($rt[result]=="0") {
$billed_amount = $amount;
if($gateway == 0) {
$order_id = next_order_id();
//create_billed_record_2($account_id,$order_id,$billed_amount); }
$billing_id = create_billing_record($account_id,$cc_num,$cc_exp,$order_id);
create_order_record("0",$order_id,$account_id,$billing_id,$sess,$attr,$attrname,$value);
create_domain_record("0","Y",$order_id,$account_id,$billing_id,$session_ip);
member_type_update($account_id,$session_ip);
delete_sessions($session_ip);
set_opt_in($account_id);
} else {
$order_id = next_order_id();
create_billed_record_2($account_id,$order_id,$billed_amount);
$billing_id = create_billing_record($account_id,$cc_num,$cc_exp,$order_id);
create_order_record("1",$order_id,$account_id,$billing_id,$sess,$attr,$attrname,$value);
create_domain_record("1","Y",$order_id,$account_id,$billing_id,$session_ip);
member_type_update($account_id,$session_ip);
//add_member_blog_account($sess);
delete_sessions($session_ip);
set_opt_in($account_id);
}
$domain_exists = get_domain_exists($account_id);
if ($domain_exists == '1') {
// SEND THE ADMIN RENEWAL EMAIL
send_mail("24",$account_id,"",$order_id,"");
// SEND THE CUSTOMER RENEWAL EMAIL
send_mail("25",$account_id,"",$order_id,"");
} else {
// SEND THE ADMIN NEW ORDER EMAIL
send_mail("2",$account_id,"",$order_id,"");
// SEND THE CUSTOMER NEW ORDER EMAIL
send_mail("12",$account_id,"",$order_id,"");
mail_latest_issue_count($email,$account_id);
}
// SEND THE REGISTRAR THE NEW DOMAINS EMAIL
//if (setup("email_22") == Y) {
// send_mail("22",$account_id,"",$order_id,"");
//}
//mail_latest_issue_count($email,$account_id);
$ret="member_order_approved.html";
}
// Update the authentication for this order
$f[order_id] = $order_id;
global $path;
unset($API_ACTION);
$API_ACTION = 'auth_order';
include ($path . 'auth.api.php');
return $ret;
}
// ATTEMPT TO BILL THE A CARD AT CHECKOUT (PREVIOUSLY STORED)
function card_s_checkout($account_id,$setup_amount,$amount,$billing_id,$name,$address,$zip,$session_ip,$sess,$attr,$attrname,$value) {
$db = new ps_DB;
$q = "SELECT billing_cc_num,billing_cc_exp FROM billing WHERE billing_id='$billing_id' AND billing_account_id='$account_id'";
$db->query($q);
$db->next_record();
$cc_num=$db->f("billing_cc_num");
$cc_num=RC4($cc_num,"de");
$cc_exp=$db->f("billing_cc_exp");
$gateway = setup("gateway");
if($gateway == 0) {
$rt[result] = "1";
}
elseif(!check_order_attempt($account_id)) {
$rt[result] = "3";
order_attempt($account_id);
} else {
$rt = card_1($account_id,$name,$address,$zip,$cc_num,$cc_exp,$amount);
order_attempt($account_id);
}
if ($rt[RESULT]=="1" || $rt[RESULT]=="") { $ret="member_order_error.html"; }
if($rt[RESULT] > "1" || $rt[RESULT] < "0") { $ret="member_order_declined.html"; send_failed_order_notice($account_id);}
//if (((($rt[result]=="1") || ($rt[result]=="5") || ($rt[result]=="4") || ($rt[result]=="25")))) {
if($rt[result]=="0") {
$billed_amount = $amount;
if($gateway == 0) {
$order_id = next_order_id();
create_order_record("0",$order_id,$account_id,$billing_id,$sess,$attr,$attrname,$value);
create_domain_record("0","Y",$order_id,$account_id,$billing_id,$session_ip);
member_type_update($account_id,$session_ip);
delete_sessions($session_ip);
set_opt_in($account_id);
} else {
$order_id = next_order_id();
create_billed_record_2($account_id,$order_id,$billed_amount);
create_order_record("1",$order_id,$account_id,$billing_id,$sess,$attr,$attrname,$value);
create_domain_record("1","Y",$order_id,$account_id,$billing_id,$session_ip);
member_type_update($account_id,$session_ip);
delete_sessions($session_ip);
}
// SEND THE ADMIN RENEWAL EMAIL
send_mail("24",$account_id,"",$order_id,"");
// SEND THE CUSTOMER RENEW CONFRIMATION EMAIL
send_mail("25",$account_id,"",$order_id,"");
$ret="member_order_approved.html";
}
// Update all Authentication...
global $path;
unset($API_ACTION);
$f[order_id] = $order_id;
$API_ACTION = 'auth_everything';
include ($path . 'auth.api.php');
return $ret;
}
// UPDATE ORDER STATUS
function update_order_status($order_id,$order_status) {
// affiliate payout control
// credit control
// coupon control
if ((($order_status==0) || ($order_status==2)))
{
// set to pending or voided
delete_affiliate_payout($order_id);
delete_coupon_order($order_id);
delete_credit_order($order_id);
}
elseif ($order_status==1)
{
// set to complete
create_affiliate_payout($order_id);
create_coupon_order($order_id);
create_credit_order($order_id);
}
// update the
$db = new ps_DB;
$q = "UPDATE orders SET
order_status = '$order_status'
WHERE order_id = '$order_id'";
$db->query($q);
// Update each individual subscription
$db = new ps_DB;
$q = "UPDATE domains SET
domain_host_status = '$order_status'
WHERE domain_order_id = '$order_id'";
$db->query($q);
// Update the auth for each subscription
$f[order_id] = $order_id;
global $path;
unset($API_ACTION);
$API_ACTION = 'auth_order';
include ($path . 'auth.api.php');
return "Order status updated.";
}
// DELETE AN AFFILIATE PAYOUT AFTER CHANGING ORDER STATUS
function delete_affiliate_payout($order_id) {
$db = new ps_DB;
$q = "DELETE FROM credit WHERE
credit_order_id = '$order_id' AND
credit_status != '1' AND
credit_type = '2'";
$db->query($q);
}
// CREATE AN AFFILIATE PAYOUT AFTER CHANGING ORDER STATUS
function create_affiliate_payout($order_id) {
$db = new ps_DB;
$q = "SELECT order_amount,order_affiliate_id FROM orders WHERE order_id='$order_id'";
$db->query($q);
$db->next_record();
$affiliate_id = $db->f("order_affiliate_id");
$order_amount = $db->f("order_amount");
$db = new ps_DB;
$q = "SELECT credit_id FROM credit WHERE
credit_order_id = '$order_id' AND
credit_type = '2'";
$db->query($q);
if($db->num_rows() == 0)
{
if (($order_amount > 0) && ($affiliate_id > 0))
{
affiliate_payout($affiliate_id, $order_id, $order_amount,"2");
}
}
}
// CREATE A CREDIT RECORD FOR AN AFFILIATE ORDER REFERRAL
function affiliate_payout($affiliate_id, $o_d_id, $order_amount, $type) {
$today = date("Y-m-d");
$db = new ps_DB;
$q = "SELECT affiliate_account_id, affiliate_type FROM affiliate WHERE affiliate_id='$affiliate_id'";
$db->query($q);
$db->next_record();
$account_id = $db->f("affiliate_account_id");
$afftype = $db->f("affiliate_type");
// VERIFY THE AFFILIATE DOESN'T GET PAID FOR THEIR OWN ACCOUNT...
if($type == "2") {
// GET THE ACCOUNT ID
$dbo = new ps_DB;
$q = "SELECT order_account_id FROM orders WHERE order_id='$o_d_id'";
$dbo->query($q);
$dbo->next_record();
$order_account_id = $dbo->f("order_account_id");
if($account_id == $order_account_id) {
// this user cannot get paid on his own order...
return FALSE;
}
$order_id = $o_d_id;
} else if ($type == "3") {
// GET THE ORDER ID
$dbo = new ps_DB;
$q = "SELECT domain_order_id FROM domains WHERE domain_id='$o_d_id'";
$dbo->query($q);
$dbo->next_record();
$order_id = $dbo->f("domain_order_id");
// GET THE ACCOUNT ID
$dbo = new ps_DB;
$q = "SELECT order_account_id FROM orders WHERE order_id='$order_id'";
$dbo->query($q);
$dbo->next_record();
$order_account_id = $dbo->f("order_account_id");
if($account_id == $order_account_id) {
// this user cannot get paid on his own order...
return FALSE;
}
$domain_id = $o_d_id;
}
if ($afftype==1) {
$sel = setup("aff_pay_1");
if ($sel == 0) {
$amount = setup("aff_pay_1a") * $order_amount;
} else {
$amount = setup("aff_pay_1a");
}
} else {
$sel = setup("aff_pay_2");
if ($sel == 0) {
$amount = setup("aff_pay_2a") * $order_amount;
} else {
$amount = setup("aff_pay_2a");
}
}
$db = new ps_DB;
$q = "INSERT INTO credit SET
credit_order_id = '$order_id',
credit_domain_id = '$domain_id',
credit_account_id = '$account_id',
credit_type = '$type',
credit_amount = '$amount',
credit_status = '0',
credit_date_added = '$today'";
if($amount > 0)
{
$db->query($q);
// EMAIL AFFILIATE
if (setup("email_9") == Y)
{
send_mail("9","","",$order_id,$affiliate_id);
}
}
}
// UPDATE COUPON
function coupon_add($coupon,$session_id) {
// VALIDATE THE COUPON CODE...
if(validate_coupon($coupon)) {
$db = new ps_DB;
$q = "UPDATE login SET coupon ='$coupon' WHERE login_id='$session_id'";
$db->query($q);
return "Your coupon is valid and will be calculated into the cost.";
} else {
return "The coupon code you entered is invalid or has expired.";
}
}
// VALIDATE THE COUPON CODE
function validate_coupon($coupon) {
GLOBAL $reg_data;
$date = date("Y-m-d");
// return the coupon amount
$dbc = new ps_DB;
$q = "SELECT * FROM coupons WHERE coupon_code = '$coupon'";
$dbc->query($q);
while($dbc->next_record())
{
if (
($coupon == $dbc->f("coupon_code")) &&
($date >= $dbc->f("start_date")) &&
($date <= $dbc->f("end_date"))
)
{
// check that this coupon has not been used up..
if ($dbc->f("usage_max") == 0)
{
// unlimited usage...
return TRUE;
}
else if ($dbc->f("usage_max") > $dbc->f("usage_count"))
{
// under the limit, ok
return TRUE;
}
}
}
// no valid matches...
return FALSE;
}
function validate_coupon_new($coupon) {
GLOBAL $reg_data;
$date = date("Y-m-d");
$coupon = strtolower($coupon);
// return the coupon amount
$dbc = new ps_DB;
$q = "SELECT * FROM coupons WHERE coupon_code LIKE '$coupon'";
$dbc->query($q);
while($dbc->next_record()) {
if ( ($coupon == $dbc->f("coupon_code")) && ($date >= $dbc->f("start_date")) && ($date <= $dbc->f("end_date")) ) {
if ($dbc->f("domain_id") != '' || $dbc->f("domain_id") != '0') {
if (isset($reg_data)) {
if ($dbc->f("domain_id") == $reg_data[membership_id]) {
// check that this coupon has not been used up..
if ($dbc->f("usage_max") == 0) {
// unlimited usage...
return TRUE;
} else if ($dbc->f("usage_max") > $dbc->f("usage_count")) {
// under the limit, ok
return TRUE;
}
} else {
return FALSE;
}
}
}
// check that this coupon has not been used up..
if ($dbc->f("usage_max") == 0) {
// unlimited usage...
return TRUE;
} else if ($dbc->f("usage_max") > $dbc->f("usage_count")) {
// under the limit, ok
return TRUE;
}
}
}
// no valid matches...
return FALSE;
}
//jquery version
function validate_coupon2($coupon) {
GLOBAL $reg_data;
$date = date("Y-m-d");
// return the coupon amount
$dbc = new ps_DB;
$q = "SELECT * FROM coupons WHERE coupon_code = '$coupon'";
$dbc->query($q);
while($dbc->next_record())
{
if (
($coupon == $dbc->f("coupon_code")) &&
($date >= $dbc->f("start_date")) &&
($date <= $dbc->f("end_date"))
)
{
// check that this coupon has not been used up..
if ($dbc->f("usage_max") == 0)
{
// unlimited usage...
return "yes";
}
else if ($dbc->f("usage_max") > $dbc->f("usage_count"))
{
// under the limit, ok
return "yes";
}
}
}
// no valid matches...
return "no";
}
// GET COUPON AMOUNT FOR SESSION
function get_coupon_amount($sess,$total) {
$db = new ps_DB;
$q = "SELECT coupon FROM login WHERE login_id='$sess'";
$db->query($q);
$db->next_record();
$coupon = $db->f("coupon");
//validate the coupon
if(validate_coupon($coupon)) {
// return the coupon amount
$dbc = new ps_DB;
$q = "SELECT * FROM coupons WHERE coupon_code = '$coupon'";
$dbc->query($q);
while($dbc->next_record())
{
if ($coupon == $dbc->f("coupon_code"))
{
$type = $dbc->f("type");
$rate = $dbc->f("rate");
if ($type == "1")
{
// flat amount
return $rate;
} else if ($type == "2")
{
// percentage
return $rate*$total;
}
}
}
}
else
{
// return 0
return 0;
}
}
// GET THE TOTAL AMOUNT OWED TO AN AFFILIATE
function get_affiliate_payout($affiliate_id) {
$db = new ps_DB;
$q = "SELECT affiliate_account_id, affiliate_type FROM affiliate WHERE affiliate_id='$affiliate_id'";
$db->query($q);
$db->next_record();
$account_id = $db->f("affiliate_account_id");
$type = $db->f("affiliate_type");
$ret = 0;
if ($type==2) {
$db = new ps_DB;
$q = "SELECT * FROM credit WHERE
credit_account_id='$account_id'
AND credit_status='0'
AND credit_type='2'";
$db->query($q);
while ($db->next_record()) {
$amount = $db->f("credit_amount");
$ret = $ret + $amount;
}
}
return $ret;
}
// UPDATE ALL AFFILIATE PAYOUTS
function affiliate_payed($date) {
$db = new ps_DB;
$q = "SELECT credit_id,credit_amount FROM credit WHERE
credit_date_added <= '$date' AND
credit_type !='1'";
$db->query($q);
while ($db->next_record()) {
$credit_id = $db->f("credit_id");
$amount = $db->f("credit_amount");
update_credit_payed($credit_id,$amount);
}
$db = new ps_DB;
$q = "UPDATE setup SET setup_aff_pay_2c='$today' WHERE setup_id='1'";
$db->query($q);
}
// DETERMINE IF A CREDIT ID IS TO BE MAILED OR IF IT CAN BE CREDITED TO THE ACCOUNT.
function is_affiliate_mail($account_id) {
$db = new ps_DB;
$q = "SELECT affiliate_type FROM affiliate WHERE affiliate_account_id='$account_id'";
$db->query($q);
if ($db->f("affiliate_type") != 1) {
$ret = "N";
} else {
$ret = "Y";
}
return $ret;
}
// UPDATE CREDIT TO PAYED
function update_credit_payed($credit_id,$amount) {
$today = date("Y-m-d");
$db = new ps_DB;
$q = "UPDATE credit SET
credit_date_applied = '$today',
credit_amount_applied = '$amount',
credit_status = '1'
WHERE credit_id='$credit_id'";
$db->query($q);
}
// UPDATE CREDIT TO PAYED COMPLETE
function useall($credit_id) {
$today = date("Y-m-d");
$dbf = new ps_DB;
$z = "UPDATE credit SET
credit_status='1',
credit_date_applied='$today',
credit_amount_applied = '0'
WHERE credit_id = '$credit_id'";
$dbf->query($z);
}
// UPDATE CREDIT TO PARTIALLY PAID
function credit_usesome($credit_id, $amount) {
$today = date("Y-m-d");
$db = new ps_DB;
$q = "SELECT credit_status,credit_amount,credit_amount_applied FROM credit WHERE credit_id='$credit_id'";
$db->query($q);
$db->next_record();
if ($db->f("credit_status") == 2) {
$prev = $db->f("credit_amount_applied");
$amount = $amount + $prev;
}
$db = new ps_DB;
$q = "UPDATE credit SET
credit_status = '2',
credit_amount_applied = '$amount',
credit_date_applied = '$today'
WHERE credit_id = '$credit_id'";
$db->query($q);
}
// DETERMINE IF A CREDIT ID IS TO BE MAILED OR IF IT CAN BE CREDITED TO THE ACCOUNT.
function is_mail_only($account_id) {
$db = new ps_DB;
$q = "SELECT affiliate_type FROM affiliate WHERE affiliate_account_id='$account_id'";
$db->query($q);
$db->next_record();
if ($db->f("affiliate_type") == "1") {
$ret = "Y";
} else {
$ret = "N";
}
return $ret;
}
// UPDATE CREDIT TO PAYED
function credit_used_1($account_id,$amount) {
$today = date("Y-m-d");
$prev = 0;
$i=1;
$amount1 = $amount;
$db = new ps_DB;
$q = "SELECT * FROM credit WHERE
credit_account_id='$account_id' AND
credit_status != '1'";
$db->query($q);
while (($db->next_record()) && ($amount > 0)) {
$credit_id = $db->f("credit_id");
$account_id = $db->f("credit_account_id");
// DETERMINE IF THIS IS A MAIL ONLY AFFILIATE PAYMENT...
//if (is_mail_only($account_id) != "Y") {
if ($db->f("credit_status") == 0) {
$credit = $db->f("credit_amount");
} elseif ($db->f("credit_status") == 2) {
$prev = $db->f("credit_amount_applied");
$credit = $db->f("credit_amount") - $prev;
}
if (($amount < $credit) && ($amount > 0)) {
//use the difference
credit_usesome($credit_id, $amount);
$amount = "0";
return true;
} elseif (($amount >= $credit) && ($amount > 0)) {
//use all the credit
$amount2 = $amount - $credit;
$amount = $amount2;
$i++;
useall($credit_id);
}
//}
}
}
// FIND OUT HOW MUCH CREDIT AN ACCOUNT HAS
function credit_exsist($account_id) {
$ret = 0;
$db = new ps_DB;
$q = "SELECT * FROM credit WHERE
credit_account_id='$account_id' AND
credit_type = '1' AND
credit_status !='1' ";
$db->query($q);
while ($db->next_record()) {
$status = $db->f("credit_status");
$type = $db->f("credit_type");
if (($type == "2") && (is_mail_only($account_id) == Y)) {
// DO NOTHING, THIS IS A MAIL ONLY ACCT
} else {
if ($status == "2") {
$amount = $db->f("credit_amount") - $db->f("credit_amount_applied");
$ret = $ret + $amount;
} elseif ($status == "0") {
$amount = $db->f("credit_amount");
$ret = $ret + $amount;
}
}
}
return $ret;
}
// ADD A CREDIT
function add_credit($f) {
$today = date("Y-m-d");
$db = new ps_DB;
$q = "INSERT INTO credit SET
credit_date_added = '$today',
credit_amount = '$f[amount]',
credit_account_id = '$f[account_id]',
credit_domain_id = '$f[domain_id]',
credit_type = '$f[type]',
credit_notes = '$f[notes]',
credit_status = '0'";
if($f[amount] > 0) {
$db->query($q);
}
// EMAIL THE CUSTOMER
if (setup("email_15")==Y) {
send_mail("15",$f[account_id],"","","");
}
}
// UPDATE CREDIT TO PAYED
function delete_credit($id) {
$db = new ps_DB;
$q = "DELETE FROM credit WHERE credit_id='$id'";
$db->query($q);
}
// GET TIME TILL AFFILIATE PAYOUTS ARE DUE
function get_payout_date() {
$today=date("Y-m-d");
$today_date=strtotime($today);
$last_date=strtotime(setup("aff_pay_2c"));
$date_diff =(($today_date-$last_date)/86400);
$period = setup("aff_pay_2b");
$ret = $period - $date_diff;
return $ret;
}
// DELETE AND UNLINK AN AFFILIATE
function delete_affiliate($id) {
$db = new ps_DB;
$q = "SELECT affiliate_account_id FROM affiliate WHERE affiliate_id='$id'";
$db->query($q);
$db->next_record();
$account_id = $db->f("affiliate_account_id");
$db = new ps_DB;
$q = "DELETE FROM affiliate WHERE affiliate_id='$id'";
$db->query($q);
$db = new ps_DB;
$q = "DELETE FROM credit WHERE credit_account_id='$account_id'
AND credit_type != '1'";
$db->query($q);
return "Affiliate ID $id Was Removed!";
}
// DELETE AND UNLINK A DOMAIN
function delete_domain($id) {
// update to inactive...
$db = new ps_DB;
$q = "UPDATE domains SET domain_host_status='0' WHERE domain_id='$id'";
$db->query($q);
// get the account ID
$db = new ps_DB;
$q = "SELECT domain_account_id FROM domains WHERE domain_id='$id'";
$db->query($q);
$db->next_record();
$f[account_id] = $db->f("domain_account_id");
// Update the account associated with this domain (subscription)
global $path;
unset($API_ACTION);
$API_ACTION = 'auth_account';
include ($path . 'auth.api.php');
$db = new ps_DB;
$q = "DELETE FROM domains WHERE domain_id='$id'";
$db->query($q);
$db = new ps_DB;
$q = "DELETE FROM credit WHERE credit_domain_id='$id'";
$db->query($q);
$db = new ps_DB;
$q = "DELETE FROM coupons WHERE domain_id='$id'";
$db->query($q);
}
// DELETE AND UNLINK AN ORDER
function delete_order($id) {
$db = new ps_DB;
$q = "UPDATE domains SET domain_host_status='0' WHERE domain_order_id='$id'";
$db->query($q);
// Update the auth for this id...
$f[order_id] = $id;
global $path;
unset($API_ACTION);
$API_ACTION ='auth_order';
include ($path . 'auth.api.php');
$db = new ps_DB;
$q = "DELETE FROM domains WHERE domain_order_id='$id'";
$db->query($q);
$db = new ps_DB;
$q = "DELETE FROM billed WHERE billed_order_id='$id'";
$db->query($q);
$db = new ps_DB;
$q = "DELETE FROM credit WHERE credit_order_id='$id'";
$db->query($q);
$db = new ps_DB;
$q = "DELETE FROM orders WHERE order_id='$id'";
$db->query($q);
$db = new ps_DB;
$q = "DELETE FROM coupons WHERE order_id='$id'";
$db->query($q);
}
// DELETE AND UNLINK AN ACCOUNT
function delete_account_1($id) {
$db = new ps_DB;
$q = "UPDATE domains SET domain_host_status='0' WHERE domain_account_id='$id'";
$db->query($q);
// Update all
global $path;
$f[account_id] = $id;
unset($API_ACTION);
$API_ACTION ='auth_account';
include ($path . 'auth.api.php');
// determine if any external database update functions need run:
unset($API_ACTION);
$API_ACTION ='del_account';
include ($path . 'auth.api.php');
$db = new ps_DB;
$q = "DELETE FROM domains WHERE domain_account_id='$id'";
$db->query($q);
$db = new ps_DB;
$q = "DELETE FROM affiliate WHERE affiliate_account_id='$id'";
$db->query($q);
$db = new ps_DB;
$q = "DELETE FROM billed WHERE billed_account_id='$id'";
$db->query($q);
$db = new ps_DB;
$q = "DELETE FROM credit WHERE credit_account_id='$id'";
$db->query($q);
$db = new ps_DB;
$q = "DELETE FROM coupons WHERE account_id='$id'";
$db->query($q);
$db = new ps_DB;
$q = "DELETE FROM orders WHERE order_account_id='$id'";
$db->query($q);
$db = new ps_DB;
$q = "DELETE FROM billing WHERE billing_account_id='$id'";
$db->query($q);
$db = new ps_DB;
$q = "DELETE FROM account WHERE account_id='$id'";
$db->query($q);
return "Deleted Account No. $account_id";
}
function cron_bill() { bill_all_now(); }
// BILL A DOMAIN MANUALLY
function bill_domain_manual($account_id,$domain_id,$amount) {
$db = new ps_DB;
$q = "SELECT domain_host_periods FROM domains WHERE domain_id='$domain_id'";
$db->query($q);
$db->next_record();
update_billed_domain($domain_id,$db->f("domain_host_periods"));
create_billed_record_3($account_id,$domain_id,$amount);
// Update auth for this domain
$f[domain_id] = $domain_id;
global $path;
unset($API_ACTION);
$API_ACTION ='auth_domain';
include ($path . 'auth.api.php');
}
// UPDATE A NEWLY BILLED DOMAIN - original version
function update_billed_domain_old($domain_id,$periods) {
//$today=date("Y-m-d");
$today=renew_date_process_alt($domain_id);
$periods++;
$db = new ps_DB;
$q = "UPDATE domains SET
domain_host_periods='$periods',
domain_host_last_billed='$today'
WHERE domain_id='$domain_id'";
$db->query($q);
}
// UPDATE A NEWLY BILLED DOMAIN - fixed version
function update_billed_domain($domain_id,$periods,$membership_id) {
$membership_id = $new_domain;
$dbf = new ps_DB;
$q = "SELECT domain_account_id, domain_host_id FROM domains WHERE domain_id = '$domain_id'";
$dbf->query($q);
$dbf->next_record();
$account_id = $dbf->f("domain_account_id");
$current_domain = $dbf->f("domain_host_id");
$today=renew_date_process_alt($domain_id);
$db = new ps_DB;
$q = "UPDATE domains SET
domain_host_last_billed='$today'
WHERE domain_id='$domain_id'";
$db->query($q);
//echo $q." ";
// set renew_date in account table
$renew_date = renew_date_process($account_id,$current_domain,$new_domain);
update_renew_date2($account_id, $renew_date);
}
// GET THE TOTAL NUMBER OF TIMES AN ACCOUNT HAS BEEN BILLED (FOR ACCOUNT PAGE)
function count_billing($id) {
$db = new ps_DB;
$q = "SELECT billed_account_id FROM billed WHERE billed_account_id='$id'";
$db->query($q);
$ret=$db->num_rows();
return $ret;
}
// GET TOTAL NUMBER OF OVERDUE DOMAINS (FOR STATISTICS)
function get_total_overdue_domains() {
$db = new ps_DB;
$q = "SELECT domain_id,domain_host_id FROM domains";
$db->query($q);
$i=0;
$cost=0;
while ($db->next_record()) {
$status = get_billing_status_bill($db->f("domain_id"));
if($status=="Y") {
$i++;
$price = get_hosting_cost($db->f("domain_host_id"));
$cost=$cost+$price;
}
}
$num = "";
$num.= $i;
$num.= " (" . setup("currency");
$num.= $cost;
$num.= ")";
return $num;
}
// GET BILLING STATUS FOR BILLING PURPOSES
function get_billing_status_bill($domain_id) {
$db = new ps_DB;
$q = "SELECT domain_start_date,domain_host_id,domain_host_periods,domain_host_last_billed FROM domains WHERE domain_id='$domain_id'";
$db->query($q);
while ($db->next_record()) {
$status = get_billing_status_bill_2($db->f("domain_host_id"),$db->f("domain_host_periods"),$db->f("domain_host_last_billed"));
}
return $status;
}
// GET BILLING STATUS FOR BILLING PURPOSES
function trial_status($domain_id) {
$db = new ps_DB;
$q = "SELECT domain_start_date,domain_host_id,domain_host_periods,domain_host_last_billed FROM domains WHERE domain_id='$domain_id'";
$db->query($q);
while ($db->next_record()) {
$status = trial_status_2($db->f("domain_host_id"),$db->f("domain_host_periods"),$db->f("domain_host_last_billed"));
}
return $status;
}
// GET BILLING STATUS & RETURN TEXT EXPLAINATION
function get_billing_status($domain_id) {
$db = new ps_DB;
$q = "SELECT domain_start_date,domain_host_id,domain_host_periods,domain_host_last_billed FROM domains WHERE domain_id='$domain_id'";
$db->query($q);
while ($db->next_record()) {
$ret = get_billing_status_explain($db->f("domain_host_id"),$db->f("domain_host_periods"),$db->f("domain_host_last_billed"));
}
return $ret;
}
// GET BILLING STATUS & RETURN TEXT EXPLAINATION
function get_renew_date($domain_id) {
$db = new ps_DB;
$q = "SELECT domain_start_date,domain_host_id,domain_host_periods,domain_host_last_billed FROM domains WHERE domain_id='$domain_id'";
$db->query($q);
while ($db->next_record()) {
$ret = get_billing_exp_date($db->f("domain_host_id"),$db->f("domain_host_periods"),$db->f("domain_host_last_billed"));
}
return $ret[date];
}
// GET DOMAIN BILLING STATUS PART 2
function get_billing_status_bill_2($membership_id,$current_periods,$last_billed) {
$db = new ps_DB;
$q = "SELECT membership_recurring,membership_frequency,membership_periods FROM membership WHERE membership_id='$membership_id'";
$db->query($q);
$db->next_record();
$today=date("Y-m-d");
$today_date=strtotime($today);
$db_date=strtotime($last_billed);
$date_diff =(($today_date-$db_date)/86400);
$frequency=$db->f("membership_frequency");
$recurring=$db->f("membership_recurring");
$total_periods=$db->f("membership_periods");
$periods_diff=$total_periods - $current_periods;
// THIS IS A RECURRING CHARGE. WE WILL CONTINUE...
if($recurring=="Y") {
// CHECK IF THERE ARE UNUSED DAYS REMAINING IN THIS PERIOD:
if (($frequency == $date_diff) || ($frequency > $date_diff)) {
// THIS CHARGE IS DUE TODAY!
if($frequency == $date_diff) {
// DUE TODAY. LETS SEE IF THIS IS THE LAST PERIOD OR NOT.
if($periods_diff == 0) {
// THIS IS THE LAST PERIOD, SO THIS LITTLE DUDE EXPIRES TODAY! DONT BILL AGAIN!
$ret = "N";
} else {
// DUE FOR REBILLING TODAY - SOCKET TO EM!
$ret = "Y";
}
// THIS CHARGE IS NOTE DUE YET
} elseif($frequency > $date_diff) {
$due = $frequency - $date_diff;
return "N";
}
// THERE ARE NO UNUSED DAYS REMAINING IN THIS PERIOD!
} else {
// THERE ARE REMANING BILLING PERIODS. WE WILL CONTINUE...
if($periods_diff != 0) {
// THIS CHARGE WAS DUE BEFORE TODAY!
if($frequency < $date_diff) {
$due = $frequency - $date_diff;
return "Y";
}
// THERE ARE NO REMAINING BILLING PERIODS, THIS SUBSCRIPTION IS EXPIRED, ACCESS DENIED!
} else {
return "N";
}
}
// THIS IS NOT A RECURRING CHARGE.
} else {
return "N";
}
return $ret;
}
// GET DOMAIN BILLING STATUS PART 2
function trial_status_2($membership_id,$current_periods,$last_billed) {
$db = new ps_DB;
$q = "SELECT membership_recurring,membership_frequency,membership_periods FROM membership WHERE membership_id='$membership_id'";
$db->query($q);
$db->next_record();
$today=date("Y-m-d");
$today_date=strtotime($today);
$db_date=strtotime($last_billed);
$date_diff =(($today_date-$db_date)/86400);
$frequency=$db->f("membership_frequency");
$recurring=$db->f("membership_recurring");
$total_periods=$db->f("membership_periods");
$periods_diff=$total_periods - $current_periods;
// THIS IS A RECURRING CHARGE. WE WILL CONTINUE...
if($recurring=="Y")
{
// THIS IS NOT A RECURRING CHARGE.
} else {
// THIS IS A RECURRING CHARGE.
}
// CHECK IF THERE ARE UNUSED DAYS REMAINING IN THIS PERIOD:
if (($frequency == $date_diff) || ($frequency > $date_diff)) {
// THIS CHARGE IS DUE TODAY!
if($frequency == $date_diff) {
// DUE TODAY. LETS SEE IF THIS IS THE LAST PERIOD OR NOT.
if($periods_diff == 0) {
// THIS IS THE LAST PERIOD, SO THIS LITTLE DUDE EXPIRES TODAY! DONT BILL AGAIN!
return TRUE;
} else {
// DUE FOR REBILLING TODAY - SOCKET TO EM!
return TRUE;
}
// THIS CHARGE IS NOTE DUE YET
} elseif($frequency > $date_diff) {
$due = $frequency - $date_diff;
return FALSE;
}
// THERE ARE NO UNUSED DAYS REMAINING IN THIS PERIOD!
} else {
// THERE ARE REMANING BILLING PERIODS. WE WILL CONTINUE...
if($periods_diff != 0) {
// THIS CHARGE WAS DUE BEFORE TODAY!
if($frequency < $date_diff) {
$due = $frequency - $date_diff;
return TRUE;
}
// THERE ARE NO REMAINING BILLING PERIODS, THIS SUBSCRIPTION IS EXPIRED, ACCESS DENIED!
} else {
return TRUE;
}
}
return FALSE;
}
// GET BILLING STATUS FOR ACCESS PROTECTION
function get_billing_status_access($domain_id) {
$db = new ps_DB;
$q = "SELECT domain_start_date,domain_host_id,domain_host_periods,domain_host_last_billed FROM domains WHERE domain_id='$domain_id'";
$db->query($q);
$db->next_record();
return get_billing_status_access_2($db->f("domain_host_id"),$db->f("domain_host_periods"),$db->f("domain_host_last_billed"));
}
// RETURN THE DATE WHEN RECURRING CHARGE IS DUE
function get_billing_exp_date($membership_id,$current_periods,$last_billed) {
$db = new ps_DB;
$q = "SELECT membership_recurring,membership_frequency,membership_periods FROM membership WHERE membership_id='$membership_id'";
$db->query($q);
$db->next_record();
$today=date("Y-m-d");
$today_date=strtotime($today);
$db_date=strtotime($last_billed);
//$date_diff=$today_date-$db_date;
$date_diff =(($today_date-$db_date)/86400);
$total_periods=$db->f("membership_periods");
$frequency=$db->f("membership_frequency");
$recurring=$db->f("membership_recurring");
$periods_diff=$total_periods - $current_periods;
if($recurring==Y) {
// THIS IS A RECURRING CHARGE. WE WILL CONTINUE...
$ret[done] = "N";
if($periods_diff >= 1) {
// THERE ARE REMANING BILLING PERIODS. WE WILL CONTINUE...
$ret[done] = "N";
if($frequency == $date_diff) {
// THIS CHARGE IS DUE TODAY!
$ret[done] = "N";
$ret[code] = "Y";
$ret[date] = $today;
} elseif($frequency < $date_diff) {
// THIS CHARGE WAS DUE BEFORE TODAY!
$days_minus = $date_diff - $frequency;
$ret[done] = "N";
$ret[code] = "N";
$ret[date] = date("Y-m-d",time() - 86400*$days_minus);
} elseif($frequency > $date_diff) {
// THIS CHARGE IS NOT DUE YET
$days_plus = $frequency - $date_diff;
$ret[done] = "N";
$ret[code] = "Y";
$ret[date] = date("Y-m-d",time() + 86400*$days_plus);
} else {
}
// THE RECURRING BILLING IS DONE FOR THIS ACCOUNT
} else {
$ret[done] = "Y";
$ret[code] = "N";
}
} else {
// THIS IS NOT A RECURRING CHARGE. THIS MUST BE BILLED FROM THE INVOICE AREA
$ret[done] = "Y";
$ret[code] = "Y";
}
return $ret;
}
// GET DOMAIN BILLING STATUS PART 2
function get_billing_status_explain($membership_id,$current_periods,$last_billed) {
$db = new ps_DB;
$q = "SELECT membership_recurring,membership_frequency,membership_periods FROM membership WHERE membership_id='$membership_id'";
$db->query($q);
$db->next_record();
$today=date("Y-m-d");
$today_date=strtotime($today);
$db_date=strtotime($last_billed);
$date_diff =(($today_date-$db_date)/86400);
//duration of the membership in days [30|365|730]
$frequency=$db->f("membership_frequency");
//Does the membership renew [Y|N]
$recurring=$db->f("membership_recurring");
//How many times the membership should renew (I think)
$total_periods=$db->f("membership_periods");
$periods_diff=$total_periods - $current_periods;
// THIS IS A RECURRING CHARGE. WE WILL CONTINUE...
if($recurring==Y) {
//echo "Remain periods: $periods_diff ";
// CHECK IF THERE ARE UNUSED DAYS REMAINING IN THIS PERIOD:
if (($frequency == $date_diff) || ($frequency > $date_diff)) {
// THIS CHARGE IS DUE TODAY!
if($frequency == $date_diff) {
// DUE TODAY. LETS SEE IF THIS IS THE LAST PERIOD OR NOT.
if($periods_diff == 0) {
// THIS IS THE LAST PERIOD, SO THIS LITTLE DUDE EXPIRES TODAY!
$ret = "Expires Today";
} else {
// JUST DUE FOR REBILLING TODAY
$ret = "Due Today";
}
// THIS CHARGE IS NOTE DUE YET
} elseif($frequency > $date_diff) {
$due = $frequency - $date_diff;
if ($due > 1) $d = "s";
// SEE IF IT WILL BE REBILLED, OR IF IT WILL EXPIRE!
if($periods_diff == 0) {
// THIS IS THE LAST PERIOD, SO THIS LITTLE DUDE EXPIRES TODAY!
$ret = "Expires in " . number_format($due,0) . " day" . $d;
} else {
// JUST DUE FOR REBILLING TODAY
$ret = "due in " . number_format($due,0) . " day" . $d;
}
}
// THERE ARE NO UNUSED DAYS REMAINING IN THIS PERIOD!
} else {
// THERE ARE REMANING BILLING PERIODS. WE WILL CONTINUE...
if($periods_diff != 0) {
// THIS CHARGE WAS DUE BEFORE TODAY!
if($frequency < $date_diff) {
$due = $date_diff - $frequency;
if ($due > 1) $d = "s";
$ret = "overdue by " . number_format($due,0) . " day" . $d . "";
}
// THERE ARE NO REMAINING BILLING PERIODS, THIS SUBSCRIPTION IS EXPIRED, ACCESS DENIED!
} else {
$ret = "Expired";
}
}
// THIS IS NOT A RECURRING CHARGE.
} else {
$ret = "Non-recurring";
}
return $ret;
}
// GET DOMAIN BILLING STATUS PART 2 FOR ACCESS PROTECTION
function get_billing_status_access_2($membership_id,$current_periods,$last_billed) {
global $GRACE_PERIOD;
if($GRACE_PERIOD == "") { } $GRACE_PERIOD == 5;
$db = new ps_DB;
$q = "SELECT membership_recurring,membership_frequency,membership_periods FROM membership WHERE membership_id='$membership_id'";
$db->query($q);
$db->next_record();
$today=date("Y-m-d");
// Use the commented line below if you dont want a grace period...
//$today_date=strtotime($today) - ($GRACE_PERIOD*86400);
$today_date=strtotime($today);
$db_date=strtotime($last_billed);
$date_diff =(($today_date-$db_date)/86400);
$frequency=$db->f("membership_frequency");
$recurring=$db->f("membership_recurring");
$total_periods=$db->f("membership_periods");
$periods_diff=$total_periods - $current_periods;
// THIS IS A RECURRING CHARGE. WE WILL CONTINUE...
if($recurring=="Y") {
// CHECK IF THERE ARE UNUSED DAYS REMAINING IN THIS PERIOD:
if (($frequency == $date_diff) || ($frequency > $date_diff)) {
// THIS CHARGE IS DUE TODAY!
if($frequency == $date_diff) {
return TRUE;
// THIS CHARGE IS NOT DUE YET
} elseif($frequency > $date_diff) {
$due = $frequency - $date_diff;
return TRUE;
}
// THERE ARE NO UNUSED DAYS REMAINING IN THIS PERIOD!
} else {
// THERE ARE REMANING BILLING PERIODS. WE WILL CONTINUE...
if($periods_diff != 0) {
// THIS CHARGE WAS DUE BEFORE TODAY, ADD THE GRACE PERIOD DAYS IN!
if($frequency < $date_diff) {
$due = $frequency - $date_diff;
return FALSE;
}
// THERE ARE NO REMAINING BILLING PERIODS, THIS SUBSCRIPTION IS EXPIRED, ACCESS DENIED!
} else {
return FALSE;
}
}
// THIS IS NOT A RECURRING CHARGE. NEVER EXPIRES OR REBILLS
} else {
return TRUE;
}
return FALSE;
}
// GET TOTAL NUMBER OF SESSIONS (FOR STATISTICS)
function get_total_sessions() {
$db = new ps_DB;
$q = "SELECT session_id FROM sessions";
$db->query($q);
$num = $db->num_rows();
return $num;
}
// GET TOTAL NUMBER OF LOGINS (FOR STATISTICS)
function get_total_logins() {
$db = new ps_DB;
$q = "SELECT login_id FROM login";
$db->query($q);
$num = $db->num_rows();
return $num;
}
// GET TOTAL NUMBER OF DOMAINS (FOR STATISTICS)
function get_total_domains() {
$db = new ps_DB;
$q = "SELECT domain_id FROM domains";
$db->query($q);
$num = $db->num_rows();
return $num;
}
// GET TOTAL NUMBER OF NEW DOMAINS (FOR STATISTICS)
function get_total_domains_today() {
$today=date("Y-m-d");
$db = new ps_DB;
$q = "SELECT domain_id FROM domains WHERE domain_start_date='$today'";
$db->query($q);
$num = $db->num_rows();
return $num;
}
// GET TOTAL NUMBER OF ACCOUNTS (FOR STATISTICS)
function get_total_accounts() {
$db = new ps_DB;
$q = "SELECT account_id FROM account";
$db->query($q);
$num = $db->num_rows();
return $num;
}
// GET TOTAL NUMBER OF PENDING ORDERS (FOR STATISTICS)
function get_total_pending_orders() {
$db = new ps_DB;
$q = "SELECT order_id,order_amount FROM orders WHERE order_status='0'";
$db->query($q);
$amount="";
$num = $db->num_rows();
while($db->next_record()) {
$total = $db->f("order_amount");
$amount = $total+$amount;
}
$ret - "";
$ret .= $num;
$ret.= " (";
$ret.= setup("currency");
$ret.= $amount;
$ret.= ") ";
return $ret;
}
// GET TOTAL NUMBER OF COMPLETE ORDERS (FOR STATISTICS)
function get_total_complete_orders() {
$db = new ps_DB;
$q = "SELECT order_id,order_amount FROM orders WHERE order_status='1'";
$db->query($q);
$amount="";
$num = $db->num_rows();
while($db->next_record()) {
$total = $db->f("order_amount");
$amount = $total+$amount;
}
$ret - "";
$ret .= $num;
$ret.= " (";
$ret.= setup("currency");
$ret.= $amount;
$ret.= ") ";
return $ret;
}
// GET TOTAL NUMBER OF ORDERS (FOR STATISTICS)
function get_total_orders() {
$db = new ps_DB;
$q = "SELECT order_id,order_amount FROM orders";
$db->query($q);
$amount="";
$num = $db->num_rows();
while($db->next_record()) {
$total = $db->f("order_amount");
$amount = $total+$amount;
}
$ret - "";
$ret .= $num;
$ret.= " (";
$ret.= setup("currency");
$ret.= $amount;
$ret.= ") ";
return $ret;
}
// GET TOTAL NUMBER OF ORDERS TODAY (FOR STATISTICS)
function get_total_orders_today() {
$today=date("Y-m-d");
$db = new ps_DB;
$q = "SELECT order_id,order_amount FROM orders WHERE order_date='$today'";
$db->query($q);
$amount="";
$num = $db->num_rows();
while($db->next_record()) {
$total = $db->f("order_amount");
$amount = $total+$amount;
}
$ret - "";
$ret .= $num;
$ret.= " (";
$ret.= setup("currency");
$ret.= $amount;
$ret.= ") ";
return $ret;
}
// GET TOTAL NUMBER OF ORDERS TODAY (FOR STATISTICS)
function get_total_orders_voided() {
$today=date("Y-m-d");
$db = new ps_DB;
$q = "SELECT order_id,order_amount FROM orders WHERE order_status='2'";
$db->query($q);
$amount="";
$num = $db->num_rows();
while($db->next_record()) {
$total = $db->f("order_amount");
$amount = $total+$amount;
}
$ret - "";
$ret .= $num;
$ret.= " (";
$ret.= setup("currency");
$ret.= $amount;
$ret.= ") ";
return $ret;
}
// SHOW SELECTED HOSTING NAME & PRICE
function show_hosting_option($membership_id) {
$db = new ps_DB;
$q = "SELECT membership_name,membership_price FROM membership WHERE membership_id ='$membership_id'";
$db->query($q);
$db->next_record();
$name = $db->f("membership_name");
$price= $db->f("membership_price");
$ret = $name;
$ret.= " - (";
$ret.= setup("currency");
$ret.= $price;
$ret.= ") ";
return $ret;
}
function show_hosting_option_no_price($membership_id) {
$db = new ps_DB;
$q = "SELECT membership_name,membership_price FROM membership WHERE membership_id ='$membership_id'";
$db->query($q);
$db->next_record();
$name = $db->f("membership_name");
$price= $db->f("membership_price");
$ret = $name;
//$ret.= " - (";
//$ret.= setup("currency");
//$ret.= $price;
//$ret.= ") ";
return $ret;
}
// SHOW CLIENTS NAME
function show_client_name($account_id) {
$db = new ps_DB;
$q = "SELECT account_name FROM account WHERE account_id ='$account_id'";
$db->query($q);
$db->next_record();
$name = $db->f("account_name");
return $name;
}
// SHOW CLIENTS DOMAINS
function show_client_domains($client_id) {
$db = new ps_DB;
$q = "SELECT domain_id FROM domains WHERE domain_account_id ='$client_id'";
$db->query($q);
$num = $db->num_rows();
return $num;
}
// SHOW CLIENTS ORDERS
function show_client_orders($client_id) {
$db = new ps_DB;
$q = "SELECT order_id FROM orders WHERE order_account_id ='$client_id'";
$db->query($q);
$num = $db->num_rows();
return $num;
}
// DELETE THE USERS CART SESSION
function delete_sessions($session_ip) {
$db = new ps_DB;
$q = "DELETE FROM sessions WHERE session_ip ='$session_ip'";
$db->query($q);
}
// CREATE A DOMAIN RECORD FOR EACH DOMAIN IN CART
function create_domain_record($status,$billed,$order_id,$account_id,$billing_id,$session_ip) {
global $session_id;
$db = new ps_DB;
$q = "SELECT * FROM sessions WHERE session_ip='$session_ip' OR session_domain = '$session_id'";
$db->query($q);
while ($db->next_record())
{
// create the domain record
$host_id = $db->f("session_membership_id");
create_domain_record_1($status,$billed,$account_id,$order_id,$billing_id,"NA",$years,$host_id);
}
return true;
}
// CREATE A DOMAIN RECORD FOR EACH DOMAIN IN CART - original version
function subscription_manual_old($f) {
$today = date("Y-m-d");
// create the subscription record
$db = new ps_DB;
$q = "INSERT INTO domains SET
domain_account_id = '$f[account_id]',
domain_order_id = '',
domain_billing_id = '',
domain_type_id = '$domain_type',
domain_start_date = '$today',
domain_years = '',
domain_host_id = '$f[membership_id]',
domain_host_status = '1',
domain_host_periods = '1',
domain_host_last_billed = '$today'";
$db->query($q);
// get the record ID just added
$db = new ps_DB;
$q = "SELECT domain_id FROM domains WHERE
domain_account_id = '$f[account_id]' AND
domain_type_id = '$domain_type' AND
domain_start_date = '$today' AND
domain_host_id = '$f[membership_id]' AND
domain_host_status = '1' AND
domain_host_periods = '1' AND
domain_host_last_billed = '$today'";
$db->query($q);
while($db->next_record())
{
$domain_id = $db->f("domain_id");
}
// get the coupon/credit details for this membership
$db = new ps_DB;
$q = "SELECT credit,credit_amount,coupon,coupon_amount FROM membership WHERE membership_id = '$f[membership_id]'";
$db->query($q);
$db->next_record();
// are we to add a coupon?
if($db->f("coupon") == "Y")
{
$coupon_amount = $db->f("coupon_amount");
// Generate a coupon for this customer
$min=12;
$max=20;
$coupon_code="";
for($i=0;$i 97 && $num < 122)){
$coupon_code.=chr($num);
}else if(($num > 65 && $num < 90)){
$coupon_code.=chr($num);
}else if(($num >48 && $num < 57)){
$coupon_code.=chr($num);
}else if($num==95){
$coupon_code.=chr($num);
}else{
$i--;
}
}
$coupon_code = strtoupper($coupon_code);
// determine the coupon type & rate
if(preg_match("/%/i",$coupon_amount))
{
// percentage
$coupon_amount = preg_replace("/%/i","",$coupon_amount);
$coupon_amount = $coupon_amount * .01;
$coupon_type = 2;
}
else
{
// fixed rate
$coupon_type = 1;
}
$coupon_amount = number_format($coupon_amount,2);
// create the coupon record
$dbco = new ps_DB;
$q = "INSERT INTO coupons SET
account_id = '$f[account_id]',
domain_id = '$domain_id',
type = '$coupon_type',
coupon_code = '$coupon_code',
usage_max = '1',
usage_count = '0',
start_date = '$today',
end_date = '2099-12-12',
rate = '$coupon_amount'";
if($coupon_amount > 0)
{
$dbco->query($q);
}
}
// are we to add a credit?
if($db->f("credit") == "Y")
{
// create a credit for this customer
$dbcr = new ps_DB;
$q = "INSERT INTO credit SET
credit_date_added = '$today',
credit_amount = '".$db->f("credit_amount")."',
credit_account_id = '$f[account_id]',
credit_domain_id = '$domain_id',
credit_type = '1',
credit_notes = 'Purchased $today',
credit_status = '0'";
$dbcr->query($q);
// EMAIL THE CUSTOMER
if (setup("email_15")==Y) {
send_mail("15",$f[account_id],"","","");
}
}
// update all authentication for this account
global $path;
unset($API_ACTION);
$API_ACTION ='auth_account';
include ($path . 'auth.api.php');
}
// CREATE A DOMAIN RECORD FOR EACH DOMAIN IN CART - fixed version
function subscription_manual ($f)
{
//print '
';
//print_r($f["attr_name"]);
//print '
';
// check for existing domain record
$dbf = new ps_DB;
$q = "SELECT domain_id FROM domains WHERE domain_account_id = '$f[account_id]'";
$dbf->query($q);
$dbf->next_record();
$domain_exists = $dbf->f("domain_id");
// create the record
$db = new ps_DB;
$today = date("Y-m-d");
$order_id = next_order_id();
if ($domain_exists == 0)
{
// create a new domain record
$q = "INSERT INTO domains SET
domain_account_id = '$f[account_id]',
domain_order_id = '$order_id',
domain_billing_id = '',
domain_type_id = '$domain_type',
domain_start_date = '$today',
domain_years = '',
domain_host_id = '$f[membership_id]',
domain_host_status = '1',
domain_host_periods = '1',
domain_host_last_billed = '$today'";
} else {
// else update the existing domain record
$q = "UPDATE domains SET
domain_account_id = '$f[account_id]',
domain_order_id = '$order_id',
domain_billing_id = '',
domain_type_id = '$domain_type',
domain_start_date = '$today',
domain_years = '',
domain_host_id = '$f[membership_id]',
domain_host_status = '1',
domain_host_periods = '1',
domain_host_last_billed = '$today'
WHERE domain_id = '$domain_exists'";
}
$db->query($q);
$account_id = $f[account_id];
$billing_id = '';
$sess = '';
$attr = $f[attr];
$attrname = $f[attr_name];
$value = $f[attr_value];
$membership_id = $f[membership_id];
if(in_array('Domain',$attrname)){
$value[2] = $membership_id;
$attrname[2] = 'Domain';
$attrname[1] = '';
}
create_order_record_manual("1",$order_id,$account_id,$billing_id,$sess,$attr,$attrname,$value,$membership_id);
//create_order_record("1",$order_id,$account_id,$billing_id,$sess,$attr,$attrname,$value);
//echo $q." ";
$renew_date = $today;
// set renew_date in account table
update_renew_date($f[account_id], $renew_date);
$status = get_sns_status($membership_id);
update_status($account_id,$status,$membership_id);
}
// CREATE ACTUAL DOMAIN RECORD
function create_domain_record_1($status,$billed,$account_id,$order_id,$billing_id,$domain,$years,$host_id) {
if ($host_id == '50') {
$alt_host_id = '43';
} elseif ($host_id == '49') {
$alt_host_id = '36';
} elseif ($host_id == '56') {
$alt_host_id = '36';
}elseif ($host_id == '57') {
$alt_host_id = '33';
} elseif ($host_id == '45') {
$alt_host_id = '38';
} else {
$alt_host_id = $host_id;
}
//Check Account_id for group status
$dba = new ps_DB;
$q = "SELECT group_master_record FROM account WHERE account_id = '$account_id'";
$dba->query($q);
$dba->next_record();
$is_group_master = $dba->f("group_master_record");
if ($is_group_master == '0' || $is_group_master == '') {
//Check for existing domain record
//Check for existing domain record
$dbf = new ps_DB;
$q = "SELECT domain_id, domain_host_id FROM domains WHERE domain_account_id = '$account_id'";
$dbf->query($q);
$dbf->next_record();
$domain_exists = $dbf->f("domain_id");
} else {
$domain_exists = 0;
}
$current_domain = $dbf->f("domain_host_id");
if ($current_domain == '35' && $host_id == '45') {
$new_domain = '38';
} else {
$new_domain = $host_id;
}
// create the record...
$db = new ps_DB;
//create a new domain record
if ($domain_exists == 0) {
$today=date("Y-m-d");
$q = "INSERT INTO domains SET
domain_account_id = '$account_id',
domain_order_id = '$order_id',
domain_billing_id = '$billing_id',
domain_type_id = '$domain_type',
domain_start_date = '$today',
domain_years = '$years',
domain_host_id = '$host_id',
domain_host_status = '$status',";
if($billed=="Y")
{
$q.= "domain_host_periods = '1',
domain_host_last_billed = '$today'";
}
else
{
$q.= "domain_host_periods = '0',
domain_host_last_billed = '$today'";
}
$db->query($q);
//Update Renewal date in member account record
$renew_date = $today;
update_renew_date ($account_id,$renew_date);
//Else update the existing domain record
} else {
$today = renew_date_process($account_id,$current_domain,$new_domain);
$q = "UPDATE domains SET
domain_account_id = '$account_id',
domain_order_id = '$order_id',
domain_billing_id = '$billing_id',
domain_type_id = '$domain_type',
domain_years = '$years',
domain_host_id = '$alt_host_id',
domain_host_status = '$status',";
if($billed=="Y")
{
$q.= "domain_host_periods = '1',
domain_host_last_billed = '$today'";
}
else
{
$q.= "domain_host_periods = '0',
domain_host_last_billed = '$today'";
}
$q.= "WHERE domain_id = '$domain_exists'";
$db->query($q);
//Update Renewal date in member account record
$renew_date = $today;
update_renew_date ($account_id,$renew_date);
}
/*
// check the status...
if($status != "1") return;
// get the record ID just added
$db = new ps_DB;
$q = "SELECT domain_id FROM domains WHERE
domain_account_id = '$account_id' AND
domain_order_id = '$order_id' AND
domain_billing_id = '$billing_id' AND
domain_type_id = '$domain_type' AND
domain_start_date = '$today' AND
domain_years = '$years' AND
domain_host_id = '$host_id' AND
domain_host_status = '$status' AND
domain_host_last_billed = '$today'";
$db->query($q);
while($db->next_record())
{
$domain_id = $db->f("domain_id");
}
// get the coupon/credit details for this membership
$db = new ps_DB;
$q = "SELECT credit,credit_amount,coupon,coupon_amount FROM membership WHERE membership_id = '$host_id'";
$db->query($q);
$db->next_record();
// are we to add a coupon?
if($db->f("coupon") == "Y")
{
$coupon_amount = $db->f("coupon_amount");
// Generate a coupon for this customer
$min=12;
$max=20;
$coupon_code="";
for($i=0;$i 97 && $num < 122)){
$coupon_code.=chr($num);
}else if(($num > 65 && $num < 90)){
$coupon_code.=chr($num);
}else if(($num >48 && $num < 57)){
$coupon_code.=chr($num);
}else if($num==95){
$coupon_code.=chr($num);
}else{
$i--;
}
}
$coupon_code = strtoupper($coupon_code);
// determine the coupon type & rate
if(eregi("%",$coupon_amount))
{
// percentage
$coupon_amount = eregi_replace("%","",$coupon_amount);
$coupon_amount = $coupon_amount * .01;
$coupon_type = 2;
}
else
{
// fixed rate
$coupon_type = 1;
}
$coupon_amount = number_format($coupon_amount,2);
// create the coupon record
$dbco = new ps_DB;
$q = "INSERT INTO coupons SET
account_id = '$account_id',
order_id = '$order_id',
domain_id = '$domain_id',
type = '$coupon_type',
coupon_code = '$coupon_code',
usage_max = '1',
usage_count = '0',
start_date = '$today',
end_date = '2099-12-12',
rate = '$coupon_amount'";
if($coupon_amount > 0)
{
$dbco->query($q);
}
}
// are we to add a credit?
if($db->f("credit") == "Y")
{
// create a credit for this customer
$dbcr = new ps_DB;
$q = "INSERT INTO credit SET
credit_date_added = '$today',
credit_amount = '".$db->f("credit_amount")."',
credit_account_id = '$account_id',
credit_order_id = '$order_id',
credit_domain_id = '$domain_id',
credit_type = '1',
credit_notes = 'Purchased $today',
credit_status = '0'";
$dbcr->query($q);
// EMAIL THE CUSTOMER
if (setup("email_15")==Y) {
send_mail("15",$f[account_id],"","","");
}
}
*/
}
// Create a subscription-based credit
function create_credit_order($order_id)
{
// get the all the subscriptions for this order...
$db = new ps_DB;
$q = "SELECT domain_id,domain_account_id,domain_host_id FROM domains WHERE domain_order_id = '$order_id'";
$db->query($q);
while($db->next_record())
{
$domain_id = $db->f("domain_id");
$account_id = $db->f("domain_account_id");
$membership_id = $db->f("domain_host_id");
// get the coupon/credit details for this membership
$dbc = new ps_DB;
$q = "SELECT credit,credit_amount,coupon,coupon_amount FROM membership WHERE membership_id = '$membership_id'";
$dbc->query($q);
$dbc->next_record();
// are we to add a credit?
if($dbc->f("credit") == "Y")
{
// check that this credit does not already exist!
$dbcheck = new ps_DB;
$q = "SELECT credit_id FROM credit WHERE
credit_amount = '".$dbc->f("credit_amount")."' AND
credit_account_id = '$account_id' AND
credit_domain_id = '$domain_id' AND
credit_order_id = '$order_id'";
$dbcheck->query($q);
if(($dbcheck->num_rows() == 0) && ($dbc->f("credit_amount") > 0))
{
// create a credit for this customer
$dbcr = new ps_DB;
$q = "INSERT INTO credit SET
credit_date_added = '$today',
credit_amount = '".$dbc->f("credit_amount")."',
credit_account_id = '$account_id',
credit_domain_id = '$domain_id',
credit_order_id = '$order_id',
credit_type = '1',
credit_notes = 'Purchased $today',
credit_status = '0'";
$dbcr->query($q);
// EMAIL THE CUSTOMER
if (setup("email_15")==Y) {
send_mail("15",$f[account_id],"","","");
}
}
}
}
}
// Delete a subscription-based credit
function delete_credit_order($order_id)
{
// get the all the subscriptions for this order...
$db = new ps_DB;
$q = "SELECT domain_id,domain_account_id,domain_host_id FROM domains WHERE domain_order_id = '$order_id'";
$db->query($q);
while($db->next_record())
{
$domain_id = $db->f("domain_id");
$account_id = $db->f("domain_account_id");
$membership_id = $db->f("domain_host_id");
// get the coupon/credit details for this membership
$dbc = new ps_DB;
$q = "SELECT credit,credit_amount,coupon,coupon_amount FROM membership WHERE membership_id = '$membership_id'";
$dbc->query($q);
$dbc->next_record();
// are we to add a credit?
if($dbc->f("credit") == "Y")
{
// check that this credit does not already exist!
$dbcheck = new ps_DB;
$q = "DELETE FROM credit WHERE
credit_amount = '".$dbc->f("credit_amount")."' AND
credit_account_id = '$account_id' AND
credit_domain_id = '$domain_id' AND
credit_type = '1' AND
credit_order_id = '$order_id'";
$dbcheck->query($q);
}
}
}
// Create a subscrioption-based coupon
function create_coupon_order($order_id)
{
$today = date("Y-m-d");
// get the all the subscriptions for this order...
$db = new ps_DB;
$q = "SELECT domain_id,domain_account_id,domain_host_id FROM domains WHERE domain_order_id = '$order_id'";
$db->query($q);
while($db->next_record())
{
$domain_id = $db->f("domain_id");
$account_id = $db->f("domain_account_id");
$membership_id = $db->f("domain_host_id");
// get the coupon/credit details for this membership
$dbc = new ps_DB;
$q = "SELECT credit,credit_amount,coupon,coupon_amount FROM membership WHERE membership_id = '$membership_id'";
$dbc->query($q);
$dbc->next_record();
// are we to add a credit?
if($dbc->f("coupon") == "Y")
{
// check that this coupon does not already exist!
$dbcheck = new ps_DB;
$q = "SELECT id FROM coupons WHERE
domain_id = '$domain_id'";
$dbcheck->query($q);
if($dbcheck->num_rows() == 0)
{
$coupon_amount = $dbc->f("coupon_amount");
// Generate a coupon for this customer
$min=12;
$max=20;
$coupon_code="";
for($i=0;$i 97 && $num < 122)){
$coupon_code.=chr($num);
}else if(($num > 65 && $num < 90)){
$coupon_code.=chr($num);
}else if(($num >48 && $num < 57)){
$coupon_code.=chr($num);
}else if($num==95){
$coupon_code.=chr($num);
}else{
$i--;
}
}
$coupon_code = strtoupper($coupon_code);
// determine the coupon type & rate
if(preg_match("/%/i",$coupon_amount))
{
// percentage
$coupon_amount = preg_replace("/%/i","",$coupon_amount);
$coupon_amount = $coupon_amount * .01;
$coupon_type = 2;
}
else
{
// fixed rate
$coupon_type = 1;
}
$coupon_amount = number_format($coupon_amount,2);
// create the coupon record
$dbco = new ps_DB;
$q = "INSERT INTO coupons SET
account_id = '$account_id',
domain_id = '$domain_id',
order_id = '$order_id',
type = '$coupon_type',
coupon_code = '$coupon_code',
usage_max = '1',
usage_count = '0',
start_date = '$today',
end_date = '2099-12-12',
rate = '$coupon_amount'";
if($coupon_amount > 0)
{
$dbco->query($q);
}
}
}
}
}
// Delete a subscription-based coupon
function delete_coupon_order($order_id)
{
// get the all the subscriptions for this order...
$db = new ps_DB;
$q = "SELECT domain_id,domain_account_id,domain_host_id FROM domains WHERE domain_order_id = '$order_id'";
$db->query($q);
while($db->next_record())
{
$domain_id = $db->f("domain_id");
$account_id = $db->f("domain_account_id");
$membership_id = $db->f("domain_host_id");
// get the coupon/credit details for this membership
$dbc = new ps_DB;
$q = "SELECT credit,credit_amount,coupon,coupon_amount FROM membership WHERE membership_id = '$membership_id'";
$dbc->query($q);
$dbc->next_record();
// are we to add a credit?
if($dbc->f("coupon") == "Y")
{
// check that this credit does not already exist!
$dbcheck = new ps_DB;
$q = "DELETE FROM coupons WHERE
domain_id = '$domain_id'";
$dbcheck->query($q);
}
}
}
// DETERMINE DOMAIN TYPE
function determine_domain_type($tld) {
$db = new ps_DB;
$q = "SELECT domain_type_id FROM domain_type WHERE domain_type_extension = '$tld'";
$db->query($q);
$db->next_record();
return $db->f("domain_type_id");
}
// USE A COUPON....
function coupon_use($coupon)
{
// get the current usage_count
$db = new ps_DB;
$q = "SELECT usage_count FROM coupons WHERE coupon_code = '$coupon'";
$db->query($q);
$db->next_record();
$num = $db->f("usage_count") + 1;
// increment the usage_count
$db = new ps_DB;
$q = "UPDATE coupons SET usage_count = '$num' WHERE coupon_code = '$coupon'";
$db->query($q);
}
// CREATE AN ORDER RECORD
function create_order_record_old($status,$order_id,$account_id,$billing_id,$sess,$attr,$attr_name,$attr_value) {
global $REMOTE_ADDR, $REMOTE_HOST, $aid;
// get the users IP
if ($REMOTE_ADDR != "") { $user_ip = $REMOTE_ADDR; } else { $user_ip = $REMOTE_HOST; }
// get the date
$today=date("Y-m-d");
// get the affiliate and any coupons used
$db = new ps_DB;
$q = "SELECT * FROM login WHERE login_id = '$sess'";
$db->query($q);
$db->next_record($q);
$coupon = $db->f("coupon");
$affiliate = $db->f("login_affiliate_id");
if($affiliate<=0) $affiliate = $aid;
// Get base fees
$base_amount = show_hosting_cost($user_ip);
// Get setup fees
$setup_amount = show_setup_cost($user_ip);
$subtotal = $base_amount + $setup_amount;
// Coupon Stuff
//if($coupon != "")
//{
//validate the coupon
// if (validate_coupon($coupon))
// {
// get the coupon amount
// $coupon_amount = number_format(get_coupon_amount($sess, $subtotal),2);
// use the coupon
// coupon_use($coupon);
// }
// else
// {
$coupon = 'NONE';
$coupon_amount ='0';
// }
//}
$subtotal = $subtotal - $coupon_amount;
if($subtotal < 0) $subtotal = 0;
// Get the tax amount
$tax_amount = $subtotal * number_format(setup("tax_rate"),2);
$subtotal = $subtotal + $tax_amount;
// Get any account credit amounts applied
//$credits = credit_exsist($account_id);
//if($credits >= $subtotal)
//{
// $credit_amount = $subtotal;
//}
//else
//{
// $credit_amount = $credits;
//}
$credit_amount = '';
// Get the total
//$amount = number_format($subtotal - $credit_amount,2);
$amount = $subtotal - $credit_amount;
// Prepare attribute text for insert
for($i = 0; $i < 10; $i++) {
$attr_value[$i] = addslashes($attr_value[$i]);
}
$db = new ps_DB;
$q = "INSERT INTO orders SET
order_id = '$order_id',
order_account_id = '$account_id',
order_billing_id = '$billing_id',
order_affiliate_id = '$affiliate',
order_amount = '$amount',
order_setup = '$setup_amount',
order_date = '$today',
order_status = '$status',
order_ip = '$user_ip',
order_attr_name_1 = '$attr_name[0]',
order_attr_value_1 = '$attr_value[0]',
order_attr_name_2 = '$attr_name[1]',
order_attr_value_2 = '$attr_value[1]',
order_attr_name_3 = '$attr_name[2]',
order_attr_value_3 = '$attr_value[2]',
order_attr_name_4 = '$attr_name[3]',
order_attr_value_4 = '$attr_value[3]',
order_attr_name_5 = '$attr_name[4]',
order_attr_value_5 = '$attr_value[4]',
order_attr_name_6 = '$attr_name[5]',
order_attr_value_6 = '$attr_value[5]',
order_attr_name_7 = '$attr_name[6]',
order_attr_value_7 = '$attr_value[6]',
order_attr_name_8 = '$attr_name[7]',
order_attr_value_8 = '$attr_value[7]',
order_attr_name_9 = '$attr_name[8]',
order_attr_value_9 = '$attr_value[8]',
order_attr_name_10 = '$attr_name[9]',
order_attr_value_10 = '$attr_value[9]',
base_amount = '$base_amount',
setup_amount = '$setup_amount',
coupon_code = '$coupon',
coupon_amount = '$coupon_amount',
tax_amount = '$tax_amount',
credit_amount = '$credit_amount',
groupid = '$groupid'";
$db->query($q);
if (($status == '1') && ($amount > 0)) {
create_affiliate_payout($order_id);
}
return true;
}
function create_order_record($status,$order_id,$account_id,$billing_id,$sess,$attr,$attr_name,$attr_value) {
global $REMOTE_ADDR, $REMOTE_HOST, $aid;
// get the users IP
if ($REMOTE_ADDR != "") { $user_ip = $REMOTE_ADDR; } else { $user_ip = $REMOTE_HOST; }
// get the date
$today=date("Y-m-d");
// Get base fees
$base_amount = show_hosting_cost($user_ip);
// Get setup fees
$subtotal = $base_amount;
$coupon = 'NONE';
$coupon_amount ='0';
$subtotal = $subtotal - $coupon_amount;
if($subtotal < 0) $subtotal = 0;
$credit_amount = '';
$amount = $subtotal - $credit_amount;
if ($billing_id == '') {
$billing_id = '0';
}
// Prepare attribute text for insert
for($i = 0; $i < 10; $i++) {
$attr_value[$i] = addslashes($attr_value[$i]);
}
$db = new ps_DB;
$q = "INSERT INTO orders SET
order_id = '$order_id',
order_account_id = '$account_id',
order_billing_id = '$billing_id',
order_amount = '$amount',
order_setup = '$setup_amount',
order_date = '$today',
order_status = '$status',
order_ip = '$user_ip',
order_attr_name_1 = '$attr_name[0]',
order_attr_value_1 = '$attr_value[0]',
order_attr_name_2 = '$attr_name[1]',
order_attr_value_2 = '$attr_value[1]',
order_attr_name_3 = '$attr_name[2]',
order_attr_value_3 = '$attr_value[2]',
order_attr_name_4 = '$attr_name[3]',
order_attr_value_4 = '$attr_value[3]',
order_attr_name_5 = '$attr_name[4]',
order_attr_value_5 = '$attr_value[4]',
order_attr_name_6 = '$attr_name[5]',
order_attr_value_6 = '$attr_value[5]',
order_attr_name_7 = '$attr_name[6]',
order_attr_value_7 = '$attr_value[6]',
order_attr_name_8 = '$attr_name[7]',
order_attr_value_8 = '$attr_value[7]',
order_attr_name_9 = '$attr_name[8]',
order_attr_value_9 = '$attr_value[8]',
order_attr_name_10 = '$attr_name[9]',
order_attr_value_10 = '$attr_value[9]',
base_amount = '$base_amount',
groupid = '$groupid'";
$db->query($q);
if (($status == '1') && ($amount > 0)) {
create_affiliate_payout($order_id);
}
return true;
}
function create_order_record_manual($status,$order_id,$account_id,$billing_id,$sess,$attr,$attr_name,$attr_value,$membership_id) {
global $REMOTE_ADDR, $REMOTE_HOST, $aid;
// get the users IP
if ($REMOTE_ADDR != "") { $user_ip = $REMOTE_ADDR; } else { $user_ip = $REMOTE_HOST; }
// get the date
$today=date("Y-m-d");
// Get base fees
$base_amount = get_hosting_cost($membership_id);
// Get setup fees
$subtotal = $base_amount;
$coupon = 'NONE';
$coupon_amount ='0';
$subtotal = $subtotal - $coupon_amount;
if($subtotal < 0) $subtotal = 0;
$credit_amount = '';
$amount = $subtotal - $credit_amount;
if ($billing_id == '') {
$billing_id = '0';
}
// Prepare attribute text for insert
for($i = 0; $i < 10; $i++) {
$attr_value[$i] = addslashes($attr_value[$i]);
}
$db = new ps_DB;
$q = "INSERT INTO orders SET
order_id = '$order_id',
order_account_id = '$account_id',
order_billing_id = '$billing_id',
order_amount = '$amount',
order_setup = '$setup_amount',
order_date = '$today',
order_status = '$status',
order_ip = '$user_ip',
order_attr_name_1 = '$attr_name[0]',
order_attr_value_1 = '$attr_value[0]',
order_attr_name_2 = '$attr_name[1]',
order_attr_value_2 = '$attr_value[1]',
order_attr_name_3 = '$attr_name[2]',
order_attr_value_3 = '$attr_value[2]',
order_attr_name_4 = '$attr_name[3]',
order_attr_value_4 = '$attr_value[3]',
order_attr_name_5 = '$attr_name[4]',
order_attr_value_5 = '$attr_value[4]',
order_attr_name_6 = '$attr_name[5]',
order_attr_value_6 = '$attr_value[5]',
order_attr_name_7 = '$attr_name[6]',
order_attr_value_7 = '$attr_value[6]',
order_attr_name_8 = '$attr_name[7]',
order_attr_value_8 = '$attr_value[7]',
order_attr_name_9 = '$attr_name[8]',
order_attr_value_9 = '$attr_value[8]',
order_attr_name_10 = '$attr_name[9]',
order_attr_value_10 = '$attr_value[9]',
base_amount = '$base_amount',
groupid = '$groupid'";
$db->query($q);
if (($status == '1') && ($amount > 0)) {
create_affiliate_payout($order_id);
}
return true;
}
// CREATE A BILLING RECORD FOR THE CREDIT CARD INFORMATION ENTERED
function create_billing_record($account_id,$cc_num,$cc_exp,$order_id) {
$cc_num=RC4($cc_num,"en");
$db = new ps_DB;
$q = "INSERT INTO billing SET
billing_account_id='$account_id',
billing_cc_num='$cc_num',
billing_cc_exp='$cc_exp',
billing_order_id='$order_id'";
$db->query($q);
$db = new ps_DB;
$q = "SELECT billing_id FROM billing WHERE billing_order_id='$order_id'";
$db->query($q);
while ($db->next_record()) {
$ret = $db->f("billing_id");
}
return $ret;
}
// GENERATE THE NEXT ORDER ID
function next_order_id() {
$db = new ps_DB;
$q = "SELECT order_id FROM orders";
$db->query($q);
while ($db->next_record()) {
$last=$db->f("order_id");
}
$ret = $last+1;
return $ret;
}
// REQUEST VALIDATION FOR AN EMAIL CHANGE FROM THE EMAIL ON FILE
function validate_email_change_1($new_email,$old_email,$pass,$id) {
// CREATE THE md5 Hash to send the user...
$md5 = strtoupper(md5($old_email . '|' . $new_email . '|' . $pass . '|' . $id));
$url = setup("url");
$company = setup("company");
$message = 'This is an automated message from ' . $company . '.
In order to complete the email change you requested, you must first validate the request by clicking the link below.
If you did not request this change, it is possible that someone gained unauthorized access to your account. It is recommended that you log into your account at ' . $url . ' and change your account password.
Your current email address on file is ' . $old_email . ' and clicking the link below will verify that you wish to change your email address to ' . $new_email . '.
' . $url . '?page=email_change_1&e1=' . $old_email . '&e2=' . $new_email . '&v=' . $md5 . '
or
Verify Update Request
Thank you!
' . $company . '
';
//echo "
$message
";
$company_name = setup("company");
$company_email= setup("email");
$headers = "From: $company_name <$company_email>\n";
$headers .= "X-Sender: <$company_email>\n";
$headers .= "Return-Path: <$company_email>\n";
mail($old_email,"Please Validate Email Change Request!",$message,$headers);
global $message;
$message .="An email has been sent to $old_email to verify this change, please check your email for details.";
return "An email has been sent to $old_email to verify this change, please check your email for details.";
}
// REQUEST VALIDATION FOR AN EMAIL CHANGE FROM THE EMAIL ON FILE
function validate_email_change_2($new_email,$old_email,$v) {
$db = new ps_DB;
$q = "SELECT * FROM account WHERE account_email = '" . sql_string_filter($db->lid, $old_email) . "'";
$db->query($q);
$db->next_record();
if ($db->num_rows() <=0) {
return FALSE;
}
$pass = $db->f("account_password");
$id = $db->f("account_id");
// CREATE THE md5 Hash to compare...
$md5 = strtoupper(md5($old_email . '|' . $new_email . '|' . $pass . '|' . $id));
if ($v != $md5) {
return FALSE;
} else {
$md5 = strtoupper(md5($old_email . '|' . $new_email . '|' . $pass . '|' . $id . '|' . date("Y-m-d") . '|VALID'));
$url = setup("url");
$company = setup("company");
$message = 'This is an automated message from ' . $company . '.
In order to complete the email change you requested, you must first validate this email address by clicking the link below.
If you do not click the link, your email on file at ' . $company . ' will not be changed.
Your current email address on file is ' . $old_email . ' and clicking the link below will permanently change your email address to ' . $new_email . '.
' . $url . '?page=email_change_2&e1=' . $old_email . '&e2=' . $new_email . '&v=' . $md5 . '
or
Verify Update Request
This link will expire after today, so you must use it immediately...
Thank you!
' . $company . '
';
//echo "
$message
";
$company_name = setup("company");
$company_email= setup("email");
$headers = "From: $company_name <$company_email>\n";
$headers .= "X-Sender: <$company_email>\n";
$headers .= "Return-Path: <$company_email>\n";
mail($old_email,"Please Validate Email Change Request!",$message,$headers);
global $message;
$message .="An email has been sent to $old_email to verify this change, please check your email for details.";
return TRUE;
}
}
// REQUEST VALIDATION FOR AN EMAIL CHANGE FROM THE EMAIL ON FILE
function validate_email_change_3($new_email,$old_email,$v) {
$db = new ps_DB;
$q = "SELECT * FROM account WHERE account_email = '" . sql_string_filter($db->lid, $old_email) . "'";
$db->query($q);
$db->next_record();
if ($db->num_rows() <=0) {
return FALSE;
}
$pass = $db->f("account_password");
$id = $db->f("account_id");
// CREATE THE md5 Hash to compare...
$md5 = strtoupper(md5($old_email . '|' . $new_email . '|' . $pass . '|' . $id . '|' . date("Y-m-d") . '|VALID'));
if ($v != $md5) {
return FALSE;
} else {
// VERIFY NON-DUPLICATE EMAIL!
$dbs = new ps_DB;
$q = "SELECT account_email FROM account WHERE account_email='" . sql_string_filter($dbs->lid, $new_email) . "'";
$dbs->query($q);
if ($dbs->num_rows() <= 0) {
$db = new ps_DB;
$q = "UPDATE account SET
account_email = '" . sql_string_filter($db->lid, $new_email) . "'
WHERE account_id = '" . sql_string_filter($db->lid, $id) . "'";
$db->query($q);
$db = new ps_DB;
$q = "SELECT * FROM account WHERE account_id = '" . sql_string_filter($db->lid, $id) . "'";
$db->query($q);
$db->next_record();
$f[name] = $db->f("account_name");
$f[address] = $db->f("account_address");
$f[city] = $db->f("account_city");
$f[state] = $db->f("account_state");
$f[zip] = $db->f("account_zip");
$f[company] = $db->f("account_company");
$f[old_password] = $db->f("account_password");
$f[old_email] = $new_email;
$f[email] = $old_email;
// determine if any external database update functions need run:
global $path;
unset($API_ACTION);
$API_ACTION ='update_member_account';
include ($path . 'auth.api.php');
// update this account authentication
$f[account_id] = $id;
unset($API_ACTION);
$API_ACTION ='auth_account';
include ($path . 'auth.api.php');
return TRUE;
} else {
//echo "Match found in db!" . $dbs->num_rows();
return FALSE;
}
return TRUE;
}
}
function validate_pass_change_1($new_password,$old_password,$email,$id) {
$str = $old_password . '|' . $new_password . '|' . $email . '|' . $id . '|' . date("Y-m-d");
$md5=strtoupper(md5($str));
$link = setup("url") . '?page=account&next_page=account&action=verify_pass_change&id='
. RC4($id,"en") . '&p1='
. RC4($old_password,"en") . '&p2='
. RC4($new_password,"en") . '&v='
. $md5;
$company = setup("company");
$message = 'This is an automated message from ' . $company . '.
In order to complete the password change you requested, you must first validate your request by clicking the link below.
If you do not click the link, your password on file at ' . $company . ' will not be changed.
If you or someone you authorized did not request this password change, we recommend that you log into your account and change your email address, as someone may have gained unauthorized access to your account.
' . $link . '
or
Verify Password Change Request
This link will expire after midnight today, so you must use it immediately...
Thank you!
' . $company . '
';
// echo "
$message
";
$company_name = setup("company");
$company_email= setup("email");
$headers = "From: $company_name <$company_email>\n";
$headers .= "X-Sender: <$company_email>\n";
$headers .= "Return-Path: <$company_email>\n";
mail($email,"Please Verify Password Request Change",$message,$headers);
return "A message has been sent to your email account for you to validate this password change request.";
}
function validate_pass_change($new_password,$old_password,$id,$v) {
global $path;
$new_password = RC4($new_password,"de");
$old_password = RC4($old_password,"de");
$id = RC4($id,"de");
$db = new ps_DB;
$q = "SELECT * FROM account WHERE account_id = '" . sql_string_filter($db->lid, $id) . "'";
$db->query($q);
$db->next_record();
if($id!=$db->f("account_id")) {
return "You are not authorized to make this change!";
} else {
$email = $db->f("account_email");
$str = $old_password . '|' . $new_password . '|' . $email . '|' . $id . '|' . date("Y-m-d");
$md5=strtoupper(md5($str));
$acpass = $db->f("account_password");
if (($v != $md5) && ($old_password == $acpass)) {
return "You have submitted a password change request that is invalid or expired!";
} else {
// run the auth api before updating, if the username or password has changed...
// at the end of the function, we will run it again to restore the new username/password set....
// get each domain id currently active, and remove the login for it from the db
$db = new ps_DB;
$q = "select domain_id from domains where domain_account_id = '" . sql_string_filter($db->lid, $id) . "' and domain_host_status='1'";
$db->query($q);
while($db->next_record())
{
// remove this login from the specified location
$f[account_id] = $id;
$f[domain_id] = $db->f("domain_id");
unset($API_ACTION);
$API_ACTION ='auth_deactivate';
include($path . 'auth.api.php');
}
// Ok! Update account...
$db = new ps_DB;
$q = "UPDATE account SET account_password = '" . sql_string_filter($db->lid, $new_password) . "' WHERE account_id = '" . sql_string_filter($db->lid, $id) . "'";
$db->query($q);
$db = new ps_DB;
$q = "SELECT * FROM account WHERE account_id = '$id'";
$db->query($q);
$db->next_record();
$f[name] = $db->f("account_name");
$f[address] = $db->f("account_address");
$f[city] = $db->f("account_city");
$f[state] = $db->f("account_state");
$f[zip] = $db->f("account_zip");
$f[company] = $db->f("account_company");
$f[old_email] = $db->f("account_email");
$f[email] = $db->f("account_email");
$f[old_password] = $new_password;
// determine if any external database update functions need run:
global $path;
unset($API_ACTION);
$API_ACTION ='update_member_account';
include ($path . 'auth.api.php');
// Sync Authentication...
$f[account_id] = $id;
unset($API_ACTION);
$API_ACTION ='auth_account';
include ($path . 'auth.api.php');
return "Your account password has been updated as requested!";
// EMAIL CUSTOMER
if(setup("email_13")==Y) {
send_mail("13",$account_id,"","","");
}
}
}
}
// UPDATE MEMBER ACCOUNT INFO
function update_member_account($f,$sess) {
global $path;
$ret="";
// Validate that the user submitting this info is logged in to the account being changed....
$pass = is_logged($sess);
if($pass == "Y") {
$account_id = get_account_id($sess);
// check the current account id against the one submitted...
if($account_id != $f[account_id]) {
// Account not logged in ...
return "You must be logged into the account you wish to update in order to make the requested changes!";
} else {
// We are ok to proceed....
// Check the old email and password against the new ones submitted to see if validation emails need to be sent....
$db = new ps_DB;
$q = "SELECT account_email,account_password FROM account WHERE account_id = '$account_id'";
$db->query($q);
$db->next_record();
$old_email = $db->f("account_email");
$old_password = $db->f("account_password");
//Compare old email...
if($f[email] != $old_email) {
// Send out an email authorization change...
$ret .= validate_email_change_1($f[email],$old_email,$old_password,$account_id);
}
//Compare old pass...
if($f[password] != $old_password) {
// Send out an password authorization change...
$ret .= validate_pass_change_1($f[password],$old_password,$old_email,$account_id);
}
// VALIDATE THE REQUIRED INFORMATION...
include($path . "setup_reg_fields.php");
// BUILD THE INSERT STATEMENT
$db = new ps_DB;
$q ="UPDATE account SET ";
// NAME
if ($f_required[name]) {
// Validate this field...
//if (eregi("^[a-zA-Z0-9_]{1,}$", $f[name])) {
if (preg_match("/^[a-zA-Z.,]{2,} {1,}[a-zA-Z,. ?]{1,}[a-zA-Z.]{2,}$/i", $f[name])) {
if($comma) $q.= ' , ';
$q.=" account_name = '" . sql_string_filter($db->lid, $f[name]) . "' ";
$comma = TRUE;
} else {
$ret.=" Please enter a valid name!";
}
} else {
if($comma) $q.= ' , ';
$q.=" account_name = '" . sql_string_filter($db->lid, $f[name]) . "' ";
$comma = TRUE;
}
// ADDRESS
if ($f_required[address]) {
// Validate this field...
//if (eregi("^[a-zA-Z0-9.,]{1,} {1,}[a-zA-Z0-9,. ?]{1,}[a-zA-Z0-9.,]{2,}$", $f[address])) {
if (strlen($f[address]) >= "2") {
if($comma) $q.= ' , ';
$q.=" account_address = '" . sql_string_filter($db->lid, $f[address]) . "' ";
$comma = TRUE;
} else {
$ret.=" Please enter a valid address!";
}
} else {
if($comma) $q.= ' , ';
$q.=" account_address = '" . sql_string_filter($db->lid, $f[address]) . "' ";
$comma = TRUE;
}
// CITY
if ($f_required[city]) {
// Validate this field...
if (strlen($f[city]) >= "2") {
if($comma) $q.= ' , ';
$q.=" account_city = '" . sql_string_filter($db->lid, $f[city]) . "' ";
$comma = TRUE;
} else {
$ret.=" Please enter a valid city!";
}
} else {
if($comma) $q.= ' , ';
$q.=" account_city = '" . sql_string_filter($db->lid, $f[city]) . "' ";
$comma = TRUE;
}
//STATE
if ($f_required[state]) {
// Validate this field...
if (strlen($f[state]) >= "2") {
if($comma) $q.= ' , ';
$q.=" account_state = '" . sql_string_filter($db->lid, $f[state]) . "' ";
$comma = TRUE;
} else {
$ret.=" Please enter a valid state!";
}
} else {
if($comma) $q.= ' , ';
$q.=" account_state = '" . sql_string_filter($db->lid, $f[state]) . "' ";
$comma = TRUE;
}
//ZIP
if ($f_required[zip]) {
// Validate this field...
if (strlen($f[zip]) >= "1") {
if($comma) $q.= ' , ';
$q.=" account_zip = '" . sql_string_filter($db->lid, $f[zip]) . "' ";
$comma = TRUE;
} else {
$ret.=" Please enter a valid zip!";
}
} else {
if($comma) $q.= ' , ';
$q.=" account_zip = '" . sql_string_filter($db->lid, $f[zip]) . "' ";
$comma = TRUE;
}
// TITLE
if ($f_required[title]) {
// Validate this field...
if (strlen($f[title]) >= "1") {
if($comma) $q.= ' , ';
$q.=" account_title = '" . sql_string_filter($db->lid, $f[title]) . "' ";
$comma = TRUE;
} else {
$ret.=" Please enter your title!";
}
} else {
if($comma) $q.= ' , ';
$q.=" account_title = '" . sql_string_filter($db->lid, $f[title]) . "' ";
$comma = TRUE;
}
// COMPANY
if ($f_required[company]) {
// Validate this field...
if (strlen($f[company]) >= "1") {
if($comma) $q.= ' , ';
$q.=" account_company = '" . sql_string_filter($db->lid, $f[company]) . "' ";
$comma = TRUE;
} else {
$ret.=" Please enter a valid company!";
}
} else {
if($comma) $q.= ' , ';
$q.=" account_company = '" . sql_string_filter($db->lid, $f[company]) . "' ";
$comma = TRUE;
}
//PHONE
if ($f_required[phone]) {
// Validate this field...
if (strlen($f[acct_phone]) >= "10") {
if($comma) $q.= ' , ';
$q.=" account_phone = '" . sql_string_filter($db->lid, $f[acct_phone]) . "' ";
$comma = TRUE;
} else {
$ret.=" Please enter a valid phone!";
}
} else {
if($comma) $q.= ' , ';
$q.=" account_phone = '" . sql_string_filter($db->lid, $f[acct_phone]) . "' ";
$comma = TRUE;
}
// FAX
if ($f_required[fax]) {
// Validate this field...
if (strlen($f[fax]) >= "10") {
if($comma) $q.= ' , ';
$q.=" account_fax = '" . sql_string_filter($db->lid, $f[fax]) . "' ";
$comma = TRUE;
} else {
$ret.=" Please enter a valid fax!";
}
} else {
if($comma) $q.= ' , ';
$q.=" account_fax = '" . sql_string_filter($db->lid, $f[fax]) . "' ";
$comma = TRUE;
}
$q.="WHERE account_id= '$account_id'";
$db->query($q);
$f[old_email] = $old_email;
$f[old_password] = $old_password;
$f[email] = $old_email;
// determine if any external database update functions need run:
global $path;
unset($API_ACTION);
$API_ACTION ='update_member_account';
include ($path . 'auth.api.php');
// EMAIL CUSTOMER
if(setup("email_13")==Y) {
send_mail("13",$account_id,"","","");
}
}
return $ret;
} else {
return "You must be logged into the account you wish to update in order to make the requested changes!";
}
}
// SEND LOST PASSWORD
function send_password($email) {
$db = new ps_DB;
$q = "SELECT account_name,account_password,account_email FROM account WHERE account_email='" . sql_string_filter($db->lid, $email) . "'";
$db->query($q);
if ($db->next_record()) {
$name =$db->f("account_name");
$ret="$name, your username and password have been sent to $email";
email_pw($db->f("account_password"),$email,$name);
} else {
$ret="The email address $email was not found in our database.";
}
return $ret;
}
// CHECK FOR DUPLICATE USER ACCOUNT
function validate_email_unused($email) {
$db = new ps_DB;
$q = "SELECT account_email FROM account WHERE account_email='" . sql_string_filter($db->lid, $email) . "' AND group_master_record = '0'";
$db->query($q);
if ($db->num_rows()==0) {
$ret="Y";
} else {
$ret="N";
}
return $ret;
}
// CHECK FOR DUPLICATE USER ACCOUNT
function validate_username_unused($user) {
$db = new ps_DB;
$q = "SELECT account_id FROM account WHERE account_username='" . sql_string_filter($db->lid, $user) . "'";
$db->query($q);
if ($db->num_rows()==0) {
return true;
} else {
return false;
}
}
// ADD NEW USER ACCOUNT
function add_new_user_account($sess,$email,$password,$name,$title,$company,$address,$city,$state,$zip,$country,$phone,$fax,$username) {
global $require_email_ver, $aid;
if ($aid == "") {
$aid = get_aid($sess);
}
$today = date("Y-m-d");
$db = new ps_DB;
$q = "INSERT INTO account SET
orig_date = '$today',
start_date = '$today',
account_affiliate_id='$aid',
account_email ='" . sql_string_filter($db->lid, $email) . "',
account_password ='" . sql_string_filter($db->lid, $password) . "',
account_name ='" . sql_string_filter($db->lid, $name) . "',
account_title ='" . sql_string_filter($db->lid, $title) . "',
account_company ='" . sql_string_filter($db->lid, $company) . "',
account_address ='" . sql_string_filter($db->lid, $address) . "',
account_city ='" . sql_string_filter($db->lid, $city) . "',
account_state ='" . sql_string_filter($db->lid, $state) . "',
account_zip ='" . sql_string_filter($db->lid, $zip) . "',
account_country ='" . sql_string_filter($db->lid, $country) . "',
account_phone ='" . sql_string_filter($db->lid, $phone) . "',
account_username ='" . sql_string_filter($db->lid, $username) . "',
account_fax ='" . sql_string_filter($db->lid, $fax) . "'";
if ($require_email_ver == "Y") {
$q .= ", account_status = '1'";
}
$db->query($q);
// insert into remote db via api...
global $path;
unset($API_ACTION);
$API_ACTION = 'add_member_account';
include_once ($path . 'auth.api.php');
if(setup("email_1") == Y) {
$db = new ps_DB;
$q = "SELECT account_id FROM account WHERE account_email = '" . sql_string_filter($db->lid, $email) . "'";
$db->query($q);
$db->next_record();
send_mail("1",$db->f("account_id"),"","","");
}
if(setup("email_11") == Y) {
$db = new ps_DB;
$q = "SELECT account_id FROM account WHERE account_email = '" . sql_string_filter($db->lid, $email) . "'";
$db->query($q);
$db->next_record();
send_mail("11",$db->f("account_id"),"","","");
}
if ($require_email_ver == "Y") {
$db = new ps_DB;
$q = "SELECT account_name,account_id,account_email,account_password FROM account WHERE account_email = '" . sql_string_filter($db->lid, $email) . "'";
$db->query($q);
$db->next_record();
$name = $db->f("account_name");
$account_id = $db->f("account_id");
$md5 = strtoupper(md5($email . '|' . $password . '|' . $account_id . '|' . $name));
$company = setup("company");
$message = "Dear " . $name . ",
This is an automated message from " . $company . " to inform you that futher action is required in order to activate your new account.
Please visit " . setup("url") . "?page=activate&v=" . $md5 . " to verify this email address and complete your account activation.
If you did not register at our site for this account, please simply ignore this email, as no futher action on your part will be required.
Thank you!
" . $company . "
";
$company_name = setup("company");
$company_email= setup("email");
$headers = "From: " . setup("company") . " <" . $company_email . ">\n";
$headers .= "X-Sender: <" . $company_email . ">\n";
$headers .= "Return-Path: <" . $company_email . ">\n";
//echo "
$message
";
mail($email,$company_name . " Account Activation Instructions",$message,$headers);
}
global $message;
$message = "Thank you, your account has been added, but is currently inactive. You must check the email address you provided during the registration process for activation instructions.";
return "Thank you, your account has been added, but is currently inactive. You must check the email address you provided during the registration process for activation instructions.";
}
// GET THE AFFILIATE ID FROM THE LOGIN RECORD...
function get_aid($sess) {
$db = new ps_DB;
$q = "SELECT login_affiliate_id FROM login WHERE login_id='" . sql_string_filter($db->lid, $sess) . "'";
$db->query($q);
$db->next_record();
$ret = $db->f("login_affiliate_id");
return $ret;
}
// SHOW LIST OF CATEGORIES
function show_category_menu($id) {
$db = new ps_DB;
$q = "SELECT * FROM category ORDER BY sort,name ASC";
$db->query($q);
echo "";
}
// SHOW LIST OF DEPENDANCY MEMBERSHIPS
function show_dependancy_menu($id) {
$db = new ps_DB;
$q = "SELECT * FROM membership ORDER BY membership_name ASC";
$db->query($q);
echo "";
}
// SHOW LIST OF TRIAL MEMBERSHIPS
function show_trial_menu($id) {
$db = new ps_DB;
$q = "SELECT * FROM membership ORDER BY membership_name ASC";
$db->query($q);
echo "";
}
// SHOW LIST OF COUNTRIES
function show_country_menu() {
$default = "840";
$db = new ps_DB;
$q = "SELECT country_id,country_name FROM country ORDER BY 'country_name'";
$db->query($q);
echo "";
}
// SHOW CLIENTS DUE SUBSCRIPTIONS
function show_due_subscriptions($id) {
$db = new ps_DB;
$q = "SELECT domain_id,domain_host_id FROM domains WHERE domain_account_id ='$id'";
$db->query($q);
echo "