function get_session()
{
session_start();
header("Cache-control: private");
return session_id();
}
function check_mysql($output)
{
if (!$output) {
$filename = "error.html";
$handle = fopen ($filename, "r");
$contents = fread ($handle, filesize ($filename));
$contents = str_replace(XmessageX, mysql_error(), $contents);
print $contents;
fclose ($handle);
exit();
}
}
function check_client($my_session) {
require("../config/config.php");
$connection = mysql_connect($host,$usr,$pwd);
$output = array();
$check_login = mysql_db_query($db, "SELECT * FROM table_logins where session='$my_session' and type='client'", $connection);
if (!$check_login) { client_message("ERROR MESSAGE","YOU MUST RUN THE INSTALL.PHP FILE FIRST"); }
if (!mysql_num_rows($check_login)) { include("../$client_dir/login_now.php"); exit(); }
while ($row = mysql_fetch_array($check_login)) {
$user = $row["user"];
}
return $user;
}
function check_user($my_session) {
require("../config/config.php");
$connection = mysql_connect($host,$usr,$pwd);
$output = array();
$check_login = mysql_db_query($db, "SELECT * FROM table_logins where session='$my_session' and type='admin'", $connection);
if (!$check_login) { admin_message("ERROR MESSAGE","YOU MUST RUN THE INSTALL.PHP FILE FIRST"); }
if (!mysql_num_rows($check_login)) { include("../$admin_dir/login_now.php"); exit(); }
list($q1,$q2)= split ("~", $aeneas, 2);
if(md5(getenv("SERVER_NAME")) != $q1) { database_error("rMEZORW oRXVMHV pVB ."); exit(); }
while ($row = mysql_fetch_array($check_login)) {
$user = $row["user"];
$check_type = mysql_db_query($db, "SELECT * FROM table_users where username='$user'", $connection);
while ($row = mysql_fetch_array($check_type)) {
$type = $row["type"];
}
}
array_push ($output,"$user");
array_push ($output,"$type");
return $output;
}
function check_format($my_session) {
require("../config/config.php");
$connection = mysql_connect($host,$usr,$pwd);
$check_M = mysql_db_query($db, "SELECT * FROM table_temp where sid='$my_session' and period_code='M' ", $connection);
check_mysql($check_M);
if (mysql_num_rows($check_M)) { return "M"; }
$check_Q = mysql_db_query($db, "SELECT * FROM table_temp where sid='$my_session' and period_code='Q' ", $connection);
check_mysql($check_Q);
if (mysql_num_rows($check_Q)) { return "Q"; }
return;
}
function display_cart($my_session) {
require("../config/config.php");
$connection = mysql_connect($host,$usr,$pwd);
$output = array();
$check = mysql_db_query($db, "SELECT * FROM table_temp where sid='$my_session'", $connection);
check_mysql($check);
if (!$check) { echo(mysql_error()); exit(); }
if (!mysql_num_rows($check)) { return "empty"; exit(); }
while ($row = mysql_fetch_array($check)) {
$product_name = $row["product_name"];
$product_price = $row["price"];
$product_code = $row["product_code"];
$setup_price = $row["setup"];
$period = $row["period"];
$period_code = $row["period_code"];
$id = $row["id"];
$totalprice += $product_price;
$totalprice += $setup_price;
$setup_price = currency_format(".%2f", $setup_price);
if ($setup_price > 0) { $setup = "
$currency $setup_price Setup Fee"; }
$period = translate_code($period_code);
$filename = "client_cart_row.html";
$handle = fopen ($filename, "r");
$contents = fread ($handle, filesize ($filename));
$contents = str_replace(Xproduct_nameX, $product_name, $contents);
$contents = str_replace(Xproduct_priceX, $product_price, $contents);
$contents = str_replace(Xproduct_codeX, $product_code, $contents);
$contents = str_replace(XsetupX, $setup, $contents);
$contents = str_replace(XperiodX, $period, $contents);
$contents = str_replace(XidX, $id, $contents);
$contents = str_replace("Z~", $currency, $contents);
array_push($output, $contents);
fclose ($handle);
unset($setup);
}
$back = array();
array_push($back, $output);
array_push($back, $totalprice);
return $back;
}
function log_search($domain,$result,$my_session,$ip)
{
require("../config/config.php");
$connection = mysql_connect($host,$usr,$pwd);
$time = time();
$log_search = mysql_db_query($db, "INSERT INTO table_log_searches (domain, result, session, time) VALUES ('$domain ($ip)', '$result', '$my_session', '$time')", $connection);
check_mysql($log_searches);
mysql_close($connection);
return;
}
function with_tax($amount,$rate)
{
$with_tax = $amount * (1+($rate/100));
return currency_format("%.2f",$with_tax);
}
function user_exists($username)
{
require("../config/config.php");
$connection = mysql_connect($host,$usr,$pwd);
$check_user = mysql_db_query($db, "SELECT username from table_customers where username='$username'", $connection);
check_mysql($check_user);
$results = mysql_num_rows($check_user);
mysql_close($connection);
return $results;
}
function message($header,$message)
{
require("../config/config.php");
$filename = "message.html";
$handle = fopen ($filename, "r");
$contents = fread ($handle, filesize ($filename));
$contents = str_replace(XheaderX, $header, $contents);
$contents = str_replace(XmessageX, $message, $contents);
@include("../$whois_dir/whois_header.html");
print $contents;
@include("../$whois_dir/whois_footer.html");
fclose ($handle);
exit();
}
function admin_message($header,$message)
{
include("../administration/header.html");
$filename = "message.html";
$handle = fopen ($filename, "r");
$contents = fread ($handle, filesize ($filename));
$contents = str_replace(XheaderX, $header, $contents);
$contents = str_replace(XmessageX, $message, $contents);
print $contents;
fclose ($handle);
include("../administration/footer.html");
exit();
}
function client_message($header,$message)
{
include("../client/header.html");
$filename = "message.html";
$handle = fopen ($filename, "r");
$contents = fread ($handle, filesize ($filename));
$contents = str_replace(XheaderX, $header, $contents);
$contents = str_replace(XmessageX, $message, $contents);
print $contents;
fclose ($handle);
include("../client/footer.html");
exit();
}
function get_password($username)
{
require("../config/config.php");
$connection = mysql_connect($host,$usr,$pwd);
$get_password = mysql_db_query($db, "SELECT * from table_customers where username='$username'", $connection);
check_mysql($get_password);
if (!mysql_num_rows($get_password)) { return; }
while ($row = mysql_fetch_array($get_password)) {
$email = $row["email"];
$firstname = $row["firstname"];
$surname = $row["surname"];
$username = $row["username"];
$password = $row["password"];
}
$filename = "../emails/forgotten_password.txt";
$handle = fopen ($filename, "r");
$contents = fread ($handle, filesize ($filename));
$contents = str_replace(XfirstnameX, $firstname, $contents);
$contents = str_replace(XsurnameX, $surname, $contents);
$contents = str_replace(XemailX, $email, $contents);
$contents = str_replace(XusernameX, $username, $contents);
$contents = str_replace(XpasswordX, $password, $contents);
fclose ($handle);
mail("$email", "$forgotten_subject", "$contents", "From: $host_name <$host_email>");
return $email;
}
function whois($domain_to_search,$extension_server,$repeat)
{
$whois_results = perform_whois($domain_to_search,$extension_server);
if (strstr($whois_results[9], "whois.") and $repeat == "1") {
$new_whois = $whois_results[9];
$new_whois = str_replace("Whois Server:", "", $new_whois);
$new_whois = str_replace("\n", "", $new_whois);
$new_whois = str_replace("\r", "", $new_whois);
$new_whois = str_replace(" ", "", $new_whois);
$whois_detailed = perform_whois($domain_to_search,$new_whois);
$whois_detailed = implode("", $whois_detailed);
}
if ($whois_detailed) {
return $whois_detailed;
} else {
$whois_results = implode("", $whois_results);
return $whois_results;
}
}
function perform_whois($domain_to_search,$extension_server)
{
$whois_results = array();
if (trim($domain_to_search) <> "") {
$fp = @fsockopen($extension_server,43);
# AMENDMENT TO SHOW FULL .DE WHOIS DATA
if (strstr($domain_to_search,".de")) { $domain_to_search = " -T dn ". $domain_to_search; }
if (!fputs($fp, "$domain_to_search\r\n")) { return 'error'; }
while(!feof($fp))
{
array_push($whois_results, fgets($fp,4096));
}
fclose($fp);
}
return $whois_results;
}
function non_whois($domain_to_search,$whois_url)
{
$whois_url = str_replace(XdomainX, $domain_to_search, $whois_url);
if (ini_get('allow_url_fopen') == "0") { message("WHOIS LOOK-UP ERROR","Your host has disabled file-access for opening URLs via fopen. In order to allow whois searches for all Domain Name extensions this must be enabled."); }
$fd = @fopen("$whois_url","r");
while ($line=@fgets($fd,1000))
{ $output.=$line; }
@fclose ($fd);
return $output;
}
function get_whois_data($ext)
{
require("../config/config.php");
$connection = mysql_connect($host,$usr,$pwd);
$extension_details = array();
$extension_query = mysql_db_query($db, "SELECT * FROM table_extensions where extension = '$ext'");
if (!$extension_query) { message("ERROR MESSAGE","YOU MUST RUN THE INSTALL.PHP FILE FIRST"); }
while ($row = mysql_fetch_array($extension_query)) {
$extension_server = $row["server"];
$extension_nomatch = $row["nomatch"];
$extension_type = $row["type"];
$extension_price1 = $row["price1"];
$extension_price2 = $row["price2"];
$extension_price3 = $row["price3"];
$extension_price4 = $row["price4"];
$extension_price5 = $row["price5"];
$extension_price6 = $row["price6"];
$extension_price7 = $row["price7"];
$extension_price8 = $row["price8"];
$extension_price9 = $row["price9"];
$extension_price10 = $row["price10"];
$extension_yes1 = $row["yes1"];
$extension_yes2 = $row["yes2"];
$extension_yes3 = $row["yes3"];
$extension_yes4 = $row["yes4"];
$extension_yes5 = $row["yes5"];
$extension_yes6 = $row["yes6"];
$extension_yes7 = $row["yes7"];
$extension_yes8 = $row["yes8"];
$extension_yes9 = $row["yes9"];
$extension_yes10 = $row["yes10"];
$extension_compulsory1 = $row["compulsory1"];
$extension_compulsory2 = $row["compulsory2"];
$extension_compulsory3 = $row["compulsory3"];
$extension_compulsory4 = $row["compulsory4"];
$extension_compulsory5 = $row["compulsory5"];
$extension_compulsory6 = $row["compulsory6"];
$extension_compulsory7 = $row["compulsory7"];
$extension_compulsory8 = $row["compulsory8"];
$extension_compulsory9 = $row["compulsory9"];
$extension_compulsory10 = $row["compulsory10"];
$extension_transferprice = $row["transferprice"];
$extension_product_code = $row["product_code"];
$extension_display_price = $row["display_price"];
$extension_transfertext = $row["transfertext"];
}
$extension_price1 = currency_format(".%2f", $extension_price1);
$extension_price2 = currency_format(".%2f", $extension_price2);
$extension_price3 = currency_format(".%2f", $extension_price3);
$extension_price4 = currency_format(".%2f", $extension_price4);
$extension_price5 = currency_format(".%2f", $extension_price5);
$extension_price6 = currency_format(".%2f", $extension_price6);
$extension_price7 = currency_format(".%2f", $extension_price7);
$extension_price8 = currency_format(".%2f", $extension_price8);
$extension_price9 = currency_format(".%2f", $extension_price9);
$extension_price10 = currency_format(".%2f", $extension_price10);
array_push($extension_details, "$extension_server");
array_push($extension_details, "$extension_nomatch");
array_push($extension_details, "$extension_type");
array_push($extension_details, "$extension_price1");
array_push($extension_details, "$extension_price2");
array_push($extension_details, "$extension_price3");
array_push($extension_details, "$extension_price4");
array_push($extension_details, "$extension_price5");
array_push($extension_details, "$extension_price6");
array_push($extension_details, "$extension_price7");
array_push($extension_details, "$extension_price8");
array_push($extension_details, "$extension_price9");
array_push($extension_details, "$extension_price10");
array_push($extension_details, "$extension_transferprice");
array_push($extension_details, "$extension_product_code");
array_push($extension_details, "$extension_display_price");
array_push($extension_details, "$extension_transfertext");
array_push($extension_details, "$extension_yes1");
array_push($extension_details, "$extension_yes2");
array_push($extension_details, "$extension_yes3");
array_push($extension_details, "$extension_yes4");
array_push($extension_details, "$extension_yes5");
array_push($extension_details, "$extension_yes6");
array_push($extension_details, "$extension_yes7");
array_push($extension_details, "$extension_yes8");
array_push($extension_details, "$extension_yes9");
array_push($extension_details, "$extension_yes10");
array_push($extension_details, "$extension_compulsory1");
array_push($extension_details, "$extension_compulsory2");
array_push($extension_details, "$extension_compulsory3");
array_push($extension_details, "$extension_compulsory4");
array_push($extension_details, "$extension_compulsory5");
array_push($extension_details, "$extension_compulsory6");
array_push($extension_details, "$extension_compulsory7");
array_push($extension_details, "$extension_compulsory8");
array_push($extension_details, "$extension_compulsory9");
array_push($extension_details, "$extension_compulsory10");
mysql_close($connection);
return($extension_details);
}
function compulsory_hosting($my_session)
{
require("../config/config.php");
$connection = mysql_connect($host,$usr,$pwd);
$query = mysql_db_query($db, "SELECT product_name FROM table_temp where sid='$my_session' and checkvalue='checked' ", $connection);
check_mysql($query);
while ($row = mysql_fetch_array($query)) {
$product_name = $row["product_name"];
$second = mysql_db_query($db, "SELECT product_name FROM table_temp where sid='$my_session' and extra='$product_name' and product_type='hosting' ", $connection);
if(!mysql_num_rows($second)) { message("$lang_must_select_host[0]","$lang_must_select_host[1]
$product_name"); }
}
}
function cart_contents($my_session)
{
require("../config/config.php");
$connection = mysql_connect($host,$usr,$pwd);
$array = array();
# $query = mysql_db_query($db, "SELECT * FROM table_temp where sid='$my_session', product_type = 'domain' and product_code != 'NO-DOMAIN' ", $connection);
# if(mysql_num_rows($query)) {
$filename = "template_cart_category_row.html";
$handle = fopen ($filename, "r");
$contents = fread ($handle, filesize ($filename));
$contents = str_replace(Xgroup_nameX, $lang_domains, $contents);
$contents = str_replace(XcontentsX, @implode(cart_contents_domains($my_session)), $contents);
array_push($array,$contents);
fclose ($handle);
# }
# $query = mysql_db_query($db, "SELECT * FROM table_temp where sid='$my_session', product_type = 'hosting' ", $connection);
# if(mysql_num_rows($query)) {
$filename = "template_cart_category_row.html";
$handle = fopen ($filename, "r");
$contents = fread ($handle, filesize ($filename));
$contents = str_replace(Xgroup_nameX, $lang_hosting, $contents);
$contents = str_replace(XcontentsX, @implode(cart_contents_hosting($my_session)), $contents);
array_push($array,$contents);
fclose ($handle);
# }
$extras_array = array();
$extras_all = array();
$extras = mysql_db_query($db, "SELECT * FROM table_groups ORDER by importance ASC", $connection);
check_mysql($extras);
while ($row = mysql_fetch_array($extras)) {
$groupname = $row["groupname"];
$inseq = $row["inseq"];
if($inseq) { array_push($extras_array,$groupname); }
array_push($extras_all,$groupname);
}
$final = mysql_db_query($db, "SELECT distinct extra FROM table_temp where sid='$my_session'", $connection);
check_mysql($final);
while ($row = mysql_fetch_array($final)) {
$extra = $row["extra"];
if(in_array($extra,$extras_all)) { array_push($extras_array,$extra); }
}
$extras_array = array_unique($extras_array);
foreach($extras_array as $e) {
$filename = "template_cart_category_row.html";
$handle = fopen ($filename, "r");
$contents = fread ($handle, filesize ($filename));
$contents = str_replace(Xgroup_nameX, "$e", $contents);
$contents = str_replace(XcontentsX, @implode(cart_contents_extras($my_session,$e)), $contents);
array_push($array,$contents);
fclose ($handle);
}
mysql_close($connection);
return($array);
}
function dynamic_prices($my_session)
{
require("../config/config.php");
$array = array();
$total = total_price($my_session,"");
$monthly = total_price($my_session,"M");
$quarterly = total_price($my_session,"Q");
if($total > 0) {
$filename = "template_cart_total_price.html";
$handle = fopen ($filename, "r");
$contents = fread ($handle, filesize ($filename));
$contents = str_replace(XtX, $total, $contents);
$contents = str_replace("Z~", $currency, $contents);
array_push($array,$contents);
fclose ($handle);
}
if($monthly > 0) {
$filename = "template_cart_monthly_price.html";
$handle = fopen ($filename, "r");
$contents = fread ($handle, filesize ($filename));
$contents = str_replace(XmX, $monthly, $contents);
$contents = str_replace("Z~", $currency, $contents);
array_push($array,$contents);
fclose ($handle);
}
if($quarterly > 0) {
$filename = "template_cart_quarterly_price.html";
$handle = fopen ($filename, "r");
$contents = fread ($handle, filesize ($filename));
$contents = str_replace(XqX, $quarterly, $contents);
$contents = str_replace("Z~", $currency, $contents);
array_push($array,$contents);
fclose ($handle);
}
return $array;
}
function final_cart_contents($my_session)
{
require("../config/config.php");
$connection = mysql_connect($host,$usr,$pwd);
$array = array();
# $query = mysql_db_query($db, "SELECT * FROM table_temp where sid='$my_session', product_type = 'domain' and product_code != 'NO-DOMAIN' ", $connection);
# if(mysql_num_rows($query)) {
$filename = "template_cart_category_row.html";
$handle = fopen ($filename, "r");
$contents = fread ($handle, filesize ($filename));
$contents = str_replace(Xgroup_nameX, $lang_domains, $contents);
$contents = str_replace(XcontentsX, @implode(final_contents_domains($my_session)), $contents);
array_push($array,$contents);
fclose ($handle);
# }
# $query = mysql_db_query($db, "SELECT * FROM table_temp where sid='$my_session', product_type = 'hosting' ", $connection);
# if(mysql_num_rows($query)) {
$filename = "template_cart_category_row.html";
$handle = fopen ($filename, "r");
$contents = fread ($handle, filesize ($filename));
$contents = str_replace(Xgroup_nameX, $lang_hosting, $contents);
$contents = str_replace(XcontentsX, @implode(final_contents_hosting($my_session)), $contents);
array_push($array,$contents);
fclose ($handle);
# }
$extras_array = array();
$extras_all = array();
$extras = mysql_db_query($db, "SELECT * FROM table_groups ORDER by importance ASC", $connection);
check_mysql($extras);
while ($row = mysql_fetch_array($extras)) {
$groupname = $row["groupname"];
$inseq = $row["inseq"];
if($inseq) { array_push($extras_array,$groupname); }
array_push($extras_all,$groupname);
}
$final = mysql_db_query($db, "SELECT distinct extra FROM table_temp where sid='$my_session'", $connection);
check_mysql($final);
while ($row = mysql_fetch_array($final)) {
$extra = $row["extra"];
if(in_array($extra,$extras_all)) { array_push($extras_array,$extra); }
}
$extras_array = array_unique($extras_array);
foreach($extras_array as $e) {
$filename = "template_cart_category_row.html";
$handle = fopen ($filename, "r");
$contents = fread ($handle, filesize ($filename));
$contents = str_replace(Xgroup_nameX, "$e", $contents);
$contents = str_replace(XcontentsX, @implode(final_contents_extras($my_session,$e)), $contents);
array_push($array,$contents);
fclose ($handle);
}
mysql_close($connection);
return($array);
}
function cart_contents_domains($my_session)
{
require("../config/config.php");
$connection = mysql_connect($host,$usr,$pwd);
$cart_contents_domains = array();
$domains_query = mysql_db_query($db, "SELECT * FROM table_temp where sid = '$my_session' and product_type LIKE 'domain' and product_name != '$lang_unknown_domain' ", $connection);
check_mysql($domains_query);
while ($row = mysql_fetch_array($domains_query)) {
$product_name = $row["product_name"];
$product_price = $row["price"];
$period_code = $row["period_code"];
$display_period = translate_code($period_code);
$id = $row["id"];
$product_price = currency_format(".%2f", $product_price);
array_push ($cart_contents_domains, " $product_name $display_period
");
$count_product++;
}
if (!$count_product) { array_push ($cart_contents_domains, "$none_yet
"); }
return($cart_contents_domains);
}
function final_contents_domains($my_session)
{
require("../config/config.php");
$connection = mysql_connect($host,$usr,$pwd);
$cart_contents_domains = array();
$domains_query = mysql_db_query($db, "SELECT * FROM table_temp where sid = '$my_session' and product_type LIKE 'domain' and product_name != '$lang_unknown_domain' ", $connection);
check_mysql($domains_query);
while ($row = mysql_fetch_array($domains_query)) {
$product_name = $row["product_name"];
$product_price = $row["price"];
$period_code = $row["period_code"];
$display_period = translate_code($period_code);
$id = $row["id"];
$product_price = currency_format(".%2f", $product_price);
array_push ($cart_contents_domains, "$product_name $display_period
");
$count_product++;
}
if (!$count_product) { array_push ($cart_contents_domains, "$none_selected
"); }
return($cart_contents_domains);
}
function email_domains($my_session)
{
require("../config/config.php");
$connection = mysql_connect($host,$usr,$pwd);
$cart_contents_domains = array();
$domains_query = mysql_db_query($db, "SELECT * FROM table_temp where sid = '$my_session' and product_type LIKE 'domain' and product_name != '$lang_unknown_domain'", $connection);
check_mysql($domains_query);
while ($row = mysql_fetch_array($domains_query)) {
$product_name = $row["product_name"];
$product_price = $row["price"];
$period_code = $row["period_code"];
$product_price = currency_format(".%2f", $product_price);
$display_period = translate_code($period_code);
$id = $row["id"];
array_push ($cart_contents_domains, "$product_name $display_period - $currency $product_price");
$count_product++;
}
if (!$count_product) { array_push ($cart_contents_domains, "$none_selected"); }
return($cart_contents_domains);
}
function cart_contents_hosting($my_session)
{
require("../config/config.php");
$connection = mysql_connect($host,$usr,$pwd);
$cart_contents_hosting = array();
$hosting_query = mysql_db_query($db, "SELECT * FROM table_temp where sid = '$my_session' and product_type LIKE 'hosting'", $connection);
check_mysql($hosting_query);
while ($row = mysql_fetch_array($hosting_query)) {
$product_name = $row["product_name"];
$product_price = $row["price"];
$period_code = $row["period_code"];
if($price > 0) {
$display_period = translate_code($period_code);
}
$id = $row["id"];
$product_price = currency_format(".%2f", $product_price);
array_push ($cart_contents_hosting, " $product_name $display_period
");
$count_product++;
}
if (!$count_product) { array_push ($cart_contents_hosting, "$none_yet
"); }
return($cart_contents_hosting);
}
function final_contents_hosting($my_session)
{
require("../config/config.php");
$connection = mysql_connect($host,$usr,$pwd);
$cart_contents_hosting = array();
$hosting_query = mysql_db_query($db, "SELECT * FROM table_temp where sid = '$my_session' and product_type LIKE 'hosting'", $connection);
check_mysql($hosting_query);
while ($row = mysql_fetch_array($hosting_query)) {
$product_name = $row["product_name"];
$product_price = $row["price"];
$period_code = $row["period_code"];
$display_period = translate_code($period_code);
$id = $row["id"];
$product_price = currency_format(".%2f", $product_price);
array_push ($cart_contents_hosting, "$product_name $display_period
");
$count_product++;
}
if (!$count_product) { array_push ($cart_contents_hosting, "$none_selected
"); }
return($cart_contents_hosting);
}
function email_hosting($my_session)
{
require("../config/config.php");
$connection = mysql_connect($host,$usr,$pwd);
$cart_contents_hosting = array();
$hosting_query = mysql_db_query($db, "SELECT * FROM table_temp where sid = '$my_session' and product_type LIKE 'hosting'", $connection);
check_mysql($hosting_query);
while ($row = mysql_fetch_array($hosting_query)) {
$product_name = $row["product_name"];
$product_price = $row["price"];
$period_code = $row["period_code"];
$display_period = translate_code($period_code);
$id = $row["id"];
$product_price = currency_format(".%2f", $product_price);
array_push ($cart_contents_hosting, "$product_name $display_period - $currency $product_price");
$count_product++;
}
if (!$count_product) { array_push ($cart_contents_hosting, "$none_selected"); }
return($cart_contents_hosting);
}
function cart_contents_extras($my_session,$e)
{
require("../config/config.php");
$connection = mysql_connect($host,$usr,$pwd);
$cart_contents_extras = array();
$extras_query = mysql_db_query($db, "SELECT * FROM table_temp where sid = '$my_session' and extra='$e' and product_type != 'domain' and product_type != 'hosting'", $connection);
check_mysql($extras_query);
while ($row = mysql_fetch_array($extras_query)) {
$product_name = $row["product_name"];
$product_price = $row["price"];
$period_code = $row["period_code"];
$display_period = translate_code($period_code);
$id = $row["id"];
$product_price = currency_format(".%2f", $product_price);
array_push ($cart_contents_extras, " $product_name $display_period
");
$count_product++;
}
if (!$count_product) { array_push ($cart_contents_extras, "$none_yet
"); }
return($cart_contents_extras);
}
function final_contents_extras($my_session,$e)
{
require("../config/config.php");
$connection = mysql_connect($host,$usr,$pwd);
$cart_contents_extras = array();
$extras_query = mysql_db_query($db, "SELECT * FROM table_temp where sid = '$my_session' and extra='$e' and product_type != 'domain' and product_type != 'hosting'", $connection);
check_mysql($extras_query);
while ($row = mysql_fetch_array($extras_query)) {
$product_name = $row["product_name"];
$product_price = $row["price"];
$period_code = $row["period_code"];
$display_period = translate_code($period_code);
$id = $row["id"];
$product_price = currency_format(".%2f", $product_price);
array_push ($cart_contents_extras, "$product_name $display_period
");
$count_product++;
}
if (!$count_product) { array_push ($cart_contents_extras, "$none_selected
"); }
return($cart_contents_extras);
}
function email_extras($my_session)
{
$cart_contents_extras = array();
require("../config/config.php");
$connection = mysql_connect($host,$usr,$pwd);
$extras_array = array();
$extras = mysql_db_query($db, "SELECT * FROM table_groups ORDER by importance ASC", $connection);
check_mysql($extras);
while ($row = mysql_fetch_array($extras)) {
$groupname = $row["groupname"];
array_push($extras_array,$groupname);
}
foreach($extras_array as $e)
{
unset($count_product);
array_push($cart_contents_extras,"$e");
$extras_query = mysql_db_query($db, "SELECT * FROM table_temp where sid = '$my_session' and extra='$e' and product_type != 'domain' and product_type != 'hosting'", $connection);
check_mysql($extras_query);
while ($row = mysql_fetch_array($extras_query)) {
$product_name = $row["product_name"];
$product_price = $row["price"];
$period_code = $row["period_code"];
$display_period = translate_code($period_code);
$id = $row["id"];
$product_price = currency_format(".%2f", $product_price);
array_push ($cart_contents_extras, "$product_name $display_period - $currency $product_price");
$count_product++;
}
if (!$count_product) { array_push ($cart_contents_extras, "$none_selected"); }
array_push($cart_contents_extras," ");
}
# ALL UNDEFINED PRODUCTS
$extras_query = mysql_db_query($db, "SELECT * FROM table_temp where sid = '$my_session' and extra > '0' and extra < '99999999' and product_type != 'domain' and product_type != 'hosting'", $connection);
check_mysql($extras_query);
if(mysql_num_rows($extras_query)) {
array_push($cart_contents_extras,"$lang_remaining");
}
while ($row = mysql_fetch_array($extras_query)) {
$product_name = $row["product_name"];
$product_price = $row["price"];
$period_code = $row["period_code"];
$display_period = translate_code($period_code);
$id = $row["id"];
$extra = $row["extra"];
$product_price = currency_format(".%2f", $product_price);
array_push ($cart_contents_extras, "$product_name $display_period - $currency $product_price");
$count_product++;
if (!$count_product) { array_push ($cart_contents_extras, "$none_selected"); }
array_push($cart_contents_extras," ");
}
return($cart_contents_extras);
}
function get_hosting($my_session)
{
require("../config/config.php");
$connection = mysql_connect($host,$usr,$pwd);
$get_hosting = array();
$domains_query = mysql_db_query($db, "SELECT * FROM table_temp where sid = '$my_session' and product_type LIKE 'domain'", $connection);
check_mysql($domains_query);
while ($row = mysql_fetch_array($domains_query)) {
$product_name = $row["product_name"];
$package_selected = mysql_db_query($db, "SELECT * from table_temp where sid = '$my_session' and product_type LIKE 'hosting' and extra = '$product_name'", $connection);
while ($row = mysql_fetch_array($package_selected)) {
$package_name = $row["product_name"];
}
if (mysql_num_rows($package_selected)) {
$filename = "template_hosting_package_selected_header.html";
} else {
$filename = "template_hosting_package_header.html";
}
$handle = fopen ($filename, "r");
$contents = fread ($handle, filesize ($filename));
$contents = str_replace(Xdomain_nameX, $product_name, $contents);
$contents = str_replace(Xpackage_nameX, $package_name, $contents);
fclose ($handle);
array_push($get_hosting, "$contents");
if (!mysql_num_rows($package_selected)) { $hosting_query = mysql_db_query($db, "SELECT * FROM table_hosting ORDER by package_importance ASC", $connection);
while ($row = mysql_fetch_array($hosting_query)) {
$package_name = $row["package_name"];
$package_price = $row["package_price"];
$package_setup = $row["package_setup"];
$package_price = $row["package_price"];
$package_id = $row["package_id"];
$package_frequency = $row["package_frequency"];
$package_description = $row["package_description"];
if ($package_frequency == "M") { $package_frequency_text = $M_text; }
elseif ($package_frequency == "Q") { $package_frequency_text = $Q_text; }
elseif ($package_frequency == "Y") { $package_frequency_text = $Y_text; }
else { $package_frequency_text = ""; }
$random = rand(0, 32768);
$package_price = currency_format(".%2f", $package_price);
$package_setup = currency_format(".%2f", $package_setup);
if ($package_setup > 0) { $setup_text = "($currency$package_setup $S_text)"; } else { $setup_text = ""; }
$filename = "template_hosting_package.html";
$handle = fopen ($filename, "r");
$contents = fread ($handle, filesize ($filename));
$contents = str_replace(XrandomX, $random, $contents);
$contents = str_replace(Xpackage_nameX, $package_name, $contents);
$contents = str_replace(Xpackage_priceX, $package_price, $contents);
$contents = str_replace(Xpackage_frequency_textX, $package_frequency_text, $contents);
$contents = str_replace(Xpackage_setupX, $package_setup, $contents);
$contents = str_replace(Xpackage_idX, $package_id, $contents);
$contents = str_replace(Xpackage_frequencyX, $package_frequency, $contents);
$contents = str_replace(Xpackage_descriptionX, $package_description, $contents);
$contents = str_replace(Xdomain_nameX, $product_name, $contents);
$contents = str_replace(Xsetup_textX, $setup_text, $contents);
fclose ($handle);
array_push($get_hosting, "$contents");
}
}
}
mysql_close($connection);
return($get_hosting);
}
function get_hosting_offers($my_session)
{
require("../config/config.php");
$connection = mysql_connect($host,$usr,$pwd);
$get_hosting = array();
$query = mysql_db_query($db, "SELECT distinct package_id FROM table_offers ORDER by package_id ASC", $connection);
while ($row = mysql_fetch_array($query)) {
$found_package_id = $row["package_id"];
$hosting_query = mysql_db_query($db, "SELECT * FROM table_hosting where id='$found_package_id' ORDER by package_importance ASC", $connection);
while ($row = mysql_fetch_array($hosting_query)) {
$package_name = $row["package_name"];
$package_price = $row["package_price"];
$package_setup = $row["package_setup"];
$package_price = $row["package_price"];
$package_id = $row["package_id"];
$package_frequency = $row["package_frequency"];
$package_description = $row["package_description"];
$offers = array();
$full = mysql_db_query($db, "SELECT * FROM table_offers where package_id='$found_package_id'", $connection);
while ($row = mysql_fetch_array($full)) {
$extension = $row["extension"];
$period = $row["period"];
$showtext = $row["showtext"];
array_push($offers,$showtext);
}
$offers = @implode("
", $offers);
if ($package_frequency == "M") { $package_frequency_text = $M_text; }
elseif ($package_frequency == "Q") { $package_frequency_text = $Q_text; }
elseif ($package_frequency == "Y") { $package_frequency_text = $Y_text; }
else { $package_frequency_text = ""; }
$package_price = currency_format(".%2f", $package_price);
$package_setup = currency_format(".%2f", $package_setup);
if ($package_setup > 0) { $setup_text = "($currency$package_setup $S_text)"; } else { $setup_text = ""; }
$filename = "template_offer_hosting_package.html";
$handle = fopen ($filename, "r");
$contents = fread ($handle, filesize ($filename));
$contents = str_replace(XrandomX, $random, $contents);
$contents = str_replace(Xpackage_nameX, $package_name, $contents);
$contents = str_replace(Xpackage_priceX, $package_price, $contents);
$contents = str_replace(Xpackage_frequency_textX, $package_frequency_text, $contents);
$contents = str_replace(Xpackage_setupX, $package_setup, $contents);
$contents = str_replace(Xpackage_idX, $package_id, $contents);
$contents = str_replace(Xfound_package_idX, $found_package_id, $contents);
$contents = str_replace(Xpackage_frequencyX, $package_frequency, $contents);
$contents = str_replace(Xpackage_descriptionX, $package_description, $contents);
$contents = str_replace(Xdomain_nameX, $product_name, $contents);
$contents = str_replace(Xsetup_textX, $setup_text, $contents);
$contents = str_replace(XoffersX, $offers, $contents);
fclose ($handle);
array_push($get_hosting, "$contents");
}
}
mysql_close($connection);
return($get_hosting);
}
function get_extras($my_session,$egroup)
{
require("../config/config.php");
$connection = mysql_connect($host,$usr,$pwd);
$get_extras = array();
$extras_query = mysql_db_query($db, "SELECT * FROM table_extras where egroup='$egroup' ORDER by extra_importance ASC", $connection);
check_mysql($extras_query);
while ($row = mysql_fetch_array($extras_query)) {
$extra_name = $row["extra_name"];
$extra_price = $row["extra_price"];
$extra_setup = $row["extra_setup"];
$extra_id = $row["extra_id"];
$extra_frequency = $row["extra_frequency"];
$extra_description = $row["extra_description"];
if ($extra_frequency == "M") { $package_frequency_text = $M_text; }
elseif ($extra_frequency == "Q") { $package_frequency_text = $Q_text; }
elseif ($extra_frequency == "Y") { $package_frequency_text = $Y_text; }
else { $extra_frequency_text = ""; }
$extra_price = currency_format(".%2f", $extra_price);
$extra_setup = currency_format(".%2f", $extra_setup);
if ($extra_setup > 0) { $setup_text = "($currency$extra_setup $S_text)"; } else { $setup_text = ""; }
$random = rand(0, 32768);
$filename = "template_extras_packages.html";
$handle = fopen ($filename, "r");
$contents = fread ($handle, filesize ($filename));
$contents = str_replace(XrandomX, $random, $contents);
$contents = str_replace(Xextra_nameX, $extra_name, $contents);
$contents = str_replace(Xextra_priceX, $extra_price, $contents);
$contents = str_replace(Xextra_frequency_textX, $package_frequency_text, $contents);
$contents = str_replace(Xextra_setupX, $extra_setup, $contents);
$contents = str_replace(Xextra_idX, $extra_id, $contents);
$contents = str_replace(Xextra_frequencyX, $extra_frequency, $contents);
$contents = str_replace(Xextra_descriptionX, $extra_description, $contents);
$contents = str_replace(Xsetup_textX, $setup_text, $contents);
$contents = str_replace(XegroupX, $egroup, $contents);
fclose ($handle);
array_push($get_extras, "$contents");
unset($package_frequency_text);
}
mysql_close($connection);
return($get_extras);
}
function get_extras_with_domains($my_session,$egroup)
{
require("../config/config.php");
$connection = mysql_connect($host,$usr,$pwd);
$get_extras = array();
$domains_query = mysql_db_query($db, "SELECT * FROM table_temp where sid = '$my_session' and product_type LIKE 'domain'", $connection);
check_mysql($domains_query);
while ($row = mysql_fetch_array($domains_query)) {
$product_name = $row["product_name"];
$filename = "template_extra_package_header.html";
$handle = fopen ($filename, "r");
$contents = fread ($handle, filesize ($filename));
$contents = str_replace(Xdomain_nameX, $product_name, $contents);
$contents = str_replace(Xgroup_nameX, $egroup, $contents);
fclose ($handle);
array_push($get_extras, "$contents");
$extras_query = mysql_db_query($db, "SELECT * FROM table_extras where egroup='$egroup' ORDER by extra_importance ASC", $connection);
check_mysql($extras_query);
while ($row = mysql_fetch_array($extras_query)) {
$extra_name = $row["extra_name"];
$extra_price = $row["extra_price"];
$extra_setup = $row["extra_setup"];
$extra_id = $row["extra_id"];
$extra_frequency = $row["extra_frequency"];
$extra_description = $row["extra_description"];
if ($extra_frequency == "M") { $package_frequency_text = $M_text; }
elseif ($extra_frequency == "Q") { $package_frequency_text = $Q_text; }
elseif ($extra_frequency == "Y") { $package_frequency_text = $Y_text; }
else { $extra_frequency_text = ""; }
$extra_price = currency_format(".%2f", $extra_price);
$extra_setup = currency_format(".%2f", $extra_setup);
if ($extra_setup > 0) { $setup_text = "($currency$extra_setup $S_text)"; } else { $setup_text = ""; }
$random = rand(0, 32768);
$filename = "template_extras_packages.html";
$handle = fopen ($filename, "r");
$contents = fread ($handle, filesize ($filename));
$contents = str_replace(XrandomX, $random, $contents);
$contents = str_replace(Xextra_nameX, "$extra_name $lang_for $product_name", $contents);
$contents = str_replace(Xextra_priceX, $extra_price, $contents);
$contents = str_replace(Xextra_frequency_textX, $package_frequency_text, $contents);
$contents = str_replace(Xextra_setupX, $extra_setup, $contents);
$contents = str_replace(Xextra_idX, $extra_id, $contents);
$contents = str_replace(Xextra_frequencyX, $extra_frequency, $contents);
$contents = str_replace(Xextra_descriptionX, $extra_description, $contents);
$contents = str_replace(Xsetup_textX, $setup_text, $contents);
$contents = str_replace(XegroupX, $egroup, $contents);
fclose ($handle);
array_push($get_extras, "$contents");
unset($package_frequency_text);
}
}
mysql_close($connection);
return($get_extras);
}
function client_extras($my_session)
{
$user_details = check_client($my_session);
require("../config/config.php");
$connection = mysql_connect($host,$usr,$pwd);
$get_extras = array();
$extras_array = array();
$extras = mysql_db_query($db, "SELECT * FROM table_groups ORDER by importance ASC", $connection);
check_mysql($extras);
while ($row = mysql_fetch_array($extras)) {
$groupname = $row["groupname"];
array_push($extras_array,$groupname);
}
foreach($extras_array as $e) {
$filename = "client_extra_header.html";
$handle = fopen ($filename, "r");
$contents = fread ($handle, filesize ($filename));
$contents = str_replace(XegroupX, $e, $contents);
fclose ($handle);
array_push($get_extras, "$contents");
$query = mysql_db_query($db, "SELECT * FROM table_groups where groupname='$e'", $connection);
while ($row = mysql_fetch_array($query)) {
$fordomains = $row["fordomains"];
$extras_query = mysql_db_query($db, "SELECT * FROM table_extras where egroup='$e' ORDER by extra_importance ASC", $connection);
check_mysql($extras_query);
while ($row = mysql_fetch_array($extras_query)) {
$extra_name = $row["extra_name"];
$extra_price = $row["extra_price"];
$extra_setup = $row["extra_setup"];
$extra_id = $row["extra_id"];
$extra_frequency = $row["extra_frequency"];
$extra_description = $row["extra_description"];
$id = $row["id"];
if ($extra_frequency == "M") { $package_frequency_text = $M_text; }
elseif ($extra_frequency == "Q") { $package_frequency_text = $Q_text; }
elseif ($extra_frequency == "Y") { $package_frequency_text = $Y_text; }
else { $extra_frequency_text = ""; }
$extra_price = currency_format(".%2f", $extra_price);
$extra_setup = currency_format(".%2f", $extra_setup);
if ($extra_setup > 0) { $setup_text = "($currency$extra_setup $S_text)"; } else { $setup_text = ""; }
$random = rand(0, 32768);
if($fordomains) { $domains = mysql_db_query($db, "SELECT product_name FROM table_products where product_type='domain' and username='$user_details' order by product_name ASC", $connection);
if(mysql_num_rows($domains)) {
while ($row = mysql_fetch_array($domains)) {
$product_name = $row["product_name"];
$id = $id . "&for=$product_name";
$filename = "client_extra_packages.html";
$handle = fopen ($filename, "r");
$contents = fread ($handle, filesize ($filename));
$contents = str_replace(XrandomX, $random, $contents);
$contents = str_replace(Xextra_nameX, "$extra_name $lang_for $product_name", $contents);
$contents = str_replace(Xextra_priceX, $extra_price, $contents);
$contents = str_replace(Xextra_frequency_textX, $package_frequency_text, $contents);
$contents = str_replace(Xextra_setupX, $extra_setup, $contents);
$contents = str_replace(Xextra_idX, $extra_id, $contents);
$contents = str_replace(Xextra_frequencyX, $extra_frequency, $contents);
$contents = str_replace(Xextra_descriptionX, $extra_description, $contents);
$contents = str_replace(Xsetup_textX, $setup_text, $contents);
$contents = str_replace(XidX, $id, $contents);
$contents = str_replace("Z~", $currency, $contents);
fclose ($handle);
array_push($get_extras, "$contents");
unset($package_frequency_text);
}
}
} else {
$filename = "client_extra_packages.html";
$handle = fopen ($filename, "r");
$contents = fread ($handle, filesize ($filename));
$contents = str_replace(XrandomX, $random, $contents);
$contents = str_replace(Xextra_nameX, $extra_name, $contents);
$contents = str_replace(Xextra_priceX, $extra_price, $contents);
$contents = str_replace(Xextra_frequency_textX, $package_frequency_text, $contents);
$contents = str_replace(Xextra_setupX, $extra_setup, $contents);
$contents = str_replace(Xextra_idX, $extra_id, $contents);
$contents = str_replace(Xextra_frequencyX, $extra_frequency, $contents);
$contents = str_replace(Xextra_descriptionX, $extra_description, $contents);
$contents = str_replace(Xsetup_textX, $setup_text, $contents);
$contents = str_replace(XidX, $id, $contents);
$contents = str_replace("Z~", $currency, $contents);
fclose ($handle);
array_push($get_extras, "$contents");
unset($package_frequency_text);
}
}
}
}
mysql_close($connection);
return($get_extras);
}
function products_to_database($my_session,$username,$status_set)
{
require("../config/config.php");
$connection = mysql_connect($host,$usr,$pwd);
$now = time();
$get_on = mysql_db_query($db, "SELECT * from table_orderno where id='1'", $connection);
while ($row = mysql_fetch_array($get_on)) {
$orderno = $row["orderno"];
}
$this_orderno = $order_no_prefix . $orderno;
$update_orderno = $orderno + 1;
$update = mysql_db_query($db, "update table_orderno set orderno='$update_orderno' where id='1'", $connection);
check_mysql($update);
$get_temps = mysql_db_query($db, "SELECT * from table_temp where sid='$my_session'", $connection);
check_mysql($get_temps);
while ($row = mysql_fetch_array($get_temps)) {
$product_name = $row["product_name"];
$product_code = $row["product_code"];
$product_type = $row["product_type"];
$period_code = $row["period_code"];
$period = $row["period"];
$price = $row["price"];
$setup = $row["setup"];
$extra = $row["extra"];
$client_order = $row["client_order"];
if ($period < 1) { $expires = "-1"; } else { $expires = time() + $period; }
if ($period_code == "M") { $notify60 = "X"; $notify30 = "X"; }
if (!$status_set) { $status_insert = $pending_product; } else { $status_insert = $status_set; }
if($client_order == "payonline") {
$get = mysql_db_query($db, "SELECT * from table_products where id='$extra'", $connection);
while ($row = mysql_fetch_array($get)) {
$this_orderno = $row["orderno"];
}
$update = mysql_db_query($db, "update table_products set status='$status_set' where id='$extra'", $connection);
check_mysql($update);
} else {
$insert = mysql_db_query($db, "INSERT into table_products (username, product_name, product_code, product_type, period, period_code, price, extra, status, expires, notify60, notify30, session, orderno, ordered) VALUES ('$username', '$product_name', '$product_code', '$product_type', '$period', '$period_code', '$price', '$extra', '$status_insert', '$expires', '$notify60', '$notify30', '$my_session', '$this_orderno', '$now')", $connection);
check_mysql($insert);
}
$delete = mysql_db_query($db, "delete from table_temp where sid='$my_session'", $connection);
}
if(mysql_num_rows($get_temps))
{
return $this_orderno;
}
}
function renew_to_database($my_session,$username,$status_set)
{
require("../config/config.php");
$connection = mysql_connect($host,$usr,$pwd);
$get_on = mysql_db_query($db, "SELECT * from table_orderno where id='1'", $connection);
while ($row = mysql_fetch_array($get_on)) {
$orderno = $row["orderno"];
}
$this_orderno = $order_no_prefix . $orderno;
$update_orderno = $orderno + 1;
$get_renews = mysql_db_query($db, "SELECT * from table_temp where sid='$my_session' and client_order='renew' ", $connection);
check_mysql($get_renews);
while ($row = mysql_fetch_array($get_renews)) {
$period = $row["period"];
$extra = $row["extra"];
$current_product = mysql_db_query($db, "SELECT * from table_products where id='$extra'", $connection);
check_mysql($current_product);
while ($row = mysql_fetch_array($current_product)) {
$expires = $row["expires"];
$orderno = $row["orderno"];
$new_expiry = $expires + $period;
$insert = mysql_db_query($db, "INSERT into table_renewdetails (product_id, datefrom, dateto, orderno) VALUES ('$extra','$expires','$new_expiry','$this_orderno')", $connection);
$update = mysql_db_query($db, "update table_products set expires='$new_expiry', orderno='$orderno~!~$this_orderno', status='$status_set' where id='$extra'", $connection);
check_mysql($update);
}
}
$delete = mysql_db_query($db, "delete from table_temp where sid='$my_session' and client_order='renew'", $connection);
if(mysql_num_rows($get_renews))
{
return $this_orderno;
}
}
function total_price($my_session,$period)
{
require("../config/config.php");
$connection = mysql_connect($host,$usr,$pwd);
if ($period) { $period = "and period_code='$period'"; }
$total_price = mysql_result(mysql_db_query($db, "SELECT SUM(price) FROM table_temp where sid = '$my_session' $period", $connection),0);
$total_setup = mysql_result(mysql_db_query($db, "SELECT SUM(setup) FROM table_temp where sid = '$my_session'", $connection),0);
if (!$period) { $total = $total_price + $total_setup; } else { $total = $total_price; }
return currency_format("%.2f",$total);
}
function client_price($my_session,$period)
{
require("../config/config.php");
$connection = mysql_connect($host,$usr,$pwd);
if ($period) { $period_code = "and period_code='$period'"; }
$total_price = mysql_result(mysql_db_query($db, "SELECT SUM(price) FROM table_temp where sid = '$my_session' $period_code", $connection),0);
return currency_format("%.2f",$total_price);
}
function convert_to_seconds($period)
{
if ($period == "Y") { return 31557600; }
elseif ($period == "1Y") { return 31557600; }
elseif ($period == "2Y") { return 63115200; }
elseif ($period == "3Y") { return 94672800; }
elseif ($period == "4Y") { return 126230400; }
elseif ($period == "5Y") { return 157788000; }
elseif ($period == "6Y") { return 189345600; }
elseif ($period == "7Y") { return 220903200; }
elseif ($period == "8Y") { return 252460800; }
elseif ($period == "9Y") { return 284018400; }
elseif ($period == "10Y") { return 315576000; }
elseif ($period == "M") { return 2629800; }
elseif ($period == "Q") { return 7889400; }
else { return 0; }
}
function database_error($message)
{
$init = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.";
$tran = "ZYXWVUTSRQPONMLKJIHGFEDCBAzyxwvutsrqponmlkjihgfedcba";
$string = strtr($message, $init, $tran);
echo("
INSTALLATION ERROR
|
If you require help installing please contact support@polyspaston.com
"); echo(""); exit(); } function database_connect($shost,$susr,$spwd) { require("config.php"); list($q1,$q2)= split ("~", $aeneas, 2); if(md5(getenv("SERVER_NAME")) != $q1) { database_error("rMEZORW oRXVMHV pVB ."); exit(); } $qfrom = '0123456789'; $qto = 'bYL+QaeVxC'; $strc = strtr($q2, $qto, $qfrom); $now = time(); if($strc < $now) { database_error("rMEZORW oRXVMHV pVB .."); exit(); } return mysql_connect($shost,$susr,$spwd); } function check_cart_accept_nodomain($my_session) { require("../config/config.php"); $connection = mysql_connect($host,$usr,$pwd); $query = mysql_db_query($db, "SELECT * FROM table_temp where sid='$my_session' ", $connection); check_mysql($query); if (!mysql_num_rows($query)) { message($lang_cart_empty[0],$lang_cart_empty[1]); exit(); } return; } function check_cart($my_session) { require("../config/config.php"); $connection = mysql_connect($host,$usr,$pwd); $query = mysql_db_query($db, "SELECT * FROM table_temp where sid='$my_session' and product_name != '$lang_unknown_domain' ", $connection); check_mysql($query); if (!mysql_num_rows($query)) { message($lang_cart_empty[0],$lang_cart_empty[1]); exit(); } return; } function translate_code($period_code) { require("../config/config.php"); if ($period_code == "M") { return $lang_period_monthly; } elseif ($period_code == "Q") { return $lang_period_quarterly; } elseif ($period_code == "TY") { return $lang_period_transfer; } elseif ($period_code == "Y") { return $lang_period_annually; } elseif ($period_code == "1Y") { return $lang_period_annually; } elseif ($period_code == "2Y") { return $lang_period_2_years; } elseif ($period_code == "3Y") { return $lang_period_3_years; } elseif ($period_code == "4Y") { return $lang_period_4_years; } elseif ($period_code == "5Y") { return $lang_period_5_years; } elseif ($period_code == "6Y") { return $lang_period_6_years; } elseif ($period_code == "7Y") { return $lang_period_7_years; } elseif ($period_code == "8Y") { return $lang_period_8_years; } elseif ($period_code == "9Y") { return $lang_period_9_years; } elseif ($period_code == "10Y") { return $lang_period_10_years; } else { return $lang_period_one_off; } } function worldpay($my_session) { $format = check_format($my_session); if ($format == "M") { $filename = "../credit_cards/worldpay-M.txt"; } elseif ($format == "Q") { $filename = "../credit_cards/worldpay-Q.txt"; } else { $filename = "../credit_cards/worldpay.txt"; } $handle = fopen ($filename, "r"); $contents = fread ($handle, filesize ($filename)); fclose ($handle); return $contents; } function paypal($my_session) { $format = check_format($my_session); if ($format == "M") { $filename = "../credit_cards/paypal-M.txt"; } elseif ($format == "Q") { $filename = "../credit_cards/paypal-Q.txt"; } else { $filename = "../credit_cards/paypal.txt"; } $handle = fopen ($filename, "r"); $contents = fread ($handle, filesize ($filename)); fclose ($handle); return $contents; } function invoice($my_session) { $filename = "../credit_cards/invoice.txt"; $handle = fopen ($filename, "r"); $contents = fread ($handle, filesize ($filename)); fclose ($handle); return $contents; } function secure($my_session) { $filename = "../credit_cards/ssl.txt"; $handle = fopen ($filename, "r"); $contents = fread ($handle, filesize ($filename)); fclose ($handle); return $contents; } function nochex($my_session) { $filename = "../credit_cards/nochex.txt"; $handle = fopen ($filename, "r"); $contents = fread ($handle, filesize ($filename)); fclose ($handle); return $contents; } function protx($my_session) { $filename = "../credit_cards/protx.txt"; $handle = fopen ($filename, "r"); $contents = fread ($handle, filesize ($filename)); fclose ($handle); return $contents; } function bankpass($my_session) { $filename = "../credit_cards/bankpass.txt"; $handle = fopen ($filename, "r"); $contents = fread ($handle, filesize ($filename)); fclose ($handle); return $contents; } function currency_format($decimal_option,$input_value) { require("../config/config.php"); $input_value = number_format($input_value, $currency_places, $currency_decimals, $currency_thousands); return $input_value; } function backup_table ($table) { require("../config/config.php"); $connection = mysql_connect($host,$usr,$pwd); $query = mysql_db_query($db, "select * from $table", $connection); $num_fields = @mysql_num_fields($query); while ($row = mysql_fetch_row($query)) { $result .= "INSERT INTO ".$table." VALUES("; for($j=0; $j<$num_fields; $j++) { # $row[$j] = addslashes($row[$j]); $row[$j] = str_replace("'", "", $row[$j]); $row[$j] = ereg_replace("\n","\\n",$row[$j]); if (isset($row[$j])) $result .= "\"$row[$j]\"" ; else $result .= "\"\""; if ($j<($num_fields-1)) $result .= ","; } $result .= ");\n"; } return $result . "\n\n\n"; } function this_date($format,$date) { require("../config/config.php"); $use = $date + $time_offset; $month = date("n", $use) - 1; $use_month = $lang_months[$month]; $time = date("g:i", $use); $day = date("j", $use); $year = date("Y", $use); if($format == "long") { $return = "$time $day $use_month $year"; } elseif($format == "short") { $return = "$day $use_month $year"; } return $return; } function heart_internet($my_session) { require("../config/config.php"); $connection = mysql_connect($host,$usr,$pwd); $email = @mysql_result(mysql_db_query($db, "SELECT email from table_customers where session='$my_session'", $connection),0); $query = mysql_db_query($db, "SELECT * from table_temp where sid='$my_session' and product_type='hosting' ", $connection); check_mysql($query); while ($row = mysql_fetch_array($query)) { $product_name = $row["product_name"]; $product_code = $row["product_code"]; $client_order = $row["client_order"]; $extra = $row["extra"]; if(!$client_order) { $workString = "authcode=$heart_auth_code;email=$email;M_domain=$extra;M_typeid=$product_code;status=Y"; $url = "http://customer.heartinternet.co.uk/addpack.cgi"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "$url"); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $workString); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $res = curl_exec($ch); $res = strip_tags($res); if(curl_error($ch)) { $error = curl_error($ch); mail("$host_email","Heart Internet Set-Up Error","There has been a problem with creating the hosting package for $extra using HostDirector\n\n$error","From: $host_email"); } else { mail($host_email,"Heart Internet Set-Up Receipt","HostDirector has created an account on your Heart Internet Reseller Control Centre\n\nPackage: $product_code\nDomain: $extra\n\nSetup details have been sent to $email\n\n$create\n\n$retval","From: $host_email"); } curl_close($ch); } } } function heart_domains($my_session) { require("../config/config.php"); $connection = mysql_connect($host,$usr,$pwd); $get = mysql_db_query($db, "SELECT * from table_customers where session='$my_session'", $connection); check_mysql($get); while ($row = mysql_fetch_array($get)) { $company = $row["company"]; $firstname = $row["firstname"]; $surname = $row["surname"]; $address1 = $row["address1"]; $address2 = $row["address2"]; $town = $row["town"]; $county = $row["county"]; $country = $row["country"]; $postcode = $row["postcode"]; $telephone = $row["telephone"]; $email = $row["email"]; } $telephone = str_replace("-", "", $telephone); $postcode = strtoupper($postcode); if(stristr($country,"United Kingdom")) { $country = 'GB'; } elseif(stristr($country,"Great Britain")) { $country = 'GB'; } elseif(stristr($country,"England")) { $country = 'GB'; } elseif(stristr($country,"UK")) { $country = 'GB'; } $query = mysql_db_query($db, "SELECT * from table_temp where sid='$my_session' and product_type='domain' and period_code != 'T'", $connection); check_mysql($query); while ($row = mysql_fetch_array($query)) { $product_name = $row["product_name"]; $product_code = $row["product_code"]; $period_code = $row["period_code"]; $client_order = $row["client_order"]; $extra = $row["extra"]; if(!is_numeric($product_name) and !$client_order) { $period_code = str_replace('Y', '', $period_code); if($company) { $type = 'organization'; $registrant = $company; } else { $type = 'individual'; $registrant = "$firstname $surname"; } $template = "customer:$heart_domains_email password:$heart_domains_password domain:$product_name domainyears:$period_code registrant:$registrant registrant-type:$type address:$address1 address2:$address2 city:$town county:$county postcode:$postcode country:$country telephone:$telephone email:$email"; mail($heart_domains_send_to,"Domain Request",$template,"From: $heart_domains_email"); mail($heart_domains_email,"Domain Request","The following was sent to Heart Internet by HostDirector. Please wait a minute or two for confirmation ..\n\n $template","From: $heart_domains_email"); unset($template); } } } function protx_crypt($total,$name,$email,$address1,$address2,$town,$county,$postcode) { require("../config/config.php"); $ThisVendorTxCode = rand(100000,999999); $stuff = "VendorTxCode=" . $ThisVendorTxCode . "&"; $stuff .= "Amount=" . $total . "&"; $stuff .= "Currency=" . $currency_code . "&"; $stuff .= "Description=" . $protx_desc . "&"; $stuff .= "SuccessURL=" . $protx_callback . "&"; $stuff .= "FailureURL=" . $protx_callback . "&"; $stuff .= "CustomerName=" . $name . "&"; $stuff .= "CustomerEmail=" . $email . "&"; $stuff .= "BillingAddress=" . "$address1\x0D\x0A$address2\x0D\x0A$town\x0D\x0A$county" . "&"; $stuff .= "BillingPostCode=" . $postcode; $crypt = base64Encode(SimpleXor($stuff,$encryption_password)); return $crypt; } function base64Encode($plain) { // Initialise output variable $output = ""; // Do encoding $output = base64_encode($plain); // Return the result return $output; } // ** Base 64 decoding function ** // PHP does it natively but just for consistency and ease of maintenance, let's declare our own function function base64Decode($scrambled) { // Initialise output variable $output = ""; // Do encoding $output = base64_decode($scrambled); // Return the result return $output; } /* The SimpleXor encryption algorithm ** ** NOTE: This is a placeholder really. Future releases of VSP Form will use AES or TwoFish. Proper encryption ** ** This simple function and the Base64 will deter script kiddies and prevent the "View Source" type tampering ** ** It won't stop a half decent hacker though, but the most they could do is change the amount field to something ** ** else, so provided the vendor checks the reports and compares amounts, there is no harm done. It's still ** ** more secure than the other PSPs who don't both encrypting their forms at all */ function simpleXor($InString, $Key) { // Initialise key array $KeyList = array(); // Initialise out variable $output = ""; // Convert $Key into array of ASCII values for($i = 0; $i < strlen($Key); $i++){ $KeyList[$i] = ord(substr($Key, $i, 1)); } // Step through string a character at a time for($i = 0; $i < strlen($InString); $i++) { // Get ASCII code from string, get ASCII code from key (loop through with MOD), XOR the two, get the character from the result // % is MOD (modulus), ^ is XOR $output.= chr(ord(substr($InString, $i, 1)) ^ ($KeyList[$i % strlen($Key)])); } // Return the result return $output; } /* The getToken function. ** ** NOTE: A function of convenience that extracts the value from the "name=value&name2=value2..." VSP reply string ** ** Works even if one of the values is a URL containing the & or = signs. */ function getToken($thisString) { // List the possible tokens $Tokens = array("Status","StatusDetail","VendorTxCode","VPSTxID","TxAuthNo","Amount","AVSCV2"); // Initialise arrays $output = array(); $resultArray = array(); // Get the next token in the sequence for ($i = count($Tokens)-1; $i >= 0 ; $i--){ // Find the position in the string $start = strpos($thisString, $Tokens[$i]); // If it's present if ($start !== false){ // Record position and token name $resultArray[$i]->start = $start; $resultArray[$i]->token = $Tokens[$i]; } } // Sort in order of position sort($resultArray); // Go through the result array, getting the token values for ($i = 0; $i