"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 ""; echo ''; while ($db->next_record()) { $dbn = $db->f("country_name"); $dbi = $db->f("country_id"); $title = $dbn; echo ""; } echo ""; } // SHOW LIST OF COUNTRIES function show_country_menu2($country) { if ($country == '') { $country = '840'; } $db = new ps_DB; $q = "SELECT country_id,country_name FROM country ORDER BY 'country_name'"; $db->query($q); echo ""; } //VALIDATE EMAIL function validate_email($email) { if(preg_match("/^.+@.+\\..+$/", $email)) { $ret="Y"; } else { $ret="N"; } return $ret; } //VALIDATE EMAIL function validate_email_domain($email) { global $path; include($path . "block_email.php"); for($i=0; $i <= count($block_email); $i++) { if($block_email[$i] != "") { $this_email = $block_email[$i] . '$'; if (preg_match("/($this_email)/i",$email)) { // email domain is blocked! return "N"; } } } return "Y"; } // SHOW ACCEPTABLE TLD'S function show_tld_list() { $q = "SELECT domain_type_extension FROM domain_type WHERE domain_type_status = 'Y' ORDER BY 'domain_type_extension'"; $db = new ps_DB; $db->query($q); $ret=""; while ($db->next_record()){ $ret.=" ."; $ret.= $db->f("domain_type_extension"); $ret.="
"; } return $ret; } // GET LOGGED IN USERS ACCOUNT ID function get_account_id($session_id) { $db = new ps_DB; $q = "SELECT login_member_id FROM login WHERE login_id = '$session_id'"; $db->query($q); $db->next_record(); $ret = $db->f("login_member_id"); return $ret; } // GET ACCOUNT NAME BY ID function get_account_name($id) { $db = new ps_DB; $q = "SELECT account_name FROM account WHERE account_id='$id'"; $db->query($q); $db->next_record(); $ret = $db->f("account_name"); return $ret; } // GET ACCOUNT NAME BY ID function get_country_name($id) { $db = new ps_DB; $q = "SELECT country_name FROM country WHERE country_id='$id'"; $db->query($q); $db->next_record(); return $db->f("country_name"); } // ATTEMPT TO LOG THE USER IN function login_user($email,$password,$session_id) { $today = mktime(); $db = new ps_DB; $q = "SELECT account_id,account_username,account_email,account_password,account_status FROM account WHERE (account_username = '" . sql_string_filter($db->lid, $email) . "' OR account_email = '" . sql_string_filter($db->lid, $email) . "')"; $db->query($q); $db->next_record(); $account_id = $db->f("account_id"); $account_status = $db->f("account_status"); $account_email = $db->f("account_email"); $account_username = $db->f("account_username"); $account_pw = $db->f("account_password"); // CHECK CREDENTIALS // USERNAME CAN BE EMAIL OR USERNAME. MAKE SURE IT'S NOT BLANK AND IS EITHER ACCOUNT_EMAIL OR ACCOUNT_USERNAME if ((($email !="") and (($email == $account_username) || ($email == $account_email))) AND // PASSWORD CAN BE PLAIN TEXT OR ENCRYPTED. MAKE SURE IT'S NOT BLANK AND IS CORRECT (($password !="") and (($password == $account_pw) || ($password == md5($account_pw)) || (md5($password) == $account_pw)))) { // Validated user login information, now lets be sure their account has been validated... if($account_status == "1") { // Oops, user needs to follow the instructions in the account activation email! return "You have entered the correct username and password, but your account has not been activated yet. Please check your email for instructions on activating your account."; } else { // User is authenticated and logged in! delete_old_logins($account_id,$session_id); // CREATE THE NEW, UPDATED SESSION RECORD $db = new ps_DB; $q = "INSERT INTO login SET login_id ='" . sql_string_filter($db->lid, $session_id) . "', login_date ='$today', login_logged ='Y', login_member_id ='$account_id'"; $db->query($q); $subs = new ps_DB; $subsq = "SELECT domain_host_id, domain_id FROM domains WHERE domain_account_id = '" . sql_string_filter($subs->lid, $account_id) . "' AND domain_host_status = '1'"; $subs->query($subsq); //Add premium & standard processing here //////////////////////////////////// // Check Membership table to find subscription numbers // Determine if member is standard, premium or trial $subs->next_record(); $sub_number = $subs->f("domain_host_id"); $domain_id = $subs->f("domain_id"); if ($sub_number == 54) { $member_level = '3'; $member_sub_level = 'A'; }elseif (($sub_number == 36) || ($sub_number == 38) || ($sub_number == 43) || ($sub_number == 45) || ($sub_number == 31)) { $member_level = '2'; $member_sub_level = 'P'; } elseif (($sub_number == 4) || ($sub_number == 33) || ($sub_number == 35) || ($sub_number == 37) || ($sub_number== 42) || ($sub_number== 46) || ($sub_number== 47) || ($sub_number== 48) || ($sub_number == 51) || ($sub_number == 53) || ($sub_number == 55)){ $member_level = '1'; $member_sub_level = 'S'; } else { $member_level = '0'; $member_sub_level = 'N'; } $status = get_billing_status_access($domain_id); if ($status) { create_cookie($member_sub_level); create_member_cookie($account_id); echo header("refresh: 0"); exit(); } return "You are now logged in to your account."; } } else { // Unable to verify username and password! return "Incorrect username or password submitted. Please double check the login details you are submitting."; } } function login_user_new($email,$password,$session_id) { $today = mktime(); $db = new ps_DB; $q = "SELECT account_id,account_username,account_email,account_password,account_status FROM account WHERE (account_username = '" . sql_string_filter($db->lid, $email) . "' OR account_email = '" . sql_string_filter($db->lid, $email) . "')"; $db->query($q); $db->next_record(); $account_id = $db->f("account_id"); $account_status = $db->f("account_status"); $account_email = $db->f("account_email"); $account_username = $db->f("account_username"); $account_pw = $db->f("account_password"); // CHECK CREDENTIALS // USERNAME CAN BE EMAIL OR USERNAME. MAKE SURE IT'S NOT BLANK AND IS EITHER ACCOUNT_EMAIL OR ACCOUNT_USERNAME if ((($email !="") and (($email == $account_username) || ($email == $account_email))) AND // PASSWORD CAN BE PLAIN TEXT OR ENCRYPTED. MAKE SURE IT'S NOT BLANK AND IS CORRECT (($password !="") and (($password == $account_pw) || ($password == md5($account_pw)) || (md5($password) == $account_pw)))) { // Validated user login information, now lets be sure their account has been validated... if($account_status == "1") { // Oops, user needs to follow the instructions in the account activation email! $ret[0] = '5'; } else { // User is authenticated and logged in! delete_old_logins($account_id,$session_id); // CREATE THE NEW, UPDATED SESSION RECORD $post = new ps_DB; $q = "INSERT INTO login SET login_id ='" . sql_string_filter($db->lid, $session_id) . "', login_date ='$today', login_logged ='Y', login_member_id ='$account_id'"; $post->query($q); $ret[0] = '1'; $ret[1] = $db->f("account_id"); $ret[2] = $db->f("account_email"); $ret[3] = $db->f("account_username"); $ret[4] = $db->f("account_password"); } } else { // Unable to verify username and password! $ret[0] = '0'; } return $ret; } // ATTEMPT TO LOG THE USER IN function activate_account($email,$password,$session_id,$v) { $today = mktime(); global $aid; if ($aid=="") { $aid = get_aid($session_id); } $db = new ps_DB; $q = "SELECT account_id,account_email,account_password,account_status,account_name FROM account WHERE account_email = '" . sql_string_filter($db->lid, $email) . "'"; $db->query($q); $db->next_record(); $account_id = $db->f("account_id"); $account_status = $db->f("account_status"); $account_email = $db->f("account_email"); $account_pw = $db->f("account_password"); $account_name = $db->f("account_name"); if (($email == $account_email) && ($password == $account_pw)) { // Validated user login information, now lets be sure their account has been validated... // Validate the md5 string... $md5 = strtoupper(md5($email . '|' . $password . '|' . $account_id . '|' . $account_name)); if($md5 != $v) { // Oops, does't appear to have the correct hash sent, probably they faked it! return "You have entered the correct username and password, but your account has not been activated yet. The activation code you entered is invalid. Please review the account activation email again to be sure it was entered correctly."; } else { // User is authenticated and logged in! delete_old_logins($account_id,$session_id); // CREATE THE NEW, UPDATED SESSION RECORD $db = new ps_DB; $q = "INSERT INTO login SET login_id ='" . sql_string_filter($db->lid, $session_id) . "', login_date ='$today', login_logged ='Y', login_affiliate_id ='$aid', login_member_id ='$account_id'"; $db->query($q); // UPDATE THE ACCOUNT RECORD $db = new ps_DB; $q = "UPDATE account SET account_status = '0' WHERE account_id = '$account_id'"; $db->query($q); return "Your account has been activated, and you are now logged in to your account."; } } else { // Unable to verify username and password! return "Incorrect username or password submitted. Please double check the login details you are submitting."; } } // DELETE OLD LOGIN SESSIONS function delete_old_logins($account_id,$session_id) { $db = new ps_DB; $q = "DELETE FROM login WHERE login_member_id='" . sql_string_filter($db->lid, $account_id) . "' OR login_id='" . sql_string_filter($db->lid, $session_id) . "'"; $db->query($q); return true; } // SEE IF THE CURRENT SESSION IS LOGGED IN function is_logged($session_id) { $db = new ps_DB; $q = "SELECT * FROM login WHERE login_id = '" . sql_string_filter($db->lid, $session_id) . "'"; $db->query($q); $db->next_record(); $ret = $db->f("login_logged"); if ($ret == "Y") { return "Y"; } else { return "N"; } } // GENERATE A NEW SESSION function generate_session_id ($aid) { ///global $user_ip; $user_ip = $_SERVER['REMOTE_ADDR']; $today=date("Y-m-d"); $sess = md5($user_ip.''.microtime()); $db = new ps_DB; $q = "INSERT INTO login SET login_id = '$sess', login_logged = 'N', login_date = '$today'"; $db->query($q); return ($sess); } function validate_session($session_id) { $db = new ps_DB; $q = "SELECT * FROM login WHERE login_id = '" . sql_string_filter($db->lid, $session_id) . "'"; $db->query($q); $db->next_record(); $logg = $db->f("login_logged"); $date= $db->f("login_date"); // CHECK IF EXISTS... if($db->num_rows() < 1) { return FALSE; } else { //CHECK IF LOGGED... if($logg=="N") { return TRUE; } else { // CHECK THAT LOGIN HASN'T EXPIRED.... (Greater than 30 minutes) if($date > (mktime()-60*30)) { // UPDATE LOGIN DATE $today = mktime(); $db = new ps_DB; $q = "UPDATE login SET login_date = '$today' WHERE login_id='" . sql_string_filter($db->lid, $session_id) . "'"; $db->query($q); // RETURN OK return TRUE; } else { // LOGOUT logout($session_id); // RETURN TRUE return TRUE; } } } } function logout($session_id) { $db = new ps_DB; $q = "UPDATE login SET login_logged = 'N' WHERE login_id = '" . sql_string_filter($db->lid, $session_id) . "'"; $db->query($q); } // SHOW HOSTING OPTIONS & PRICES MENU function show_hosting_menu($domain,$count,$id) { $db = new ps_DB; $q = "SELECT session_2 FROM sessions WHERE session_id = '$id'"; $db->query($q); $db->next_record(); $default = $db->f("session_2"); $db = new ps_DB; $q = "SELECT membership_setup,membership_name,membership_price,membership_id FROM membership WHERE membership_active='Y' ORDER BY 'membership_id'"; $db->query($q); $style="style= \"font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 9px; font-weight: normal; color: #000000; background-color: #F5F5F5\""; echo ""; return $ret; } // SHOW DOMAIN OPTIONS & PRICES MENU function show_domain_menu($domain,$count,$id) { $db = new ps_DB; $q = "SELECT * FROM sessions WHERE session_id = '$id'"; $db->query($q); $db->next_record(); $default = $db->f("session_1"); $db = new ps_DB; $q = "SELECT * FROM domain_type WHERE domain_type_extension = '$tld'"; $db->query($q); $db->next_record(); $i=1; $style="style= \"font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 9px; font-weight: bold; color: #000066; background-color: #CCCCCC\""; echo ""; return $ret; } // SHOW DOMAIN OPTIONS & PRICES MENU function show_domain_menu_2($domain) { $db = new ps_DB; $q = "SELECT * FROM sessions WHERE session_id = '$id'"; $db->query($q); $db->next_record(); $default = $db->f("session_1"); $db = new ps_DB; $q = "SELECT * FROM domain_type WHERE domain_type_extension = '$tld'"; $db->query($q); $db->next_record(); $i=1; echo ""; return $ret; } // GET TOTAL SETUP FEES function show_setup_cost($ip) { global $session_id; $db = new ps_DB; $q = "SELECT session_membership_id FROM sessions WHERE session_ip = '$ip' OR session_domain = '$session_id'"; $db->query($q); $total=0; while ($db->next_record()) { $membership_id = $db->f("session_membership_id"); $cost = get_setup_cost($membership_id); $total = $cost+$total; } return $total; } // GET TOTAL SETUP FEES PART 2 function get_setup_cost($membership_id) { $db = new ps_DB; $q = "SELECT membership_setup FROM membership WHERE membership_id = '$membership_id'"; $db->query($q); $db->next_record(); $ret = $db->f("membership_setup"); return $ret; } // GET MEMEBERSHIP NAME function show_hosting_name($user_ip) { global $session_id; $db = new ps_DB; $q = "SELECT session_membership_id FROM sessions WHERE session_ip = '$user_ip' OR session_domain = '$session_id'"; $db->query($q); $total=0; while ($db->next_record()) { $membership_id = $db->f("session_membership_id"); $name = get_hosting_name($membership_id); } return $name; } // GET TOTAL HOSTING COST function get_hosting_name($membership_id) { $db = new ps_DB; $q = "SELECT membership_name FROM membership WHERE membership_id = '$membership_id'"; $db->query($q); $db->next_record(); $ret = $db->f("membership_name"); return $ret; } // GET TOTAL HOSTING COST function show_hosting_cost($ip) { global $session_id; $db = new ps_DB; $q = "SELECT session_membership_id FROM sessions WHERE session_ip = '$ip' OR session_domain = '$session_id'"; $db->query($q); $total=0; while ($db->next_record()) { $membership_id = $db->f("session_membership_id"); $cost = get_hosting_cost($membership_id); $total = $cost+$total; } return $total; } // GET TOTAL HOSTING COST function get_hosting_cost($membership_id) { $db = new ps_DB; $q = "SELECT membership_price FROM membership WHERE membership_id = '$membership_id'"; $db->query($q); $db->next_record(); $ret = $db->f("membership_price"); return $ret; } // GET YEARLY REGISTRATION COST function get_yearly_cost($years,$tld) { $db = new ps_DB; $q = "SELECT domain_type_p$years FROM domain_type WHERE domain_type_extension = '$tld'"; $db->query($q); $db->next_record(); $ret = $db->f("domain_type_p$years"); return $ret; } // UPDATE THE CART & CART OPTIONS function cart_update_domain($id,$length,$hosting) { $db = new ps_DB; $q = "UPDATE sessions SET session_1 = '$length', session_2 = '$hosting' WHERE session_id = '$id'"; $db->query($q); return true; } // REMOVE A DOMAIN FROM THE CART function cart_remove_domain($id) { $db = new ps_DB; $q = "DELETE FROM sessions WHERE session_id='$id'"; $db->query($q); } // SETUP A NEW SESSION BASED ON USERS IP function cart_add($ip,$membership_id) { global $session_id; $db = new ps_DB; // $q = "SELECT membership_id FROM membership WHERE membership_id='$membership_id' AND membership_active ='Y'"; $q = "SELECT membership_id FROM membership WHERE membership_id='$membership_id'"; $db->query($q); $db->next_record(); if ($db->num_rows() == 0) { return "Membership ID: " . $membership_id . " does not exist or is not an active membership."; } else { $db = new ps_DB; // $q = "SELECT session_id FROM sessions WHERE session_ip='$ip' AND session_membership_id='$membership_id'"; $q = "SELECT session_id FROM sessions WHERE session_ip='$ip'"; $db->query($q); $db->next_record(); if ($db->num_rows() >= "1") { //return "Membership ID: " . $membership_id . " is already in your cart."; $db = new ps_DB; $q = "UPDATE sessions SET session_membership_id = '$membership_id', session_ip = '$ip', session_affiliate_id = '$affiliate_id' WHERE session_domain = '$session_id' "; $db->query($q); } else { $db = new ps_DB; $q = "INSERT INTO sessions SET session_membership_id = '$membership_id', session_ip = '$ip', session_affiliate_id = '$affiliate_id', session_domain = '$session_id'"; $db->query($q); } } } // DETERMINE IF CART IS EMPTY OR NOT function cart_mini($ip) { global $session_id; $db = new ps_DB; $q = "SELECT session_id FROM sessions WHERE session_ip='$ip' OR session_domain = '$session_id'"; $db->query($q); $num = $db->num_rows(); return $num; } // GET THE NAME OF A MEMBERSHIP function get_membership_name($id) { $db = new ps_DB; $q = "SELECT membership_name FROM membership WHERE membership_id='$id'"; $db->query($q); $db->next_record(); $name = $db->f("membership_name"); return $name; } // Check dependancy issues: function check_dependancy($session_id) { check_dependancy_trial($session_id); // loop through cart contents $db = new ps_DB; $q = "SELECT session_membership_id FROM sessions WHERE session_domain = '$session_id'"; $db->query($q); while($db->next_record()) { // check each membership in cart to see if it has dependancy requirements $id = $db->f("session_membership_id"); $dbm = new ps_DB; $q = "SELECT membership_name,dependancy FROM membership WHERE membership_id = '$id'"; $dbm->query($q); $dbm->next_record(); { // check each membership for dependancy requirements $name = $dbm->f("membership_name"); $de = $dbm->f("dependancy"); if($de > 0) { // see if the dependant item is already in the cart $dbm1 = new ps_DB; $q = "SELECT session_membership_id FROM sessions WHERE session_domain = '$session_id' AND session_membership_id = '$de'"; $dbm1->query($q); if($dbm1->num_rows() == 0) { // if not, check to see if it is in user's account, and that it is not pending/voided $account_id = get_account_id($session_id); $dbm2 = new ps_DB; $q = "SELECT domain_id, domain_host_status FROM domains WHERE domain_account_id = '$account_id' AND domain_host_id = '$de' "; //AND domain_host_status= '1' $dbm2->query($q); $dbm2->next_record(); $domain_id = $dbm2->f("domain_id"); $domain_host_status = $dbm2->f("domain_host_status"); //echo $domain_host_status; //$status = get_billing_status($domain_id); $status = get_billing_status_access($domain_id); if ($status != '1') { $overdue = 'Y';} //echo $status; if($domain_host_status == 0 || $overdue == "Y") { // if not in cart, or active in account, add the dependant to the cart global $user_ip, $aid; $db3 = new ps_DB; $q = "INSERT INTO sessions SET session_membership_id = '$de', session_ip = '$user_ip', session_affiliate_id = '$aid', session_domain = '$session_id'"; $db3->query($q); // notify the user of the dependancy issue $dbm4 = new ps_DB; $q = "SELECT membership_name,dependancy FROM membership WHERE membership_id = '$de'"; $dbm4->query($q); $dbm4->next_record(); $name_de = $dbm4->f("membership_name"); echo "
> Please Note:

We have added $name_de to your cart because it is required in order to purchase $name.

If you do not wish to order both products, it is fine to delete $name from your cart below, before you purchase.


"; } } } } } } // Check dependancy issues: function check_dependancy_trial($session_id) { $account_id = get_account_id($session_id); // loop through cart contents $db = new ps_DB; $q = "SELECT session_membership_id FROM sessions WHERE session_domain = '$session_id'"; $db->query($q); while($db->next_record()) { // check each membership in cart to see if the user has already ordered it or the permanent one $id = $db->f("session_membership_id"); $dbm = new ps_DB; $q = "SELECT membership_name,trial,trial_plan,membership_id FROM membership WHERE membership_id = '$id'"; $dbm->query($q); $dbm->next_record(); { // check each membership for dependancy requirements $name = $dbm->f("membership_name"); $trial_plan = $dbm->f("trial_plan"); $trial = $dbm->f("trial"); $membership_id = $dbm->f("membership_id"); if($trial == 'Y') { // see if the user already has trial_plan or membership_id in their account... $dbm1 = new ps_DB; $q = "SELECT domain_id FROM domains WHERE (domain_host_id = '$membership_id' OR domain_host_id = '$trial_plan') AND domain_account_id = '$account_id'"; $dbm1->query($q); if($dbm1->num_rows() > 0) { // Delete it from the cart! $dbm2 = new ps_DB; $q = "DELETE FROM sessions WHERE session_membership_id = '$membership_id' OR session_membership_id = '$trial_plan'"; $dbm2->query($q); // alert the user... echo "
> Please Note:

$name has been removed from your cart because you have already subscribed to this trial, and cannot do so again.


"; } } } } } //ADD ACCOUNT function add_account($f) { global $path; $today=date("Y-m-d"); if ($f[group_record]!='1'){ // Verify email is not currently used if($f[account_email] != ''){ if(validate_email_unused($f[account_email]) == 'N'){ return "
Account could not be created, email already exists in the billing database!"; } } // Verify email is not currently used if($f[account_username] != ''){ if(!validate_username_unused($f[account_username])){ return "
Account could not be created, username already exists in the billing database!"; }} // Verify username/email is not currently used in one of the API databases //$arr = DA_API_VALIDATION($f[account_username],$f[account_email]); //if(!$arr[email]) // return "
Account could not be created, email already exists in our system!"; //if(!$arr[username]) // return "
Account could not be created, username already exists in our system!"; } // get the country if($f[account_country] == "") { $country = $f[country]; } else { $country = $f[acount_country]; } //if (!isset($f[status]) || $f[status] == '') { $status = '0'; } else { $status = $f[status]; } $member_number = next_member_number(); // Insert the record $db = new ps_DB; $q = "INSERT INTO account SET orig_date = '$today', start_date = '$today', account_username= '" . sql_string_filter($db->lid, $f[account_username]) . "', account_password= '" . sql_string_filter($db->lid, $f[account_password]) . "', account_email = '" . sql_string_filter($db->lid, $f[account_email]) . "', account_name = '" . sql_string_filter($db->lid, $f[account_name]) . "', account_title = '" . sql_string_filter($db->lid, $f[account_title]) . "', account_company = '" . sql_string_filter($db->lid, $f[account_company]) . "', account_address = '" . sql_string_filter($db->lid, $f[account_address]) . "', account_city = '" . sql_string_filter($db->lid, $f[account_city]) . "', account_state = '" . sql_string_filter($db->lid, $f[account_state]) . "', account_zip = '" . sql_string_filter($db->lid, $f[account_zip]) . "', account_country = '" . sql_string_filter($db->lid, $country) . "', account_phone = '" . sql_string_filter($db->lid, $f[account_phone]) . "', account_status = '" . sql_string_filter($db->lid, $f[status]) . "', account_fax = '" . sql_string_filter($db->lid, $f[account_fax]) . "', member_number = '" . sql_string_filter($db->lid, $member_number) . "', groupid = '" . sql_string_filter($db->lid, $f[groupid]) . "', group_master_record = '" . sql_string_filter($db->lid, $f[group_record]) . "', opt_out ='" . sql_string_filter($db->lid, $f[opt_out]) . "'"; $db->query($q); //status ='" . sql_string_filter($db->lid, $status) . "', //update contacts database $name = explode(' ',$f[account_name]); if ($name[0] != '') { $first_name = $name[0]; } if ($name[1] != '') { $last_name = $name[1]; } if ($name[2] != '') { $last_name = $name[1] .' '.$name[2]; } if ($name[3] != '') { $last_name = $name[1] .' '.$name[2].' '.$name[3]; } $dba = new ps_DB; $qa = "INSERT INTO contacts SET add_date = '$today', email ='" . sql_string_filter($dba->lid, $f[account_email]) . "', source ='accounts', first_name ='" . sql_string_filter($dba->lid, $first_name) . "', last_name ='" . sql_string_filter($dba->lid, $last_name) . "', title ='" . sql_string_filter($dba->lid, $f[account_title]) . "', company ='" . sql_string_filter($dba->lid, $f[account_company]) . "', address ='" . sql_string_filter($dba->lid, $f[account_address]) . "', city ='" . sql_string_filter($dba->lid, $f[account_city]) . "', state ='" . sql_string_filter($dba->lid, $f[account_state]) . "', zip ='" . sql_string_filter($dba->lid, $f[account_zip]) . "', country ='" . sql_string_filter($dba->lid, $country) . "', phone ='" . sql_string_filter($dba->lid, $f[account_phone]) . "'"; $dba->query($qa); // determine if any external database update functions need run: unset($API_ACTION); $API_ACTION ='add_account'; include_once($path . 'auth.api.php'); return "Account was added to the database!"; } // ADMIN UPDATE ACCOUNT function update_account($f) { global $path; $DO_API = false; $db = new ps_DB; $q = "SELECT account_email,account_username,account_password,group_master_record FROM account WHERE account_id='" . sql_string_filter($db->lid, $f[account_id]) . "'"; $db->query($q); $db->next_record(); $old_email = trim($db->f("account_email")); $new_email = trim($f['account_email']); $old_password = $db->f("account_password"); $old_username = $db->f("account_username"); $account_id = $f[account_id]; $group_record = $db->f("group_master_record"); if ($group_record != '1') { // check if the email if(($old_email != stripslashes($new_email)) || ($new_email=="")) { // validate that the email is not used. return message if so if ((validate_email_unused($new_email) == 'N') || ($new_email=="")) return "
Account could not be updated, email was left blank or already exists in the database!"; } // check if password has changed if($old_password != $f[account_password]) { // validate the password is not blank //if(!eregi("^[_a-zA-Z0-9-]{4,}$",$f[account_password])) //if($f[account_password] != '') // { // return "
Account could not be updated, password was left blank, is less than 4 characters, or includes illegal characters!"; //} //else // { // set the AUTH update to take place $DO_API = true; //} } // check if password has changed if($old_username != stripslashes($f[account_username])) { // validate that the email is not used. return message if so $admin_login = setup("login"); if((((!validate_username_unused($f[account_username])) || ($f[account_username] == "") || ($f[account_username] == $admin_login)))) { // return the error message return "
Account could not be updated, username was left blank or already exists in the database!"; } else { // set the AUTH update to take place $DO_API = true; } } } // 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.... if($DO_API) { // 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, $f[account_id]) . "' and domain_host_status='1'"; $db->query($q); while($db->next_record()) { // remove this login from the specified location $f[domain_id] = $db->f("domain_id"); unset($API_ACTION); $API_ACTION ='auth_deactivate'; include($path . 'auth.api.php'); } } $db = new ps_DB; $q = "UPDATE account SET account_username ='" . sql_string_filter($db->lid, $f[account_username]) . "', account_password ='" . sql_string_filter($db->lid, $f[account_password]) . "', account_email ='" . sql_string_filter($db->lid, $new_email) . "', account_name ='" . sql_string_filter($db->lid, $f[account_name]) . "', account_title ='" . sql_string_filter($db->lid, $f[account_title]) . "', account_company ='" . sql_string_filter($db->lid, $f[account_company]) . "', account_address ='" . sql_string_filter($db->lid, $f[account_address]) . "', account_city ='" . sql_string_filter($db->lid, $f[account_city]) . "', account_state ='" . sql_string_filter($db->lid, $f[account_state]) . "', account_zip ='" . sql_string_filter($db->lid, $f[account_zip]) . "', account_country ='" . sql_string_filter($db->lid, $f[country]) . "', account_phone ='" . sql_string_filter($db->lid, $f[account_phone]) . "', member_number ='" . sql_string_filter($db->lid, $f[member_number]) . "', account_status ='" . sql_string_filter($db->lid, $f[account_status]) . "', account_fax ='" . sql_string_filter($db->lid, $f[account_fax]) . "',"; if ($f[group_membership] != '') { //$q .= " group_membership ='" . sql_string_filter($db->lid, $f[group_membership]) . "',"; $q .= " account_membership_id ='" . sql_string_filter($db->lid, $f[group_membership]) . "',"; $q .= " group_member_type ='" . sql_string_filter($db->lid, $f[group_member_type]) . "',"; //$group_member_type= $db->f("group_member_type"); } if ($group_record == '1') { $q .= " group_status ='" . sql_string_filter($db->lid, $f[group_status]) . "',"; if ($f[group_status] == '0') { $q .= " group_header ='0',"; } else { $q .= " group_header ='" . sql_string_filter($db->lid, $f[group_header]) . "',"; } } if ($f[galleryid] != '') { $q .= " galleryid ='" . sql_string_filter($db->lid, $f[galleryid]) . "',"; } if ($f[digest] != '') { $q .= " digest ='" . sql_string_filter($db->lid, $f[digest]) . "'"; } $q .= " email_opt_out ='" . sql_string_filter($db->lid, $f[estatus]) . "' WHERE account_id ='" . sql_string_filter($db->lid, $f[account_id]) . "'"; $db->query($q); //update contacts database $name = explode(' ',$f[account_name]); if ($name[0] != '') { $first_name = $name[0]; } if ($name[1] != '') { $last_name = $name[1]; } if ($name[2] != '') { $last_name = $name[1] .' '.$name[2]; } if ($name[3] != '') { $last_name = $name[1] .' '.$name[2].' '.$name[3]; } $dba = new ps_DB; $qa = "UPDATE contacts SET email ='" . sql_string_filter($dba->lid, $new_email) . "', source ='accounts', first_name ='" . sql_string_filter($dba->lid, $first_name) . "', last_name ='" . sql_string_filter($dba->lid, $last_name) . "', title ='" . sql_string_filter($dba->lid, $f[account_title]) . "', company ='" . sql_string_filter($dba->lid, $f[account_company]) . "', address ='" . sql_string_filter($dba->lid, $f[account_address]) . "', city ='" . sql_string_filter($dba->lid, $f[account_city]) . "', state ='" . sql_string_filter($dba->lid, $f[account_state]) . "', zip ='" . sql_string_filter($dba->lid, $f[account_zip]) . "', country ='" . sql_string_filter($dba->lid, $country) . "', phone ='" . sql_string_filter($dba->lid, $f[account_phone]) . "', opt_out ='" . sql_string_filter($dba->lid, $f[estatus]) . "', digest ='" . sql_string_filter($dba->lid, $f[digest]) . "' WHERE source = 'accounts' AND email LIKE'" . sql_string_filter($dba->lid, $old_email) . "'"; $dba->query($qa); if ($f[estatus] == '1') { $dbb = new ps_DB; $qb = "UPDATE event_merge SET email_optout ='" . sql_string_filter($dbb->lid, $f[estatus]) . "' WHERE customer_email LIKE'" . sql_string_filter($dbb->lid, $old_email) . "'"; $dbb->query($qb); } // Send this account update to any external databases: unset($API_ACTION); $API_ACTION ='update_account'; include($path . 'auth.api.php'); if($DO_API) { // Update the authentication for this account unset($API_ACTION); $API_ACTION ='auth_account'; include ($path . 'auth.api.php'); } } // UPDATE A CREDIT RECORD function credits_edit($f) { $db = new ps_DB; $q = "UPDATE credit SET credit_status = '$f[status]', credit_amount = '$f[amount]', credit_amount_applied = '$f[amount_applied]', credit_notes = '$f[notes]' WHERE credit_id='$f[id]'"; $db->query($q); return "The credit was updated."; } // DELET A CREDIT RECORD function credit_delete($id) { $db = new ps_DB; $q = "DELETE FROM credit WHERE credit_id='$id'"; $db->query($q); return "The credit was deleted."; } // UPDATE A CREDIT RECORD function member_update_account($path,$account_password,$account_email,$account_name,$account_company,$account_address,$account_city,$account_state,$account_zip,$account_country,$account_fax,$account_phone,$account_membership_id,$account_status, $account_pmt_type,$account_acct_no,$account_acct_exp,$account_check_no,$account_check_rt,$account_id) { $db = new ps_DB; $q = "UPDATE account SET account_password='$account_password', account_email='$account_email', account_name='$account_name', account_company='$account_company', account_address='$account_address', account_city='$account_city', account_state='$account_state', account_zip='$account_zip', account_country='$account_country', account_phone='$account_phone', account_fax='$account_fax' WHERE account_email='$account_email'"; $db->query($q); // update this account $f[account_id] = $account_id; global $path; unset($API_ACTION); $API_ACTION ='auth_account'; include ($path . 'auth.api.php'); return "Thank you, your account has been updated!"; } function domains_edit($f) { $db = new ps_DB; $q = "UPDATE domains SET domain_host_status ='$f[status]', domain_host_last_billed ='$f[last_billed]', domain_host_periods ='$f[periods]' WHERE domain_id ='$f[domain_id]'"; $db->query($q); // send this to the authentication api to update this specific domain record. (subscription) global $path; unset($API_ACTION); $API_ACTION ='auth_domain'; include ($path . 'auth.api.php'); return "Subscription $f[domain_id] has been updated."; } function affiliate_edit($f) { $db = new ps_DB; $q = "UPDATE affiliate SET affiliate_type = '$f[type]', affiliate_name = '$f[name]', affiliate_address='$f[address]', affiliate_city= '$f[city]', affiliate_state= '$f[state]', affiliate_zip= '$f[zip]', payout_acct = '$f[payout_acct]', affiliate_country='$f[country]' WHERE affiliate_id ='$f[affiliate_id]'"; $db->query($q); return "Affiliate has been updated"; } function affiliate_add($f) { $date = date("Y-m-d"); $db = new ps_DB; $q = "SELECT * FROM account WHERE account_id = '$f[account_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[country] = $db->f("account_country"); $f[zip] = $db->f("account_zip"); $db = new ps_DB; $q = "INSERT INTO affiliate SET affiliate_account_id='$f[account_id]', affiliate_date = '$date', affiliate_type = '$f[type]', affiliate_name = '$f[name]', affiliate_address='$f[address]', affiliate_city= '$f[city]', affiliate_state= '$f[state]', affiliate_zip= '$f[zip]', affiliate_country='$f[country]' "; $db->query($q); echo "Affiliate has been added"; } //DELETE ACCOUNT function delete_account($account_id) { $db = new ps_DB; $q = "DELETE FROM account WHERE account_id='$account_id'"; $db->query($q); $db = new ps_DB; $q = "DELETE FROM affiliate WHERE affiliate_account_id='$account_id'"; $db->query($q); $db = new ps_DB; $q = "DELETE FROM orders WHERE order_account_id='$account_id'"; $db->query($q); $db = new ps_DB; $q = "DELETE FROM domains WHERE domain_account_id='$account_id'"; $db->query($q); $db = new ps_DB; $q = "DELETE FROM credit WHERE credit_account_id='$account_id'"; $db->query($q); echo "Deleted Account No. $account_id"; } //DELETE ATTRIBUTE function delete_attribute($id) { $db = new ps_DB; $q = "DELETE FROM attributes WHERE attribute_id='$id'"; $db->query($q); return "Deleted Attribute No. $id"; } //ADD MEMBERSHIP function add_membership($f) { $db = new ps_DB; $q = "INSERT INTO membership SET membership_directory_id = '$f[directory_id]', membership_name = '$f[membership_name]', membership_desc = '$f[membership_desc]', membership_price = '$f[membership_price]', membership_recurring = '$f[membership_recurring]', membership_frequency = '$f[membership_frequency]', membership_approval = '$f[membership_approval]', membership_url = '$f[membership_url]', membership_active = '$f[membership_active]', membership_setup = '$f[membership_setup]', membership_periods = '$f[membership_periods]', coupon = '$f[coupon]', coupon_amount = '$f[coupon_amount]', credit = '$f[credit]', credit_amount = '$f[credit_amount]', trial = '$f[trial]', trial_plan = '$f[trial_for]', dependancy = '$f[dependancy]', category = '$f[category]', sort = '$f[sort]'"; $db->query($q); } //UPDATE MEMBERSHIP function update_membership($f) { $db = new ps_DB; $q = "UPDATE membership SET membership_directory_id = '$f[directory_id]', membership_name = '$f[membership_name]', membership_desc = '$f[membership_desc]', membership_price = '$f[membership_price]', membership_recurring = '$f[membership_recurring]', membership_frequency = '$f[membership_frequency]', membership_approval = '$f[membership_approval]', membership_url = '$f[membership_url]', membership_active = '$f[membership_active]', membership_setup = '$f[membership_setup]', membership_periods = '$f[membership_periods]', coupon = '$f[coupon]', coupon_amount = '$f[coupon_amount]', credit = '$f[credit]', credit_amount = '$f[credit_amount]', trial = '$f[trial]', trial_plan = '$f[trial_for]', dependancy = '$f[dependancy]', category = '$f[category]', sort = '$f[sort]' WHERE membership_id='$f[membership_id]'"; $db->query($q); // Update the authentication for all subscriptions associated with this membership global $path; unset($API_ACTION); $API_ACTION ='auth_membership'; include ($path . 'auth.api.php'); } //DELETE MEMBERSHIP function membership_delete($membership_id) { // update all subscriptions to pending $db = new ps_DB; $q = "UPDATE domains SET domain_host_status='0' WHERE domain_host_id='$membership_id'"; $db->query($q); // remove all htaccess, etc $f[membership_id] = $membership_id; global $path; unset($API_ACTION); $API_ACTION = 'auth_membership'; include ($path . 'auth.api.php'); // delete this membership $db = new ps_DB; $q = "DELETE FROM membership WHERE membership_id='$membership_id'"; $db->query($q); // delete all associated subscriptions $db = new ps_DB; $q = "DELETE FROM domains WHERE domain_host_id='$membership_id'"; $db->query($q); } function unhtmlentities ($string) { $trans_tbl = get_html_translation_table (HTML_ENTITIES); $trans_tbl = array_flip ($trans_tbl); return strtr ($string, $trans_tbl); } // UPDATE ADMINISTRATION SETUP OPTIONS function update_administration($f) { $supe = $f[setup_superuser]; $date = setup("aff_pay_2c"); if ($date == "") { $date = date("Y-m-d"); } // ADD SLASHES TO HTML INPUT FIELD $header = unhtmlentities(addslashes($f[header])); $footer = unhtmlentities(addslashes($f[footer])); $faq = unhtmlentities(addslashes($f[faq])); $company_info = unhtmlentities(addslashes($f[company_info])); $contact_info = unhtmlentities(addslashes($f[contact_info])); $acceptable_use = unhtmlentities(addslashes($f[acceptable_use])); $privacy_policy = unhtmlentities(addslashes($f[privacy_policy])); // $curl_path = unhtmlentities(addslashes($f[setup_path2])); $curl_path = $f[setup_path2]; if ($f[acc_aff_1] == "Y") { $acc_aff = "Y "; } else { $acc_aff = "N "; } if ($f[acc_aff_2] == "Y") { $acc_aff .= "Y "; } else { $acc_aff .= "N "; } if ($f[acc_aff_3] == "Y") { $acc_aff .= "Y "; } else { $acc_aff .= "N "; } if ($f[acc_aff_4] == "Y") { $acc_aff .= "Y "; } else { $acc_aff .= "N "; } if ($f[acc_aff_5] == "Y") { $acc_aff .= "Y "; } else { $acc_aff .= "N "; } if ($f[superuser] == setup("superuser")) { if ($f[setup_superuser] == "") { $supe = setup("superuser"); } $db = new ps_DB; $q = "UPDATE setup SET setup_login = '$f[setup_login]', setup_password = '$f[setup_password]', setup_superuser = '$supe', setup_path = '$f[setup_path]', setup_url = '$f[setup_url]', setup_ssl_url = '$f[setup_ssl_url]', setup_email = '$f[setup_email]', setup_company = '$f[setup_company]', setup_email_signup = '$f[setup_email_signup]', setup_email_admin = '$f[setup_email_admin]', setup_currency = '$f[setup_currency]', setup_tax = '$f[setup_tax]', setup_tax_rate = '$f[setup_tax_rate]', setup_max_results = '$f[setup_max_results]', setup_grace_period = '$f[setup_grace_period]', setup_template_file = '$f[setup_template_file]', setup_require_email_ver = '$f[setup_require_email_ver]', setup_domain_suggest = '$f[setup_domain_suggest]', setup_affiliate = '$f[setup_affiliate]', setup_aff_type = '$acc_aff', setup_aff_pay_1 = '$f[setup_aff_pay_1]', setup_aff_pay_1a = '$f[setup_aff_pay_1a]', setup_aff_pay_2 = '$f[setup_aff_pay_2]', setup_aff_pay_2a = '$f[setup_aff_pay_2a]', setup_aff_pay_2b = '$f[setup_aff_pay_2b]', setup_aff_pay_2c = '$date', setup_gateway = '$f[gateway]', setup_curl = '$curl_path', setup_gw_userid = '$f[userid]', setup_gw_password = '$f[password]', setup_gw_1 = '$f[gw_1]', setup_gw_2 = '$f[gw_2]', setup_header = '$header', setup_footer = '$footer', setup_faq = '$faq', setup_company_info = '$company_info', setup_contact_info = '$contact_info', setup_acceptable_use = '$acceptable_use', setup_privacy_policy = '$privacy_policy', setup_topmenu_bg = '$f[topmenu_bg]', setup_topmenu_font = '$f[topmenu_font]', setup_leftmenu_bg = '$f[leftmenu_bg]', setup_leftmenu_font = '$f[leftmenu_font]', setup_leftmenu_search = '$f[leftmenu_search]', setup_leftmenu_cart = '$f[leftmenu_cart]', setup_leftmenu_width = '$f[leftmenu_width]', setup_registrar = '$f[registrar]', setup_email_1 = '$f[1]', setup_email_2 = '$f[2]', setup_email_3 = '$f[3]', setup_email_4 = '$f[4]', setup_email_5 = '$f[5]', setup_email_6 = '$f[6]', setup_email_7 = '$f[7]', setup_email_8 = '$f[8]', setup_email_9 = '$f[9]', setup_email_10 = '$f[10]', setup_email_11 = '$f[11]', setup_email_12 = '$f[12]', setup_email_13 = '$f[13]', setup_email_14 = '$f[14]', setup_email_15 = '$f[15]', setup_email_16 = '$f[16]', setup_email_17 = '$f[17]', setup_email_18 = '$f[18]', setup_email_19 = '$f[19]', setup_email_20 = '$f[20]', setup_email_21 = '$f[21]', setup_email_22 = '$f[22]', setup_email_23 = '$f[23]', setup_pp_acc_checks = '$f[setup_pp_acc_checks]', setup_pp_acc_2 = '$f[setup_pp_acc_2]', setup_pp_acc_3 = '$f[setup_pp_acc_3]', setup_pp_acc_4 = '$f[setup_pp_acc_4]', setup_pp_acc_5 = '$f[setup_pp_acc_5]', setup_pp_acc_6 = '$f[setup_pp_acc_6]', setup_pp_acc_7 = '$f[setup_pp_acc_7]', setup_pp_acc_8 = '$f[setup_pp_acc_8]', setup_pp_acc_9 = '$f[setup_pp_acc_9]', setup_pp_acc_10 = '$f[setup_pp_acc_10]', setup_pp_acc_11 = '$f[setup_pp_acc_11]', setup_pp_acc_2_acct = '$f[setup_pp_acc_2_acct]', setup_pp_acc_2_curr = '$f[setup_pp_acc_2_curr]', setup_pp_acc_3_acct = '$f[setup_pp_acc_3_acct]', setup_pp_acc_3_curr = '$f[setup_pp_acc_3_curr]', setup_pp_acc_4_acct = '$f[setup_pp_acc_4_acct]', setup_pp_acc_5_acct = '$f[setup_pp_acc_5_acct]', setup_pp_acc_5_pass = '$f[setup_pp_acc_5_pass]', setup_pp_acc_6_acct = '$f[setup_pp_acc_6_acct]', setup_pp_acc_7_acct = '$f[setup_pp_acc_7_acct]', setup_pp_acc_7_pass = '$f[setup_pp_acc_7_pass]', setup_pp_acc_8_acct = '$f[setup_pp_acc_8_acct]', setup_pp_acc_8_pass = '$f[setup_pp_acc_8_pass]', setup_pp_acc_9_acct = '$f[setup_pp_acc_9_acct]', setup_pp_acc_9_pass = '$f[setup_pp_acc_9_pass]', setup_pp_acc_10_acct = '$f[setup_pp_acc_10_acct]', setup_pp_acc_11_acct = '$f[setup_pp_acc_11_acct]', setup_pp_acc_11_curr = '$f[setup_pp_acc_11_curr]', setup_d_name = '$f[setup_d_name]', setup_d_address = '$f[setup_d_address]', setup_d_city = '$f[setup_d_city]', setup_d_state = '$f[setup_d_state]', setup_d_zip = '$f[setup_d_zip]', setup_d_country = '$f[setup_d_country]', setup_d_title = '$f[setup_d_title]', setup_d_company = '$f[setup_d_company]', setup_d_phone = '$f[setup_d_phone]', setup_d_fax = '$f[setup_d_fax]', setup_r_name = '$f[setup_r_name]', setup_r_address = '$f[setup_r_address]', setup_r_city = '$f[setup_r_city]', setup_r_state = '$f[setup_r_state]', setup_r_zip = '$f[setup_r_zip]', setup_r_country = '$f[setup_r_country]', setup_r_title = '$f[setup_r_title]', setup_r_company = '$f[setup_r_company]', setup_r_phone = '$f[setup_r_phone]', setup_r_fax = '$f[setup_r_fax]' WHERE setup_id='1'"; $db->query($q); return "The administration options were updated!"; } else { return "You did not provide the correct superuser password. The administration options have not been updated."; } } // ADD & ACTIVATE A NEW AFFILIATE RECORD function add_affiliate($f) { // check that this user is not already an affiliate: $db = new ps_DB; $q = "select affiliate_account_id from affiliate where affiliate_account_id = '$account_id'"; $db->query($q); if($db->num_rows() != 0) return "We could not create the affiliate account - one already exists for your account."; $today=date("Y-m-d"); $account_id = get_account_id($f[session_id]); $db = new ps_DB; $q = "INSERT INTO affiliate SET affiliate_account_id= '$account_id', affiliate_date = '$today', affiliate_type = '$f[affiliate_type]', affiliate_name = '$f[name]', affiliate_address = '$f[address]', affiliate_city = '$f[city]', affiliate_state = '$f[state]', affiliate_zip = '$f[zip]', payout_acct = '$f[payout_acct]', affiliate_country = '$f[country]'"; $db->query($q); // MAIL THE ADMINISTRATOR if(setup("email_3") == Y) { send_mail("3",$account_id,"","",""); } // MAIL THE AFFILIATE if(setup("email_8") == Y) { send_mail("8",$account_id,"","",""); } return "Your affiliate account has been set up"; } // ADD A NEW NEWSLETTER function newsletter_add($f) { $db = new ps_DB; $q = "INSERT INTO newsletter SET name = '$f[name]', description = '$f[desc]', active = '$f[active]'"; $db->query($q); return "The newsletter has been added."; } // UPDATE NEWSLETTER function newsletter_update($f) { $db = new ps_DB; $q = "UPDATE newsletter SET name = '$f[name]', description = '$f[desc]', active = '$f[active]' WHERE id = '$f[id]'"; $db->query($q); return "The newsletter has been updated."; } // DELETE NEWSLETTER function newsletter_delete($f) { $db = new ps_DB; $q = "DELETE FROM newsletter WHERE id = '$f[id]'"; $db->query($q); return "The newsletter has been deleted."; } // SEND THE NEWSLETTER function newsletter_send($f) { // // Get a list of account ids to send to... $db = new ps_DB; $q = "SELECT account_id FROM newsletter_subscr WHERE newsletter_id = '$f[id]'"; $db->query($q); while($db->next_record()) { // send each account the newsletter! // Get account details.... $acct_id = $db->f("account_id"); $dba = new ps_DB; $q = "SELECT account_email,account_name FROM account WHERE account_id = '$acct_id'"; $dba->query($q); $dba->next_record(); $email = $dba->f("account_email"); $name = $dba->f("account_name"); echo "Send $email <$name>
"; // SEND THE MAIL... newsletter_send_mail($f,$email,$name,$acct_id); } return "
Sent all subscribers the newsletter."; } // SEND THE MAIL function newsletter_send_mail($f,$email,$name,$acct) { // Compose the email message: $remove = setup("url") . '?page=newsletter_remove&nid=' . $f[id] . '&acid=' . $acct; $title = preg_replace('//',$name,$f[title]); $message = preg_replace('//i',$name,$f[message]); $message = preg_replace('//i',$remove,$message); $to = $name . ' <' . $email . '>'; $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>"; if($f[html]=='Y') $headers .= "\nContent-Type: text/html; charset=iso-8859-1"; mail($email,$title,$message,$headers); } function newsletter_sub_count($id) { $db = new ps_DB; $q = "SELECT id FROM newsletter_subscr WHERE newsletter_id = '$id'"; $db->query($q); return $db->num_rows(); } function newsletter_unsub($f) { $db = new ps_DB; $q = "DELETE FROM newsletter_subscr WHERE account_id='$f[acid]' AND newsletter_id='$f[nid]'"; $db->query($q); return "You have been removed from this newsletter."; } function newsletter_acct_active($account_id,$id) { $db = new ps_DB; $q = "SELECT account_id FROM newsletter_subscr WHERE newsletter_id = '$id' AND account_id = '$account_id'"; $db->query($q); return $db->num_rows(); } // if($newsletter_auto_sub == "Y") newsletter_sub_all($account_id); // subscribe an account to all available subscriptions function newsletter_sub_all($account_id) { // GET EACH NEWSLETTER $db = new ps_DB; $q = "SELECT id FROM newsletter ORDER BY name ASC"; $db->query($q); while($db->next_record()) { $news_id=$db->f("id"); //create! $dbd = new ps_DB; $q = "INSERT INTO newsletter_subscr SET newsletter_id='$news_id', account_id='$account_id'"; $dbd->query($q); } } function newsletter_sub($f) { global $n_id; // GET EACH NEWSLETTER $db = new ps_DB; $q = "SELECT id FROM newsletter ORDER BY name ASC"; $db->query($q); while($db->next_record()) { $news_id=$db->f("id"); if($n_id[$db->f("id")] == "Y") { // add this newsletter // Make sure already not subscribed $dbd = new ps_DB; $q = "SELECT id FROM newsletter_subscr WHERE newsletter_id='$news_id' AND account_id='$f[account_id]'"; $dbd->query($q); if($dbd->num_rows() <= 0) { //create! $dbd = new ps_DB; $q = "INSERT INTO newsletter_subscr SET newsletter_id='$news_id', account_id='$f[account_id]'"; $dbd->query($q); } // else make no changes! } else { // remove this newsletter $dbd = new ps_DB; $q = "DELETE FROM newsletter_subscr WHERE newsletter_id='$news_id' AND account_id='$f[account_id]'"; $dbd->query($q); } } } // GET AN AFFILIATE ID BY THE CUSTOMERS ACCOUNT ID function get_affiliate_id($acct) { $db = new ps_DB; $q = "SELECT affiliate_id FROM affiliate WHERE affiliate_account_id='$acct'"; $db->query($q); $db->next_record(); $ret = $db->f("affiliate_id"); return $ret; } // SHOW ALL REFERRALS FOR AN AFFILIATE function show_affiliate_referrals($affiliate_id) { $db = new ps_DB; $q = "SELECT login_id FROM login WHERE login_affiliate_id='$affiliate_id'"; $db->query($q); $ret = $db->num_rows(); return $ret; } // SHOW ALL ORDERS FOR AN AFFILIATE function show_affiliate_orders($affiliate_id) { $db = new ps_DB; $q = "SELECT order_id FROM orders WHERE order_affiliate_id='$affiliate_id'"; $db->query($q); $ret = $db->num_rows(); return $ret; } // CHECK IF THE SELECTED ACCOUNT IS SET UP AS AN AFFILIATE function affiliate_exist($account_id) { $db = new ps_DB; $q = "SELECT affiliate_id FROM affiliate WHERE affiliate_account_id='$account_id'"; $db->query($q); if ($db->num_rows() < 1) { $ret = "N"; } else { $ret = "Y"; } return $ret; } // UPDATE EMAIL TEMPLATE function update_email_template($f) { $db = new ps_DB; $email_name = addslashes($f[name]); $email_temp = addslashes($f[template]); $q = "UPDATE email SET email_name = '$email_name', email_template = '$email_temp' WHERE email_id = '$f[id]'"; $db->query($q); } // PARSE A MAIL RECORD AND SEND IT OUT... function send_mail($email_id,$account_id,$domain_id,$order_id,$affiliate_id) { // IF ACCOUNT ID EXSISTS, GET THE ACCOUNT INFO.. if($account_id !="") { $db = new ps_DB; $q = "SELECT * FROM account WHERE account_id='" . sql_string_filter($db->lid, $account_id) . "'"; $db->query($q); $db->next_record(); $name = $db->f("account_name"); $address = $db->f("account_address"); $city = $db->f("account_city"); $state = $db->f("account_state"); $zip = $db->f("account_zip"); $email = $db->f("account_email"); $username = $db->f("account_username"); $pw = $db->f("account_password"); $title = $db->f("account_title"); $company = $db->f("account_company"); } // IF DOMAIN ID EXSISTS, GET THE ACCOUNT INFO.. if($domain_id !="") { $db = new ps_DB; $q = "SELECT * FROM domains WHERE domain_id='" . sql_string_filter($db->lid, $domain_id) . "'"; $db->query($q); $db->next_record(); $domain = $db->f("domain_name"); $plan = $db->f("domain_host_id"); //if ($plan == '48') { // $plan = '55'; //} else { //$plan = $plan; //} $db = new ps_DB; $q = "SELECT membership_name FROM membership WHERE membership_id='" . sql_string_filter($db->lid, $plan) . "'"; $db->query($q); $db->next_record(); $planname = $db->f("membership_name"); } //echo $planname; // IF ORDER ID IS SET if($order_id !="") { $db = new ps_DB; $q = "SELECT order_id, order_amount, order_attr_value_1, order_billing_id FROM orders WHERE order_id='" . sql_string_filter($db->lid, $order_id) . "'"; $db->query($q); $db->next_record(); $id = $db->f("order_id"); $amount = $db->f("order_amount"); $referrer = $db->f("order_attr_value_1"); //$billing_order_id = $db->f("order_billing_id"); $new_domains =""; $tran_domains =""; $db = new ps_DB; $q = "SELECT * FROM domains WHERE domain_order_id='" . sql_string_filter($db->lid, $order_id) . "'"; $db->query($q); $sub=""; while ($db->next_record()) { $membership_id = $db->f("domain_host_id"); $sub .= show_hosting_option_no_price($membership_id) . "\r\n"; $sub .= "---------------------------------------------- \r\n"; $subscriptions = "SUBSCRIPTION(S) ORDERED: \r\n"; $subscriptions .= "---------------------------------------------- \r\n"; $subscriptions .= $sub; } } $cc_data = get_cc_data($order_id); $ccnumber = $cc_data[cc]; $cctype = $cc_data[type]; // IF ACCOUNT ID EXSISTS, GET THE ACCOUNT INFO.. if($affiliate_id !="") { $db = new ps_DB; $q = "SELECT * FROM affiliate WHERE affiliate_id='$affiliate_id'"; $db->query($q); $db->next_record(); $account_id = $db->f("affiliate_account_id"); $name = $db->f("affiliate_name"); $address = $db->f("affiliate_address"); $city = $db->f("affiliate_city"); $state = $db->f("affiliate_state"); $zip = $db->f("affiliate_zip"); $db = new ps_DB; $q = "SELECT account_email,account_username FROM account WHERE account_id='$account_id'"; $db->query($q); $db->next_record(); $username = $db->f("account_email"); $email = $db->f("account_email"); } // GET THE EMAIL TEMPLATE INFO FROM THE DATABASE $db = new ps_DB; $q = "SELECT * FROM email WHERE email_id='$email_id'"; $db->query($q); $db->next_record(); $subject = $db->f("email_name"); if ($subject == 'New Order'){ $subject = $subject.' -- '; $subject .= show_hosting_option_no_price($membership_id); } if ($subject == 'SNS Renewal'){ $subject = $subject.' -- '; $subject .= show_hosting_option_no_price($membership_id); } $template = $db->f("email_template"); $company_email = setup("email"); // DETERMINE WHO TO SEND THIS TO if ($email_id <= "7") { $to_email = $company_email; } elseif (($email_id >= 8) && ($email_id <= 10)) { $to_email = $email; } elseif (($email_id >= 11) && ($email_id <= 21)) { $to_email = $email; } elseif (($email_id >= 22) && ($email_id <= 23)) { $to_email = setup("registrar"); if (($email_id == 22) && ($new_count == 0)) { return true; } } elseif($email_id == "24") { $to_email = $company_email; //$to_email = 'scott@schramke.com'; } elseif($email_id == "25") { $to_email = $email; } elseif($email_id == "26") { $to_email = $email; } $today = date("Y-m-d"); // START THE FILTERING PROCCESS (COMMON SHORTCUTS): $pat=" "; $template = preg_replace("/($pat)/i", "\r\n", $template); $template = preg_replace("/
/i", "\r\n", $template); $template = preg_replace("//", setup("company"), $template); $template = preg_replace("//", setup("email"), $template); $template = preg_replace("//", setup("currency"), $template); $template = preg_replace("//", $today, $template); $template = preg_replace("//", setup("url"), $template); $template = preg_replace("//", $name, $template); $template = preg_replace("/
/", $address, $template); $template = preg_replace("//", $city, $template); $template = preg_replace("//", $state, $template); $template = preg_replace("//", $zip, $template); $template = preg_replace("//", $email, $template); $template = preg_replace("//", $username, $template); $template = preg_replace("//", $pw, $template); $template = preg_replace("//", $planname, $template); $template = preg_replace("//", $id, $template); $template = preg_replace("//", $amount, $template); $template = preg_replace("//", $subscriptions, $template); $template = preg_replace("//", $domain_id, $template); $template = preg_replace("//", $referrer, $template); $template = preg_replace("//", $company, $template); $template = preg_replace("//", $title, $template); $template = preg_replace("/<CCNUMBER>/", $ccnumber, $template); $template = preg_replace("/<CCTYPE>/", $cctype, $template); // $template = str_replace("\n", "\r\n", $template); $subject = preg_replace("/<company>/", setup("company"), $subject); $subject = preg_replace("/<email>/", setup("email"), $subject); $subject = preg_replace("/<currency>/", setup("currency"), $subject); $subject = preg_replace("/<date>/", $today, $subject); $subject = preg_replace("/<url>/", setup("url"), $subject); $subject = preg_replace("/<NAME>/", $name, $subject); $subject = preg_replace("/<ADDRESS>/", $address, $subject); $subject = preg_replace("/<CITY>/", $city, $subject); $subject = preg_replace("/<STATE>/", $state, $subject); $subject = preg_replace("/<ZIP>/", $zip, $subject); $subject = preg_replace("/<EMAIL>/", $email, $subject); $subject = preg_replace("/<USERNAME>/", $username, $subject); $subject = preg_replace("/<PW>/", $pw, $subject); $subject = preg_replace("/<PLANNAME>/", $planname, $subject); $subject = preg_replace("/<ID>/", $id, $subject); $subject = preg_replace("/<AMOUNT>/", $amount, $subject); $subject = preg_replace("/<SUBSCR_ID>/", $domain_id, $subject); $message = $template; // CREATE THE HEADERS $headers = "From: " . setup("company") . "<" . $company_email . ">\r\n"; $headers .= "X-Sender: <" . $company_email . ">\r\n"; $headers .= "Return-Path: <" . $company_email . ">\r\n"; $headers .= 'Bcc: scott@stratnews.com' . "\r\n"; error_reporting(0); if (!mail($to_email, $subject, $message, $headers)) { global $error; $error .= "<BR>Unable to email server, email id $email_id not sent!"; } error_reporting(E_ALL ^ E_NOTICE); } //SEND USER LOST PASSWORD EMAIL function email_pw($account_password,$account_email,$account_name) { $company_email = setup("email"); $company_name = setup("company"); $db = new ps_DB; $q = "select account_username from account where account_email = '" . sql_string_filter($db->lid, $account_email) . "'"; $db->query($q); $db->next_record(); $username = $db->f("account_username"); $subject = $company_name; $subject .= ": Password Reminder\r\n"; $message = "Hello $account_name, your $company_name login and password are below.\r\n"; $message .="Account Username: $username\r\n"; $message .="Account Password: $account_password\r\n"; $message .="Log into the Account Management page to update your information or renew your subscription:\r\n"; $message .="https://www.stratnews.com/orders/?page=account\r\n"; $message .="Thank you,\r\nCustomer Service\r\n$company_name\r\n"; $message = str_replace("\n", "\r\n", $message); $headers = "From: $company_name <subscriptions@stratnews.com>\r\n"; $headers .= "X-Sender: <subscriptions@stratnews.com>\r\n"; $headers .= "Return-Path: <subscriptions@stratnews.com>\r\n"; error_reporting(0); if (!mail($account_email, $subject, $message, $headers)) { global $error; $ret = "<BR>Unable to connect to email server, password email not sent!"; } error_reporting(E_ALL ^ E_NOTICE); return $ret; } // SEND A SUPPORT TICKET TO THE ADMIN function add_ticket($account_id,$domain_id,$type,$title,$mess) { $date=date("Y-m-d"); $company_email = setup("email"); $company_name = setup("company"); $db = new ps_DB; $q = "SELECT account_name,account_email FROM account WHERE account_id='$account_id'"; $db->query($q); $db->next_record(); $name=$db->f("account_name"); $cust_email=$db->f("account_email"); if ($type=="0") $type="Other"; if ($type=="1") $type="Billing Question"; if ($type=="2") $type="Sales Inquiry"; if ($type=="3") $type="Tech Support"; $subject = "New Ticket: " . $type; $message = $name . " has just submitted a new contact ticket, see the message below: ------------------------------------------------- Type: $type ------------------------------------------------- Title: $title ------------------------------------------------- Message: $mess ------------------------------------------------- Date: $date ------------------------------------------------- "; $headers = "From: $name <$cust_email>\n"; $headers .= "X-Sender: <$cust_email>\n"; $headers .= "Return-Path: <$cust_email>\n"; error_reporting(0); if (!mail($company_email, $subject, $message, $headers)) { global $error; $ret = "<BR>Unable to connect to email server, support ticket email not sent!"; } error_reporting(E_ALL ^ E_NOTICE); //echo "<pre> $message </pre>"; return "<BR><BR>Thank you, your message has been sent to $company_name. <BR><BR>We will be in touch with you as soon as possible!"; } // SHOW LAST FEW DIGITS OF CREDIT CARD NUMBER... function show_hidden_cc_1($cc_num) { $cc_num=RC4($cc_num,"de"); //$cc = ereg_replace("^............","",$cc_num) ; //$ret = "XXXX-XXXX-XXXX-" . $cc; $cc1 = substr($cc_num, 0, 4) ; $cc2 = substr($cc_num, -4, 4) ; $ret = $cc1 . "-XXXX-XXXX-" . $cc2; return $ret; } // SHOW LAST FEW DIGITS OF CREDIT CARD NUMBER... function show_hidden_cc($cc_num) { //$cc = ereg_replace("^............","",$cc_num) ; //$ret = "XXXX-XXXX-XXXX-" . $cc; $cc1 = substr($cc_num, 0, 4) ; $cc2 = substr($cc_num, -4, 4) ; $ret = $cc1 . "-XXXX-XXXX-" . $cc2; return $ret; } //SHOW LIST OF AVAILABLE CREDIT CARDS ON FILE function show_cc_list($account_id,$billing_id) { $db = new ps_DB; $q = "SELECT * FROM billing WHERE billing_account_id='$account_id'"; $db->query($q); $ret = "<select name=\"billing_id\" class=\"inputfield\">"; while($db->next_record()) { if ($billing_id==$db->f("billing_id")) { $sel=" selected"; } else { $sel=""; } $cc_num=$db->f("billing_cc_num"); $cc_num=RC4($cc_num,"de"); $cc_type = identify($cc_num); $ret .= "<option value=\"" . $db->f("billing_id") . "\"" . $sel . ">" . $cc_type . " No: " . show_hidden_cc($cc_num) . " Expires: " . $db->f("billing_cc_exp") . "</option>"; } $ret.="</select>"; return $ret; } // UPDATE CREDIT CARD INFORMATION function update_billing_account($account_id,$billing_id,$cc_num,$cc_exp,$address,$city,$state,$zip) { $dba = new ps_DB; $qa = "SELECT * FROM billing WHERE billing_id='" . sql_string_filter($dba->lid, $billing_id) . "' AND billing_account_id='" . sql_string_filter($dba->lid, $account_id) . "'"; $dba->query($qa); $dba->next_record(); $cc_num_filed = $dba->f("billing_cc_num"); $cc_num_filed=RC4($cc_num_filed,"de"); $cc_num_new=RC4($cc_num,"en"); $db = new ps_DB; $q = "UPDATE billing SET "; if ($cc_num != $cc_num_filed) { $q .= "billing_cc_num='" . sql_string_filter($db->lid, $cc_num_new) . "',"; } $q .= "billing_cc_exp='" . sql_string_filter($db->lid, $cc_exp) . "' WHERE billing_account_id='$account_id'"; //AND billing_id='$billing_id'"; $db->query($q); $dba = new ps_DB; $qa = "UPDATE account SET 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) . "' WHERE account_id='$account_id'"; $dba->query($qa); //EMAIL THE CUSTOMER //if(setup("email_14") == Y) { // send_mail("14",$account_id,"","",""); //} } // UPDATE CREDIT CARD INFORMATION function update_billing_account_2($account_id,$billing_id,$cc_num,$cc_exp) { $dba = new ps_DB; $qa = "SELECT * FROM billing WHERE billing_id='" . sql_string_filter($dba->lid, $billing_id) . "' AND billing_account_id='" . sql_string_filter($dba->lid, $account_id) . "'"; $dba->query($qa); $dba->next_record(); $cc_num_filed = $dba->f("billing_cc_num"); $cc_num_filed=RC4($cc_num_filed,"de"); $cc_num_new=RC4($cc_num,"en"); $db = new ps_DB; $q = "UPDATE billing SET "; if ($cc_num != $cc_num_filed) { $q .="billing_cc_num='" . sql_string_filter($db->lid, $cc_num_new) . "',"; } $q .="billing_cc_exp='" . sql_string_filter($db->lid, $cc_exp) . "' WHERE billing_account_id='$account_id'"; //AND billing_id='$billing_id'"; $db->query($q); } //CHECK TO SEE IF A CREDIT CARD EXSISTS ON FILE OR NOT... function check_cc_list($account_id) { $db = new ps_DB; $q = "SELECT billing_id FROM billing WHERE billing_account_id='$account_id'"; $db->query($q); return $db->num_rows(); } //CHECK TO SEE IF CUSTOMER HAS ANY REGISTERED DOMAINS OR NOT... function check_domain_list($account_id) { $db = new ps_DB; $q = "SELECT domain_id FROM domains WHERE domain_account_id='$account_id'"; $db->query($q); return $db->num_rows(); } // ADD AN ATTRIBUTE function add_attribute($f) { $db = new ps_DB; $q = "INSERT INTO attributes SET attribute_name = '$f[name]', attribute_desc = '$f[desc]', attribute_active = '$f[active]', attribute_value = '$f[value]', attribute_type = '$f[type]'"; $db->query($q); } // UPDATE AN ATTRIBUTE function update_attribute($f) { $db = new ps_DB; $q = "UPDATE attributes SET attribute_name = '$f[name]', attribute_desc = '$f[desc]', attribute_type = '$f[type]', attribute_active = '$f[active]', attribute_value = '$f[value]', attribute_1 = '$f[_1]', attribute_2 = '$f[_2]', attribute_3 = '$f[_3]', attribute_4 = '$f[_4]', attribute_5 = '$f[_5]', attribute_6 = '$f[_6]', attribute_7 = '$f[_7]', attribute_8 = '$f[_8]', attribute_9 = '$f[_9]', attribute_10 = '$f[_10]' WHERE attribute_id= '$f[id]'"; $db->query($q); } //SHOW LIST OF REGISTERED DOMAINS & THEIR PLANS function show_attribute_list($count,$id) { $db = new ps_DB; $q = "SELECT * FROM attributes WHERE attribute_id='$id'"; $db->query($q); $db->next_record(); echo '<select name="value[' . $count . ']" class="fields">'; $i=1; while($i <=10) { $val = "attribute_" . $i; $ret = $db->f($val); echo $val; if ($ret != "") { echo "<option value=\"" . $ret . "\""; if ($ret == $db->f("attribute_value")) { echo " selected"; } echo ">" . $ret . "</option>"; } $i++; } echo "</select>"; } function coupons_add($f) { $db = new ps_DB; $q = "INSERT INTO coupons SET coupon_code = '$f[coupon_code]', start_date = '$f[start_date]', end_date = '$f[end_date]', type = '$f[type]', rate = '$f[rate]', usage_max = '$f[usage_max]', usage_count = '$f[usage_count]', notes = '$f[notes]'"; $db->query($q); } function coupons_edit($f) { $db = new ps_DB; $q = "UPDATE coupons SET coupon_code = '$f[coupon_code]', start_date = '$f[start_date]', end_date = '$f[end_date]', type = '$f[type]', rate = '$f[rate]', usage_max = '$f[usage_max]', usage_count = '$f[usage_count]', notes = '$f[notes]' WHERE id = '$f[id]'"; $db->query($q); } function coupons_delete($f) { $db = new ps_DB; $q = "DELETE FROM coupons WHERE id = '$f[id]'"; $db->query($q); } function block_ip_add($f) { $db = new ps_DB; $q = "INSERT INTO block_ip SET ip = '$f[ip]', note = '$f[note]'"; $db->query($q); } function block_ip_edit($f) { $db = new ps_DB; $q = "UPDATE block_ip SET ip = '$f[ip]', note = '$f[note]' WHERE id = '$f[id]'"; $db->query($q); } function block_ip_delete($id) { $db = new ps_DB; $q = "DELETE FROM block_ip WHERE id = '$id'"; $db->query($q); } function block_email_add($f) { $db = new ps_DB; $q = "INSERT INTO block_email SET domain = '$f[domain]', note = '$f[note]'"; $db->query($q); } function block_email_edit($f) { $db = new ps_DB; $q = "UPDATE block_email SET domain = '$f[domain]', note = '$f[note]' WHERE id = '$f[id]'"; $db->query($q); } function block_email_delete($id) { $db = new ps_DB; $q = "DELETE FROM block_email WHERE id = '$id'"; $db->query($q); } function category_add($f) { $db = new ps_DB; $q = "INSERT INTO category SET sort = '$f[sort]', description = '$f[description]', name = '$f[name]'"; $db->query($q); } function category_edit($f) { $db = new ps_DB; $q = "UPDATE category SET sort = '$f[sort]', description = '$f[description]', name = '$f[name]' WHERE id = '$f[id]'"; $db->query($q); } function category_delete($id) { $db = new ps_DB; $q = "DELETE FROM category WHERE id = '$id'"; $db->query($q); } function tax_add($f) { $db = new ps_DB; $q = "INSERT INTO tax SET country = '$f[country]', state = '$f[state]', rate = '$f[rate]'"; $db->query($q); } function tax_delete($id) { $db = new ps_DB; $q = "DELETE FROM tax WHERE id = '$id'"; $db->query($q); } //SHOW LIST OF REGISTERED DOMAINS & THEIR PLANS function show_domain_list($account_id,$domain_id) { $db = new ps_DB; $q = "SELECT domain_host_id,domain_id FROM domains WHERE domain_account_id='$account_id' ORDER BY domain_host_id"; $db->query($q); $ret = "<select name=\"domain_id\" class=\"inputfield\">"; while($db->next_record()) { if ($domain_id==$db->f("domain_id")) { $sel=" selected"; } else { $sel=""; } $ret .= "<option value=\"" . $db->f("domain_id") . "\"" . $sel . ">"; $ret .= get_membership_name($db->f("domain_host_id")); $ret .= " </option>"; } $ret.="</select>"; return $ret; } //SHOW LIST OF REGISTERED DOMAINS THAT ARE EXPIRING SOON function show_domain_exp_list($account_id,$domain_id) { $i=0; $db = new ps_DB; $q = "SELECT domain_name,domain_id FROM domains WHERE domain_account_id='$account_id' ORDER BY domain_name"; $db->query($q); $ret = "<select name=\"domain_id\">"; while($db->next_record()) { $days = check_domain_status($db->f("domain_id")); if ($days<=30) { if ($domain_id==$db->f("domain_id")) { $sel=" selected"; } else { $sel=""; } $ret .= "<option value=\"" . $db->f("domain_id") . "\"" . $sel . ">Expires in " . $days . " days -> " . $db->f("domain_name") . "</option>"; $i++; } } if ($i==0) { $ret .= "<option value=\"\" selected>You have no domains due to expire within 30 days.</option>"; } $ret.="</select>"; return $ret; } //SHOW LIST CUSTOMERS ORDERS function show_order_list($account_id,$order_id) { $db = new ps_DB; $q = "SELECT order_id,order_amount,order_status FROM orders WHERE order_account_id='$account_id' ORDER BY order_date"; $db->query($q); if ($db->num_rows() > 0) { $ret = "<select name=\"order_id\" class=\"inputfield\">"; while($db->next_record()) { if ($order_id==$db->f("order_id")) { $sel=" selected"; } if ($db->f("order_status")==1) { $status="complete "; } if ($db->f("order_status")==0) { $status="pending "; } if ($db->f("order_status")==2) { $status="voided "; } if ($db->f("order_status")==3) { $status="cancelled "; } if ($db->f("order_status")==4) { $status="declined "; } $ret .= "<option value=\"" . $db->f("order_id") . "\"" . $sel . ">Order No. " . $db->f("order_id") . " -> " . $status . " -> " . setup("currency") . $db->f("order_amount") . "</option>"; } $ret.="</select>"; } else { $ret = "No order records for this account."; } return $ret; } // SHOW A LIST OF BILLED CHARGES... function show_billing_list($account_id,$billed_id) { $db = new ps_DB; $q = "SELECT * FROM billed WHERE billed_account_id='$account_id' ORDER BY billed_date"; $db->query($q); if ($db->num_rows() == 0) { $ret = "No billing records for this account."; } else { $ret = "<select name=\"billed_id\" class=\"inputfield\">"; while($db->next_record()) { $amount = $total = (number_format ($db->f("billed_amount"), 2, ".", "")); if ($amount <= 0) { $data = " Credit "; } else { $data = setup("currency") . "" . $amount; } if ($billed_id==$db->f("billed_id")) { $sel=" selected"; } else { $sel=""; } $ret .= "<option value=\"" . $db->f("billed_id") . "\"" . $sel . ">Date. " . $db->f("billed_date") . " -> " . $data . "</option>"; } if ($db->num_rows=="0") { $ret .= "<option value=\"\">You have no charges billed to your account.</option>"; } $ret.="</select>"; } return $ret; } // SHOW HOSTING OPTIONS & PRICES MENU FOR CUSTOMERS WISHING TO UPDATE THEIR HOSTING PLAN function show_hosting_menu_2($domain_id,$membership_id) { $db = new ps_DB; $q = "SELECT membership_setup,membership_name,membership_price,membership_id FROM membership WHERE membership_active='Y' ORDER BY 'membership_name'"; $db->query($q); echo "<SELECT NAME=\"membership_id\" class=\"inputfield\">"; while ($db->next_record()) { $dbn = $db->f("membership_name"); $dbp = $db->f("membership_price"); $dbi = $db->f("membership_id"); $dbs = $db->f("membership_setup"); $title = $dbn; $title.= " ("; $title.= setup("currency"); $title.= $dbp; $title.= ")"; if ($dbs>0) { $title .= " + (" . setup("currency") . "" . $dbs . " setup)"; } echo "<OPTION VALUE=\"$dbi\""; if ($membership_id == $dbi) echo " selected"; echo ">$title</OPTION> "; } echo "</SELECT>"; return $ret; } // SHOW A LIST OF PAYOUT OPTIONS: function show_payout_options() { $db = new ps_DB; $q = "SELECT setup_aff_type FROM setup WHERE setup_id='1'"; $db->query($q); $db->next_record(); echo "<select name=\"affiliate_type\" class=\"fields\">"; if (($db->f("setup_aff_type") == 0) || ($db->f("setup_aff_type") == 1)) { echo "<option value=\"1\">Credit Payout to my Account</option>"; } if (($db->f("setup_aff_type") == 0) || ($db->f("setup_aff_type") == 2)) { echo "<option value=\"2\">Send me my Payout via Paypal</option>"; } echo "</select>"; // return $ret; } // SHOW A LIST OF PAYOUT OPTIONS: function show_payout_options1() { $db = new ps_DB; $q = "SELECT setup_aff_type FROM setup WHERE setup_id='1'"; $db->query($q); $db->next_record(); echo "<select name=\"type\" class=\"fields\">"; echo '<option value="">---- ALL ----</option>'; if (($db->f("setup_aff_type") == 0) || ($db->f("setup_aff_type") == 1)) { echo "<option value=\"1\">Payout by Account Credit</option>"; } if (($db->f("setup_aff_type") == 0) || ($db->f("setup_aff_type") == 2)) { echo "<option value=\"2\">Payout via Paypal</option>"; } echo "</select>"; // return $ret; } // SHOW A LIST OF PAYOUT OPTIONS: function show_payout_options2($id) { echo "<select name=\"type\" class=\"fields\">"; echo "<option value=\"1\""; if ($id == 1) { echo " selected"; } echo ">Payout by Account Credit</option>"; echo "<option value=\"2\""; if ($id == 2) { echo " selected"; } echo ">Payout via Paypal</option>"; echo "</select>"; // return $ret; } // SHOW A LIST OF ACCOUNTS... function show_account_list($account_id) { $db = new ps_DB; $q = "SELECT account_id,account_name FROM account ORDER BY account_name"; $db->query($q); $ret = "<select name=\"account_id\" class=\"fields\">"; while($db->next_record()) { $name = strtoupper($db->f("account_name")); if ($account_id==$db->f("account_id")) { $sel=" selected"; } else { $sel=""; } $ret .= "<option value=\"" . $db->f("account_id") . "\"" . $sel . ">" . $name . "</option>"; } if ($db->num_rows=="0") { $ret .= "<option value=\"\">There are no active accounts.</option>"; } $ret.="</select>"; return $ret; } // SHOW A LIST OF ACCOUNTS... function show_account_list_non_affiliate($account_id) { $db = new ps_DB; $q = "SELECT account_id,account_name FROM account ORDER BY account_name"; $db->query($q); $ret = "<select name=\"account_id\" class=\"fields\">"; while($db->next_record()) { $acct = $db->f("account_id"); $dba = new ps_DB; $qq = "SELECT affiliate_id FROM affiliate WHERE affiliate_account_id = '$acct'"; $dba->query($qq); $dba->next_record(); if($dba->num_rows() == 0) { $i++; $name = strtoupper($db->f("account_name")); if ($account_id==$db->f("account_id")) { $sel=" selected"; } else { $sel=""; } $ret .= "<option value=\"" . $db->f("account_id") . "\"" . $sel . ">" . $name . "</option>"; } } if ($i< 1) { $ret .= "<option value=\"\">No available accounts</option>"; } $ret.="</select>"; return $ret; } // SHOW A LIST OF ACCOUNTS... function show_account_list_2($account_id) { $db = new ps_DB; $q = "SELECT account_id,account_name FROM account ORDER BY account_name ASC"; $db->query($q); $ret = "<select name=\"account_id\" class=\"fields\">"; while($db->next_record()) { $ret .= "<option value=\"" . $db->f("account_id") . "\"" . $sel . ">Acct No. " . $db->f("account_id") . " -> " . $db->f("account_name") . "</option>"; } if ($db->num_rows=="0") { $ret .= "<option value=\"\">There are no active accounts.</option>"; } $ret.="</select>"; return $ret; } // SHOW A LIST OF ACCOUNTS... function show_account_list_3($account_id) { $db = new ps_DB; $q = "SELECT account_id,account_name FROM account ORDER BY account_name ASC"; $db->query($q); $ret = '<select name="account_id" class="fields">'; $ret .= '<option value="">---- ALL ----</option>'; while($db->next_record()) { $ret .= '<option value="' . $db->f("account_id") . '">' . $db->f("account_name") . '</option>'; } if ($db->num_rows=="0") { $ret .= '<option value="">There are no active accounts.</option>'; } $ret.="</select>"; return $ret; } // SHOW A LIST OF AFFILIATE ACCOUNTS... function show_affiliate_list1() { $db = new ps_DB; $q = "SELECT affiliate_id,affiliate_name FROM affiliate ORDER BY affiliate_name ASC"; $db->query($q); $ret = "<select name=\"affiliate\" class=\"fields\">"; $ret.= '<option value="">---- ALL ----</option>'; while($db->next_record()) { $ret .= "<option value=\"" . $db->f("affiliate_id") . "\"" . $sel . ">" . $db->f("affiliate_name") . "</option>"; } $ret.="</select>"; return $ret; } // SHOW A LIST OF AFFILIATE ACCOUNTS... function show_affiliate_list($account_id) { $db = new ps_DB; $q = "SELECT affiliate_id,affiliate_name FROM affiliate ORDER BY affiliate_name ASC"; $db->query($q); $ret = "<select name=\"affiliate_id\ class=\"fields\">"; while($db->next_record()) { $ret .= "<option value=\"" . $db->f("affiliate_id") . "\"" . $sel . ">Affiliate No. " . $db->f("affiliate_id") . " -> " . $db->f("affiliate_name") . "</option>"; } if ($db->num_rows=="0") { $ret .= "<option value=\"\">There are no affiliate accounts.</option>"; } $ret.="</select>"; return $ret; } // CREATE A BILLING RECORD FOR THIS TRANSACTION function create_billed_record($account_id,$domain_id,$amount) { $today=date("Y-m-d"); $db = new ps_DB; $q = "INSERT INTO billed SET billed_account_id ='$account_id', billed_membership_id ='$domain_id', billed_date ='$today', billed_amount ='$amount', billed_type ='2'"; $db->query($q); // GET ORDER ID FOR THIS TRANSACTION: $db= new ps_DB; $q = "SELECT domain_order_id FROM domains WHERE domain_id = '$domain_id'"; $db->query($q); $db->next_record(); $order_id = $db->f("domain_order_id"); // GET AFFILIATE ID FOR THIS TRANSACTION: $db= new ps_DB; $q = "SELECT order_affiliate_id FROM orders WHERE order_id = '$order_id'"; $db->query($q); $db->next_record(); $affiliate_id = $db->f("order_affiliate_id"); // CREATE AFFILIATE PAYOUT: if (($amount > 0) && ($affiliate_id != "")) { affiliate_payout($account_id, $domain_id, $amount,"3"); } } // CREATE A BILLING RECORD FOR THIS ORDER function create_billed_record_2($account_id,$order_id,$amount) { $today=date("Y-m-d"); $db = new ps_DB; $q = "INSERT INTO billed SET billed_account_id='$account_id', billed_order_id ='$order_id', billed_date='$today', billed_amount='$amount', billed_type='3'"; $db->query($q); // GET AFFILIATE ID FOR THIS TRANSACTION: $db= new ps_DB; $q = "SELECT order_affiliate_id FROM orders WHERE order_id = '$order_id'"; $db->query($q); $db->next_record(); $affiliate_id = $db->f("order_affiliate_id"); // CREATE AFFILIATE PAYOUT: if (($amount > 0) && ($affiliate_id != "")) { affiliate_payout($account_id, $order_id, $amount,"2"); } } // CREATE A BILLING RECORD FOR THIS RECURRING CHARGE function create_billed_record_3($account_id,$domain_id,$amount) { $today=date("Y-m-d"); $db = new ps_DB; $q = "INSERT INTO billed SET billed_account_id='$account_id', billed_membership_id ='$domain_id', billed_date='$today', billed_amount='$amount', billed_type='1'"; $db->query($q); // GET ORDER ID FOR THIS TRANSACTION: $db= new ps_DB; $q = "SELECT domain_order_id FROM domains WHERE domain_id = '$domain_id'"; $db->query($q); $db->next_record(); $order_id = $db->f("domain_order_id"); // GET AFFILIATE ID FOR THIS TRANSACTION: $db= new ps_DB; $q = "SELECT order_affiliate_id FROM orders WHERE order_id = '$order_id'"; $db->query($q); $db->next_record(); $affiliate_id = $db->f("order_affiliate_id"); // CREATE AFFILIATE PAYOUT: if (($amount > 0) && ($affiliate_id != "")) { affiliate_payout($affiliate_id, $domain_id, $amount,"2"); } } // RENEW THE DOMAIN RECORD function renew_domain_record($account_id,$domain_id,$new_term) { $db = new ps_DB; $q = "SELECT domain_years,domain_name FROM domains WHERE domain_id='$domain_id'"; $db->query($q); $db->next_record(); $domain_name = $db->f("domain_name"); $years = $db->f("domain_years") + $new_term; $db = new ps_DB; $q = "UPDATE domains SET domain_years ='$years' WHERE domain_id='$domain_id' AND domain_account_id='$account_id'"; $db->query($q); // EMAIL ADMIN if(setup("email_4") == Y) { send_mail("4",$account_id,$domain_id,"",""); } // EMAIL CUSTOMER if(setup("email_20") == Y) { send_mail("20",$account_id,$domain_id,"",""); } // EMAIL REGISTRAR if(setup("email_23") == Y) { send_renewal_email($account_id,$domain_id,$domain_name,$new_term); } } // PRINT DOMAIN NAME FROM ID ONLY... function print_domain_name($id) { $db = new ps_DB; $q = "SELECT domain_name FROM domains WHERE domain_id='$id'"; $db->query($q); $db->next_record(); $ret=$db->f("domain_name"); return $ret; } // PRINT MONTHLY COST FROM DOMAIN ID ... function print_hosting_cost($id) { $db = new ps_DB; $q = "SELECT domain_host_id FROM domains WHERE domain_id='$id'"; $db->query($q); $db->next_record(); $membership_id=$db->f("domain_host_id"); $db = new ps_DB; $q = "SELECT membership_price FROM membership WHERE membership_id='$membership_id'"; $db->query($q); $db->next_record(); $ret=$db->f("membership_price"); return $ret; } // get the tax for a specific account.... function get_account_tax_rate() { global $session_id; // if logged in... if(is_logged($session_id) != "N") { // get the user's account id $account_id = get_account_id($session_id); // get the user's country & state $db = new ps_DB; $q = "SELECT account_country,account_state FROM account WHERE account_id = '$account_id'"; $db->query($q); $db->next_record(); $country = $db->f("account_country"); $state = strtoupper($db->f("account_state")); // check for matches $db = new ps_DB; $q = "SELECT * FROM tax WHERE country='$country'"; $db->query($q); while($db->next_record()) { $c = $db->f("country"); $s = strtoupper($db->f("state")); $r = $db->f("rate"); // check if country & state both match if(($country == $c) && ($state == $s)) { return $r; } // check if this is a match all scenario if(($country == $c) && ($s == "*")) { return $r; } } // if no matches, get the global value from setup... $db = new ps_DB; $q = "SELECT setup_tax_rate FROM setup WHERE setup_id='1'"; $db->query($q); $db->next_record(); return $db->f("setup_$field"); } else { // display 'must be logged in' message... return 'LOGIN'; } } // GET A SETTING FROM THE SETUP TABLE OF THE DATABASE... function setup($field) { // return the correct tax rate: if($field == "tax_rate") return get_account_tax_rate(); $db = new ps_DB; $q = "SELECT setup_$field FROM setup WHERE setup_id='1'"; $db->query($q); $db->next_record(); return $db->f("setup_$field"); } // SHOW THE APPROPRIATE NOTE FORM function note_showform($note_type,$id) { if ($note_type=="1") { $field="account"; $title="Account Notes"; $show_page = ' <input type="hidden" name="page" value="add_clients"> <input type="hidden" name="account_id" value="'. $id .'"> '; } else if ($note_type=="2") { $field="order"; $title="Order Notes"; $show_page = ' <input type="hidden" name="page" value="orders_view"> <input type="hidden" name="order_id" value="'. $id .'"> '; ; } else if ($note_type=="3") { $field="domain"; $title="Subscription Notes"; $show_page = '<input type="hidden" name="page" value="domains_edit"> <input type="hidden" name="domain_id" value="'. $id .'"> '; } elseif ($note_type=="4") { $field="account"; $title="Account Notes"; $show_page = ' <input type="hidden" name="page" value="add_groups"> <input type="hidden" name="account_id" value="'. $id .'"> '; } $db=new ps_DB; $q="SELECT note_id,note_message FROM notes WHERE note_" . $field . "_id='$id'"; $db->query($q); $db->next_record(); //echo $page; if ($db->num_rows() < 1) { // SHOW THE 'ADD NOTES' FORM echo '<form name="notes" method="post"> <table width="200" border="0" cellspacing="0" cellpadding="0" class="fields_back"> <tr> <td width="10"></td> <td width="179" height="20">'.$title.':</td> <td width="7" height="20"><img src="images/red_corner1.gif" width="7" height="20"></td> </tr> </table> <table width="400" border="0" cellspacing="0" cellpadding="1"> <tr> <td width="450" bgcolor="#990000"> <table width="100%" border="0" cellspacing="0" cellpadding="0" class="fields_text"> <tr> <td> <div align="center"> <table width="400" border="0" cellspacing="0" cellpadding="2" class="fields_text"> <td width="25%">  </td> <td width="70%"> <div align="right"> </div> </td> </tr> </table> <textarea name="note_message" class="fields" cols="50" rows="6"></textarea> </div> </td> </tr> </table> <table width="400" border="0" cellspacing="0" cellpadding="2" class="fields_text" bgcolor="#96B8F1"> <tr> <td width="75%" style="color:red;"><center>today\'s date will be auto prepended.</center></td> <td width="25%"> <div align="right"> <input type="submit" name="Submit" value=":: submit ::" class="fields"> <input type="hidden" name="note_type" value="' . $note_type . '"> <input type="hidden" name="action" value="note_control"> <input type="hidden" name="note_id" value="' . $id . '"> ' . $show_page . ' <input type="hidden" name="status" value="new"> </div> </td> </tr> </table> </td> </tr> </table> </form>'; } else { // SHOW THE 'UPDATE NOTES' FORM echo '<form name="notes" method="post"> <table width="200" border="0" cellspacing="0" cellpadding="0" class="fields_back"> <tr> <td width="10"></td> <td width="179" height="20">'.$title.':</td> <td width="7" height="20"><img src="images/red_corner1.gif" width="7" height="20"></td> </tr> </table> <table width="400" border="0" cellspacing="0" cellpadding="1"> <tr> <td width="450" bgcolor="#990000"> <table width="100%" border="0" cellspacing="0" cellpadding="8" class="fields_text"> <tr> <td style="font-weight:bold;"><br />' . nl2br($db->f("note_message")) . ' </td> </tr> <tr> <td class="fields_text"><span style="color:blue;">Add Notes Below:</span> <div align="center"> <textarea name="note_message" class="fields" cols="60" rows="4"></textarea> </div> </td> </tr> </table> <table width="400" border="0" cellspacing="0" cellpadding="2" class="fields_text" bgcolor="#96B8F1"> <tr> <td width="75%" style="color:red;"><center>today\'s date will be auto prepended.</center></td> <td width="25%"> <div align="right"> <input type="submit" name="Submit" value=":: submit ::" class="fields"> <input type="hidden" name="note_type" value="' . $note_type . '"> <input type="hidden" name="action" value="note_control"> <input type="hidden" name="note_id" value="' . $id . '"> <input type="hidden" name="note_record_id" value="' . $db->f("note_id") . '"> ' . $show_page . ' <input type="hidden" name="status" value="update"> </div> </td> </tr> </table> </td> </tr> </table> </form>'; } } // FUNCTION TO ADD AND UPDATE NOTES function note_control($f) { if ($f[note_type]==1) $field="account"; if ($f[note_type]==2) $field="order"; if ($f[note_type]==3) $field="domain"; if ($f[note_type]==4) $field="account"; $date = date("D m-d-Y"); //$note = eregi_replace("\[d\]", "[ " . $date . " ] ", $f[note_message]); //$note = $note . '\n'; if ($f[status] == "new") { // RECORD DOES NOT EXSIST, WE WILL CREATE A NEW ONE... $note = "[ " . $date . " ] ". $f[note_message]; $dbf=new ps_DB; $qf="INSERT INTO notes SET note_" . $field . "_id = '$f[note_id]', note_message = '" . sql_string_filter($dbf->lid, $note) . "'"; $dbf->query($qf); } elseif($f[status] == "update") { $db=new ps_DB; if ($f[note_record_id] == '' && $f[note_type]==1) { $qb="SELECT * FROM notes WHERE note_account_id='$f[note_account_id]'"; } else { $qb="SELECT * FROM notes WHERE note_id='$f[note_record_id]'"; } $db->query($qb); $db->next_record(); $note = trim($db->f("note_message")); $note .= ' '; $note .= "[ " . $date . " ] ". $f[note_message]; $note_id = $db->f("note_id"); $dbf=new ps_DB; //$q="UPDATE notes SET note_message = '$note' WHERE note_" . $field . "_id = '$f[note_id]'"; $q="UPDATE notes SET note_message = '" . sql_string_filter($dbf->lid, $note) . "' WHERE note_id = '$note_id'"; $dbf->query($q); } } // ADD A DIRECTORY function add_directory($f) { // Area Add... global $path; unset($API_ACTION); $API_ACTION ='area_add'; include ($path . 'auth.api.php'); } // UPDATE A DIRECTORY function update_directory($f) { // Area Update... global $path; $API_ACTION ='area_update'; include ($path . 'auth.api.php'); // Area Update... unset($API_ACTION); $API_ACTION ='auth_directory'; include ($path . 'auth.api.php'); } // DELETE A DIRECTORY function delete_directory($id) { // Area Update... $f[directory_id] = $id; global $path; unset($API_ACTION); $API_ACTION ='area_delete'; include ($path . 'auth.api.php'); // Area Update... $f[directory_id] = $id; global $path; unset($API_ACTION); $API_ACTION ='area_everything'; include ($path . 'auth.api.php'); } // UPDATE ALL DIRECTORYS / AREAS function update_all_directory() { global $path; unset($API_ACTION); $API_ACTION ='auth_everything'; include ($path . 'auth.api.php'); } // SHOW A LIST OF DIRECTORIES... function show_directory_list($directory_id) { $db = new ps_DB; $q = "SELECT directory_name,directory_id FROM directory ORDER BY directory_name ASC"; $db->query($q); $ret = "<select name=\"directory_id\" class=\"fields\">"; $ret.= '<option value="0">-- NONE --</option>'; while($db->next_record()) { $ret .= "<option value=\"" . $db->f("directory_id") . "\"" . $sel; if ($db->f("directory_id") == $directory_id) $ret.= " selected"; $ret .= ">" . $db->f("directory_name") . "</option>"; } if ($db->num_rows() == 0) { $ret .= "<option value=>You must first add Protected Directories.</option>"; } $ret.="</select>"; return $ret; } // SHOW A LIST OF SUBSCRIPTION OPTIONS function show_subscription_list() { $db = new ps_DB; $q = "SELECT membership_name,membership_id FROM membership WHERE membership_active ='Y' ORDER BY membership_name ASC"; $db->query($q); $class = ""; $ret = "<select name=\"membership_id\" class=\"fields\">"; while($db->next_record()) { $ret .= "<option value=\"" . $db->f("membership_id") . "\"" . $sel; $ret .= ">" . $db->f("membership_name") . "</option>"; } if ($db->num_rows() == 0) { $ret .= "<option value=>No Subscriptions Configured.</option>"; } $ret.="</select>"; return $ret; } // SHOW A LIST OF SUBSCRIPTION OPTIONS function show_subscription_list_all() { $db = new ps_DB; $q = "SELECT membership_name,membership_id FROM membership WHERE membership_active ='Y' ORDER BY membership_name ASC"; $db->query($q); $class = ""; $ret = "<select name=\"membership_id\" class=\"fields\">"; $ret.='<option value="">-- ALL --</option>'; while($db->next_record()) { $ret .= '<option value="' . $db->f("membership_id") . '">' . $db->f("membership_name") . '</option>'; } if ($db->num_rows() == 0) { $ret .= "<option value=>No Subscriptions Configured.</option>"; } $ret.="</select>"; return $ret; } // SHOW A LIST OF SUBSCRIPTION OPTIONS function show_subscription_list1() { $db = new ps_DB; $q = "SELECT membership_name,membership_id FROM membership ORDER BY membership_name ASC"; $db->query($q); $class = ""; $ret = "<select name=\"membership_id\" class=\"fields\">"; while($db->next_record()) { $ret .= "<option value=\"" . $db->f("membership_id") . "\"" . $sel; $ret .= ">" . $db->f("membership_name") . "</option>"; } if ($db->num_rows() == 0) { $ret .= "<option value=>No Subscriptions Configured.</option>"; } $ret.="</select>"; return $ret; } // SHOW A LIST OF SUBSCRIPTION OPTIONS function show_subscription_list2() { $db = new ps_DB; $q = "SELECT membership_name,membership_id FROM membership ORDER BY membership_name ASC"; $db->query($q); $ret = "<select name=\"membership_id\" class=\"fields\">"; while($db->next_record()) { $ret .= "<option value=\"" . $db->f("membership_id") . "\"" . $sel; $ret .= ">" . $db->f("membership_name") . "</option>"; } if ($db->num_rows() == 0) { $ret .= "<option value=>No Subscriptions Configured.</option>"; } $ret.="</select>"; return $ret; } // ENCODE/DECODE THE CREDIT CARD INFO USING RC4 function RC4($data, $case) { global $path; include($path . "setup.php"); include($salt); if ($case == 'de') { $data = urldecode($data); } $key[] = ""; $box[] = ""; $temp_swap = ""; $pwd_length = 0; $pwd_length = strlen($pwd); for ($i = 0; $i <= 255; $i++) { $key[$i] = ord(substr($pwd, ($i % $pwd_length), 1)); $box[$i] = $i; } $x = 0; for ($i = 0; $i <= 255; $i++) { $x = ($x + $box[$i] + $key[$i]) % 256; $temp_swap = $box[$i]; $box[$i] = $box[$x]; $box[$x] = $temp_swap; } $temp = ""; $k = ""; $cipherby = ""; $cipher = ""; $a = 0; $j = 0; for ($i = 0; $i < strlen($data); $i++) { $a = ($a + 1) % 256; $j = ($j + $box[$a]) % 256; $temp = $box[$a]; $box[$a] = $box[$j]; $box[$j] = $temp; $k = $box[(($box[$a] + $box[$j]) % 256)]; $cipherby = ord(substr($data, $i, 1)) ^ $k; $cipher .= chr($cipherby); } if ($case == 'de') { $cipher = urldecode(urlencode($cipher)); } else { $cipher = urlencode($cipher); } return $cipher; } // DETERMINE CREDIT CARD TYPE function identify($cc_no) { $cc_no = preg_replace ("/[^0-9]+/", '', $cc_no); // Get card type based on prefix and length of card number if (preg_match ("/^4(.{12}|.{15})$/", $cc_no)) { return 'Visa'; } elseif (preg_match ("/^5[1-5].{14}$/", $cc_no)) { return 'MasterCard'; } elseif (preg_match ("/^3[47].{13}$/", $cc_no)) { return 'Amex'; } elseif (preg_match ("/^3(0[0-5].{11}|[68].{12})$/", $cc_no)) { return 'Diners'; } elseif (preg_match ("/^6011.{12}$/", $cc_no)) { return 'Discover'; } elseif (preg_match ("/^(3.{15}|(2131|1800).{11})$/", $cc_no)) { return 'JCB'; } else { return "N"; } } // DETERMINE CREDIT CARD TYPE function identify_card($cc_no) { $cc_no = preg_replace ('/[^0-9]+/', '', $cc_no); // Get card type based on prefix and length of card number if (preg_match ('/^4(.{12}|.{15})$/', $cc_no)) { return 'Y'; //VISA } elseif (preg_match ('/^5[1-5].{14}$/', $cc_no)) { return 'Y'; //MasterCard } elseif (preg_match ('/^3[47].{13}$/', $cc_no)) { return 'Y'; //AMEX } elseif (preg_match ('/^3(0[0-5].{11}|[68].{12})$/', $cc_no)) { return 'N'; //DINERS } elseif (preg_match ('/^6011.{12}$/', $cc_no)) { return 'Y'; //DISCOVER } else { return "N"; } } function clean_exp($exp) { $exp = preg_replace ("/ /", "", $exp); $exp = preg_replace ("/-/", "", $exp); $exp = preg_replace ("#\/#", "", $exp); $exp = preg_replace ("#\\\#", "", $exp); $exp = preg_replace ("#\|#", "", $exp); $exp = preg_replace ("#\.#", "", $exp); return $exp; } function identify_month($exp) { if(preg_match('/^10/', $exp)) { return "10"; } if(preg_match('/^11/', $exp)) { return "11"; } if(preg_match('/^12/', $exp)) { return "12"; } $exp = preg_replace ("/0/", "", $exp); if(preg_match('/^1/', $exp)) { return "01"; } if(preg_match('/^2/', $exp)) { return "02"; } if(preg_match('/^3/', $exp)) { return "03"; } if(preg_match('/^4/', $exp)) { return "04"; } if(preg_match('/^5/', $exp)) { return "05"; } if(preg_match('/^6/', $exp)) { return "06"; } if(preg_match('/^7/', $exp)) { return "07"; } if(preg_match('/^8/', $exp)) { return "08"; } if(preg_match('/^9/', $exp)) { return "09"; } else {return "No Match"; } } function identify_month_2($exp) { if(preg_match('/^10/', $exp)) { return "10"; } if(preg_match('/^11/', $exp)) { return "11"; } if(preg_match('/^12/', $exp)) { return "12"; } $exp = preg_replace ("/0/", "", $exp); if(preg_match('/^1/', $exp)) { return "1"; } if(preg_match('/^2/', $exp)) { return "2"; } if(preg_match('/^3/', $exp)) { return "3"; } if(preg_match('/^4/', $exp)) { return "4"; } if(preg_match('/^5/', $exp)) { return "5"; } if(preg_match('/^6/', $exp)) { return "6"; } if(preg_match('/^7/', $exp)) { return "7"; } if(preg_match('/^8/', $exp)) { return "8"; } if(preg_match('/^9/', $exp)) { return "9"; } else {return "No Match"; } } function identify_year($exp) { if(preg_match('/2000$/', $exp)) { return "00"; } if(preg_match('/2001$/', $exp)) { return "01"; } if(preg_match('/2002$/', $exp)) { return "02"; } if(preg_match('/2003$/', $exp)) { return "03"; } if(preg_match('/2004$/', $exp)) { return "04"; } if(preg_match('/2005$/', $exp)) { return "05"; } if(preg_match('/2006$/', $exp)) { return "06"; } if(preg_match('/2007$/', $exp)) { return "07"; } if(preg_match('/2008$/', $exp)) { return "08"; } if(preg_match('/2009$/', $exp)) { return "09"; } if(preg_match('/2010$/', $exp)) { return "10"; } if(preg_match('/2011$/', $exp)) { return "11"; } if(preg_match('/2012$/', $exp)) { return "12"; } if(preg_match('/2013$/', $exp)) { return "13"; } if(preg_match('/2014$/', $exp)) { return "14"; } if(preg_match('/2015$/', $exp)) { return "15"; } if(preg_match('/2016$/', $exp)) { return "16"; } if(preg_match('/2017$/', $exp)) { return "17"; } if(preg_match('/2018$/', $exp)) { return "18"; } if(preg_match('/2019$/', $exp)) { return "19"; } if(preg_match('/2020$/', $exp)) { return "20"; } if(preg_match('/2021$/', $exp)) { return "21"; } if(preg_match('/2022$/', $exp)) { return "22"; } if(preg_match('/2023$/', $exp)) { return "23"; } if(preg_match('/2024$/', $exp)) { return "24"; } if(preg_match('/2025$/', $exp)) { return "25"; } if(preg_match('/2026$/', $exp)) { return "26"; } if(preg_match('/2027$/', $exp)) { return "27"; } if(preg_match('/2028$/', $exp)) { return "28"; } if(preg_match('/2029$/', $exp)) { return "29"; } if(preg_match('/2030$/', $exp)) { return "30"; } else { return "No Match"; } } // DETERMINE THE SELECTED PAYMENT PROCESSOR AND SEND THE INFO THERE AND GET RESULTS... function DEPRECATED_card_1($account_id,$name,$address,$zip,$cc_num,$cc_exp,$amount) { error_reporting(E_ALL ^ E_NOTICE); if($name == "") { global $account_name; } else { $account_name=$name; } $gateway = setup("gateway"); //TEST MODE, SEND SUCCESSFULL CHARGE MESSAGE if ($gateway == "0") { $ret = 1; } else if ($gateway=="S") { // SkipJack $ret = charge_skipjack($account_id,$account_name,$address,$zip,$cc_num,$cc_exp,$amount,$gateway); } else if ((((($gateway == "1") || ($gateway =="3") || ($gateway =="6") || ($gateway =="7") || ($gateway =="R"))))) { // (Authorize.net) (ECX) (PlanetPayment) (RTWare) $ret = charge_five($account_id,$account_name,$address,$zip,$cc_num,$cc_exp,$amount,$gateway); } else if ($gateway =="2") { // (ECHO) $ret = charge_echo($account_id,$account_name,$address,$zip,$cc_num,$cc_exp,$amount,$gateway); } else if ($gateway =="4") { // (IBill) $ret = charge_ibill($account_id,$account_name,$address,$zip,$cc_num,$cc_exp,$amount,$gateway); } else if ($gateway =="5") { // (Netbilling) $ret = charge_netbilling($account_id,$account_name,$address,$zip,$cc_num,$cc_exp,$amount,$gateway); } else if ($gateway =="8") { // (Verisign Payflow Pro) $ret = charge_verisign($account_id,$account_name,$address,$zip,$cc_num,$cc_exp,$amount,$gateway); } else if ($gateway =="9") { // (BLUEPAY) $ret = charge_bluepay($account_id,$account_name,$address,$zip,$cc_num,$cc_exp,$amount,$gateway); } else if ($gateway =="K") { // (PROTX DIRECT) $ret = charge_protx($account_id,$account_name,$address,$zip,$cc_num,$cc_exp,$amount,$gateway); } else if ($gateway =="J") { // (PAYSYSTEMS IMA) $ret = charge_paysystems($account_id,$account_name,$address,$zip,$cc_num,$cc_exp,$amount,$gateway); } else if ($gateway =="L") { // (PLUGNPAY) $ret = charge_plugnpay($account_id,$account_name,$address,$zip,$cc_num,$cc_exp,$amount,$gateway); } else if ($gateway =="M") { // (DPI Link) $ret = charge_dpilink($account_id,$account_name,$address,$zip,$cc_num,$cc_exp,$amount,$gateway); } else if ($gateway =="N") { // (eWay) $ret = charge_eway($account_id,$account_name,$address,$zip,$cc_num,$cc_exp,$amount,$gateway); } else if ($gateway =="O") { // (SurePay) $ret = charge_surepay($account_id,$account_name,$address,$zip,$cc_num,$cc_exp,$amount,$gateway); } else if ($gateway =="P") { // (SecPay) $ret = charge_secpay($account_id,$account_name,$address,$zip,$cc_num,$cc_exp,$amount,$gateway); } else if ($gateway =="R") { // (PSIGate) $ret = charge_psigate($account_id,$account_name,$address,$zip,$cc_num,$cc_exp,$amount,$gateway); } else if ($gateway =="T") { // (EFT Secure) $ret = charge_eftsecure($account_id,$account_name,$address,$zip,$cc_num,$cc_exp,$amount,$gateway); } else if ($gateway =="U") { // (Ogone) $ret = charge_ogone($account_id,$account_name,$address,$zip,$cc_num,$cc_exp,$amount,$gateway); } else if (((((((((( ($gateway== "A") || ($gateway == "B") || ($gateway == "C") || ($gateway== "D") || ($gateway == "E") || ($gateway == "F") || ($gateway== "G") || ($gateway == "H") || ($gateway == "I") || ($gateway == "Q") )))))))))) { // (Redirect for payment forms: Paypal, Worldpay, 2checkout, etc...) $ret = "2"; } return $ret; } function card_1($account_id,$name,$address,$zip,$cc_num,$cc_exp,$amount) { error_reporting(E_ALL ^ E_NOTICE); $db = new ps_DB; $q = "SELECT * FROM account WHERE account_id = '$account_id'"; $db->query($q); $db->next_record(); $bill_name = $db->f("account_name"); $bill_fname = $db->f("account_bill_fname"); $bill_lname = $db->f("account_bill_name"); $bill_address = $db->f("account_address"); $bill_city = $db->f("account_city"); $bill_state = $db->f("account_state"); $bill_zip = $db->f("account_zip"); $bill_phone = $db->f("account_phone"); $bill_country = $db->f("account_country"); $bill_email = $db->f("account_email"); $bill_cc_type = hl_CardType($cc_num); $cc_expmo = substr($cc_exp,0,2); $cc_expyr = substr($cc_exp,2,4); $reg_data['CcNumber']=$cc_num; $reg_data['ca_months']=$cc_expmo; $reg_data['ca_years']=$cc_expyr; $reg_data['CcType']=$bill_cc_type; $reg_data['CcName']=$bill_name; $reg_data['CcFName']=$bill_fname; $reg_data['CcLName']=$bill_lname; $reg_data['EmailAdr']=$bill_email; $reg_data['address1']=$bill_address; $reg_data['City']=$bill_city; $reg_data['State']=$bill_state; $reg_data['PostalCode']=$bill_zip; $reg_data['country']=$bill_country; //$ret = charge_verisign($account_id,$account_name,$address,$zip,$cc_num,$cc_exp,$amount,$gateway); $ret = charge_verisign_verbose($reg_data,$amount,'llc'); return $ret; } function get_membership_amount($membership_id) { $dm = new ps_DB; $q = "SELECT membership_price FROM membership WHERE membership_id = '$membership_id'"; $dm->query($q); $dm->next_record(); $amount=$dm->f("membership_price"); return $amount; } // ATTEMPT TO BILL ALL DUE ACCOUNTS NOW! function DEPRECATED_bill_all_now() { // update all trial subscriptions to the correct permanent subscriptions //trial_sub_update(); $url = setup("url"); $ret=""; $db = new ps_DB; $q = "SELECT * FROM domains"; //$q = "SELECT * FROM domains_test"; $db->query($q); $ret=""; $gw = setup("gateway"); // LOOP THROUGH EACH DOMAIN while ($db->next_record()) { $account_id = $db->f("domain_account_id"); $billing_id = $db->f("domain_billing_id"); //CHECK IF THIS ACCOUNT IS EXPIRED $expired = get_mailing_status($account_id); if ($billing_id != '' || $billing_id != '0') { if ($expired != 'sns.expired' || $expired != '') { //CHECK IF THIS ACCOUNT HAS AUTO RENEW ENABLED $dbr = new ps_DB; //$qr = "SELECT account_name,account_email,opt_out FROM account_test WHERE account_id = $account_id"; $qr = "SELECT account_name,account_email,opt_out FROM account WHERE account_id = $account_id"; $dbr->query($qr); $dbr->next_record(); $opt_out = $dbr->f("opt_out"); $member_name = $dbr->f("account_name"); $member_email = $dbr->f("account_email"); $subscription_id = $db->f("domain_id"); $membership_id = $db->f("domain_host_id"); $amount = get_membership_amount($db->f("domain_host_id")); $status = get_billing_status_bill_2($db->f("domain_host_id"),$db->f("domain_host_periods"),$db->f("domain_host_last_billed"),$db->f("domain_host_last_billed")); $days = get_expire_status($db->f("domain_host_id"),$db->f("domain_host_periods"),$db->f("domain_host_last_billed")); if (($opt_out==0) && ($status==Y) && ($amount > 0) && ($days <= 90)) { unset($C_CARD); // SUBSCRIPTION IS DUE FOR BILLING NOW! $ret.= "<BR>"; // CHECK IF THIS ACCOUNT HAS ANY CREDIT CARD ON FILE if ($db->f("domain_billing_id") > 0) { $C_CARD = TRUE; } else { $C_CARD = FALSE; } // BEGIN STORED CREDIT CARD INFORMATION LOOP if($C_CARD) { // SEE IF A SUPPORTED GATEWAY IS CONFIGURED... if ((((((((((((($gw == "0") || ($gw == "1") || ($gw == "2") || ($gw == "3") || ($gw == "4") || ($gw == "5") || ($gw == "6") || ($gw == "7") || ($gw == "8") || ($gw == "9") || ($gw == "Y") || ($gw == "Z"))))))))))))) { // LETS TRY TO CHARGE THIS CARD! $domain=$db->f("domain_name"); $ret.= "Connecting to gateway to bill account Id: " . $db->f("domain_account_id") .' Name: ' . $member_name . ' Email: ' . $member_email; $billed= quick_bill($db->f("domain_billing_id"),$db->f("domain_id"),$db->f("domain_host_id"),$db->f("domain_account_id")); if ($billed[result]=="1") { // BILLED OK AT VIA GATEWAY! update_billed_domain($db->f("domain_id"),$db->f("domain_host_periods"),$membership_id); $ret.= " RESULT: > Billed & Updated < "; // EMAIL THE CUSTOMER if (setup("email_17")==Y) { send_mail("17",$db->f("domain_account_id"),$db->f("domain_id"),"",""); } } elseif ($billed[result]=="2") { // BILLING DECLINED AT GATEWAY $ret.= " RESULT: > Card Declined... Emailed Customer < "; set_opt_out($account_id); //set_opt_out_test($account_id); // EMAIL THE CUSTOMER if (setup("email_19")==Y) { send_mail("19",$db->f("domain_account_id"),$db->f("domain_id"),"",""); $ret.= " -- Sent payment declined email to account! "; } $ret.= " <BR>"; } elseif ($billed[result]=="3") { $ret.= " RESULT: > Gateway Error... Verify your configuration < "; } else { $ret.= " RESULT: > Unknown Error... Verify your configuration < "; } } else { // LETS ASSUME THIS MERCHANT IS STORING CARDS FOR MANUAL PROCESSING AND NOTIFY HIM! $ret.= "No Gateway For Account Id:" . $db->f("domain_account_id") . " RESULT: > Emailing Admin Manual Billing Notification < "; $m_email[] = "" . $url . "/admin/?page=domains_edit&account_id=" . $db->f("domain_account_id") . "&domain_id=" . $db->f("domain_id"); } } else { // NO CARD ON FILE, COULDN'T USE IT IF WE WANTED TO! SEND THE CUSTOMER A PAYMENT LINK! //$ret.= "No Card On File For Account Id:" . $db->f("domain_account_id") . " RESULT: > Payment Link Emailed To Customer < "; $ret.= "No Card On File For Account Id:" . $db->f("domain_account_id"); //send_mail("16",$db->f("domain_account_id"),$db->f("domain_id"),"",""); set_opt_out($account_id); } } // billing not due or less than 0... } //End of expired check } //End billing info check } // end of loop... if ($ret == '') { $ret = 'No Accounts processed'; } mail("scott@stratnews.com", "Auto Billing is done", "Date: " . date("m j, Y g:i a") . "\n" . $ret); log_auto_billing($ret); // SEND MERCHANT EMAIL IF NEEDED.. $mmesage ="While attempting to bill all due cards on file on " . date("M-d-y") . ", DreamAccount was unable to connect to the gateway (or you are simply storing the card info) to bill the accounts below. Since they have a card on file, DreamAccount assumes you wish to bill them manually. The link(s) below will take you to each due subscription. "; for ($i=0;$i<=count($m_email);$i++) { $mmessage.= $m_email[$i]; } if(count($m_email) > 0) { mail(setup("email"),"Manual Credit Card Processing Required",$mmessage); } return $ret; } // end of function... function bill_all_now(){ } // BILL A SPECIFIED DOMAIN ACCOUNT function quick_bill($billing_id,$domain_id,$host_id,$account_id) { $db = new ps_DB; $q = "SELECT * FROM account WHERE account_id = '$account_id'"; $db->query($q); $db->next_record(); $name = $db->f("account_name"); $address = $db->f("account_address"); $city = $db->f("account_city"); $state = $db->f("account_state"); $zip = $db->f("account_zip"); $phone = $db->f("account_phone"); $fax = $db->f("account_fax"); $email = $db->f("account_email"); $db = new ps_DB; $q = "SELECT * FROM billing WHERE billing_id = '$billing_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"); //If no billing record exsists, return 6 so function bill_all_now can email customer. if ($cc_num == "") return 4; $db = new ps_DB; $q = "SELECT membership_price,membership_name FROM membership WHERE membership_id = '$host_id'"; $db->query($q); $db->next_record(); $sub_total=$db->f("membership_price"); $desc=$db->f("membership_name"); $tax = get_state_tax($sub_total,$state); $total = $sub_total + $tax; $amount = number_format($total,2); $rt = card($account_id,$name,$address,$zip,$cc_num,$cc_exp,$amount); if ($rt[result]=="0") { $billed_amount = $rt[amount]; create_billed_record_3($account_id,$domain_id,$billed_amount); } else { $rt[amount] = "0"; } return $rt; } // DETERMINE ANY CREDITS, ETC, AND APPLY THEM, CALC TOTAL TO BE BILLED. function DEPRECATED_card($account_id,$name,$address,$zip,$cc_num,$cc_exp,$amount) { global $message; // CHECK IF CREDIT EXSISTS OR NOT // $credit = credit_exsist($account_id); // if ($credit > 0) { // // // IF SO, CHECK IF THE CREDIT IS LARGER THAN THE AMOUNT // if($credit >= $amount) { // // // IF SO: -> DONT BILL THE CARD -> UPDATE THE CREDIT RECORD -> RETURN APPROVAL! // credit_used_1($account_id,$amount); // // $message= "<BR>You have a credit totaling <B>" . setup("currency"); // $message.= number_format($credit,2); // $message.=" </B> in your account.<BR>"; // $message.= setup("currency") . "" . number_format($amount,2) . " of your credit has applied to this transaction.<BR><BR>"; // // $result = "4"; // $amount = "0.00"; // // echo $message; // // // OTHERWISE, SEND THE DIFFERENCE TO THE CORRECT PROCCESSOR // } elseif ($credit < $amount) { // $charge_amount = $amount - $credit; // $rt = card_1($account_id,$name,$address,$zip,$cc_num,$cc_exp,$charge_amount); // // // IF APPROVED: -> UPDATE THE CREDIT RECORD -> RETURN RESULTS // if ($rt=="1") credit_used_1($account_id,$credit); // $result = $rt; // $amount = $charge_amount; // // $message.= "<BR>You have a credit totaling <B>" . setup("currency"); // $message.= number_format($credit,2); // $message.= " </B> in your account.<BR>"; // $message.= "<BR>All of your credit has applied to this transaction.<BR><BR>"; // // echo $message; // // } // // // IF NO CREDIT EXSISTS, SEND THE AMOUNT TO THE CORRECT PROCESSOR // } else { if ($amount > 0) { $rt = card_1($account_id,$name,$address,$zip,$cc_num,$cc_exp,$amount); } else { $rt = 1; } // IF APPROVED: -> RETURN RESULTS $result = $rt; $amount = $amount; // } return array ("result" => $result, "amount" => $amount); } function card($account_id,$name,$address,$zip,$cc_num,$cc_exp,$amount) { global $message; if ($amount > 0) { $rt = card_1($account_id,$name,$address,$zip,$cc_num,$cc_exp,$amount); } else { $rt = 1; } // IF APPROVED: -> RETURN RESULTS $result = $rt; $amount = $amount; return array ("result" => $result, "amount" => $amount); } function cancel_subscription($id) { // GET THE SUBSCRITPION INFO $db = new ps_DB; $q = "SELECT domain_host_id,domain_host_periods,domain_account_id FROM domains WHERE domain_id = '$id'"; $db->query($q); $db->next_record(); $membership = $db->f("domain_host_id"); $period = $db->f("domain_host_periods"); $account_id = $db->f("domain_account_id"); // GET THE MEMBERSHIP INFO $dbm = new ps_DB; $q = "SELECT membership_periods FROM membership WHERE membership_id = '$membership'"; $dbm->query($q); $dbm->next_record(); $periods = $dbm->f("membership_periods"); // UPDATE THE SUBSCRIPTION INFO $dbm = new ps_DB; $q = "UPDATE domains SET domain_host_periods = '$periods' WHERE domain_id = '$id'"; $dbm->query($q); // MOD email admin subscription cancellation $dba = new ps_DB; $q = "SELECT account_name, account_email FROM account WHERE account_id = 'account_id'"; $dba->query($q); $dba->next_record(); $account_name = $dba->f("account_name"); $account_email = $dba->f("account_email"); $message = "Subscription Id: " . $id . "\n"; $message .= "User Details: " . $account_name." - ".$account_email; $title = "Subscription cancellation"; $company_email = setup("email"); $headers = "From: <$company_email>\n"; $headers .= "X-Sender: <$company_email>\n"; $headers .= "Return-Path: <$company_email>\n"; // send the admin subscription cancelation email.. #mail($company_email,$title,$message,$headers); return "Subscription Id $id has been canceled, will not be billed again, and will expire at the end of this period."; } //CVS EXPORT function account_export($f) { global $records, $membership_id, $delimiter, $order_by, $count, $db_name; $db = new ps_DB; $cvs_output=""; $i=0; $q = "SELECT account_id,"; //$prev=""; while($i <= 20) { if($count[$i]=="Y") { if (isset($prev)) { $q .= ","; $q .= $db_name[$i]; } else { $q .= $db_name[$i]; $prev=""; } } $i++; } $q .= " FROM account "; $q .= " ORDER by $order_by"; $db->query($q); while ($db->next_record()) { $show = FALSE; $account_id = $db->f("account_id"); // DETERMINE IF THIS RECORD SHOULD SHOW . . . if ($records=="1") { // SHOW ALL! $show = TRUE; } else if ($records=="2") { // SHOW ALL WITH SUBSCR SELECTED if (acct_subscribed_to_this($account_id,$membership_id,"")) { $show = TRUE; } } else if ($records=="3") { // SHOW ALL WITH ACTIVE SUBSCR SELECTED if (acct_subscribed_to_this($account_id,$membership_id,"A")) { $show = TRUE; } } else if ($records=="4") { // SHOW ALL WITH INACTIVE SUBSCR SELECTED if (acct_subscribed_to_this($account_id,$membership_id,"I")) { $show = TRUE; } } else { $show = TRUE; } if($show) { $i=0; while($i <= 20) { if($count[$i]=="Y") { $cvs_output.=$db->f($db_name[$i]); $cvs_output.=$delimiter; } $i++; } $cvs_output.= "\n"; $matches++; } $total++; } echo "<BR>FOUND $total ACCOUNTS AND $matches MATCHES FOR THIS EXPORT<BR><BR>"; return $cvs_output; } // CHECK IF THIS ACCOUNT HAS SUBSCRIPTION ID, AND IF IT IS INACTIVE OR ACTIVE.... (status blank, A, or I) function acct_subscribed_to_this($account_id,$subscription_id,$status) { $db= new ps_DB; $q = "SELECT domain_id FROM domains WHERE domain_account_id = '$account_id' AND domain_host_id = '$subscription_id'"; if($status=="A") { $q.=" AND domain_host_status = '1'"; } elseif ($status=="I") { $q.=" AND domain_host_status != '1'"; } $db->query($q); $db->next_record(); if($db->num_rows() ==0) { return FALSE; } else { if($status=="") { return TRUE; } elseif ($status=="I") { return TRUE; } elseif ($status=="A") { //check the billing status to be sure subscription is active... if(get_billing_status_access($db->f("domain_id")) == "Y") { return TRUE; } else { return FALSE; } } } } function send_mass_email($f) { $ret=" "; $pat = "\n\r"; $message = preg_replace("/$ret/i",$pat,$f[message]); /* recipients */ $to = $f[from_name] . "<" . $f[from_email] . ">" . ", " ; /* additional headers */ $headers = "From: " . $f[from_name] . "<" . $f[from_email] . ">\n"; $headers .= "Bcc: ". $f[recipients] . ""; if($f[html]=='Y') $headers .= "\nContent-Type: text/html; charset=iso-8859-1"; // SEND THE EMAIL mail($to,$f[subject],$message,$headers); return "Your message was sent to the selected recipients"; } function delete_old_logins_cron() { // Logs out all sessions that are older than 3 days and have no associated account or affiliate record. $expire = mktime() - 86400*1; $db=new ps_DB; $q = "SELECT login_id FROM login WHERE login_logged = 'N' AND login_member_id = '0' AND login_affiliate_id = '0' AND login_date <= '$expire'"; $db->query($q); // DELETE ALL MATCHING LOGIN & SESSION RECORDS while($db->next_record()) { $sess = $db->f("login_id"); $dbl = new ps_DB; $q = "DELETE FROM login WHERE login_id='$sess'"; $dbl->query($q); $dbl = new ps_DB; $q = "DELETE FROM sessions WHERE session_domain='$sess'"; $dbl->query($q); } // DELETE ALL ORDER_ATTEMPT RECORDS OLDER THAN 1 day $today = date("Y-m-d"); $db=new ps_DB; $q = "DELETE FROM order_attempt WHERE date != '$today'"; $db->query($q); return "Performed session/cart cleanup for expired data..."; } // Check if we should allow this order or not... function check_order_attempt($account_id) { global $MAX_ORDER_ATTEMPTS, $MAX_ORDERS_PER_DAY; $today = date("Y-m-d"); // Just in case they are not defined in setup.php... if((!isset($MAX_ORDER_ATTEMPTS)) || ($MAX_ORDER_ATTEMPTS < 1)) { $MAX_ORDER_ATTEMPTS = 100; } if((!isset($MAX_ORDERS_PER_DAY)) || ($MAX_ORDERS_PER_DAY < 1)) { $MAX_ORDERS_PER_DAY = 100; } // first, we verify that this user has // not gone over today's attempt limit: $db = new ps_DB; $q = "SELECT account_id FROM order_attempt WHERE account_id = '$account_id' AND date = '$today'"; $db->query($q); if($db->num_rows() >= $MAX_ORDER_ATTEMPTS) { return FALSE; } else { // now, we check that this user has not // already made todays maximum order limit. $db = new ps_DB; $q = "SELECT order_id FROM orders WHERE order_account_id = '$account_id' AND order_date = '$today'"; $db->query($q); if($db->num_rows() >= $MAX_ORDERS_PER_DAY) { return FALSE; } else { return TRUE; } } } // Add an order attempt to the database... function order_attempt($account_id) { $today = date("Y-m-d"); $db = new ps_DB; $q = "INSERT INTO order_attempt SET account_id = '$account_id', date = '$today'"; $db->query($q); return TRUE; } // Process charges for 2checkout postback... function TWO_checkout_post($f) { global $path; include($path . "post_back_2checkout.php"); return post_back_2checkout($f); } /********************************************************** Directory Type Methods: ***********************************************************/ // get the directory_type for DIRECTORY_ID <-----------------<<<<- function get_dir_type_directory($id) { $db = new ps_DB; $q = "SELECT directory_type FROM directory WHERE directory_id='$id'"; $db->query($q); $db->next_record(); return $db->f("directory_type"); } // get the directory_type for MEMBERSHIP_ID <-----------------<<<<- function get_dir_type_membership($id) { $db = new ps_DB; $q ="select membership_directory_id from membership where membership_id='$id'"; $db->query($q); $db->next_record(); $directory_id = $db->f("membership_directory_id"); $db = new ps_DB; $q = "SELECT directory_type FROM directory WHERE directory_id='$directory_id'"; $db->query($q); $db->next_record(); return $db->f("directory_type"); } // get the directory_type for DOMAIN_ID <------------------<<<<- function get_dir_type_domain($id) { $dba = new ps_DB; $q = "SELECT domain_host_id FROM domains WHERE domain_id='$id'"; $dba->query($q); $dba->next_record(); $membership_id = $dba->f("domain_host_id"); $db = new ps_DB; $q ="select membership_directory_id from membership where membership_id='$membership_id'"; $db->query($q); $db->next_record(); $directory_id = $db->f("membership_directory_id"); $db = new ps_DB; $q = "SELECT directory_type FROM directory WHERE directory_id='$directory_id'"; $db->query($q); $db->next_record(); return $db->f("directory_type"); } // validation function... function DA_API_VALIDATION($username,$email) { global $path; // List of available mods to load.. require_once($path . 'mod_htaccess.inc.php'); // 0 require_once($path . 'mod_pmachine.inc.php'); // 4 require_once($path . 'mod_vbulletin.inc.php'); // 5 require_once($path . 'mod_phpbb.inc.php'); // 6 require_once($path . 'mod_phpnuke.inc.php'); // 7 require_once($path . 'mod_postnuke.inc.php'); // 8 require_once($path . 'mod_freeradius.inc.php'); // 9 require_once($path . 'mod_ldap.inc.php'); // 10 require_once($path . 'mod_invboard.inc.php'); // 11 require_once($path . 'mod_yabbse.inc.php'); // 12 require_once($path . 'mod_mambo.inc.php'); // 13 require_once($path . 'mod_xaraya.inc.php'); // 14 require_once($path . 'mod_geeklog.inc.php'); // 15 /* ---------- usage example ---------------- // check for this username/password in <NAME>: if(<NAME>_MOD) { $mod_<name> = new MOD_<NAME>; $mod_<name>->validate($username,$password); $<name>[un] = $mod_<name>->username; $<name>[pw] = $mod_<name>->password; { $<name>[un] = TRUE; $<name>[pw] = TRUE; } ---------- usage example ---------------- */ // check for this username/password in pMachine: if(PMACHINE_MOD) { $mod_pmachine = new MOD_PMACHINE; $mod_pmachine->validate($username,$email); $pmachine[un] = $mod_pmachine->username; $pmachine[em] = $mod_pmachine->email; } else { $pmachine[un] = TRUE; $pmachine[em] = TRUE; } // check for this username/password in vBulletin: if(VBULLETIN_MOD) { $mod_vbulletin = new MOD_VBULLETIN; $mod_vbulletin->validate($username,$email); $vbulletin[un] = $mod_vbulletin->username; $vbulletin[em] = $mod_vbulletin->email; } else { $vbulletin[un] = TRUE; $vbulletin[em] = TRUE; } // check for this username/password in PHPBB: if(PHPBB_MOD) { $mod_phpbb = new MOD_PHPBB; $mod_phpbb->validate($username,$email); $phpbb[un] = $mod_phpbb->username; $phpbb[em] = $mod_phpbb->email; } else { $phpbb[un] = TRUE; $phpbb[em] = TRUE; } // check for this username/password in PHPNUKE: if(PHPNUKE_MOD) { $mod_phpnuke = new MOD_PHPNUKE; $mod_phpnuke->validate($username,$email); $phpnuke[un] = $mod_phpnuke->username; $phpnuke[em] = $mod_phpnuke->email; } else { $phpnuke[un] = TRUE; $phpnuke[em] = TRUE; } // check for this username/password in POSTNUKE: if(POSTNUKE_MOD) { $mod_postnuke = new MOD_POSTNUKE; $mod_postnuke->validate($username,$email); $postnuke[un] = $mod_postnuke->username; $postnuke[em] = $mod_postnuke->email; } else { $postnuke[un] = TRUE; $postnuke[em] = TRUE; } // check for this username/password in FREERADIUS: if(FREERADIUS_MOD) { $mod_freeradius = new MOD_FREERADIUS; $mod_freeradius->validate($username,$email); $freeradius[un] = $mod_freeradius->username; $freeradius[em] = $mod_freeradius->email; } else { $freeradius[un] = TRUE; $freeradius[em] = TRUE; } // check for this username/password in LDAP: if(LDAP_MOD) { $mod_ldap = new MOD_LDAP; $mod_ldap->validate($username,$email); $ldap[un] = $mod_ldap->username; $ldap[em] = $mod_ldap->email; } else { $ldap[un] = TRUE; $ldap[em] = TRUE; } // check for this username/password in INVISION BOARD: if(INVBOARD_MOD) { $mod_invboard = new MOD_INVBOARD; $mod_invboard->validate($username,$email); $invboard[un] = $mod_invboard->username; $invboard[em] = $mod_invboard->email; } else { $invboard[un] = TRUE; $invboard[em] = TRUE; } // check for this username/password in YaBBSE: if(YABBSE_MOD) { $mod_yabbse = new MOD_YABBSE; $mod_yabbse->validate($username,$email); $yabbse[un] = $mod_yabbse->username; $yabbse[em] = $mod_yabbse->email; } else { $yabbse[un] = TRUE; $yabbse[em] = TRUE; } // check for this username/password in MAMBO: if(MAMBO_MOD) { $mod_mambo = new MOD_MAMBO; $mod_mambo->validate($username,$email); $mambo[un] = $mod_mambo->username; $mambo[em] = $mod_mambo->email; } else { $mambo[un] = TRUE; $mambo[em] = TRUE; } // check for this username/password in XARAYA: if(XARAYA_MOD) { $mod_xaraya = new MOD_XARAYA; $mod_xaraya->validate($username,$email); $xaraya[un] = $mod_xaraya->username; $xaraya[em] = $mod_xaraya->email; } else { $xaraya[un] = TRUE; $xaraya[em] = TRUE; } // check for this username/password in GEEKLOG: if(GEEKLOG_MOD) { $mod_geeklog = new MOD_GEEKLOG; $mod_geeklog->validate($username,$email); $geeklog[un] = $mod_geeklog->username; $geeklog[em] = $mod_geeklog->email; } else { $geeklog[un] = TRUE; $geeklog[em] = TRUE; } //-------------------------------------------------------------------------------- // get the results for the username: if ( // add additional mod conditions here... ($pmachine[un]) && ($vbulletin[un]) && ($phpbb[un]) && ($postnuke[un]) && ($phpnuke[un]) && ($freeradius[un]) && ($ldap[un]) && ($invboard[un]) && ($yabbse[un]) && ($mambo[un]) && ($xaraya[un]) && ($geeklog[un]) ) { $return[username] = TRUE; } else { $return[username] = FALSE; } // get the results for the password: if ( // add additional mod conditions here... ($pmachine[em]) && ($vbulletin[em]) && ($phpbb[em]) && ($postnuke[em]) && ($phpnuke[em]) && ($freeradius[em]) && ($ldap[em]) && ($invboard[em]) && ($yabbse[em]) && ($mambo[em]) && ($xaraya[em]) && ($geeklog[em]) ) { $return[email] = TRUE; } else { $return[email] = FALSE; } if(isset($return)) { return $return; } else { $r[email] = true; $r[username] = true; return $r; } } // Trial Subscription Manager... function trial_sub_update() { // LOOP THROUGH ALL THE MEMBERSHIPS, WHERE TRIAL = Y $db = new ps_DB; $q ="select membership_id,trial_plan,membership_frequency from membership where trial='Y'"; $db->query($q); while($db->next_record()) { $trial_plan = $db->f("trial_plan"); // LOOP THROUGH EACH SUBSCRIPTION RECORD, WHERE DOMIN_ID = $MEMBERSHIP_ID $membership_id = $db->f("membership_id"); $dbd = new ps_DB; $q ="SELECT * FROM domains WHERE domain_host_id = '$membership_id'"; $dbd->query($q); while($dbd->next_record()) { $domain_id = $dbd->f("domain_id"); $account_id = $dbd->f("account_id"); // FIND OUT WHEN THIS PLAN EXPIRES. $status = trial_status_2($dbd->f("domain_host_id"),$dbd->f("domain_host_periods"),$dbd->f("domain_host_last_billed")); // IF IT IS EXPIRED, OR EXPIRES TODAY, THEN SWITCH IT TO THE TRAIL_PLAN FOR THIS MEMBERSHIP if($status) { // SET DOMAIN_HOST_LAST_BILLED TO (TODAY - MEMBERSHIP_FREQUENCY) (YYYY-MM-DD) $orig_date = mktime($dbd->f("domain_start_billed")); // GET THE FREQUENCY FOR THE NEW PLAN $dbb = new ps_DB; $q ="SELECT membership_frequency FROM membership WHERE membership_id = '$trial_plan'"; $dbb->query($q); $dbb->next_record(); // CALCULATE THE DUE DATE TO MAKE IT DUE TODAY... $last_billed = mktime() - (86400*$dbb->f("membership_frequency")); $last_billed = date("Y-m-d",$last_billed); // UPDATE THE DOMAIN RECORD... $dbd = new ps_DB; $q ="UPDATE domains SET domain_host_id = '$trial_plan', domain_host_last_billed = '$last_billed' WHERE domain_id = '$domain_id'"; $dbd->query($q); } } } // Update the directories update_all_directory(); return "All expired trial subscriptions have been updated to the correct permanent subscription.<BR><BR>"; } function hl_CardType($CardNum) { $CardNum = preg_replace('/[^0-9]/','',$CardNum); if (preg_match('/^5[1-5].{14}$/', $CardNum)) return 'Mastercard'; if (preg_match('/^4.{15}$|^4.{12}$/', $CardNum)) return 'Visa'; if (preg_match('/^3[47].{13}$/', $CardNum)) return 'American Express'; if (preg_match('/^6011.{12}$/', $CardNum)) return 'Discover'; if (preg_match('/^30[0-5].{11}$|^3[68].{12}$/', $CardNum)) return 'dnc'; if (preg_match('/^3.{15}$|^2131|1800.{11}$/', $CardNum)) return 'jcb'; if (preg_match('/^2014.{11}$|^2149.{11}$/', $CardNum)) return 'enr'; //if (!hl_LuhnMod10( $CardNum)) return 'bad'; return 'unknown'; } function get_cc_data($order_id) { $dba = new ps_DB; $qa = "SELECT order_billing_id FROM orders WHERE order_id='$order_id'"; $dba->query($qa); $dba->next_record(); $billing_id =$dba->f("order_billing_id"); $db = new ps_DB; $q = "SELECT billing_cc_num FROM billing WHERE billing_id='$billing_id'"; $db->query($q); $db->next_record(); $cc_num =$db->f("billing_cc_num"); $CardNum=RC4($cc_num,"de"); $cc = show_hidden_cc_1($cc_num); $type = hl_CardType($CardNum); $cc_data = array ("cc" => $cc, "type" => $type); return $cc_data; } function get_cc_data2($billing_order_id) { $db = new ps_DB; $q = "SELECT billing_cc_num FROM billing WHERE billing_order_id=$billing_order_id"; $db->query($q); $db->next_record(); $cc_num =$db->f("billing_cc_num"); $CardNum=RC4($cc_num,"de"); $cc = show_hidden_cc_1($cc_num); $type = hl_CardType($CardNum); //$cc_data = $cc; $cc_data[0] = "$cc"; $cc_data[1] = "$type"; return $cc_data; } // renew date function alt version function renew_date_process_alt($domain_id) { $remainingdays = get_remaining_days_start_alt($domain_id); $remainingsecs = $remainingdays * 86400; $today=date("Y-m-d"); $today_date=strtotime($today) ; if ($remainingdays == '0') { $newdate = $today_date; } else { $newdate = ($today_date + $remainingsecs); } //$ret = date("Y-m-d", $newdate ) . ' ' . $remainingdays; $ret = date("Y-m-d", $newdate ); return $ret; } function get_remaining_days_start_alt($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_remaining_days($db->f("domain_host_id"),$db->f("domain_host_periods"),$db->f("domain_host_last_billed")); } return $ret; } // renew date function function renew_date_process_old($account_id) { $remainingdays = get_remaining_days_start($account_id); $remainingsecs = $remainingdays * 86400; $today=date("Y-m-d"); $today_date=strtotime($today) ; if ($remainingdays == '0') { $newdate = $today_date; } else { $newdate = ($today_date + $remainingsecs); } //$ret = date("Y-m-d", $newdate ) . ' ' . $remainingdays; $ret = date("Y-m-d", $newdate ); return $ret; } function renew_date_process($account_id,$current_domain,$new_domain) { $status = get_mailing_status($account_id); $remainingdays = get_remaining_days_start($account_id); if (($current_domain == '33' OR $current_domain == '42') AND ($new_domain == '36' OR $new_domain == '43')) { $daysleft = $remainingdays / 1.5; $remainingdays = number_format($daysleft,0); } if ($new_domain == '49') { $daysleft = $remainingdays / 1.5; $remainingdays = number_format($daysleft,0); } $remainingsecs = $remainingdays * 86400; if ($status == 'sns.expired') { $remainingdays = '0'; } $today=date("Y-m-d"); $today_date=strtotime($today) ; if ($remainingdays == '0') { $newdate = $today_date; } else { $newdate = ($today_date + $remainingsecs); } //$ret = date("Y-m-d", $newdate ) . ' ' . $remainingdays; $ret = date("Y-m-d", $newdate ); return $ret; } function get_remaining_days_start($account_id) { $db = new ps_DB; $q = "SELECT domain_start_date,domain_host_id,domain_host_periods,domain_host_last_billed FROM domains WHERE domain_account_id = '$account_id'"; $db->query($q); while ($db->next_record()) { $ret = get_remaining_days($db->f("domain_host_id"),$db->f("domain_host_periods"),$db->f("domain_host_last_billed")); } return $ret; } function get_remaining_days_old($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) { //echo "Remain periods: $periods_diff <BR>"; // 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"; $ret = '0'; } else { // JUST DUE FOR REBILLING TODAY //$ret = "Due Today"; $ret = '0'; } // 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; $ret = number_format($due,0); } else { // JUST DUE FOR REBILLING TODAY //$ret = "due in " . number_format($due,0) . " day" . $d; $ret = number_format($due,0); } } // 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; $ret = number_format($due,0); $ret = '0'; } // THERE ARE NO REMAINING BILLING PERIODS, THIS SUBSCRIPTION IS EXPIRED, ACCESS DENIED! } else { //$ret = "Expired"; $ret = '0'; } } // THIS IS NOT A RECURRING CHARGE. } else { $ret = "Non-recurring"; $ret = '0'; } return $ret; } function get_remaining_days($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) { //echo "Remain periods: $periods_diff <BR>"; // 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"; $ret = '0'; } else { // JUST DUE FOR REBILLING TODAY //$ret = "Due Today"; $ret = '0'; } // 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; $ret = number_format($due,0); } else { // JUST DUE FOR REBILLING TODAY //$ret = "due in " . number_format($due,0) . " day" . $d; $ret = number_format($due,0); } } // 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; $due = $frequency - $date_diff; if ($due > 1) $d = "s"; //$ret = "overdue by " . number_format($due,0) . " day" . $d; $ret = number_format($due,0); //if ($ret < '-90') { //$ret = '0'; //} } // THERE ARE NO REMAINING BILLING PERIODS, THIS SUBSCRIPTION IS EXPIRED, ACCESS DENIED! } else { //$ret = "Expired"; $ret = '0'; } } // THIS IS NOT A RECURRING CHARGE. } else { $ret = "Non-recurring"; $ret = '0'; } return $ret; } function renew_date_process_addyear($account_id) { $remainingdays = get_remaining_days_start($account_id); $remainingsecs = ($remainingdays * 86400) + 31536000; $today=date("Y-m-d"); $today_date=strtotime($today) ; if ($remainingdays == '0') { $newdate = $today_date; } else { $newdate = ($today_date + $remainingsecs); } //$ret = date("Y-m-d", $newdate ) . ' ' . $remainingdays; $ret = date("Y-m-d", $newdate ); return $ret; } function renew_date_calc_start($account_id,$renew_date) { $dbd = new ps_DB; $qd = "SELECT domain_host_id FROM domains WHERE domain_account_id = '$account_id'"; $dbd->query($qd); $dbd->next_record(); $membership_id = $dbd->f("domain_host_id"); $db = new ps_DB; $q = "SELECT membership_frequency FROM membership WHERE membership_id='$membership_id'"; $db->query($q); $db->next_record(); $frequency = $db->f("membership_frequency"); $frequency_secs = $frequency * 86400; $renew_date2 = strtotime($renew_date) ; $newdate = $renew_date2 - $frequency_secs; $ret = date("Y-m-d", $newdate ); return $ret; } function renew_date_calc_end($account_id,$renew_date) { $dbd = new ps_DB; $qd = "SELECT domain_host_id FROM domains WHERE domain_account_id = '$account_id'"; $dbd->query($qd); $dbd->next_record(); $membership_id = $dbd->f("domain_host_id"); $db = new ps_DB; $q = "SELECT membership_frequency FROM membership WHERE membership_id='$membership_id'"; $db->query($q); $db->next_record(); $frequency = $db->f("membership_frequency"); $frequency_secs = $frequency * 86400; $renew_date2 = strtotime($renew_date) ; $newdate = $renew_date2 + $frequency_secs; $ret = date("Y-m-d", $newdate ); return $ret; } //Update Renewal Date in table.Account function update_renew_date ($account_id,$renew_date) { $date1 = renew_date_calc_end($account_id,$renew_date); $db = new ps_DB; $q = "UPDATE account SET renew_date = '$date1' WHERE account_id = '$account_id'"; $db->query($q); } function update_renew_date2 ($account_id,$renew_date) { $db = new ps_DB; $q = "UPDATE account SET renew_date = '$renew_date' WHERE account_id = '$account_id'"; $db->query($q); } function sql_string_filter ($db_connection, $input_string) { // if( get_magic_quotes_gpc() ) // { // $value = stripslashes( $input_string ); // } // Check if mysql_real_escape_string() exists // if( function_exists( "mysql_real_escape_string" ) ) // { $value = mysqli_real_escape_string($db_connection, $input_string); // } // For PHP version < 4.3.0 use addslashes // else // { // $value = addslashes( $value ); // } return $value; } function check_auth($this_id){ global $membership_cookie, $sns_inews_cookie, $this_id; if (!isset($membership_cookie)) { if (!isset($sns_inews_cookie)) { $ret = 'N' ; return $ret; } else { if ($this_id == 'F') { if (isset($sns_inews_cookie[F]) && ($sns_inews_cookie[F] == Y )){ $ret = 'Y' ; return $ret; } if (isset($sns_inews_cookie[R]) && ($sns_inews_cookie[R] == Y )){ $ret = 'Y' ; return $ret; } } } } if ($this_id == 'F') { if (isset($membership_cookie[R]) && ($membership_cookie[R] == Y )){ $ret = 'Y' ; return $ret; } } if ($this_id == 'Z' ) { $page_level = "4"; } elseif ($this_id == 'A' ) { $page_level = "3"; } elseif ($this_id == 'P' ) { $page_level = "2"; } elseif($this_id == 'S' || $this_id == 'F') { $page_level = "1"; } else { $page_level = "0"; } if (isset($membership_cookie[Z]) && ($membership_cookie[Z] == Y )){ $level = "4"; } elseif (isset($membership_cookie[A]) && ($membership_cookie[A] == Y )){ $level = "3"; } elseif (isset($membership_cookie[P]) && ($membership_cookie[P] == Y )){ $level = "2"; } elseif(isset($membership_cookie[S]) && ($membership_cookie[S] == Y )) { $level = "1"; } else { $level = "0"; } //echo $level; if ($level < $page_level ) { $ret = 'N' ; return $ret; } else { $ret = 'Y' ; return $ret; } } function check_which_cookie() { global $membership_cookie,$sns_inews_cookie; if (isset($membership_cookie[Z]) && ($membership_cookie[Z] == Y )){ $level = "9"; } elseif (isset($membership_cookie[A]) && ($membership_cookie[A] == Y )){ $level = "7"; } elseif (isset($membership_cookie[P]) && ($membership_cookie[P] == Y )){ $level = "5"; } elseif(isset($membership_cookie[S]) && ($membership_cookie[S] == Y )) { $level = "3"; } elseif(isset($membership_cookie[R]) && ($membership_cookie[R] == Y )) { $level = "1"; } else { if (isset($sns_inews_cookie[F]) && ($sns_inews_cookie[F] == Y )){ $level = "1"; } else { $level = "0"; } } return $level; } function delete_cookie() { global $membership_cookie, $this_id; setcookie("membership_cookie[$this_id]"); $membership_cookie[$this_id] = "N"; $auth_message = "Your session has been terminated or timed out, please login below."; } function create_cookie($member_sub_level) { global $membership_cookie, $this_id; setcookie("membership_cookie[$member_sub_level]","Y", time() + 604800, "/"); $membership_cookie[$this_id] = "Y"; $auth_message = "Cookie Created!"; } function create_zoom_cookie($member_sub_level) { global $membership_cookie, $this_id; setcookie("membership_cookie[$member_sub_level]","Y", time() + 157784630, "/members/"); $membership_cookie[$this_id] = "Y"; $auth_message = "Cookie Created!"; } function create_member_cookie($account_id) { global $sns_cookie, $account_id; $cookie_value=RC4($account_id,"en"); //$cookie_value = $validate[5].'-'.$validate[6]; setcookie("sns_cookie",$cookie_value, time() + 604800, "/"); //$fire_cookie[$speaker_id] = "Y"; //$auth_message = "Cookie Created!"; } function check_inews_registration($customer_email){ $reply = strtolower($customer_email); //$reply = sanitize_sql_string($customer_email); $reply = addslashes(htmlentities($customer_email, ENT_QUOTES)); $db = new ps_DB; $q = "SELECT * FROM event_merge WHERE customer_email LIKE '$reply' AND verified = '1' AND noindex = '0' AND speaker = 's' "; //$q = "SELECT verified FROM event_merge WHERE customer_email LIKE '$customer_email' "; $db->query($q); $db->next_record(); $verified = $db->f("verified"); if ($verified == '1' ) { $ret[0] = 'Y'; } else { $ret[0] = 'N'; } $ret[1] = $db->f("customer_firstname"); $ret[2] = $db->f("customer_lastname"); $ret[3] = $db->f("customer_title"); $ret[4] = $db->f("company_name"); $ret[5] = $db->f("event"); $ret[6] = $db->f("event_clientid"); return $ret; } function inews_create_cookie($member_sub_level) { global $sns_inews_cookie, $this_id; setcookie("sns_inews_cookie[$member_sub_level]","Y", time() + 604800, "/"); $sns_inews_cookie[$this_id] = "Y"; //$auth_message = "Cookie Created!"; } function inews_create_speaker_cookie($validate) { global $sns_inews_speaker_cookie; $cookie_value = $validate[5].'-'.$validate[6]; setcookie("sns_inews_speaker_cookie",$cookie_value, time() + 604800, "/"); //$fire_cookie[$speaker_id] = "Y"; //$auth_message = "Cookie Created!"; } function inews_create_registered_cookie($validate) { global $sns_inews_registered_cookie; $cookie_value = $validate[4]; setcookie("sns_inews_registered_cookie",$cookie_value, time() + 604800, "/"); //$fire_cookie[$speaker_id] = "Y"; //$auth_message = "Cookie Created!"; } function check_digest_registration($customer_email){ $reply = strtolower($customer_email); //$reply = sanitize_sql_string($customer_email); $reply = addslashes(htmlentities($customer_email, ENT_QUOTES)); $db = new ps_DB; $q = "SELECT * FROM digest_signups WHERE email LIKE '$reply' AND active = '1' AND confirmed = '1' "; $db->query($q); $db->next_record(); $confirmed = $db->f("confirmed"); if ($confirmed == '1' ) { $ret[0] = 'Y'; } else { $ret[0] = 'N'; } $ret[1] = $db->f("fname"); $ret[2] = $db->f("lname"); $ret[3] = $db->f("email"); $ret[4] = $db->f("record_id"); return $ret; } function check_which_cookie_logout() { global $membership_cookie; if (isset($membership_cookie[A]) && ($membership_cookie[A] == Y )){ $this_id = "A"; } elseif (isset($membership_cookie[P]) && ($membership_cookie[P] == Y )){ $this_id = "P"; } else { $this_id = "S"; } return $this_id; } function get_sns_member_info(){ global $sns_cookie; $account_id=RC4($sns_cookie,"de"); $db = new ps_DB; $q = "SELECT account_name, account_title, account_company, account_email, status FROM account WHERE account_id = '$account_id'"; $db->query($q); $db->next_record(); $dba = new ps_DB; $qa = "SELECT domain_host_id FROM domains WHERE domain_account_id = '$account_id'"; $dba->query($qa); $dba->next_record(); //$fullname = explode(" ",$db->f("account_name")); $viewer_data[0] = $account_id; $viewer_data[1] = $db->f("account_name"); $viewer_data[2] = $db->f("account_company"); $viewer_data[3] = $db->f("account_email"); $viewer_data[4] = $db->f("account_title"); $viewer_data[5] = $dba->f("domain_host_id"); $viewer_data[6] = $db->f("status"); return $viewer_data; } function get_sns_staff_info($account_id){ $db = new ps_DB; $q = "SELECT account_name, account_title, account_company, account_email, status FROM account WHERE account_id = '$account_id'"; $db->query($q); $db->next_record(); $dba = new ps_DB; $qa = "SELECT domain_host_id FROM domains WHERE domain_account_id = '$account_id'"; $dba->query($qa); $dba->next_record(); //$fullname = explode(" ",$db->f("account_name")); $viewer_data[0] = $account_id; $viewer_data[1] = $db->f("account_name"); $viewer_data[2] = $db->f("account_company"); $viewer_data[3] = $db->f("account_email"); $viewer_data[4] = $db->f("account_title"); $viewer_data[5] = $dba->f("domain_host_id"); $viewer_data[6] = $db->f("status"); return $viewer_data; } function track_login(){ global $sns_cookie, $sns_inews_speaker_cookie; if(isset($sns_cookie)){ $account_id=RC4($sns_cookie,"de"); } else { $account_id=$sns_inews_speaker_cookie; } if(isset($_SERVER[REQUEST_URI])) { $page=$_SERVER[REQUEST_URI];} else {$page='nada';} if(isset($_SERVER[REMOTE_ADDR])) { $ip=$_SERVER[REMOTE_ADDR];} else {$ip='nope';} if ($account_id != '') { if (isset($_SERVER[REMOTE_ADDR]) && $_SERVER[REMOTE_ADDR] != '70.89.152.22') { $db = new ps_DB; $q = "INSERT INTO member_logins SET account_id = '" . sql_string_filter($db->lid, $account_id) . "', page_id = '" . sql_string_filter($db->lid, $page) . "', ip_address = '" . sql_string_filter($db->lid, $ip) . "'"; $db->query($q); } } } function get_nav(){ global $sns_inews_speaker_cookie, $membership_cookie, $sns_cookie, $sns_inews_cookie, $sns_inews_registered_cookie; $page = 'http://www.tapsns.com'.$_SERVER[REQUEST_URI]; //Determine Membership Level $member_level = get_member_level(); //Get Navigation $nav = '<table cellSpacing="0" cellPadding="0" border="0" align="left" class="leftnav_table">'; $db = new ps_DB; $q = "SELECT * FROM dreamaccount.nav WHERE hide = 1 AND level <= $member_level ORDER BY sort_order ASC"; $db->query($q); $line = ''; while ($db->next_record()) { $nav_id = $db->f("nav_id"); $name = $db->f("title"); $alt = $db->f("alt_text"); $link = $db->f("link"); $sort = $db->f("sort_order"); $highlight = $db->f("highlight"); $note=''; if ($highlight == '1') { $new = ' - <span style="color:yellow">NEW!</span>'; } else { $new = ''; } if($line == ''){ if ($sort >= 300) { $line = 'Y'; } } if ($line == 'Y') { $note = ' <tr> <td><IMG width="1" height="6" src="/images/pixel.gif"></td> <td><IMG height="6" src="/images/pixel.gif"></td> </tr> <tr> <td><IMG width="1" height="6" src="/images/pixel.gif"></td> <td class="leftnav">Member\'s Area:</td> </tr> <tr> <td><IMG width="1" height="6" src="/images/pixel.gif"></td> <td><IMG height="6" src="/images/pixel.gif"></td> </tr>'; $line = 'N'; } $block = ' <tr> <td><IMG width="1" height="6" src="/images/pixel.gif"></td> <td> <A class="leftnav" onmouseover="imgbutton_'.$nav_id.'.src=\'/images/redbump.gif\'" style="TEXT-DECORATION: none; color: #d0d0d0" onmouseout="imgbutton_'.$nav_id.'.src=\'/images/bluebump.gif\'" href="'.$link.'" target="_top" alt="'.$alt.'" title="'.$alt.'">'; if($page == $link){ $block .= ' <IMG height=12 src="/images/redbump.gif" width=12 border=0 name=imgbutton_'.$nav_id.'> '.$name.$new.'</A>'; } else { $block .= ' <IMG height=12 src="/images/bluebump.gif" width=12 border=0 name=imgbutton_'.$nav_id.'> '.$name.$new.'</A>'; } $block .= ' </td> </tr> <tr> <td><IMG width="1" height="6" src="/images/pixel.gif"></td> <td><IMG height="6" src="/images/pixel.gif"></td> </tr>'; if($member_level > '0') { if ($nav_id != '12' && $nav_id != '85') { $nav .= $note.$block; } else { $nav .= $note; } } else { $nav .= $note.$block; } } $nav .= '</table>'; return $nav; } function next_member_number() { $db = new ps_DB; $q = "SELECT MAX(member_number) AS nextnum FROM account"; $db->query($q); $db->next_record(); $last=$db->f("nextnum"); $ret = $last+1; return $ret; } ?> <? function get_media_spotlight() { $db = new ps_DB; $q = "SELECT * FROM dreamaccount.media WHERE spotlight != '0' ORDER BY spotlight ASC"; $db->query($q); if ($db->num_rows() > 0) { $ret = ''; while ($db->next_record()) { $event = $db->f("event"); $title = $db->f("title"); $desc = $db->f("desc"); $duration = $db->f("duration"); $session_type = $db->f("session_type"); $record_date = $db->f("record_date"); $date1 = strtotime($record_date); $date2 = date('F d, Y', $date1); $audio_path = $db->f("audio_path"); $audio_filename = $db->f("audio_filename"); $video_path = $db->f("video_path"); $video_filename = $db->f("video_filename"); $trans_path = $db->f("trans_path"); $trans_filename = $db->f("trans_filename"); if ($event == 'fire2006') { $event_title = 'Future in Review 2006'; $location = 'San Diego, CA at the Hotel Del Coronado'; } elseif ($event == 'wcdinner2006') { $event_title = 'West Coast Dinner 2006'; $location = 'San Francisco, CA at the Mark Hopkins Hotel'; } elseif ($event == 'nydinner2006') { $event_title = 'New York Dinner 2006'; $location = 'New York, NY at the Waldorf=Astoria'; } if($event2 == '' || $event2 != $event){ //$ret .= '<tr><td><br><br><FONT SIZE=4><B><FONT COLOR=990000>SNS '. $event_title . '</B></FONT></FONT><br></td></tr>'; $event2 = $event; } if ($event = 'fire2006') { $audio_path = '/' . $audio_path; } if ($video_path != '') { $watch_video = '<td class="smalltext" align="center" width="33%">'; $watch_video .= '<a href="' . $video_path . $video_filename . '"><img src="media/fire2006/images/wmv.gif" border="0"></a><br>'; $watch_video .= '<a href="' . $video_path . $video_filename . '">Watch the video</a></td>'; } if ($audio_path != '') { $listen_audio = '<td class="smalltext" align="center" width="34%" >'; $listen_audio .= '<a href="' . $audio_path . $audio_filename . '"><img src="media/fire2006/images/mp3.jpg" border="0"></a><br>'; $listen_audio .= '<a href="' . $audio_path . $audio_filename . '">Listen to the audio</a></td>'; } if ($trans_path != '') { $read_trans = '<td class="smalltext" align="center" width="33%" >'; $read_trans .= '<a href="' . $trans_path . $trans_filename . '"><img src="media/fire2006/images/pdf.jpg" border="0"></a><br>'; $read_trans .= '<a href="' . $trans_path . $trans_filename . '">Read the transcript</a></td>'; } $ret.='<tr> <td valign="top" align="center"><img src="' . $db->f("image_path") . '" alt="" border="1"></td> </tr> <tr> <td valign="top" align="center"><div width="150" style="text-align:left;"> <font size="2" face="Times, serif"><b>' . $title . ':</b> <br><!--' . $desc . ' - '. $duration .'--></font></div> </td> </tr> <tr> <td colspan="2"> <div align="center"><font size="2" face="Times, serif">[<a href="' . $video_path . $video_filename . '">Windows Media Stream</a>]</font></div> <br> </td> </tr>'; $watch_video = ''; $listen_audio = ''; $read_trans = ''; } } else { $ret = ""; } return $ret; } //UPDATE MEMBER RECORD FOR MEMBER TYPE function member_type_update($account_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); $db->next_record(); $host_id = $db->f("session_membership_id"); if($host_id == 33 || $host_id == 42 || $host_id == 52 || $host_id == 55 || $host_id == 57){ $member_type = 'sns.normal'; } elseif ($host_id == 36 || $host_id == 43 || $host_id == 49 || $host_id == 50 || $host_id == 56){ $member_type = 'sns.premium'; } elseif ($host_id == 35){ $member_type = 'sns.grpnormal'; } elseif ($host_id == 38 || $host_id == 45){ $member_type = 'sns.grppremium'; } else { $member_type = 'sns.week1'; } $dba = new ps_DB; $q2 = "UPDATE account SET status = '$member_type' WHERE account_id = '$account_id'"; $dba->query($q2); } //UPDATE MEMBER RECORD FOR MEMBER TYPE function member_type_update2($account_id,$host_id) { if($host_id == 33 || $host_id == 42 || $host_id == 52 || $host_id == 55 || $host_id == 57){ $member_type = 'sns.normal'; } elseif ($host_id == 36 || $host_id == 43 || $host_id == 49 || $host_id == 50 || $host_id == 56){ $member_type = 'sns.premium'; } elseif ($host_id == 35){ $member_type = 'sns.grpnormal'; } elseif ($host_id == 38 || $host_id == 45){ $member_type = 'sns.grppremium'; } elseif ($host_id == 58 ){ $member_type = 'sns.digest'; } else { $member_type = 'sns.week1'; } $db = new ps_DB; $q = "UPDATE account SET status = '$member_type' WHERE account_id = '$account_id'"; $db->query($q); } // GET BILLING STATUS & RETURN TEXT EXPLAINATION function get_billing_status_sns($account_id) { $db = new ps_DB; $q = "SELECT domain_start_date,domain_host_id,domain_host_periods,domain_host_last_billed FROM domains WHERE domain_account_id='$account_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; } //MEMBERSHIP RENEWAL MAILINGS function mail_renewal_notice_test($form){ $queries=array(); if(is_array($form["account_id"])){ foreach($form["account_id"] as $d){ array_push($queries,"SELECT account_name, account_email FROM account WHERE account_id=" . intval($d)); } } for($i=0; $i <= count($queries); $i++) { if($queries[$i] != "") { $db = new ps_DB; $q = $queries[$i]; $db->query($q); $db->next_record(); $ret .= 'Member Name: <b>'.$db->f("account_name"). '</b> email: '.$db->f("account_email").'<br>'; } } return $ret; } function mail_renewal_notice_test2($form){ $queries=array(); if(is_array($form["account_id"])){ foreach($form["account_id"] as $d){ array_push($queries,"SELECT account_name, account_email FROM account WHERE account_id=" . intval($d)); } } for($i=0; $i <= count($queries); $i++) { if($queries[$i] != "") { $db = new ps_DB; $q = $queries[$i]; $db->query($q); $db->next_record(); $status = get_billing_status_sns($d); $renewal_text .= 'Dear '.$db->f("account_name"). ', Your SNS subscription is '.$status.'. Thank you for taking the time to review your account; instructions for renewing are at the end of this letter.'; $ret .= 'Member Name: <b>'.$db->f("account_name"). '</b> email: '.$db->f("account_email").'<br>'; //$ret2 .= 'Member Name: '.$db->f("account_name"). ' email: '.$db->f("account_email")."\n"; //mail("schram@u.washington.edu,susan@tapsns.com", "Single issue sent", "Finished on " . date("m j, Y g:i a")); } } mail("scott@stratnews.com", "Renewal Notices Sent", "Finished on " . date("m j, Y g:i a") . "\n" . $renewal_text); return $ret; } //MAIL RENEWAL NOTICES - THE REAL FUNCTION! function mail_renewal_notice($form){ if(is_array($form["account_id"])){ foreach($form["account_id"] as $d){ $db = new ps_DB; $q = "SELECT account_name, account_email, renew_date FROM account WHERE account_id=" . intval($d); $db->query($q); $db->next_record(); $today=date("Y-m-d"); $today_date=strtotime($today); $last_billed = $db->f("renew_date"); $db_date=strtotime($last_billed); if ($last_billed != '') { if ($today_date == $db_date) { $date_note = 'Your SNS membership is due today'; } elseif ($today_date <= $db_date) { $date_note = 'Your SNS membership is due ' . date('l \t\h\e jS \of F Y',$db_date); } else { $date_note = 'Your SNS membership was due ' . date('l \t\h\e jS \of F Y',$db_date); } } else { $date_note = 'Your SNS membership is due to expire within the next 90 days.'; } $status = get_billing_status_sns($d); $renewal_text = 'Dear '.$db->f("account_name"). ', '. $date_note. '. We are notifying you now to ensure plenty of time for renewal, so you will be guaranteed uninterrupted delivery of the SNS newsletter, invitations to special events, and access to Members-only web features. We will continue to send you reminders on a monthly basis until we receive your payment. But why take a chance? To renew now, please visit the SNS homepage at http://www.stratnews.com/ and click on "Renew Now!" just below our upcoming event notices. The site will take you to a secure form for credit card processing. If you prefer to pay by check, please contact Jessica Crouch, at 360-378-8628 or by email at subscriptions@stratnews.com. For the last thirteen months you have had an unfair competitive advantage; you have had personal access to SNS predictions during a time when SNS continued to be the most accurate predictive newsletter in the computer and telecom industries. What did you see before your competitors saw it? - The first suggestion and prediction that Carly Fiorina wouldn\'t last at HP, and why; - The outcomes of both the U.S. and European antitrust suits vs. Microsoft, and the long-term effects Steve Ballmer\'s approach will have for the company; - The return of online ad revenues with expanding broadband service, the related increase in VC funding, and the unfolding effects of SNS\' "Hyperstructural Economics" on the U.S. and global economies; - Continued accurate prediction of exact Yen/dollar ratios, for those doing business in the second-largest market in the world; - The emergence of selected e-commerce sites as the newest strategic technology platforms, transcending the strategic importance of boxes and surprising many inner industry players; - And the re-alliance of all of the major players of the technology industry, as new technical and financial issues force them into new positions with increased or reduced profit potential. Of course, you can read a few of these things second hand, in places like the New York Times, the WSJ, PC Week, the Red Herring, or the Financial Times of London, but then you\'d just be reading what everyone else reads. Not much of an advantage there� Perhaps even better, you had a chance to see what other leaders in the business thought about the future. Weekly personal email from members like Bill Gates, Michael Dell, David Brin, Barry Diller, Elon Musk, and many others, helped provide you with a strategic view unavailable anywhere else. What should you expect in the future from SNS? More of the same. More cool email, as more industry leaders become readers. More technology, market, and global forecasts, in a year of increasing change. More leverage in competition and investment, when you need it the most. What does it cost? $595 per year, or $995 for two years. We also offer Premium Subscriptions with the SNS archives and opinions on markets and companies, for $895 per year. Contact Jessica (360-378-8628 or subscriptions@stratnews.com) to pay by check or to inquire about volume corporate subscriptions and special rates for teachers, students and independent journalists. To securely renew your membership online, just visit the SNS homepage at http://www.stratnews.com/ and click on Renew Now!. Thanks for your past support of SNS. I hope you will continue to enjoy the SNS newsletter and special events throughout this coming, most interesting year. Sincerely, Mark R. Anderson President Strategic News Service(tm) LLC P.O. Box 1969 Friday Harbor, WA 98250 USA Tel. 360-378-3431 Fax. 360-378-7041 Email: mark@stratnews.com On The Web: http://www.stratnews.com'; $ret .= 'Member Name: <b>'.$db->f("account_name"). '</b> email: '.$db->f("account_email").'<br>'; $ret2 .= 'Member Name: '.$db->f("account_name"). ' email: '.$db->f("account_email")."\r\n"; mail($db->f("account_email"), "***SNS*** Renewal Notice", $renewal_text, "From:\"Strategic News Service\"<subscriptions@mailsrv.stratnews.com>\r\nReply-To:subscriptions@mailsrv.stratnews.com\r\n"); } } mail("subscriptions@stratnews.com", "Renewal Notices Sent", "Finished on " . date("m j, Y g:i a") . "\r\n" . $ret2, "From:\"Strategic News Service\"<subscriptions@mailsrv.stratnews.com>\r\nReply-To:subscriptions@mailsrv.stratnews.com\r\n"); return $ret; } //MAIL RENEWAL NOTICES - For Auto-renew folks only function mail_autorenewal_notice($form){ if(is_array($form["account_id"])){ foreach($form["account_id"] as $d){ $db = new ps_DB; $q = "SELECT account_name, account_email, status, renew_date FROM account WHERE account_id=" . intval($d); $db->query($q); $db->next_record(); $subtype = $db->f("status"); $today=date("Y-m-d"); $today_date=strtotime($today); $last_billed = $db->f("renew_date"); $db_date=strtotime($last_billed); if ($last_billed != '') { if ($today_date == $db_date) { $date_note = 'Your SNS membership is due today'; } elseif ($today_date <= $db_date) { $date_note = 'Your SNS membership is due ' . date('l \t\h\e jS \of F\, Y',$db_date); } else { $date_note = 'Your SNS membership was due ' . date('l \t\h\e jS \of F\, Y',$db_date); } } else { $date_note = 'Your SNS membership is due to expire within the next 30 days.'; } if ($subtype == 'sns.normal' || $subtype == 'sns.grpnormal') { $upgradetext = 'If you wish to use a different card for renewal, or upgrade to a premium subscription'; } else { $upgradetext = 'If you wish to use a different card for renewal'; } $renewal_text = 'Dear '.$db->f("account_name"). ', '. $date_note. '. At the end of your subscription period your subscription will be automatically renewed with the credit card we have on file. '. $upgradetext. ', please contact our administrator, Jessica Crouch, at 360-378-8628, or email subscriptions@stratnews.com. Thank you for continuing to be an SNS member. Mark Anderson CEO Strategic News Service(tm) LLC P.O. Box 1969 Friday Harbor, WA 98250 USA Tel. 360-378-3431 Fax. 360-378-7041 Email: mark@stratnews.com On The Web: http://www.stratnews.com'; $ret .= 'Member Name: <b>'.$db->f("account_name"). '</b> email: '.$db->f("account_email").'<br>'; $ret2 .= 'Member Name: '.$db->f("account_name"). ' email: '.$db->f("account_email")."\r\n"; //$ret .= 'Member Name: <b>'.$db->f("account_name"). '</b> email: scott@tapsns.com<br>'; //$ret2 .= 'Member Name: '.$db->f("account_name"). ' email: scott@tapsns.com\r\n'; mail($db->f("account_email"), "***SNS*** Renewal Notice", $renewal_text, "From:\"Strategic News Service\"<subscriptions@mailsrv.stratnews.com>\r\nReply-To:subscriptions@mailsrv.stratnews.com\r\n"); //mail("scott@tapsns.com", "***SNS*** Renewal Notice", $renewal_text, "From:\"mark r anderson\"<mark@stratnews.com>\r\nReply-To:mark@stratnews.com\r\n"); } } mail("scott@stratnews.com", "Auto-Renewal Pre-Notices Sent", "Finished on " . date("m j, Y g:i a") . "\r\n" . $ret2, "From:\"Strategic News Service\"<subscriptions@mailsrv.stratnews.com>\r\nReply-To:subscriptions@mailsrv.stratnews.com\r\n"); //mail("scott@tapsns.com", "Auto-Renewal Pre-Notices Sent", "Finished on " . date("m j, Y g:i a") . "\r\n" . $ret2, "From:\"mark r anderson\"<mark@stratnews.com>\r\nReply-To:mark@stratnews.com\r\n"); return $ret; } // GET DOMAIN BILLING STATUS 90DAYS UNTIL EXPIRE function get_billing_status_bill_90days($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)+90; $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; } //MEMBERSHIP RENEWAL function renew_member($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 ('auth.api.php'); return "Order status updated."; } //SHOW MEMBERSHIP LEVEL SELECT function show_membership_select($status) { $dba = new ps_DB; $q = "SELECT * FROM sns_level"; $dba->query($q); $ret = "<select name=\"sns_status\" class=\"fields\">"; if ($groupid==0) { $ret .= "<option value=\"0\" selected>Not a Member</option>"; }else{ $ret .= "<option value=\"0\">Not a Member</option>"; } while($dba->next_record()) { if ($status==$dba->f("name")) { $sel=" selected"; } else {$sel="";} $ret .= "<option value=\"" . $dba->f("name") . "\"" . $sel . ">" . $dba->f("name") . "</option>"; } $ret.="</select>"; return $ret; } //ADD USER TO APACHE DB FOR NEWLSLETTER MAILING function add_to_apache($session_id) { global $session_id; // GET THE CUSTOMERS INFO: $account_id = get_account_id($session_id); $dbd = new ps_DB; $q = "SELECT account_username,account_password FROM account WHERE account_id='$account_id'"; $dbd->query($q); $dbd->next_record(); $account_username = $dbd->f("account_username"); $account_password = $dbd->f("account_password"); //Insert user info to tapsns_users $expire = get_expire_date($session_id); $extra = $expire . ':<' . $f[account_username] . '>'; $db = new apache_ps_DB; $q = "INSERT INTO tapsns_users SET username= '$f[account_username]', password= '$f[account_password]', extra= '$extra'"; $db->apache_query($q); //Insert user group info to tapsns_groups $group = get_user_group($session_id); if ($group = 31) { $group_type = 'sns.comp'; } elseif ($group = 33 || $group = 42) { $group_type = 'sns.normal'; } elseif ($group = 36 || $group = 43) { $group_type = 'sns.premium'; } elseif ($group = 35 || $group = 37 || $group = 39 || $group = 44 || $group = 46) { $group_type = 'sns.grpnormal'; } elseif ($group = 38 || $group = 45) { $group_type = 'sns.grppremium'; } else { $group_type = 'sns.week1'; } $dba = new apache_ps_DB; $q = "INSERT INTO tapsns_groups SET username= '$f[account_username]', groups= '$group_type'"; $dba->apache_query($q); } // GET USER GROUP function get_user_group($session_id) { global $session_id; //Get Membership type $dba = new ps_DB; $q = "SELECT session_membership_id FROM sessions WHERE session_ip = '$ip' OR session_domain = '$session_id'"; $dba->query($q); $total=0; $dba->next_record(); $ret = $dba->f("session_membership_id"); return $ret; } // GET EXPIRE DATE function get_expire_date($session_id) { global $session_id; $today=date("Y-m-d"); $today_date=strtotime($today); //Get Membership type $dba = new ps_DB; $q = "SELECT session_membership_id FROM sessions WHERE session_ip = '$ip' OR session_domain = '$session_id'"; $dba->query($q); $total=0; $dba->next_record(); $membership_id = $dba->f("session_membership_id"); //Get subscription duration/frequency $db = new ps_DB; $q = "SELECT membership_frequency FROM membership WHERE membership_id = '$membership_id'"; $db->query($q); $db->next_record(); $frequency = $db->f("membership_frequency"); $ret = $frequency * ($today_date/86400); $ret = date("Y/m/D",$ret); return $ret; } //SHOW GROUPs function show_group_select($groupid) { $dba = new ps_DB; //$q = "SELECT groupid,account_name FROM account WHERE group_master_record = '1' AND group_status = '1' ORDER BY account_name"; $q = "SELECT groupid,account_name FROM account WHERE group_master_record = '1' ORDER BY account_name"; $dba->query($q); $ret = "<select name=\"groupid\" class=\"fields\">"; if ($groupid==0) { $ret .= "<option value=\"0\" selected>Not a group Member</option>"; }else{ $ret .= "<option value=\"0\">Not a group Member</option>"; } while($dba->next_record()) { if ($groupid==$dba->f("groupid")) { $sel=" selected"; } else {$sel="";} $ret .= "<option value=\"" . $dba->f("groupid") . "\"" . $sel . ">" . $dba->f("account_name") . "</option>"; } $ret.="</select>"; return $ret; } //SHOW GROUP TYPE function show_group_type_select($group_membership) { $dba = new ps_DB; $q = "SELECT membership_id,name FROM dreamaccount.group_type"; $dba->query($q); $ret = "<select name=\"group_membership\" class=\"fields\">"; if ($group_membership==0) { $ret .= "<option value=\"0\" selected>Select Group Type</option>"; }else{ $ret .= "<option value=\"0\">Select Group Type</option>"; } while($dba->next_record()) { if ($group_membership==$dba->f("membership_id")) { $sel=" selected"; } else {$sel="";} $ret .= "<option value=\"" . $dba->f("membership_id") . "\"" . $sel . ">" . $dba->f("name") . "</option>"; } $ret.="</select>"; return $ret; } function show_group_member_type_select($group_member_type) { $ret = '<select name="group_member_type" class="fields">'; $ret .= '<option value="0">Select Group Type</option>'; if ($group_member_type=='35') { $ret .= '<option value="35" selected>Group Standard</option>'; } else { $ret .= '<option value="35">Group Standard</option>'; } if ($group_member_type=='38') { $ret .= '<option value="38" selected>Group Premium</option>'; } else { $ret .= '<option value="38">Group Premium</option>'; } if ($group_member_type=='4') { $ret .= '<option value="4" selected>Free Trial</option>'; } else { $ret .= '<option value="4">Free Trial</option>'; } if ($group_member_type=='31') { $ret .= '<option value="31" selected>Complimentary</option>'; } else { $ret .= '<option value="31">Complimentary</option>'; } $ret.="</select>"; return $ret; } function get_group_type($membership_id){ $dba = new ps_DB; $q = "SELECT name FROM group_type WHERE membership_id = '$membership_id'"; $dba->query($q); $dba->next_record(); $ret = $dba->f("name"); echo $ret; } //SHOW GROUP MEMBER LIST function show_group_member_list($groupid) { $db = new ps_DB; $q = "SELECT account_id,account_name,account_email,status,renew_date FROM account WHERE groupid='$groupid' AND group_master_record = '0' ORDER BY account_name"; $db->query($q); if ($db->num_rows() > 0) { $ret = ""; while($db->next_record()) { $account_id = $db->f("account_id"); $views = get_subscriber_total_issues_viewed($account_id); if ($db->f("status") != 'sns.expired') { $ret .= "<tr><td><a href=\"?page=add_clients&account_id=" . $account_id . "&set_action=client_update\">" . $db->f("account_name") . "</a></td><td><span style='color:green'>" . $db->f("renew_date") . "</span></td><td>" . $db->f("account_email") . "</td><td>". $views ."</td></tr>"; } else { $ret .= "<tr><td><a href=\"?page=add_clients&account_id=" . $account_id . "&set_action=client_update\"><span style=\"color:grey\"> " . $db->f("account_name") . "</span></a></td><td><span style='color:red'>" . $db->f("renew_date") . "</span></td><td style='color:grey'>" . $db->f("account_email") . "</td><td style='color:grey'>". $views ."</td></tr>"; } } } else { $ret = "No members for this group."; } return $ret; } //SHOW GROUP MEMBER LIST - WITH CHECKBOX function show_group_member_checkbox_list($groupid) { $db = new ps_DB; $q = "SELECT account_id,account_name,account_email,group_member_type FROM account WHERE groupid='$groupid' AND group_master_record = '0' ORDER BY account_name"; $db->query($q); if ($db->num_rows() > 0) { $ret = ''; while($db->next_record()) { if ($db->f("group_member_type") == 38){ $member_type = 'Premium'; } else { $member_type = 'Standard'; } $ret .= '<tr><td>' . $db->f("account_name") . '</td><td>' . $db->f("account_email") . '</td><td>' . $member_type . '</td><td><input type="checkbox" name="account_id[]" value="' . $db->f("account_id") . '"></td></tr>'; } } else { $ret = "No members for this group."; } return $ret; } //GET GROUP MEMBER COUNT function get_group_member_count($groupid) { $ret = array(); $db = new ps_DB; $q = "SELECT groupid FROM account WHERE groupid='$groupid' AND group_master_record = '0' AND status != 'sns.expired'"; //$q = "SELECT groupid FROM account WHERE groupid='$groupid' AND group_master_record = '0'"; $db->query($q); $ret['active'] = $db->num_rows(); //get expired $dba = new ps_DB; $qa = "SELECT groupid FROM account WHERE groupid='$groupid' AND group_master_record = '0' AND status = 'sns.expired'"; //$q = "SELECT groupid FROM account WHERE groupid='$groupid' AND group_master_record = '0'"; $dba->query($qa); $ret['expired'] = $dba->num_rows(); return $ret; } //CHECK GROUP MEMBERSHIP function check_group_member($account_email) { $db = new ps_DB; $q = "SELECT groupid FROM account WHERE account_email='$account_email' AND group_master_record = '0'"; $db->query($q); $db->next_record(); $ret = $db[groupid]; return $ret; } //GET SUBSCRIBER_TOTAL_ISSUES_VIEWED function get_subscriber_total_issues_viewed($account_id){ $db = new ps_DB; $q = "SELECT issue FROM sns_tracking WHERE account_id = '$account_id'"; $db->query($q); $views = $db->num_rows(); return $views; } //SHOW GROUP MEMBER ADMIN function show_group_member_admin($groupid) { $dba = new ps_DB; $q = "SELECT account_email FROM account WHERE groupid = '$groupid' AND group_admin = '1'"; $dba->query($q); if ($dba->num_rows() > 0) { $ret = ""; while($dba->next_record()) { $ret .= $dba->f("account_email");} } else { $ret = "No admin for this group."; } return $ret; } //Remove Member from group function update_group_account($form,$session_id) { deactivate_group_member($form); //delete_member_blog_account($form); remove_group_member($form); } //Deactivate member account function deactivate_group_member($form) { $queries=array(); if(is_array($form["account_id"])){ foreach($form["account_id"] as $d){ array_push($queries,"DELETE FROM domains WHERE domain_account_id=" . intval($d)); } } for($i=0; $i <= count($queries); $i++) { if($queries[$i] != "") { $db = new ps_DB; $q = $queries[$i]; $db->query($q); } } } //DELETE MEMBER BLOG ACCOUNT function delete_member_blog_account($form) { $queries=array(); if(is_array($form["account_id"])){ foreach($form["account_id"] as $d){ array_push($queries,"DELETE FROM dreamaccount.wp_users WHERE account_id=" . intval($d)); } } for($i=0; $i <= count($queries); $i++) { if($queries[$i] != "") { $db = new ps_DB; $q = $queries[$i]; $db->query($q); } } } //Remove Member from group function remove_group_member($form) { $queries=array(); if(is_array($form["account_id"])){ foreach($form["account_id"] as $d){ array_push($queries,"UPDATE account SET group_member_type = '0', group_membership = '0', groupid = 0 WHERE account_id =" . intval($d)); } } for($i=0; $i <= count($queries); $i++) { if($queries[$i] != "") { $db = new ps_DB; $q = $queries[$i]; $db->query($q); } } } //ADD GROUP MEMBER ACCOUNT function add_group_member($f) { global $path; $today=date("Y-m-d"); $new = '1'; //Verify required fields if (($f[account_email] == '') || ($f[account_username] == '') || ($f[account_password] == '')){ return '<BR>All required fields were not filled-in. <br>If you continue to have trouble, please <a href="mailto:subscriptions@stratnews.com">contact us</a>.'; exit; } else { //check group member count $member_count = get_group_member_count($groupid); if (($member_count >= 11) && ($f[group_membership] == 39)) { return '<BR>Account could not be added!<br>Your group account is limited to 10 members. <br>If you have questions, please <a href="mailto:subscriptions@stratnews.com">contact us</a>.'; exit; } else { // Verify email is not currently used if($f[account_email] != ''){ if(validate_email_unused($f[account_email]) == 'N'){ //return "<BR>Account could not be created, email already exists in the database!"; $new = '0'; }}}} // Verify username is not currently used if($f[account_username] != ''){ if(!validate_username_unused($f[account_username])){ //return "<BR>Account could not be created, username already exists in the database!"; $new = '0'; }} // Verify username/email is not currently used in one of the API databases //$arr = DA_API_VALIDATION($f[account_username],$f[account_email]); //if(!$arr[email]){ // return "<BR>Account could not be created, email already exists in our system!"; //} // if(!$arr[username]){ // return "<BR>Account could not be created, username already exists in our system!"; //} // get the country if($f[account_country] == "") { $country = $f[country]; } else { $country = $f[acount_country]; } //Check membership type to add if ((($f[group_membership] == 39) && ($f[group_member_type] == 35)) || (($f[group_membership] == 37) && ($member_count <= 11))) { $ret = "<br>Standard Membership within allowed quota: <b>No charge</b>"; $no_order_record = '1'; $domain_host_status = 1; $host_id = 46; } else { //determine amount of charge if ($f[group_membership] == 37) { if ($f[group_member_type] == 35) { $host_id = 35; $amount = 295; $ret = "<br>Standard Member added to $f[account_company]. A \$295 charge is pending on your account"; } else { $host_id = 38; $amount = 595; $ret = "<br>Premium Member added to $f[account_company]. A \$595 charge is pending on your account"; } } else { $host_id = 45; $amount = 300; $ret = "<br>Premium Member added to $f[account_company]. A \$300 charge is pending on your account"; } $no_order_record = '0'; $domain_host_status = 0; } // Check if already a group member if ($f[groupid] == check_group_member($f[account_email])) { $new = '2'; } //INSERT/UPDATE MEMBER ACCOUNT if ($new == '2') { $ret = "<BR>Account could not be added, member is already in group $f[account_company]!"; exit; } elseif ($new == '0') { $db = new ps_DB; $q = "UPDATE account SET groupid = '$f[groupid]', group_member_type = '$f[group_member_type]', group_membership = '$f[group_membership]' WHERE account_email = '$f[account_email]' AND group_master_record = 0"; $db->query($q); $ret .= "<br>Update successful."; } else { $db = new ps_DB; $q = "INSERT INTO account SET orig_date = '$today', start_date = '$today', account_username= '$f[account_username]', account_password= '$f[account_password]', account_email = '$f[account_email]', account_name = '$f[account_name]', account_company = '$f[account_company]', account_address = '$f[account_address]', account_city = '$f[account_city]', account_state = '$f[account_state]', account_zip = '$f[account_zip]', account_country = '$country', account_phone = '$f[account_phone]', account_fax = '$f[account_fax]', group_member_type = '$f[group_member_type]', group_membership = '$f[group_membership]', groupid = '$f[groupid]'"; $db->query($q); $new = '0'; $ret .= "<br>New member account added."; } $dba = new ps_DB; $q = "SELECT account_id FROM account WHERE account_email = '$f[account_email]' AND group_master_record = '0' "; $dba->query($q); $dba->next_record(); $member_account_id = $dba->f("account_id"); // determine if any external database update functions need run: //unset($API_ACTION); //$API_ACTION ='add_account'; //include_once($path . 'auth.api.php'); //UPDATE BILLING FOR GROUP $account_id = $f[account_id]; $billing_id = check_cc_list($account_id); $groupid = $f[groupid]; if ($new == '0') { group_member_checkout($account_id,$billing_id,$amount,$groupid,$host_id,$member_account_id,$no_order_record,$domain_host_status); } add_group_member_blog_account($f,$member_account_id); return $ret; } //CREATE GROUP MEMBER ORDER RECORD function create_group_member_order_record($status,$order_id,$account_id,$billing_id,$groupid,$amount,$user_ip) { // get the date $today=date("Y-m-d"); $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_10 = 'groupid', order_attr_value_10 = '$groupid', base_amount = '$base_amount', setup_amount = '$setup_amount', coupon_code = '$coupon', coupon_amount = '$coupon_amount', tax_amount = '$tax_amount', credit_amount = '$credit_amount'"; $db->query($q); $dba = new ps_DB; $q = "INSERT INTO group_orders SET group_order_id = '$order_id', 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', groupid = '$groupid'"; $dba->query($q); return true; } //CREATE GROUP MEMBER DOMAIN ENTRY function create_group_member_domain_record($status,$billed,$member_account_id,$order_id,$billing_id,$domain,$years,$host_id) { // create the record... $db = new ps_DB; $today=date("Y-m-d"); $q = "INSERT INTO domains SET domain_account_id = '$member_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); } // BILL GROUP A MEMBERSHIP function group_member_checkout($account_id,$billing_id,$amount,$groupid,$host_id,$member_account_id,$no_order_record,$domain_host_status) { global $billed_amount, $form, $path, $message, $REMOTE_ADDR, $REMOTE_HOST, $aid; // get the users IP if ($REMOTE_ADDR != "") { $user_ip = $REMOTE_ADDR; } else { $user_ip = $REMOTE_HOST; } $session_ip = $user_ip; $billed_amount = $amount; $order_id = next_order_id(); if ($no_order_record == '0') { create_group_member_order_record("0",$order_id,$account_id,$billing_id,$groupid,$amount,$user_ip); cart_add($REMOTE_ADDR,$host_id); } create_group_member_domain_record($domain_host_status,"Y",$member_account_id,$order_id,$billing_id,$domain,$years,$host_id); //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"); } // ADD GROUP MEMBER DOMAIN RECORD function add_group_member_domain_record($f) { // create the record... $db = new ps_DB; $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', domain_host_periods = '1', domain_host_last_billed = '$today'"; $db->query($q); } function add_group_member_blog_account($f,$member_account_id) { $now = gmdate('Y-m-d H:i:s'); $user_ip = $_SERVER['REMOTE_ADDR']; $pass = $f[account_password]; $account_id = $member_account_id; $db = new ps_DB; $q = "INSERT INTO dreamaccount.wp_users SET user_login = '$f[account_username]', user_pass = MD5('$pass1'), user_nickname = '$f[account_username]', user_email = '$f[account_email]', user_ip = '$user_ip', dateYMDhour = '$now', user_level = '1', user_idmode = 'nickname', account_id = '$account_id'"; $db->query($q); } function add_member_blog_account($session_id) { $now = gmdate('Y-m-d H:i:s'); $user_ip = $_SERVER['REMOTE_ADDR']; $account_id = get_account_id($session_id); $dba = new ps_DB; $q = "SELECT * FROM account WHERE account_id = '$account_id'"; $dba->query($q); $dba->next_record(); $f_name = explode(" ",$dba->f("account_name")); $username = $dba->f("account_username"); $pass = $dba->f("account_password"); $email = $dba->f("account_email"); $db = new ps_DB; $q = "INSERT INTO dreamaccount.wp_users SET user_login = '$username', user_pass = MD5('$pass1'), user_firstname = '$f_name[0]', user_lastname = '$f_name[1]', user_nickname = '$username', user_email = '$f[account_email]', user_ip = '$user_ip', dateYMDhour = '$now', user_level = '1', user_idmode = 'nickname', account_id = '$account_id'"; $db->query($q); } //GET GROUP MASTER ACCOUNT BILLING function group_master_billing($groupid,$group_membership) { if ($group_membership == 39) { $price = 1495; } elseif($group_membership == 37) { $price = 2950; } else { $price = 0; } } function group_member_billing($groupid) { $db = new ps_DB; $q = "SELECT order_amount FROM orders WHERE order_attr_value_10 = $groupid"; $db->query($q); while ($db->next_record()) { $account_id = $db->f("account_id"); //$pending = $db->f("order_status"); if ($db->f("order_status") == 0) { $subtotal += $db->f("order_amount"); } } return $subtotal; } function update_group_renew_date($groupid,$newdate){ $db = new ps_DB; $q = "SELECT account_id FROM account WHERE groupid = '$groupid' AND status NOT LIKE 'sns.expired'"; //$q = "SELECT account_id FROM account WHERE groupid = '$groupid'"; $db->query($q); while($db->next_record()){ $accountid = $db->f("account_id"); //$new_sub_date = renew_date_calc_start($account_id,$renew_date); $new_sub_date = renew_date_calc_start($accountid,$newdate); $dba = new ps_DB; $qa = "UPDATE domains SET domain_host_last_billed = '$new_sub_date' where domain_account_id = '$accountid'"; $dba->query($qa); //echo $qa . '<br>'; $dbb = new ps_DB; $qb = "UPDATE account SET renew_date ='$newdate' WHERE account_id ='$accountid'"; $dbb->query($qb); //echo $qb . '<br>'; } } //VERIFY GROUP B MEMBERSHIP //function group_b_verify($address='', $needle=array()) function group_b_verify($form) { $address = $form[address]; $needle=array(); $db = new ps_DB; $q = "SELECT * FROM dreamaccount.group_domains "; $db->query($q); while ($db->next_record()) { array_push($needle, $db->f("domain")); } if(validate_email($address) == 'Y'){ foreach($needle as $n) { if (stristr($address, $n) !== FALSE ) { return TRUE; } } //echo $array; return FALSE; } else { $ret = 'I'; } return $ret; } /** * Makes an ID based on current date/time * * This function COM_creates a 17 digit sid for stories based on the 14 digit date * and a 3 digit random number that was seeded with the number of microseconds * (.000001th of a second) since the last full second. NOTE: this is now used for more than * just stories! * * @return string $sid Story ID * */ function COM_makesid() { $sid = date( "YmdHis" ); srand(( double )microtime() * 1000000 ); $sid .= rand( 0,999 ); return $sid; } function make_discount_code() { //$acceptedChars = 'azertyuiopqsdfghjklmwxcvbnAZERTYUIOPQSDFGHJKLMWXCVBN0123456789'; $acceptedChars = 'azertyuipqsdfghjkmwxcvbnAZERTYUIPQSDFGHJKLMWXCVBN0123456789'; $max = strlen($acceptedChars)-1; $password = null; for($i=0; $i < 8; $i++) { $password .= $acceptedChars(mt_rand(0, $max)); } return $password; } //////////// //PUBLISHING FUNCTIONS /** * Prints Google(tm)-like paging navigation * * @param string $base_url base url to use for all generated links * @param int $curpage current page we are on * @param int $num_pages Total number of pages * @return string HTML formated widget */ function COM_printPageNavigation( $base_url, $curpage, $num_pages ) { $hasargs = strstr( $base_url, '?' ); if( $num_pages == 1 ) { return; } $retval = ''; if( $curpage > 1 ) { if( $hasargs ) { $retval .= '<strong><a href="' . $base_url . '&page=' . ( $curpage - 1 ) . '">Previous</a></strong>   '; } else { $retval .= '<strong><a href="' . $base_url . '?page=' . ( $curpage - 1 ) . '">Previous</a></strong>   '; } } else { $retval .= '<strong>Previous</strong>   ' ; } for( $pgcount = ( $curpage - 100 ); ( $pgcount <= ( $curpage + 99 )) AND ( $pgcount <= $num_pages ); $pgcount++ ) { if( $pgcount <= 0 ) { $pgcount = 1; } if( $pgcount == $curpage ) { $retval .= '<b>' . $pgcount . '</b> '; } else { if( $hasargs ) { $retval .= '<a href="' . $base_url . '&page=' . $pgcount . '">' . $pgcount . '</a> '; } else { $retval .= '<a href="' . $base_url . '?page=' . $pgcount . '">' . $pgcount . '</a> '; } } if( $pgcount == '20' || $pgcount == '40') { $retval .= '<br>      '; } } if( $curpage == $num_pages ) { $retval .= '  <strong>Next</strong> '; } else { if( $hasargs ) { $retval .= '  <strong><a href="' . $base_url . '&page=' . ( $curpage + 1 ) . '">Next</a></strong>'; } else { $retval .= '  <strong><a href="' . $base_url . '?page=' . ( $curpage + 1 ) . '">Next</a></strong>'; } } if( !empty( $retval )) { $retval = '<div class="pagenav">' . $retval . '</div>'; } return $retval; } // WRITE VERISIGN RESPONSE DATA TO CONF_CORP LOG FILE function write_cc_data($ret) { $file = 'C:/EXT_ROOT/cc_logs/confcorp_cclogs.html'; $file_handle = fopen($file,"a"); fwrite($file_handle, $ret); fclose($file_handle); } // WRITE VERISIGN RESPONSE DATA TO LLC LOG FILE function write_llc_cc_data($ret) { $file = 'C:/EXT_ROOT/cc_logs/llc_cclogs.html'; $file_handle = fopen($file,"a"); fwrite($file_handle, $ret); fclose($file_handle); } // CHARGE THE CARD USING VERISIGN function DEPRECATED_charge_verisign_sns_conf_corp($name,$address,$zip,$cc_num,$cc_exp,$amount) { putenv ("PFPRO_CERT_PATH=D:\wwwroot\payflowpro\win32\certs"); $debugverisign = 'N'; $month = identify_month($cc_exp); $year = identify_year($cc_exp); //$cc_exp = $month . "" . $year; $CERT_PATH = "D:\\wwwroot\\payflowpro\\win32\\certs"; $PATH = "D:\\wwwroot\\payflowpro\\win32\\bin\\pfpro"; $USER="tapsns"; $VENDOR="tapsns"; $PARTNER="VeriSign"; $PWD = "zTY(7j%b@FHS"; if ($debugverisign == "Y") { //$AMT = '15'; } else { $AMT = $amount; } $ACCT = $cc_num; $EXPDATE = $cc_exp; $ADDRESS = $address; $ZIP = $zip; $TRXTYPE = "S"; $TENDER = "C"; // $ret = `export PFPRO_CERT_PATH=$CERT_PATH; $PATH test-payflow.verisign.com 443 'USER=$USER&VENDOR=$VENDOR&PARTNER=$PARTNER&PWD=$PWD&TRXTYPE=$TRXTYPE&TENDER=$TENDER&ACCT=$ACCT&EXPDATE=$EXPDATE&AMT=$AMT&ADDRESS=$ADDRESS&ZIP=$ZIP' 15`; // $ret = exec('D:\wwwroot\payflowpro\win32\bin\pfpro test-payflow.verisign.com 443 "TRXTYPE=S&TENDER=C&PWD=$PWD&USER=$USER&VENDOR=$VENDOR&PARTNER=$PARTNER&ACCT=$ACCT&EXPDATE=$EXPDATE&AMT=$AMT&ADDRESS=$ADDRESS&ZIP=$ZIP" 30'); $objCOM = new COM("PFProCOMControl.PFProCOMControl.1"); $parmList = "TRXTYPE=S&TENDER=C&COMMENT2=PHP/COM Test Transaction"; $parmList .= "&ZIP=" . $ZIP; $parmList .= "&ACCT=" . $ACCT; $parmList .= "&PWD=" . $PWD; $parmList .= "&USER=" . $USER; $parmList .= "&VENDOR=" . $USER; $parmList .= "&PARTNER=" . $PARTNER; $parmList .= "&EXPDATE=" . $EXPDATE; $parmList .= "&AMT=" . $AMT; $ctx1 = $objCOM->CreateContext("payflow.verisign.com", 443, 30, "", 0, "", ""); $ret = $objCOM->SubmitTransaction($ctx1, $parmList, strlen($parmList)); $objCOM->DestroyContext($ctx1); // SHOW DEBUG INFO // if (setup("gw_2") == "Y") { if ($debugverisign == "Y") { echo "<PRE><BR>Displaying Gateway Debug Info<BR><BR>"; echo "Gateway URL -> payflow.verisign.com 443<BR>"; echo "Posted Data -> USER=$USER&VENDOR=$VENDOR&PARTNER=$PARTNER&PWD=$PWD&TRXTYPE=$TRXTYPE&TENDER=$TENDER&ACCT=$ACCT&EXPDATE=$EXPDATE&AMT=$AMT&ADDRESS=$ADDRESS&ZIP=$ZIP<BR><BR>"; echo "Gateway Return -> " . $ret . "\n\n</PRE>"; //echo "Gateway URL -> test-payflow.verisign.com 443 <BR><BR>"; //echo "Posted Data -> USER=$USER&VENDOR=$VENDOR&PARTNER=$PARTNER&PWD=$PWD&TRXTYPE=$TRXTYPE&TENDER=$TENDER&ACCT=$ACCT&EXPDATE=$EXPDATE&AMT=$AMT&ADDRESS=$ADDRESS&ZIP=$ZIP<BR><BR>"; //echo "Gateway Return -> " . $ret . "\n\n</PRE>"; } //Write response data to log file $cc1 = substr($cc_num, 0, 4) ; $cc2 = substr($cc_num, -4, 4) ; $cchidden = $cc1 . "-XXXX-XXXX-" . $cc2; $log_data = '<font color="#000080">' . date("F j, Y, g:i a") .'</font> -- ' ; $log_data .= $name.' ' ; $log_data .= $ret.' ' ; $log_data .= "ACCT=$cchidden&EXPDATE=$EXPDATE&AMT=$AMT&ADDRESS=$ADDRESS&ZIP=$ZIP <br>\n"; write_cc_data($log_data); $pat = "&"; $arr = explode($pat, $ret); $pat = "="; $arr0 = explode($pat, $arr[0]); $arr1 = explode($pat, $arr[1]); $arr2 = explode($pat, $arr[2]); $arr3 = explode($pat, $arr[3]); $arr4 = explode($pat, $arr[4]); $arr5 = explode($pat, $arr[5]); $arr6 = explode($pat, $arr[6]); if ($arr0[1]=="") { return "3"; } elseif ($arr0[1]=="0") { return "1"; } elseif ((($arr0[1]=="12") || ($arr0[1]=="23") || ($arr0[1]=="24"))) { return "2"; } elseif ($arr0[1]=="1") { return "2"; } else { return "3"; } } function DEPRECATED_charge_verisign_sns_conf_corp_test($name,$address,$zip,$cc_num,$cc_exp,$amount) { putenv ("PFPRO_CERT_PATH=D:\wwwroot\payflowpro\win32\certs"); $debugverisign = 'Y'; $month = identify_month($cc_exp); $year = identify_year($cc_exp); //$cc_exp = $month . "" . $year; $CERT_PATH = "D:\\wwwroot\\payflowpro\\win32\\certs"; $PATH = "D:\\wwwroot\\payflowpro\\win32\\bin\\pfpro"; $USER="tapsns"; $VENDOR="tapsns"; $PARTNER="VeriSign"; $PWD = "zTY(7j%b@FHS"; if ($debugverisign == "Y") { $AMT = '5'; } else { $AMT = $amount; } $ACCT = $cc_num; $EXPDATE = $cc_exp; $ADDRESS = $address; $ZIP = $zip; $TRXTYPE = "S"; $TENDER = "C"; // $ret = `export PFPRO_CERT_PATH=$CERT_PATH; $PATH test-payflow.verisign.com 443 'USER=$USER&VENDOR=$VENDOR&PARTNER=$PARTNER&PWD=$PWD&TRXTYPE=$TRXTYPE&TENDER=$TENDER&ACCT=$ACCT&EXPDATE=$EXPDATE&AMT=$AMT&ADDRESS=$ADDRESS&ZIP=$ZIP' 15`; // $ret = exec('D:\wwwroot\payflowpro\win32\bin\pfpro test-payflow.verisign.com 443 "TRXTYPE=S&TENDER=C&PWD=$PWD&USER=$USER&VENDOR=$VENDOR&PARTNER=$PARTNER&ACCT=$ACCT&EXPDATE=$EXPDATE&AMT=$AMT&ADDRESS=$ADDRESS&ZIP=$ZIP" 30'); $objCOM = new COM("PFProCOMControl.PFProCOMControl.1"); $parmList = "TRXTYPE=S&TENDER=C&COMMENT2=PHP/COM ConfCorp Test Transaction"; $parmList .= "&ZIP=" . $ZIP; $parmList .= "&ACCT=" . $ACCT; $parmList .= "&PWD=" . $PWD; $parmList .= "&USER=" . $USER; $parmList .= "&VENDOR=" . $USER; $parmList .= "&PARTNER=" . $PARTNER; $parmList .= "&EXPDATE=" . $EXPDATE; $parmList .= "&AMT=" . $AMT; if ($debugverisign == "Y") { $ctx1 = $objCOM->CreateContext("test-payflow.verisign.com", 443, 30, "", 0, "", ""); } else { $ctx1 = $objCOM->CreateContext("payflow.verisign.com", 443, 30, "", 0, "", ""); } $ret = $objCOM->SubmitTransaction($ctx1, $parmList, strlen($parmList)); $objCOM->DestroyContext($ctx1); // SHOW DEBUG INFO // if (setup("gw_2") == "Y") { if ($debugverisign == "Y") { echo "<PRE><BR>Displaying Gateway Debug Info<BR><BR>"; echo "Gateway URL -> payflow.verisign.com 443<BR>"; echo "Posted Data -> USER=$USER&VENDOR=$VENDOR&PARTNER=$PARTNER&PWD=$PWD&TRXTYPE=$TRXTYPE&TENDER=$TENDER&ACCT=$ACCT&EXPDATE=$EXPDATE&AMT=$AMT&ADDRESS=$ADDRESS&ZIP=$ZIP<BR><BR>"; echo "Gateway Return -> " . $ret . "\n\n</PRE>"; //echo "Gateway URL -> test-payflow.verisign.com 443 <BR><BR>"; //echo "Posted Data -> USER=$USER&VENDOR=$VENDOR&PARTNER=$PARTNER&PWD=$PWD&TRXTYPE=$TRXTYPE&TENDER=$TENDER&ACCT=$ACCT&EXPDATE=$EXPDATE&AMT=$AMT&ADDRESS=$ADDRESS&ZIP=$ZIP<BR><BR>"; //echo "Gateway Return -> " . $ret . "\n\n</PRE>"; } //Write response data to log file $cc1 = substr($cc_num, 0, 4) ; $cc2 = substr($cc_num, -4, 4) ; $cchidden = $cc1 . "-XXXX-XXXX-" . $cc2; $log_data = '<font color="#000080">' . date("F j, Y, g:i a") .'</font> -- ' ; $log_data .= $name.' ' ; $log_data .= $ret.' ' ; $log_data .= "ACCT=$cchidden&EXPDATE=$EXPDATE&AMT=$AMT&ADDRESS=$ADDRESS&ZIP=$ZIP <br>\n"; write_cc_data($log_data); $pat = "&"; $arr = explode($pat, $ret); $pat = "="; $arr0 = explode($pat, $arr[0]); $arr1 = explode($pat, $arr[1]); $arr2 = explode($pat, $arr[2]); $arr3 = explode($pat, $arr[3]); $arr4 = explode($pat, $arr[4]); $arr5 = explode($pat, $arr[5]); $arr6 = explode($pat, $arr[6]); if ($arr0[1]=="") { return "3"; } elseif ($arr0[1]=="0") { return "1"; } elseif ((($arr0[1]=="12") || ($arr0[1]=="23") || ($arr0[1]=="24"))) { return "2"; } elseif ($arr0[1]=="1") { return "2"; } else { return "3"; } } //FIRE CHECKOUT & REGISTRATION function DEPRECATED_fire_card_checkout($form) { $name = addslashes($form["card_firstname"]) . ' ' . addslashes($form["card_lastname"]); $address = addslashes($form["card_address"]); $zip = addslashes($form["card_zip"]); $cc_num = addslashes($form["customer_cc_number"]); $cc_exp = addslashes($form["customer_cc_expmo"]) . addslashes($form["customer_cc_expyr"]); $amount = calculate_cost($form); $f_code = addslashes($form["f_code"]); $new_code = addslashes($form["new_code"]); if ($f_code != '') { $new_code = ''; } $ret = '<br><br><font color="#D83634" size="4" face="Times, serif"> <strong><br>SNS Future in Review 2007</strong></font> <br><b>May 22-25, at the Hotel del Coronado in San Diego, CA</b> <br><br>Billing Credit card for $' . $amount . ', please wait...<br>'; //Charge the card $rt = charge_verisign_sns_conf_corp($name,$address,$zip,$cc_num,$cc_exp,$amount); if($rt[result]=="3") { $ret.='<p>We are having trouble contacting our processor to process at this time. <br> Please attempt this charge again or contact us if the problem continues.</p>'; } if($rt[result]=="2") { $ret.=' <br><p>The credit card you have provided has been declined by our processor.<br> Please use the back button to confirm your Credit Card information<br> is correct and try submitting your registration again.<br><br> If you continue to have trouble submitting your registration,<br> please <a href="mailto:subscriptions@stratnews.com"><b>contact us</b></a> to complete your registration.</p><br>'; //update_firedb($form); } if (((($rt[result]=="1") || ($rt[result]=="5") || ($rt[result]=="4") || ($rt[result]=="25")))) { //IF CARD IS GOOD - UPDATE THE FIRE DB AND ADD FIRE AUTHORIZATION add_fire_auth($form); update_firedb($form); //SEND CONFIRMATION EMAILS send_form_data($form,'mark@stratnews.com'); send_form_data($form,'scott@stratnews.com'); send_form_data($form,'sam@stratnews.com'); send_form_data($form,'jessicac@stratnews.com'); send_form_data($form,'sally@stratnews.com'); confirmation_email($form); if ($f_code != '') { deactivate_f_code($f_code); } if($new_code != '') { add_new_code($new_code); } //PRINT CONFIRMATION MESSAGE TO WEBPAGE $ret.='<br><br> Total paid: $' . $amount . ' (US) <br><br> Thank you for registering for the SNS FiRe 2007 Conference. Like FiRe 2006, this year\'s conference will feature world experts as both speakers and participants, at the beautiful Hotel del Coronado in San Diego. Our focus will be on accurate exploration of trends in technology, economics, bioinformatics, policy innovation, and several new topics, as they relate to technology outcomes. '; if($new_code != '') { $ret.=' <br><br> <b>FiRe Friends Discount Offer!</b><br> Invite a friend to FiRe for $300 off. Your friend will also receive a 1 year subscription to SNS for Free! Simply give them this unique discount code: <font color="red">'. $new_code . '</font> and have them register today.'; } $ret.=' <!-- <br><br> Please be sure to reserve your room at the Hotel del Coronado (1-800-468-3533) as soon as possible. Don\'t forget to mention the Strategic News Service FiRe Conference to lock in the special room rate of $299 per night. --> <br><br> IMPORTANT: Please send your photo and biography (350 words or less) to our Editor-in-Chief, Sally, at <a href="sally@stratnews.com">sally@stratnews.com</a>. If we already have your bio and photo from the previous year, we will re-post them unless we receive an update from you. You are also invited to include a paragraph describing your favorite philanthropic organization(s), to be published with your bio in the 2007 event book. <br><br> Strategic News Service<br> P.O. Box 1969<br> Friday Harbor, WA 98250<br> <br><br>You will also receive a confirmation via email.<br><br>'; } return $ret; } ////AUTO MAIL NEW SUBSCRIBERS function mail_latest_issue_count($email,$account_id) { require("admin/mail/class.phpmailer.php"); //$f = $HTTP_POST_VARS; //$address = $form[address]; /////////////////////////// //Send to a single address $address = $email; $mail = new PHPMailer(); $mail->From = "mark@stratnews.com"; $mail->FromName = "Strategic News Service"; $mail->Host = "mail.stratnews.com"; $mail->Mailer = "smtp"; $issue = get_latest_issue(); //Get Subject Title $subjectpath = "C:/EXT_ROOT/sns_archive/" . $issue . "/name.txt"; $sp = fopen( $subjectpath, "r" ); $subjecttext = fgets( $sp,60 ); fclose($sp); //Get Newsletter HTML //$htmlpath = "D:/sns_archive/" . $issue . "/plain.txt"; $htmlpath = "C:/EXT_ROOT/sns_archive/" . $issue . "/html.html"; $htmlfile = fopen( $htmlpath, "r" ); $contents = fread($htmlfile, filesize($htmlpath)); fclose($htmlfile); //Get Newsletter Text $textpath = "C:/EXT_ROOT/sns_archive/" . $issue . "/plain.txt"; //$htmlpath = "D:/sns_archive/" . $issue . "/html.html"; $textfile = fopen( $textpath, "r" ); $text_contents = fread($textfile, filesize($textpath)); fclose($textfile); $counter ='<img src="http://www.stratnews.com/image_count.php?account_id='.$account_id.'&issue='. $issue .'">'; $contents = preg_replace("/<COUNTER>/", $counter, $contents); $body = $contents; $text_body = $text_contents; $mail->Subject = $subjecttext; //$mail->ContentType = "text/html"; $mail->Body = $body; $mail->AltBody = $text_body; $mail->AddAddress($address, $address); $mail->AddAttachment("C:/EXT_ROOT/sns_archive/" . $issue . "/sns.pdf", "SNS" . $issue . ".pdf"); if(!$mail->Send()) { $msg = "There has been a mail error sending to " . $address . "<br>"; } else { $msg = "Sent mail to " . $address . "<br>"; } // Clear all addresses and attachments for next loop $mail->ClearAddresses(); $mail->ClearAttachments(); record_sent_issue($issue,$account_id); mail("scott@stratnews.com", "Latest issue sent to new subscriber", $msg . "\nFinished on " . date("m j, Y g:i a")); } function mail_latest_issue($email) { require("admin/mail/class.phpmailer.php"); //$f = $HTTP_POST_VARS; //$address = $form[address]; /////////////////////////// //Send to a single address $address = $email; $mail = new PHPMailer(); $mail->From = "mark@stratnews.com"; $mail->FromName = "Strategic News Service"; $mail->Host = "10.10.10.10"; $mail->Mailer = "smtp"; $issue = get_latest_issue(); //$address = 'schram@u.washington.edu'; //Get Subject Title $subjectpath = "D:/sns_archive/" . $issue . "/name.txt"; $sp = fopen( $subjectpath, "r" ); $subjecttext = fgets( $sp,60 ); fclose($sp); //Get Newsletter HTML //$htmlpath = "D:/sns_archive/" . $issue . "/plain.txt"; $htmlpath = "C:/EXT_ROOT/sns_archive/" . $issue . "/html.html"; $htmlfile = fopen( $htmlpath, "r" ); $contents = fread($htmlfile, filesize($htmlpath)); fclose($htmlfile); //Get Newsletter Text $textpath = "C:/EXT_ROOT/sns_archive/" . $issue . "/plain.txt"; //$htmlpath = "D:/sns_archive/" . $issue . "/html.html"; $textfile = fopen( $textpath, "r" ); $text_contents = fread($textfile, filesize($textpath)); fclose($textfile); $body = $contents; $text_body = $text_contents; $mail->Subject = $subjecttext; //$mail->ContentType = "text/html"; $mail->Body = $body; $mail->AltBody = $text_body; $mail->AddAddress($address, $address); $mail->AddAttachment("C:/EXT_ROOT/sns_archive/" . $issue . "/sns.pdf", "SNS" . $issue . ".pdf"); if(!$mail->Send()) { $msg = "There has been a mail error sending to " . $address . "<br>"; } else { $msg = "Sent mail to " . $address . "<br>"; } // Clear all addresses and attachments for next loop $mail->ClearAddresses(); $mail->ClearAttachments(); mail("scott@stratnews.com", "Latest issue sent to new subscriber", $msg . "\nFinished on " . date("m j, Y g:i a")); } function get_latest_issue() { // set directory name $dir = "C:/EXT_ROOT/sns_archive/"; $dl = array(); if ($hd = opendir($dir)) { while ($sz = readdir($hd)) { if (preg_match("/^\./",$sz)==0) $dl[] = $sz; } closedir($hd); } rsort($dl); $counter = 1; while (list($key, $val) = each($dl)) { if ($counter <= 1){ $ret .= $val ; $counter++; } } return $ret; } // ATTEMPT TO BILL ALL WEEK 4 TRIALS NOW! function bill_trials_now() { echo 'start billing'; // update all trial subscriptions to the correct permanent subscriptions //trial_sub_update(); $url = setup("url"); //$ret=""; $db = new ps_DB; $q = "SELECT * FROM domains WHERE domain_host_id = 48 OR domain_host_id = 59 "; //$q = "SELECT * FROM domains_test WHERE domain_host_id = 48"; $db->query($q); $gw = setup("gateway"); // LOOP THROUGH EACH DOMAIN while ($db->next_record()) { $current_domain = $db->f("domain_host_id"); if ($current_domain == '48') { //$new_domain = '33'; //$amount = '595'; $new_domain = '55'; $amount = '195'; } else { $new_domain = '55'; $amount = '195'; } $subscription_id = $db->f("domain_id"); $membership_id = $db->f("domain_host_id"); $order_id = $db->f("domain_order_id"); $accountid = $db->f("domain_account_id"); $today = $db->f("domain_host_last_billed"); $last_billed = renew_date_process($accountid,$current_domain,$new_domain); $dbx = new ps_DB; $qx = "SELECT * FROM account WHERE account_id = $accountid"; $dbx->query($qx); $dbx->next_record(); $week = $dbx->f("status"); $member_name = $dbx->f("account_name"); $title = $dbx->f("account_title"); $company = $dbx->f("account_company"); $member_email = $dbx->f("account_email"); $address = $dbx->f("account_address"); $city = $dbx->f("account_city"); $state = $dbx->f("account_state"); $zip = $dbx->f("account_zip"); $country = $dbx->f("account_country"); $phone = $dbx->f("account_phone"); $username = $dbx->f("account_username"); $sub_total = get_membership_amount($new_domain); $tax = get_state_tax($sub_total,$state); $total = $sub_total + $tax; $amount = number_format($total,2); $namebreak = explode(' ',$member_name); $reg_data['membership_id'] = $membership_id; $reg_data['pay_amount'] = $sub_total; $reg_data['tax'] = $tax; $reg_data['paymethod'] = 'cc'; $reg_data['Username'] = $username; $reg_data['EmailAdr'] = $member_email; $reg_data['FirstName'] = $namebreak[0]; $reg_data['LastName'] = $namebreak[1]; $reg_data['Title'] = $title; $reg_data['Company'] = $company; $reg_data['CcFName'] = $reg_data['FirstName']; $reg_data['CcLName'] = $reg_data['LastName']; $reg_data['address1'] = $address; $reg_data['City'] = $city; $reg_data['State'] = $state; $reg_data['PostalCode'] = $zip; $reg_data['country'] = $country; $reg_data['phone'] = $phone; $reg_data['renewal'] = '1'; $invoice_id = 'CCW'.$d . mt_rand(11,99); $reg_data['snscompany'] = 'llc'; if ($week == 'sns.week4' ) { echo 'stop 1<br>'; //CHECK IF THIS ACCOUNT HAS AUTO RENEW ENABLED $opt_out = $dbx->f("opt_out"); $name = $dbx->f("account_name"); //$subscription_id = $db->f("domain_id"); //$membership_id = $db->f("domain_host_id"); //$amount = get_membership_amount($db->f("domain_host_id")); //$amount = '595'; //$status = get_billing_status_bill_2($db->f("domain_host_id"),$db->f("domain_host_periods"),$db->f("domain_host_last_billed"),$db->f("domain_host_last_billed")); if ($opt_out==0) { echo 'stop 2<br>'; unset($C_CARD); // SUBSCRIPTION IS DUE FOR BILLING NOW! //$ret= "<BR>\n"; // CHECK IF THIS ACCOUNT HAS ANY CREDIT CARD ON FILE if ($db->f("domain_billing_id") > 0) { $C_CARD = TRUE; } else { $C_CARD = FALSE; } // BEGIN STORED CREDIT CARD INFORMATION LOOP if($C_CARD) { echo 'stop 3<br>'; // LETS TRY TO CHARGE THIS CARD! $trial_domain_id = $new_domain; $domain = $db->f("domain_name"); $billing_id = $db->f("domain_billing_id"); $dbs = new ps_DB; $qs = "SELECT billing_cc_num FROM billing WHERE billing_id = '$billing_id'"; $dbs->query($qs); $dbs->next_record(); $cc_num=$dbs->f("billing_cc_num"); $cc_num=RC4($cc_num,"de"); $cc1 = substr($cc_num, 0, 4) ; $cc2 = substr($cc_num, -4, 4) ; $cchidden = $cc1 . "-XXXX-XXXX-" . $cc2; $ret = "Connecting to gateway to bill account ID: " . $db->f("domain_account_id"); $billed= quick_bill($db->f("domain_billing_id"),$db->f("domain_id"),$trial_domain_id,$db->f("domain_account_id")); if ($billed[result]=="0") { // BILLED OK AT VIA GATEWAY! //update_billed_domain($db->f("domain_id"),$db->f("domain_host_periods")); $order_id = next_order_id(); //create_trial_order_record($order_id,$accountid,$billing_id); create_trial_order_record($order_id,$accountid,$billing_id,$amount,$new_domain); upgrade_week4($accountid); update_trials_domain($subscription_id,$last_billed,$current_domain); update_renew_date ($accountid,$today); save_invoice_data($reg_data,$accountid,$billing_id,$order_id,$invoice_id,'1'); $ret.= " RESULT: " . $name . " Billed & Updated - CC: " . $cchidden . ' Amount $' . $amount . ' ' ; //echo $ret; // EMAIL THE CUSTOMER //if (setup("email_17")==Y) { send_mail("26",$db->f("domain_account_id"),$db->f("domain_id"),"",""); //} } elseif ($billed[result] > "1" || $billed[result] < "0") { // BILLING DECLINED AT GATEWAY $ret.= " RESULT: > Card Declined... Emailed Customer < "; //echo $ret; expire_week4($accountid); //EMAIL THE CUSTOMER if (setup("email_19")==Y) { send_mail("19",$db->f("domain_account_id"),$db->f("domain_id"),"",""); $ret.= " -- Sent payment declined email to account! "; //echo $ret; } $ret.= " <BR>"; } elseif ($billed[result]=="1" || $billed[result]=="") { $ret.= " RESULT: > Gateway Error... Verify your configuration < "; //echo $ret; } else { $ret.= " RESULT: > Unknown Error... Verify your configuration < "; //echo $ret; } } else { // NO CARD ON FILE, COULDN'T USE IT IF WE WANTED TO! SEND THE CUSTOMER A PAYMENT LINK! //$ret.= "No Card On File For Account Id:" . $db->f("domain_account_id") . " RESULT: > Payment Link Emailed To Customer < "; $ret.= "No Card On File For Account Id:" . $db->f("domain_account_id"); //send_mail("16",$db->f("domain_account_id"),$db->f("domain_id"),"",""); //echo $ret; } } // billing not due or less than 0... } $trialstatus .= $ret; $ret=""; } // end of loop... $date = date("Y-m-d"); $trialstatus .= 'Trial billings for:' . $date; log_trial_billing($trialstatus); $file = 'C:/EXT_ROOT/sns_data/' . $date . '-trial-billing.txt'; $statusfile = fopen( $file, "r" ); if ($statusfile != '') { $statuscontents = fread($statusfile, filesize($file)); } else { $statuscontents = 'No Trials eligible for billing'; } fclose($statusfile); //mail("mark@stratnews.com,scott@tapsns.com,lynne@stratnews.com", "Trial Billing is done", "Finished at: " . date("m j, Y g:i a") . "\n" . $statuscontents); mail("scott@stratnews.com", "Trial Billing is done", "Finished at: " . date("m j, Y g:i a") . "\n" . $statuscontents); return $ret; } // end of function... function create_trial_order_record($order_id,$accountid,$billing_id,$amount,$domain_id) { $today=date("Y-m-d"); $db = new ps_DB; $q = "INSERT INTO orders SET order_id = '$order_id', order_account_id = '$accountid', order_billing_id = '$billing_id', order_amount = '$amount', order_date = '$today', order_status = '1', order_attr_name_3 = 'Domain', order_attr_value_3 = '$domain_id', order_ip = '127.0.0.1', base_amount = '$amount'"; $db->query($q); return true; } function update_account_subscription($f){ $today=date("Y-m-d"); $db = new ps_DB; $q = "SELECT account_email,account_username,account_password,renew_date,status FROM account WHERE account_id='" . sql_string_filter($db->lid, $f[account_id]) . "'"; $db->query($q); $db->next_record(); $old_email = $db->f("account_email"); $f[old_email] = $old_email; $old_password = $db->f("account_password"); $old_username = $db->f("account_username"); $renew_date = $f[renew_date]; $account_id = $f[account_id]; $groupid = $f[groupid]; $dbstatus = $db->f("status"); $group_record = $f[group_record]; $old_renew_date = $db->f("renew_date"); //update renew date and set subscription start date if($renew_date != $old_renew_date){ if($groupid != '0' && $group_record == '1'){ update_group_renew_date($groupid,$renew_date); echo $groupid; } else { $new_sub_date = renew_date_calc_start($account_id,$renew_date); $dbr = new ps_DB; $qr = "UPDATE domains SET domain_host_last_billed = '$new_sub_date' where domain_account_id = '" . sql_string_filter($dbr->lid, $f[account_id]) . "'"; $dbr->query($qr); //echo $qr; } } if ($f[sns_status] == 'sns.expired' && $dbstatus != 'sns.expired') { $f[note_type] = 1; $f[status] = 'update'; $f[note_account_id] = $account_id; $f[note_message] = '<span style="color:red;">Subscription cancelled</span>'; $f[note_record_id] = ''; note_control($f); } if ($f[sns_status] != 'sns.expired' && $dbstatus == 'sns.expired') { $f[note_type] = 1; $f[status] = 'update'; $f[note_account_id] = $account_id; $f[note_message] = '<span style="color:green;">Subscription restarted</span>'; $f[note_record_id] = ''; note_control($f); } $db = new ps_DB; $q = "UPDATE account SET groupid ='" . sql_string_filter($db->lid, $f[groupid]) . "', group_membership ='" . sql_string_filter($db->lid, $f[group_membership]) . "', status ='" . sql_string_filter($db->lid, $f[sns_status]) . "', opt_out ='" . sql_string_filter($db->lid, $f[opt_out]) . "',"; if ($f[sns_status] == 'sns.expired') { $q .= "cancel_date ='$today',"; } else { $q .= "cancel_date ='',"; } $q .= "renew_date ='" . sql_string_filter($db->lid, $f[renew_date]) . "' WHERE account_id ='" . sql_string_filter($db->lid, $f[account_id]) . "'"; $db->query($q); } // UPDATE TRIAL DOMAIN STATUS function update_trials_domain($subscription_id,$last_billed,$membership_id) { if ($membership_id == '48') { $trial_plan = '55'; } else { $trial_plan = '55'; } // CALCULATE THE DUE DATE TO MAKE IT DUE TODAY... //$last_billed = mktime() - (86400*365); //$last_billed = date("Y-m-d"); // UPDATE THE DOMAIN RECORD... $dbd = new ps_DB; $q ="UPDATE domains SET domain_host_id = '$trial_plan', domain_host_last_billed = '$last_billed' WHERE domain_id = '$subscription_id'"; $dbd->query($q); } function rotate_buckets(){ //Get Goodbye Text $goodbyepath = "C:/EXT_ROOT/sns_data/notices/goodbye.txt"; $goodbyefile = fopen( $goodbyepath, "r" ); $goodbyecontents = fread($goodbyefile, filesize($goodbyepath)); fclose($goodbyefile); $status_query = "status = 'sns.week1' OR status = 'sns.week2' OR status = 'sns.week3' OR status = 'sns.week4' "; $db = new ps_DB; $q = "SELECT account_id, status, account_email FROM account WHERE $status_query ORDER BY status"; $db->query($q); //max_results $total_records = $db->num_rows(); while ($db->next_record()){ if ($db->f("status") == 'sns.week1'){ $new_status = 'sns.week2'; } elseif ($db->f("status") == 'sns.week2'){ $new_status = 'sns.week3'; } elseif ($db->f("status") == 'sns.week3'){ $new_status = 'sns.week4'; } else { $new_status = 'sns.expired'; } $account_id = $db->f("account_id"); $status = $new_status; $old_status = $db->f("status"); $account_email = $db->f("account_email"); $rotatestatus = update_trial_record($account_id,$status,$old_status,$account_email,$goodbyecontents); $logdata .= $rotatestatus; echo $rotatestatus; } log_bucket_rotation($logdata); } // UPDATE ACCOUNT STATUS ... function upgrade_week4($account_id) { $dbs = new ps_DB; $q = "UPDATE account SET status = 'sns.normal' WHERE account_id = '$account_id'"; $dbs->query($q); } function expire_week4($account_id) { $today = date("Y-m-d"); $dbs = new ps_DB; $q = "UPDATE account SET status = 'sns.expired', cancel_date = '$today' WHERE account_id = '$account_id'"; $dbs->query($q); } function update_trial_record($account_id,$status,$old_status,$account_email,$goodbyecontents){ $db = new ps_DB; $q = "UPDATE account SET status = '$status' WHERE account_id = '$account_id'"; if (!$db->query($q)) { $ret .= "Unable to update account: " . $account_email . "<br>\n"; } else { $ret .= "Account updated: " . $account_email . " Trial Status changed from " . $old_status . " to " . $status . "<br>\n"; if ($status == 'sns.expired') { mail($account_email, "Trial has ended", $goodbyecontents, "From: Strategic News Service <subscriptions@mailsrv.stratnews.com>\r\n"); $ret .= "Account Expired mail sent to: " . $account_email . " Trial Status changed from " . $old_status . " to " . $status . "<br>\n"; } } return $ret; } function log_trial_billing($trialstatus) { $date = date("Y-m-d"); $file = 'C:/EXT_ROOT/sns_data/' . $date . '-trial-billing.txt'; if (!$file_handle = fopen($file,"a")) { echo "Cannot open file"; } if (!fwrite($file_handle, $trialstatus)) { echo "Cannot write to file"; } fclose($file_handle); } function log_bucket_rotation($rotatestatus) { $date = date("Y-m-d"); $file = 'C:/EXT_ROOT/sns_data/' . $date . '-bucket-rotation.txt'; if (!$file_handle = fopen($file,"a")) { echo "Cannot open file"; } if (!fwrite($file_handle, $rotatestatus)) { echo "Cannot write to file"; } fclose($file_handle); } function log_auto_billing($ret) { $date = date("Y-m-d"); $file = 'C:/EXT_ROOT/sns_data/' . $date . '-auto-billing.txt'; if (!$file_handle = fopen($file,"a")) { echo "Cannot open file"; } if (!fwrite($file_handle, $ret)) { echo "Cannot write to file"; } fclose($file_handle); } function log_renewal_sent($ret) { $date = date("Y-m-d"); $file = 'C:/EXT_ROOT/sns_data/' . $date . '-renewals_sent.txt'; if (!$file_handle = fopen($file,"a")) { echo "Cannot open file"; } if (!fwrite($file_handle, $ret)) { echo "Cannot write to file"; } fclose($file_handle); } //HAIKU DISPLAY function show_latest_haiku() { $id = date('z') - 53; //$id = date('z'); $dbe = new ps_DB; $qe = "SELECT text FROM dreamaccount.haiku2 WHERE haiku_id = '$id' "; $dbe->query($qe); $dbe->next_record(); $text = $dbe->f("text"); $ret = ' <table><tr><td align="center"> <br>' . $text . '<br><br></td></tr></table>'; return $ret; } function show_featured_haiku() { $db = new ps_DB; $q = "SELECT text FROM dreamaccount.haiku2 WHERE featured = '1' "; $db->query($q); $ret = '<table>'; while($db->next_record()) { $text = $db->f("text"); $ret .= ' <table><tr><td align="center"> <br>' . $text . '<br><br></td></tr>'; } $ret .= '</table>'; return $ret; } // GET DOMAIN BILLING STATUS PART 2 function get_expire_status($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) { //echo "Remain periods: $periods_diff <BR>"; // 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 = number_format($due,0); } else { // JUST DUE FOR REBILLING TODAY $ret = number_format($due,0); } } // 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 = number_format($due,0); } // 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; } function get_renewal_days($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 of start of subscription $date_diff =(($today_date-$db_date)/86400); //86400secs = 1 day $frequency=$db->f("membership_frequency"); //billed every 365 or 730 days $recurring=$db->f("membership_recurring"); //yes "Y" $total_periods=$db->f("membership_periods"); //billed for the next 10 years $periods_diff=$total_periods - $current_periods; // THIS IS A RECURRING CHARGE. WE WILL CONTINUE... if($recurring==Y) { //echo "Remain periods: $periods_diff <BR>"; // 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['note'] = "Expires Today"; } else { // JUST DUE FOR REBILLING TODAY $ret['sign'] = "+"; $ret['days'] = 0; } // THIS CHARGE IS NOT DUE YET } elseif($frequency > $date_diff) { $due = $frequency - $date_diff; // 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['sign'] = "+"; $ret['days'] = number_format($due,0); } else { // JUST DUE FOR REBILLING TODAY $ret['sign'] = "+"; $ret['days'] = number_format($due,0); } } // 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; $ret['sign'] = "-"; $ret['days'] = number_format($due,0); $ret['note'] = "Expired"; } // THERE ARE NO REMAINING BILLING PERIODS, THIS SUBSCRIPTION IS EXPIRED, ACCESS DENIED! } else { $ret['note'] = "Expired"; } } // THIS IS NOT A RECURRING CHARGE. } else { $ret['note'] = "Non-recurring"; } return $ret; } function get_mailing_status($account_id) { $db = new ps_DB; $q = "SELECT status FROM account WHERE account_id = $account_id"; $db->query($q); $db->next_record(); $ret = $db->f("status"); return $ret; } function get_optout_status($account_id) { $db = new ps_DB; $q = "SELECT opt_out FROM account WHERE account_id = $account_id"; $db->query($q); $db->next_record(); $ret = $db->f("opt_out"); return $ret; } function set_opt_out($account_id) { $db = new ps_DB; $q = "UPDATE account SET opt_out = '1' WHERE account_id = $account_id"; $db->query($q); } function set_opt_out_test($account_id) { $db = new ps_DB; $q = "UPDATE account_test SET opt_out = '1' WHERE account_id = $account_id"; $db->query($q); } function set_opt_in($account_id) { $db = new ps_DB; $q = "UPDATE account SET opt_out = '0' WHERE account_id = $account_id"; $db->query($q); } function record_sent_issue($issue,$account_id) { $today = date("Y-m-d"); $db = new ps_DB; $q = "INSERT INTO sent_issues SET issue = '$issue', account_id = '$account_id', date = '$today' "; $db->query($q); } function update_status($account_id,$status,$membership_id) { $db = new ps_DB; $q = "UPDATE account SET status = '$status', account_membership_id = '$membership_id' WHERE account_id = '$account_id'"; $db->query($q); } function get_sns_status($membership_id){ switch ($membership_id) { case "4": $ret = 'sns.week1'; break; case "48": $ret = 'sns.week1'; break; case "33": $ret = 'sns.normal'; break; case "42": $ret = 'sns.normal'; break; case "36": $ret = 'sns.premium'; break; case "43": $ret = 'sns.premium'; break; case "35": $ret = 'sns.grpnormal'; break; case "38": $ret = 'sns.grppremium'; break; case "31": $ret = 'sns.comp'; break; case "51": $ret = 'sns.pcomp'; break; case "54": $ret = 'sns.aoc'; break; case "52": $ret = 'sns.normal'; break; case "55": $ret = 'sns.normal'; break; case "53": $ret = 'sns.normal'; break; default: $ret = '0'; } return $ret; } function get_domain_exists($account_id) { $dbf = new ps_DB; $q = "SELECT domain_id FROM domains WHERE domain_account_id = '$account_id'"; $dbf->query($q); $dbf->next_record(); $exists = $dbf->f("domain_id"); if($exists > 0) { $ret = '1'; } else { $ret = '0'; } return $ret; } function send_failed_order_notice($account_id) { $dbf = new ps_DB; $q = "SELECT * FROM account WHERE account_id = '$account_id'"; $dbf->query($q); $dbf->next_record(); $name = $dbf->f("account_name"); $email = $dbf->f("account_email"); $title = $dbf->f("account_title"); $company = $dbf->f("account_company"); $today = date("Y-m-d, g:ia"); $info = ' The following client had trouble processing their payment: Date: '.$today.' Name: '.$name.' Title: '.$title.' Company: '.$company.' Email: '.$email.' '; mail("scott@stratnews.com", "SNS Failed Order Notice", $info, "From: SNS Notices <subscriptions@mailsrv.stratnews.com>\r\n"); } function check_mailed2($notice_id,$account_id) { $dbf = new ps_DB; $q = "SELECT record_id FROM sent_notices WHERE notice_id = '$notice_id' AND account_id = '$account_id'"; $dbf->query($q); $dbf->next_record(); $exists = $dbf->f("record_id"); if($exists > 0) { $ret = '1'; } else { $ret = '0'; } return $ret; } function convert_smart_quotes($string) { $search = array(chr(141), chr(145), chr(146), chr(147), chr(148), chr(151), chr(237)); //$replace = array('‘', // '’', // '“', // '”', // '—', // '’'); $replace = array("'", "'", "'", '"', '"', '-', "'"); return str_replace($search, $replace, $string); } // GET COUPON AMOUNT FOR SESSION function get_coupon_discount($price,$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 $number = $rate*$price; $number = number_format($number, 2, '.', ''); return $number; } } } } else { // return 0 return 0; } } function get_coupon_discount_review($price,$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 $number = $rate*$price; $number = number_format($number, 2, '.', ''); return $number; } } } // } // else // { // return 0 // return 0; // } } function get_order_cost($membership_id,$coupon,$paymethod) { if ($paymethod == 'wire' || $coupon != '') { $price = get_membership_amount($membership_id); } else { $price = get_membership_amount($membership_id); // switch($membership_id) { // case "33": //standard 1yr // $price = '526.25'; // //$price = '476'; // break; // case "42": //standard 2yr // $price = '883.20'; // break; // case "36": //premium 1yr // $price = '791.67'; // //$price = '716'; // break; // case "43": //premium 2yr // $price = '1508.60'; // break; // case "48": //trial - 1 month // $price = '14.95'; // break; // case "55": //trial - 3 month // $price = '195'; // break; // } } //$price = get_membership_amount($membership_id); if ($coupon != '') { $discount = get_coupon_discount($price,$coupon); } else { $discount = '0'; } $total = number_format($price - $discount,2); return $total; } function get_order_cost_with_tax($membership_id,$coupon,$paymethod,$state) { if ($paymethod == 'wire' || $coupon != '') { $price = get_membership_amount($membership_id); } else { $price = get_membership_amount($membership_id); } if ($coupon != '') { $discount = get_coupon_discount($price,$coupon); } else { $discount = '0'; } $sub_total = $price - $discount; $tax = get_state_tax($sub_total,$state); $total = $sub_total + $tax; $total = number_format($total,2); return $total; } function get_renew_order_cost($membership_id,$coupon,$paymethod) { $price = get_membership_amount($membership_id); if ($coupon != '') { $discount = get_coupon_discount($price,$coupon); } else { $discount = '0'; } $total = number_format($price - $discount,2); return $total; } function get_renew_order_cost_with_tax($membership_id,$coupon,$paymethod,$state) { $price = get_membership_amount($membership_id); if ($coupon != '') { $discount = get_coupon_discount($price,$coupon); } else { $discount = '0'; } $sub_total = $price - $discount; $tax = get_state_tax($sub_total,$state); $total = $sub_total + $tax; $total = number_format($total,2); return $total; } function get_discount_price($membership_id){ $price = get_membership_amount($membership_id); // switch($membership_id) { // case "33": //standard 1yr // $price = '526.25'; // //$price = '476'; // break; // case "42": //standard 2yr // $price = '883.20'; // break; // case "36": //premium 1yr // //$price = '716'; // $price = '791.67'; // break; // case "43": //premium 2yr // $price = '1508.60'; // break; // } return $price; } function new_signup_confirmation($reg_data,$order_id) { $today = date("M j, Y"); $amount = get_order_cost($reg_data['membership_id'],$reg_data['promocode'],$reg_data['paymethod']); $membership_name = get_membership_name($reg_data['membership_id']); if ($reg_data['membership_id'] == '33') { $member_type = 'Standard'; }else{ $member_type = 'Premium'; } if ($reg_data['order_id'] == ''){ $reg_data['order_id'] = $order_id; } //$member_type = 'Premium'; $subject='Welcome to Strategic News Service!'; $notice=' Hello '.$reg_data['FullName'].', Thank you for ordering Strategic News Service. You will receive the latest issue along with this confimation notice.'; if ($member_type == 'Standard') { $notice.=' Be sure to visit our website at https://www.stratnews.com/members/subscribers-home.php As a '.$member_type.' member you have access to: * Members\' Research Desktop, featuring members\' top-ranked Web sites in five categories * Members\' Library, featuring members\' book & blog recommendations in business, economics, management and more * Resources, presenting links and sources Mark Anderson uses to create the newsletter * A Glossary of frequently used terms and acronyms in the SNS newsletter'; } elseif ($member_type == 'Premium') { $notice.=' Be sure to visit our website at https://www.stratnews.com/members/psubscribers-home.php As a '.$member_type.' member you have access to: * To a multi-year searchable Archive of past issues of SNS * A much-expanded Premium Research Desktop (over 200 member-ranked Web sites in 11 categories) * Expanded Premium Members\' Library featuring members\' book & blog recommendations in business, economics, management and more * Resources, presenting links and sources Mark Anderson uses to create the newsletter * One-click bookstore featuring members\' book recommendations in all categories, including members\' comments * Select descriptive list of companies, managers and markets that have been mentioned (positively or negatively) in SNS * A Glossary of frequently used terms and acronyms in the SNS newsletter'; } $notice.=' Also check in to the SNS Blog (http://www.stratnews.com/blog/), where you can find additional content and commentary from Mark. To view the status of your account at any time, login to your account page here: https://www.stratnews.com/orders/?page=account&next_page=account --------------------------------------------------- Summary Invoice for '.$reg_data['FullName'].' You placed Order Id: '.$reg_data['order_id'].' on '.$today.'. Order Info: Amount: $'.$amount.' '.$membership_name.' Billing Info: '.$reg_data['CcName'].' '.$reg_data['address1'].' '.$reg_data['City'].', '.$reg_data['State'].' '.$reg_data['PostalCode'].' Email: '.$reg_data['EmailAdr'].' Username: '.$reg_data['Username'].' Password: '.$reg_data['password1'].' --------------------------------------------------- You can review and print full invoices from the account page linked above. We\'re here, we\'re human and we have a clue. Whether you need assistance, need to vent or want to say how much you love Strategic News Service, just holler. We read every customer email every day and usually respond within an hour, so drop us a line at subscriptions@stratnews.com. Thank you, Jessica Crouch We will never release your personal information to any other organization without your express permission. Read our Privacy Policy here: http://www.stratnews.com/privacy.php. '; $to_mail = $reg_data['EmailAdr']; // CREATE THE HEADERS $headers = '"From: Strategic News Service <subscriptions@stratnews.com>"'; //$headers .= 'Bcc: monitor@tapsns.com' . "\r\n"; if (!@mail($reg_data['EmailAdr'], $subject, $notice, "From: Strategic News Service <subscriptions@stratnews.com>\r\n")) { mail("scott@stratnews.com", "New Signup: Bad Email", "Unable to send Confirmation email to ".$reg_data['EmailAdr'] . ' for a new '.$membership_name.' subscription on ' . date("m j, Y g:i a") . "\r\n", "From:\"Strategic News Service\"<subscriptions@mailsrv.stratnews.com>\r\nReply-To:subscriptions@mailsrv.stratnews.com\r\n"); } } function signup_confirmation_trial($reg_data,$order_id) { $today = date("M j, Y"); $amount = get_order_cost($reg_data['membership_id'],$reg_data['promocode'],$reg_data['paymethod']); if ($reg_data['order_id'] == ''){ $reg_data['order_id'] = $order_id; } //$member_type = 'Premium'; $subject='Welcome to Strategic News Service!'; $notice=' Hello '.$reg_data['FullName'].', Thank you for ordering a trial of Strategic News Service. You will receive the latest issue along with this confimation notice. Be sure to visit our website at https://www.stratnews.com/members/subscribers-home.php As a trial member you have access to: * Members\' Research Desktop, featuring members\' top-ranked Web sites in five categories * Members\' Library, featuring members\' book & blog recommendations in business, economics, management and more * Resources, presenting links and sources Mark Anderson uses to create the newsletter * A Glossary of frequently used terms and acronyms in the SNS newsletter Also check in to the SNS Blog (http://www.stratnews.com/blog/), where you can find additional content and commentary from Mark. To view the status of your account at any time, login to your account page here: https://www.stratnews.com/orders/?page=account&next_page=account --------------------------------------------------- Summary Invoice for '.$reg_data['FullName'].' You placed Order Id: '.$reg_data['order_id'].' on '.$today.'. Order Info: Amount: $'.$amount.' 4 week Trial Subscription Billing Info: '.$reg_data['CcName'].' '.$reg_data['address1'].' '.$reg_data['City'].', '.$reg_data['State'].' '.$reg_data['PostalCode'].' Email: '.$reg_data['EmailAdr'].' Username: '.$reg_data['Username'].' Password: '.$reg_data['password1'].' --------------------------------------------------- You can review and print full invoices from the account page linked above. Reminder: Your 4 week trial will be automatically upgraded to a 3 month subscription at the standard rate of $195. Upgrades may be cancelled until 30 days after the upgrade. Trials are non-refundable. We\'re here, we\'re human and we have a clue. Whether you need assistance, need to vent or want to say how much you love Strategic News Service, just holler. We read every customer email every day and usually respond within an hour, so drop us a line at subscriptions@stratnews.com. Thank you, Jessica Crouch We will never release your personal information to any other organization without your express permission. Read our Privacy Policy here: http://www.stratnews.com/privacy.php. '; $to_mail = $reg_data['EmailAdr']; // CREATE THE HEADERS $headers = '"From: Strategic News Service <subscriptions@stratnews.com>"'; //$headers .= 'Bcc: monitor@tapsns.com' . "\r\n"; if (!@mail($reg_data['EmailAdr'], $subject, $notice, "From: Strategic News Service <subscriptions@stratnews.com>\r\n")) { mail("scott@stratnews.com", "New Trial Signup: Bad Email", "Unable to send Confirmation email to ".$reg_data['EmailAdr'] . ' for a Trial subscription on ' . date("m j, Y g:i a") . "\r\n", "From:\"Strategic News Service\"<subscriptions@mailsrv.stratnews.com>\r\nReply-To:subscriptions@mailsrv.stratnews.com\r\n"); } } function signup_confirmation_trial3($reg_data,$order_id) { $today = date("M j, Y"); $amount = get_order_cost($reg_data['membership_id'],$reg_data['promocode'],$reg_data['paymethod']); if ($reg_data['order_id'] == ''){ $reg_data['order_id'] = $order_id; } //$member_type = 'Premium'; $subject='Welcome to Strategic News Service!'; $notice=' Hello '.$reg_data['FullName'].', Welcome to Strategic News Service Newsletter, the most accurate predictive newsletter covering the computing and communications industries. You now have access to strategic information that is not available in the press about critical computer and telecommunications issues, trends and events. You have chosen the Quarterly Subscription rate of $195 for 3 months of SNS. If you would like to continue your subscription on or before the renewal date, you have several choices: renew for another quarter at $195 convert to a Full Year Subscription with credit for your first quarter for an additional $400 ($595 for a year) convert to a Premium Subscription for an additional $700 ($895 for a year). You will receive the latest issue along with this confimation notice. Be sure to visit our website at https://www.stratnews.com/members/subscribers-home.php As a trial member you have access to: * Members\' Research Desktop, featuring members\' top-ranked Web sites in five categories * Members\' Library, featuring members\' book & blog recommendations in business, economics, management and more * Resources, presenting links and sources Mark Anderson uses to create the newsletter * A Glossary of frequently used terms and acronyms in the SNS newsletter Also check in to the SNS Blog (http://www.stratnews.com/blog/), where you can find additional content and commentary from Mark. To view the status of your account at any time, login to your account page here: https://www.stratnews.com/orders/?page=account --------------------------------------------------- Summary Invoice for '.$reg_data['FullName'].' You placed Order Id: '.$reg_data['order_id'].' on '.$today.'. Order Info: Amount: $'.$amount.' Quarterly Subscription Billing Info: '.$reg_data['CcName'].' '.$reg_data['address1'].' '.$reg_data['City'].', '.$reg_data['State'].' '.$reg_data['PostalCode'].' Email: '.$reg_data['EmailAdr'].' Username: '.$reg_data['Username'].' Password: '.$reg_data['password1'].' --------------------------------------------------- You can review and print full invoices from the account page linked above. We\'re here, we\'re human and we have a clue. Whether you need assistance, need to vent or want to say how much you love Strategic News Service, just holler. We read every customer email every day and usually respond within an hour, so drop us a line at subscriptions@stratnews.com. Thank you, Jessica Crouch We will never release your personal information to any other organization without your express permission. Read our Privacy Policy here: http://www.stratnews.com/privacy.php. '; $to_mail = $reg_data['EmailAdr']; // CREATE THE HEADERS $headers = '"From: Strategic News Service <subscriptions@stratnews.com>"'; //$headers .= 'Bcc: monitor@tapsns.com' . "\r\n"; if (!@mail($reg_data['EmailAdr'], $subject, $notice, "From: Strategic News Service <subscriptions@stratnews.com>\r\n")) { mail("scott@stratnews.com", "New 3 Month Trial Signup: Bad Email", "Unable to send Confirmation email to ".$reg_data['EmailAdr'] . ' for a Trial subscription on ' . date("m j, Y g:i a") . "\r\n", "From:\"Strategic News Service\"<subscriptions@mailsrv.stratnews.com>\r\nReply-To:subscriptions@mailsrv.stratnews.com\r\n"); } } function signup_confirmation_wire($reg_data) { $today = date("M j, Y"); $amount = get_order_cost($reg_data['membership_id'],$reg_data['promocode'],$reg_data['paymethod']); $membership_name = get_membership_name($reg_data['membership_id']); if ($reg_data['membership_id'] == '33') { $member_type = 'Standard'; }else{ $member_type = 'Premium'; } $subject='Welcome to Strategic News Service!'; $notice=' Hello '.$reg_data['FullName'].', Thank you for ordering Strategic News Service. Your subscription will be activated once payment is received. Please wire your payment to: Bank Name: Key Bank of Washington Branch: Friday Harbor Branch, Friday Harbor, Washington (US) Routing Number: 125000574 Account Name: Strategic News Service LLC Account Number: 473711006949 To view the status of your account at any time, login to your account page here: https://www.stratnews.com/orders/?page=account --------------------------------------------------- Summary Invoice for '.$reg_data['FullName'].' Order Info: Amount: $'.$amount.' '.$membership_name.' Billing Info: '.$reg_data['CcName'].' '.$reg_data['address1'].' '.$reg_data['City'].', '.$reg_data['State'].' '.$reg_data['PostalCode'].' Email: '.$reg_data['EmailAdr'].' Username: '.$reg_data['Username'].' Password: '.$reg_data['password'].' --------------------------------------------------- You can review and print full invoices from the account page linked above. We\'re here, we\'re human and we have a clue. Whether you need assistance, need to vent or want to say how much you love Strategic News Service, just holler. We read every customer email every day and usually respond within an hour, so drop us a line at subscriptions@stratnews.com. Thank you, Jessica Crouch We will never release your personal information to any other organization without your express permission. Read our Privacy Policy here: http://www.stratnews.com/privacy.php. '; $to_mail = $reg_data['EmailAdr']; // CREATE THE HEADERS $headers = '"From: Strategic News Service <subscriptions@stratnews.com>"'; //$headers .= 'Bcc: monitor@tapsns.com' . "\r\n"; //mail($account_email, "Trial has ended", $goodbyecontents, "From: Strategic News Service <mark@stratnews.com>\r\n"); if (!@mail($reg_data['EmailAdr'], $subject, $notice, "From: Strategic News Service <subscriptions@stratnews.com>\r\n")) { mail("scott@stratnews.com", "New Signup: Bad Email", "Unable to send Confirmation email to ".$reg_data['EmailAdr'] . ' for a Wire payment subscription on ' . date("m j, Y g:i a") . "\r\n", "From:\"Strategic News Service\"<subscriptions@mailsrv.stratnews.com>\r\nReply-To:subscriptions@mailsrv.stratnews.com\r\n"); } } function email_admin_wire_signup_notice($reg_data) { $today = date("M j, Y"); $amount = get_order_cost($reg_data['membership_id'],$reg_data['promocode'],$reg_data['paymethod']); $membership_name = get_membership_name($reg_data['membership_id']); if ($reg_data['membership_id'] == '33') { $member_type = 'Standard'; }else{ $member_type = 'Premium'; } $subject='New Order: Wire Transfer Signup'; $notice=' A new wire transfer subscription was placed on '. date("m j, Y g:i a") .' --------------------------------------------------- Name: '.$reg_data['FullName'].' Title: '.$reg_data['Title'].' Company: '.$reg_data['Company'].' Referral Source: '.$reg_data['refer']. ' ' . $reg_data['refer_other'].' Order Info: Amount: $'.$amount; if ($reg_data['promocode'] != '') { $notice.=' Promotional Code:' .$reg_data['promocode']; } $notice.= ' Subscription: '.$membership_name.' Billing Info: Name: '.$reg_data['CcName'].' Address: '.$reg_data['address1']; if ($reg_data['address2'] != '') { $notice.= ' '. $reg_data['address2'].' '; } $notice.= $reg_data['City'].', '.$reg_data['State'].' '.$reg_data['PostalCode'].' Phone: '.$reg_data['phone'].' Email: '.$reg_data['EmailAdr'].' Username: '.$reg_data['Username'].' Password: '.$reg_data['password1'].' --------------------------------------------------- Account Admin Area: https://www.stratnews.com/orders/admin/?page=clients&search=N&email='.$reg_data['EmailAdr'].' '; @mail('andrea@accountability-resources.com,jessicac@stratnews.com,mark@stratnews.com,scott@stratnews.com', $subject, $notice, "From:\"Strategic News Service\"<subscriptions@mailsrv.stratnews.com>\r\nReply-To:subscriptions@mailsrv.stratnews.com\r\n"); } function get_member_invoices($account_id) { $dbd = new ps_DB; $qd = "SELECT record_id, invoice_id, date, pay_status FROM invoices WHERE account_id='$account_id' ORDER BY date DESC"; $dbd->query($qd); $ret = "<select name=\"invoice_id\" class=\"inputfield\">"; while($dbd->next_record()){ $invoice_date = $dbd->f("date"); $invoice_id = $dbd->f("invoice_id"); $record_id = $dbd->f("record_id"); $pay_status = $dbd->f("pay_status"); if ($pay_status =='1') { $status = 'Paid'; } else { $status = 'Pending'; } $ret .= "<option value=\"" . $dbd->f("invoice_id") . "\">Invoice Date. " . $dbd->f("date") . " -> " . $status . "</option>"; } $ret.="</select>"; return $ret; } function show_member_info($viewer_data){ global $viewer_data; $account_id = $viewer_data[0]; $fullname = $viewer_data[1]; $company = $viewer_data[2]; $email = $viewer_data[3]; $title = $viewer_data[4]; $results = '<table width="170" border="0" cellpadding="4" cellspacing="0" style="background-color:#e0e0e0"> <tr><td bgcolor="#EBEBEB" style="font-size:12pt;"> <span align="center" style="font-size:11pt;font-weight:bold;text-align:center;">Welcome '.$fullname.'</span> <br><br><i>Here is the current info we have for you.</i> <br><br><span style="font-size:10pt;color:#4e137c">'.$fullname.',<br>'.$title.',<br>'.$company.'</span> </td></tr></table>'; return $results; } function get_member_level(){ global $sns_inews_speaker_cookie, $membership_cookie, $sns_cookie, $sns_inews_cookie, $sns_inews_registered_cookie; if( (isset($membership_cookie['R'])) && ($membership_cookie['R'] == "Y")) { $member_level = '1'; //Registered iNews Users } elseif( (isset($membership_cookie['S'])) && ($membership_cookie['S'] == "Y")) { $member_level = '2'; //Standard Members } elseif( (isset($membership_cookie['P'])) && ($membership_cookie['P'] == "Y")) { $member_level = '3'; //Premium Members } elseif( (isset($membership_cookie['A'])) && ($membership_cookie['A'] == "Y")) { $member_level = '4'; //AOC members } elseif( (isset($membership_cookie['Z'])) && ($membership_cookie['Z'] == "Y")) { $member_level = '5'; //Staff } elseif( (isset($sns_inews_cookie['F'])) && ($sns_inews_cookie['F'] == "Y")) { $member_level = '1'; //FiRe Speaker } else { $member_level = '0'; //Default level = 0 ie the public } return $member_level; } function REMOVE_get_nav(){ global $sns_inews_speaker_cookie, $membership_cookie, $sns_cookie, $sns_inews_cookie, $sns_inews_registered_cookie; $page = 'http://www.stratnews.com'.$_SERVER[REQUEST_URI]; //Determine Membership Level $member_level = get_member_level(); //Get Navigation $nav = '<table cellSpacing="0" cellPadding="0" border="0" align="left" class="leftnav_table">'; $db = new ps_DB; $q = "SELECT * FROM dreamaccount.nav WHERE hide = 1 AND level <= $member_level ORDER BY sort_order ASC"; $db->query($q); $line = ''; while ($db->next_record()) { $nav_id = $db->f("nav_id"); $name = $db->f("title"); $alt = $db->f("alt_text"); $link = $db->f("link"); $sort = $db->f("sort_order"); $highlight = $db->f("highlight"); $note=''; if ($highlight == '1') { $new = ' - <span style="color:yellow">NEW!</span>'; } else { $new = ''; } if($line == ''){ if ($sort >= 300) { $line = 'Y'; } } if ($line == 'Y') { $note = ' <tr> <td><IMG width="1" height="6" src="/images/pixel.gif"></td> <td><IMG height="6" src="/images/pixel.gif"></td> </tr> <tr> <td><IMG width="1" height="6" src="/images/pixel.gif"></td> <td class="leftnav">Member\'s Area:</td> </tr> <tr> <td><IMG width="1" height="6" src="/images/pixel.gif"></td> <td><IMG height="6" src="/images/pixel.gif"></td> </tr>'; $line = 'N'; } $block = ' <tr> <td><IMG width="1" height="6" src="/images/pixel.gif"></td> <td> <A class="leftnav" onmouseover="imgbutton_'.$nav_id.'.src=\'/images/redbump.gif\'" style="TEXT-DECORATION: none; color: #d0d0d0" onmouseout="imgbutton_'.$nav_id.'.src=\'/images/bluebump.gif\'" href="'.$link.'" target="_top" alt="'.$alt.'" title="'.$alt.'">'; if($page == $link){ $block .= ' <IMG height=12 src="/images/redbump.gif" width=12 border=0 name=imgbutton_'.$nav_id.'> '.$name.$new.'</A>'; } else { $block .= ' <IMG height=12 src="/images/bluebump.gif" width=12 border=0 name=imgbutton_'.$nav_id.'> '.$name.$new.'</A>'; } $block .= ' </td> </tr> <tr> <td><IMG width="1" height="6" src="/images/pixel.gif"></td> <td><IMG height="6" src="/images/pixel.gif"></td> </tr>'; if($member_level > '0') { if ($nav_id != '12') { $nav .= $note.$block; } else { $nav .= $note; } } else { $nav .= $note.$block; } } $nav .= '</table>'; return $nav; } function get_state_tax($sub_total,$state){ $state = strtolower($state); $state = substr($state,0,2); //echo $state; if ($state == 'wa') { $tax = $sub_total * .081; } else { $tax = 0; } //echo $tax; return $tax; } function get_invoice_data($invoice_id){ //$invoice_id = sanitize_html_string($invoice_id); $db = new ps_DB; $q = "SELECT * FROM invoices WHERE invoice_id='$invoice_id'"; //$q = "SELECT * FROM invoices WHERE invoice_id='CCW228719'"; $db->query($q); $db->next_record(); $reg_data['snscompany'] = $db->f("snscompany"); $reg_data['invoice_id'] = $db->f("invoice_id"); $reg_data['order_id'] = $db->f("order_id"); $reg_data['billing_id'] = $db->f("billing_id"); $reg_data['CcName'] = $db->f("card_name"); $reg_data['CcFName'] = $db->f("card_fname"); $reg_data['CcLName'] = $db->f("card_lname"); $reg_data['address1'] = $db->f("card_address1"); $reg_data['address2'] = $db->f("card_address2"); $reg_data['Company'] = $db->f("company"); $reg_data['City'] = $db->f("card_city"); $reg_data['State'] = $db->f("card_state"); $reg_data['PostalCode'] = $db->f("card_zip"); $reg_data['membership_id'] = $db->f("membership_id"); $reg_data['promocode'] = $db->f("promocode"); $reg_data['tax_paid'] = $db->f("tax_paid"); $reg_data['pay_amount'] = $db->f("pay_amount"); $reg_data['paymethod'] = $db->f("pay_method"); $reg_data['pay_status'] = $db->f("pay_status"); $reg_data['EmailAdr'] = $db->f("email"); $reg_data['Username'] = $db->f("username"); $reg_data['FullName'] = $db->f("full_name"); $reg_data['FirstName'] = $db->f("first_name"); $reg_data['LastName'] = $db->f("last_name"); $reg_data['password1'] = $db->f("password"); $reg_data['renewal'] = $db->f("renewal"); $reg_data['date'] = $db->f("date"); return $reg_data; } function load_invoice_template($reg_data){ if ($reg_data['snscompany'] == 'llc') { $snscompany = 'Strategic News Service<br> PO Box 1969<br> Friday Harbor, WA 98250'; } else { $snscompany = 'SNS Conference Corp.<br> 38 Yew Lane<br> Friday Harbor, WA 98250'; } $invdate = date( 'F jS, Y',strtotime( $reg_data['date'])); $billing = $reg_data['CcFName'].' '.$reg_data['CcLName'].'<br />'; $billing .= $reg_data['Company'].'<br />'; if ($reg_data['membership_id'] != '58') { $billing .= $reg_data['address1'].'<br />'; if ($reg_data['address2'] != '') { $billing .= $reg_data['address2'].'<br />'; } $billing .= $reg_data['City'].', '.$reg_data['State'].' '.$reg_data['PostalCode'].'<br />'; if ($reg_data['paymethod'] == 'cc') { $billing .= $ccdata['type'].'<br />'; $billing .= $ccdata['cc'].'<br />'; } } if ($reg_data['pay_status'] == '1') { $terms = 'PAID'; } else { $terms = 'Due on receipt'; } $quantity = '1'; $description = get_membership_name($reg_data['membership_id']); $total = $reg_data['pay_amount'] + $reg_data['tax_paid']; $total = number_format($total,2); $template = include('C:/WWW/orders/invoice.php'); $template = preg_replace("/<SNSCOMPANY>/", $snscompany, $template); $template = preg_replace("/<INVDATE>/", $invdate, $template); $template = preg_replace("/<INVOICENUM>/", $reg_data['invoice_id'], $template); $template = preg_replace("/<BILLINGINFO>/", $billing, $template); $template = preg_replace("/<PONO>/", $pono, $template); $template = preg_replace("/<DUEDATE>/", $duedate, $template); $template = preg_replace("/<TERMS>/", $terms, $template); $template = preg_replace("/<QUANTITY>/", $quantity, $template); $template = preg_replace("/<DESCRIPTION>/", $description, $template); $template = preg_replace("/<TAX>/", $reg_data['tax_paid'], $template); $template = preg_replace("/<AMOUNT>/", $reg_data['pay_amount'], $template); $template = preg_replace("/<THANKYOU>/", $thankyou, $template); $template = preg_replace("/<TOTAL>/", $total, $template); return $template; } function save_invoice_data($reg_data,$account_id,$billing_id,$order_id,$invoice_id,$paid){ $today = date("Y-m-d"); //$account_id = sanitize_sql_string($account_id); // $invoice_id = $account_id . mt_rand(11,99); $name = $reg_data['FirstName']. ' ' . $reg_data['LastName']; $ccname = $reg_data['CcFName']. ' ' . $reg_data['CcLName']; $db = new ps_DB; $q = "INSERT INTO invoices SET invoice_id='$invoice_id', order_id='$order_id', billing_id='$billing_id', account_id='$account_id', membership_id ='" . sql_string_filter($db->lid, $reg_data['membership_id']) . "', promocode ='" . sql_string_filter($db->lid, $reg_data['promocode']) . "', pay_amount ='" . sql_string_filter($db->lid, $reg_data['pay_amount']) . "', tax_paid ='" . sql_string_filter($db->lid, $reg_data['tax']) . "', pay_method ='" . sql_string_filter($db->lid, $reg_data['paymethod']) . "', pay_status ='$paid', username ='" . sql_string_filter($db->lid, $reg_data['Username']) . "', email ='" . sql_string_filter($db->lid, $reg_data['EmailAdr']) . "', password ='" . sql_string_filter($db->lid, $reg_data['password1']) . "', full_name ='" . sql_string_filter($db->lid, $name) . "', first_name ='" . sql_string_filter($db->lid, $reg_data['FirstName']) . "', last_name ='" . sql_string_filter($db->lid, $reg_data['LastName']) . "', title ='" . sql_string_filter($db->lid, $reg_data['Title']) . "', company ='" . sql_string_filter($db->lid, $reg_data['Company']) . "', card_name ='" . sql_string_filter($db->lid, $ccname) . "', card_fname ='" . sql_string_filter($db->lid, $reg_data['CcFName']) . "', card_lname ='" . sql_string_filter($db->lid, $reg_data['CcLName']) . "', card_address1 ='" . sql_string_filter($db->lid, $reg_data['address1']) . "', card_address2 ='" . sql_string_filter($db->lid, $reg_data['address2']) . "', card_city ='" . sql_string_filter($db->lid, $reg_data['City']) . "', card_state ='" . sql_string_filter($db->lid, $reg_data['State']) . "', card_zip ='" . sql_string_filter($db->lid, $reg_data['PostalCode']) . "', card_country ='" . sql_string_filter($db->lid, $reg_data['country']) . "', card_phone ='" . sql_string_filter($db->lid, $reg_data['phone']) . "', referrer ='" . sql_string_filter($db->lid, $reg_data['refer']) . "', referrer_other ='" . sql_string_filter($db->lid, $reg_data['refer_other']) . "', renewal ='" . sql_string_filter($db->lid, $reg_data['renewal']) . "', date = '$today'"; $db->query($q); } function show_spotlight_books() { $dba = new ps_DB; $q = "SELECT * FROM books WHERE spotlight != '0' ORDER BY spotlight ASC "; $dba->query($q); $ret = '<table border="0" cellpadding="6" width="100%">'; if ($dba->num_rows() > 0) { while($dba->next_record()) { unset($recommended); unset($count); unset($view_comments); unset($plural); $book_id = $dba->f("book_id"); $db = new ps_DB; $qa = "SELECT * FROM books_comments WHERE book_id = $book_id"; $db->query($qa); $nrows = $db->num_rows(); $count = 1; if ($nrows > 1) {$plural = 's';} while($db->next_record()){ $name = $db->f("name"); $comment = $db->f("comment"); if($comment != ''){$view_comments = 1;} $recommended.= $name; if($nrows - $count == 1){$recommended.= ' and ';} elseif($count < $nrows){$recommended.= ', ';} $count++; } $book_id = $dba->f("book_id"); $title = $dba->f("title"); $title = convert_smart_quotes($title); $author = $dba->f("author"); $author = convert_smart_quotes($author); $link = $dba->f("link"); $pubinfo = $dba->f("pubinfo"); $image = $dba->f("image"); $ret .= '<tr><td valign="top"> <a href="'.$link.'" target="_blank" alt="Buy ' . $title . '" title="Buy ' . $title . '"><img hspace="5" align="left" border="0" style="border:solid 1px black;" src="images/books/' . $image . '"></a> </td><td valign="top"><a href="'.$link.'" target="_blank" alt="Buy ' . $title . '" title="Buy ' . $title . '"><b>' . $title . '</b></a>' ; $ret .= '<br>By '.$author.'<br>'.$pubinfo; if($recommended != ''){ $ret .= '<br>Recommended by SNS Member'.$plural.' '.$recommended; } if($view_comments == 1){ $ret .= '<br><a href="javascript:popUp(\'comments.php?bookid='.$book_id.'\')"><i>View comments</i>'; } $ret .= '</td></tr>'; } $ret .= '</table>'; } else { $ret = "Page Error"; } return $ret; } ?><? /////////////////////////////////////// // sanitize.inc.php // Sanitization functions for PHP // by: Gavin Zuchlinski, Jamie Pratt, Hokkaido // webpage: http://libox.net // Last modified: September 27, 2003 // // Many thanks to those on the webappsec list for helping me improve these functions /////////////////////////////////////// // Function list: // sanitize_paranoid_string($string) -- input string, returns string stripped of all non // alphanumeric // sanitize_system_string($string) -- input string, returns string stripped of special // characters // sanitize_sql_string($string) -- input string, returns string with slashed out quotes // sanitize_html_string($string) -- input string, returns string with html replacements // for special characters // sanitize_int($integer) -- input integer, returns ONLY the integer (no extraneous // characters // sanitize_float($float) -- input float, returns ONLY the float (no extraneous // characters) // sanitize($input, $flags) -- input any variable, performs sanitization // functions specified in flags. flags can be bitwise // combination of PARANOID, SQL, SYSTEM, HTML, INT, FLOAT, LDAP, // UTF8 /////////////////////////////////////// define("PARANOID", 1); define("SQL", 2); define("SYSTEM", 4); define("HTML", 8); define("INT", 16); define("FLOAT", 32); define("LDAP", 64); define("UTF8", 128); // internal function for utf8 decoding // thanks to Jamie Pratt for noticing that PHP's function is a little // screwy function my_utf8_decode($string) { return strtr($string, "???????¥µÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýÿ", "SOZsozYYuAAAAAAACEEEEIIIIDNOOOOOOUUUUYsaaaaaaaceeeeiiiionoooooouuuuyy"); } // paranoid sanitization -- only let the alphanumeric set through function sanitize_paranoid_string($string, $min='', $max='') { $string = preg_replace("/[^a-zA-Z0-9]/", "", $string); $len = strlen($string); if((($min != '') && ($len < $min)) || (($max != '') && ($len > $max))) return FALSE; return $string; } // sanitize a string in prep for passing a single argument to system() (or similar) function sanitize_system_string($string, $min='', $max='') { $pattern = '/(;|\||`|>|<|&|^|"|'."\n|\r|'".'|{|}|[|]|\)|\()/i'; // no piping, passing possible environment variables ($), // seperate commands, nested execution, file redirection, // background processing, special commands (backspace, etc.), quotes // newlines, or some other special characters $string = preg_replace($pattern, '', $string); $string = '"'.preg_replace('/\$/', '\\\$', $string).'"'; //make sure this is only interpretted as ONE argument $len = strlen($string); if((($min != '') && ($len < $min)) || (($max != '') && ($len > $max))) return FALSE; return $string; } // sanitize a string for SQL input (simple slash out quotes and slashes) function sanitize_sql_string($string, $min='', $max='') { $pattern[0] = '/(\\\\)/'; $pattern[1] = "/\"/"; $pattern[2] = "/'/"; $replacement[0] = '\\\\\\'; $replacement[1] = '\"'; $replacement[2] = "\\'"; $len = strlen($string); if((($min != '') && ($len < $min)) || (($max != '') && ($len > $max))) return FALSE; return preg_replace($pattern, $replacement, $string); } // sanitize a string for SQL input (simple slash out quotes and slashes) function sanitize_ldap_string($string, $min='', $max='') { $pattern = '/(\)|\(|\||&)/'; $len = strlen($string); if((($min != '') && ($len < $min)) || (($max != '') && ($len > $max))) return FALSE; return preg_replace($pattern, '', $string); } // sanitize a string for HTML (make sure nothing gets interpretted!) function sanitize_html_string($string) { $pattern[0] = '/\&/'; $pattern[1] = '/</'; $pattern[2] = "/>/"; $pattern[3] = '/\n/'; $pattern[4] = '/"/'; $pattern[5] = "/'/"; $pattern[6] = "/%/"; $pattern[7] = '/\(/'; $pattern[8] = '/\)/'; $pattern[9] = '/\+/'; //$pattern[10] = '/-/'; $replacement[0] = '&'; $replacement[1] = '<'; $replacement[2] = '>'; $replacement[3] = '<br>'; $replacement[4] = '"'; //$replacement[5] = '''; $replacement[5] = "\\'"; $replacement[6] = '%'; $replacement[7] = '('; $replacement[8] = ')'; $replacement[9] = '+'; // $replacement[10] = '-'; return preg_replace($pattern, $replacement, $string); } // make int int! function sanitize_int($integer, $min='', $max='') { $int = intval($integer); if((($min != '') && ($int < $min)) || (($max != '') && ($int > $max))) return FALSE; return $int; } // make float float! function sanitize_float($float, $min='', $max='') { $float = floatval($float); if((($min != '') && ($float < $min)) || (($max != '') && ($float > $max))) return FALSE; return $float; } // glue together all the other functions function sanitize($input, $flags, $min='', $max='') { if($flags & UTF8) $input = my_utf8_decode($input); if($flags & PARANOID) $input = sanitize_paranoid_string($input, $min, $max); if($flags & INT) $input = sanitize_int($input, $min, $max); if($flags & FLOAT) $input = sanitize_float($input, $min, $max); if($flags & HTML) $input = sanitize_html_string($input, $min, $max); if($flags & SQL) $input = sanitize_sql_string($input, $min, $max); if($flags & LDAP) $input = sanitize_ldap_string($input, $min, $max); if($flags & SYSTEM) $input = sanitize_system_string($input, $min, $max); return $input; } ///ADDITIONAL INPUT FILTERS // // // escaping and slashing all POST and GET variables. you may add $_COOKIE and $_REQUEST if you want them sanitized. // array_walk_recursive($_POST, 'sanitizeVariables'); // array_walk_recursive($_GET, 'sanitizeVariables'); // // // sanitization // function sanitizeVariables(&$item, $key) { // if (!is_array($item)) // { // // undoing 'magic_quotes_gpc = On' directive // if (get_magic_quotes_gpc()) // $item = stripcslashes($item); // // $item = sanitizeText($item); // } // } // // // does the actual 'html' and 'sql' sanitization. customize if you want. // function sanitizeText($text) { // $text = str_replace("<", "<", $text); // $text = str_replace(">", ">", $text); // $text = str_replace("\"", """, $text); // $text = str_replace("'", "'", $text); // // // it is recommended to replace 'addslashes' with 'mysql_real_escape_string' or whatever db specific fucntion used for escaping. However 'mysql_real_escape_string' is slower because it has to connect to mysql. // $text = addslashes($text); // // return $text; // } // // // export POST variables as GLOBALS. remove if you want // //foreach (array_keys($_POST) as $ehsanKey) { // // $GLOBALS[$ehsanKey] = $_POST[$ehsanKey]; // //} // // // export GET variables as GLOBALS. remove if you want // //foreach (array_keys($_GET) as $ehsanKey) { // // $GLOBALS[$ehsanKey] = $_GET[$ehsanKey]; // //} // // // preventing the key used above for iteration from getting into globals (in case 'register_globals = On') // //unset($ehsanKey); // // // the reverse function of 'sanitizeText'. you may use it in pages which need the original data (e.g. for an HTML editor) // function unsanitizeText($text) { // $text = stripcslashes($text); // // $text = str_replace("'", "'", $text); // $text = str_replace(">", ">", $text); // $text = str_replace(""", "\"", $text); // $text = str_replace("<", "<", $text); // // return $text; // } ?>