$db_host='localhost';
$db_user='mpa3_admin';
$db_pass='ilphyeb5';
$db_pass_backup='';
$tables_header='1';
$tables_odd='2';
$tables_even='3';
$cookie_exp='336';
$twotier_percent='5';
$ip_exp='336';
$local_wire_fee='0';
$international_wire_fee='30';
$local_check_fee='0';
$international_check_fee='0';
$local_ipayout_fee='0';
$international_ipayout_fee='0';
$local_epass_fee='0';
$international_epass_fee='0';
$processing_fees='0';
$curl='/usr/local/bin/curl';
$path_to_php='';
$program_name='Gunzblazing V5';
$eur_usd_rate='1.27';
$default_program='4';
$default_site='2';
$sms_params='11';
$f2g_min_payout='74';
$mpush_id='';
$mpush_password='';
$mpush_percent='';
$wm_ref_redirect_url='http://www.gunzblazing.com/';
$check_threshold='25';
$rebills_threshold='25';
$currency_sign='$';
$minpayoutsteps='50,100,150,200,250,500,1000,1500,2000,2500,3000,5000';
$vat='';
$localbilling_active='';
$hide_trials_days='35';
$ipayout_mid='0cdd515f-aa1a-4566-a87b-17197772f232';
$ipayout_username='brian@pistolmedia.com';
$ipayout_password='aebn23';
$ipayout_test_mode='0';
$ipayout_upload_automatically='0';
$table_heading='';
$table_dark='';
$table_light='';
$consoles_active='0';
$no_affiliate_no_trial='0';
$active_banlist='0';
$ct_set='';
$auto_approve='0';
$email_confirmations='0';
$auto_approve_on_email='0';
$irs_usa='0';
$enable_cexit='0';
$test_mode='1';
$links_to_mpa2='';
$use_sql='1';
$no_credit_webmaster='100002';
$webmasters_approval='';
$merge_follow_me='1';
$reduce_active_chargebacks='0';
$show_fees='0';
$use_eu='1';
$f2g_active='0';
$aff_rep_links_override='0';
$epoch_direct_jp='1';
$send_member_approve_email='0';
$ipayout_test_mode='0';
$ipayout_upload_automatically='0';
$paxum_email='';
$paxum_loginid='';
$paxum_test_mode='';
$paxum_upload_automatically='';
$local_paxum_fee='0';
$international_paxum_fee='0';
?>
?>
function Encrypt($string, $public_key)
{
$fp = fopen($public_key, "r");
$pkey = fread($fp, 8192);
fclose($fp);
openssl_get_publickey($pkey);
// encrypt
openssl_public_encrypt($string, $encrypted_string, $pkey);
return $encrypted_string;
}
function encdec($str_message, $dec=0)
{
return $str_message;
global $key_shift;
$passkey = ($key_shift*$key_shift-$key_shift)*($key_shift*$key_shift)*$key_shift;
$str_message = utf8_decode($str_message);
if($dec) {
$str_message = substr_replace($str_message,"",-strlen($passkey));
}
$len_str_message=strlen($str_message);
$str_encrypted_message="";
for ($position = 0;$position<$len_str_message;$position++)
{
//$key_to_use = (($len_str_message+$position)+1);
$key_to_use = $position*$position + $key_shift;
$key_to_use = (255+$key_to_use) % 255;
$byte_to_be_encrypted = substr($str_message, $position, 1);
$ascii_num_byte_to_encrypt = ord($byte_to_be_encrypted);
$xored_byte = $ascii_num_byte_to_encrypt ^ $key_to_use; //xor operation
$encrypted_byte = chr($xored_byte);
$str_encrypted_message .= $encrypted_byte;
}
if($dec == 0)
$str_encrypted_message .= $passkey;
return utf8_encode($str_encrypted_message);
}
function encordec($str) {
return $str;
global $key_shift;
$passkey = ($key_shift*$key_shift-$key_shift)*($key_shift*$key_shift)*$key_shift;
if( !preg_match("/$passkey/", $str ))
return $str;
else
return encdec($str,1);
}
?>
$gallery_db_host='';
$gallery_db_name='';
$gallery_db_user='';
$gallery_db_pass='';
$gallhits_path='';
$gallhit_url='';
$god_db_host='';
$god_db_name='';
$god_db_user='';
$god_db_pass='';
$godhits_path='';
$godhit_url='';
$hg_as_gotd_source='';
$hg_as_gotd_to_use='0';
$pod_db_host='';
$pod_db_name='';
$pod_db_user='';
$pod_db_pass='';
$podhits_path='';
$podhit_url='';
$no_commas='0';
?>
function http_post($url,$query,$send_header = false, $custom_header='')
{
global $conn;
if ($url=='http://gunzblazing.com/adp.php') $url ='http://pwd.gunzblazing.com/adp.php';
$httpheader = array ("MIME-Version: 1.0","Content-transfer-encoding: text","Content-Type: application/x-www-form-urlencoded");
if ($custom_header!='') $httpheader = $custom_header;
$ch = curl_init();
curl_setopt ($ch, CURLOPT_POST,1);
curl_setopt ($ch, CURLOPT_POSTFIELDS,$query);
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/4.0");
if ($send_header)
{
curl_setopt ($ch, CURLOPT_HEADER, 1);
curl_setopt ($ch, CURLOPT_HTTPHEADER, $httpheader);
}
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_TIMEOUT, 120);
curl_setopt ($ch, CURLOPT_FOLLOWLOCATION , 0);
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
$result = curl_exec ($ch);
if ($conn->debug) echo " \ncurl_error:".curl_error($ch)." \n";
curl_close($ch);
//echo "result".$result."\n ";
return $result;
}
function http_get($url,$send_header = false)
{
global $conn;
$httpheader = array ("MIME-Version: 1.0","Content-transfer-encoding: text","Content-Type: application/x-www-form-urlencoded");
$ch = curl_init();
curl_setopt ($ch, CURLOPT_POST,0);
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/4.0");
if ($send_header)
{
curl_setopt ($ch, CURLOPT_HEADER, 1);
curl_setopt ($ch, CURLOPT_HTTPHEADER, $httpheader);
}
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_TIMEOUT, 120);
curl_setopt ($ch, CURLOPT_FOLLOWLOCATION , 0);
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
$result = curl_exec ($ch);
if ($conn->debug) echo " \ncurl_error:".curl_error($ch)." \n";
curl_close($ch);
return $result;
}
?>
//hostname_check
class Webmaster
{
public $id = '';
public $username = '';
public $password = '';
public $inhouse = 0;
public $company = '';
public $website = '';
public $email = '';
public $name = '';
public $fname = '';
public $lname = '';
public $phone = '';
public $icq = '';
public $program = '';
public $payto = '';
public $address = '';
public $city = '';
public $state = '';
public $full_state = '';
public $zip = '';
public $country = '';
public $full_country = '';
public $payment_method = '';
public $wm_paypal_email = '';
public $wm_ipayout_email = '';
public $wm_paxum_email = '';
public $wm_ipayout_registered = '';
public $wm_epassporte_email = '';
public $wire_account_number = '';
public $wire_swift = '';
public $wire_aba = '';
public $wire_bank_name = '';
public $wire_bank_city = '';
public $wire_bank_country = '';
public $revupcardid = '';
public $taxid = '';
public $vat = '';
public $minpay = '';
public $datebirth = '';
public $approved = '';
public $active = '';
public $frozen = '';
public $disabled = '';
public $reason = '';
public $ma = '';
public $disable_date = '';
public $date_registered = '';
public $massmail = '1';
public $ip = '';
public $reg_country = '';
public $notes = '';
public $allowed_products = '';
public $dialer = '';
public $data_correct = false;
public $consoles = 1;
public $signup_mails = 0;
public $ch_details = 1;
public $brute_force = 1;
public $brute_force_attempts = 99;
public $date_edited = '';
public $form_template_file = 'admin_alter_webmaster.html';
public $notes_template_file = 'admin_wm_member_notes.html';
public $allowed_products_template_file = 'admin_allowed_products_select.html';
public $payment_history_template_file = 'admin_payment_history.html';
public $console_management_template_file = 'admin_console_management.html';
public $aff_rep_select_template_file = 'admin_aff_rep_select.html';
public $rewards_points_template_file = 'admin_wm_rewards_points.html';
public $edit_wm_settings_template_file = 'admin_edit_wm_settings.html';
public $ch_details_email_template = 'ch_details_email.html';
public $brute_force_email_template = 'brute_force_email.html';
public $wm_join_confirmation_mail_template = 'wm_join_confirmation_mail.html';
public $message='';
public $minpay_array = array(50,100,150,200,250,500,1000,1500,2000,2500,3000,5000,10000);
public $authentication_retries = 3;
public $lock_time = 3600; //seconds
public $wm_point_exist = false;
public $monitored_fields = array('ch_details','email', 'payto', 'address', 'city', 'state', 'zip', 'country', 'wm_paypal_email', 'wm_ipayout_email', 'wm_paxum_email','wm_cashx_email','wm_epassporte_email', 'wire_account_number', 'wire_swift', 'wire_aba', 'wire_bank_name', 'wire_bank_city', 'wire_bank_country', 'revupcardid', 'taxid');
public $errors = array(-2=>'This username is already taken. Please try another one.');
public $twotier_percent = '-1.00';
public $is_aff_rep = 0;
public $xml_container;
public $reason_deny='';
public function Webmaster($id = null, $key='id')
{
global $conn, $ADODB_FETCH_MODE, $minpayoutsteps;
$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
$this->table = TBL_PREFIX."webmasters";
$sql = "SELECT * FROM $this->table WHERE id = -1";
$result = $conn->Execute($sql);
$obj_vars = $result->FetchObj();
if (array_key_exists($key, $obj_vars))
{
$query = "SELECT * from $this->table where $key='$id'";
$result = $conn->GetAll($query);
if (@! is_array($result[0])) return 0;
$row = $result[0];
foreach ($row as $property_name=>$value)
{
$this->$property_name = $value;
}
$this->password = encordec($this->password);
$this->email = encordec($this->email);
}
$sql = "select points from ".TBL_PREFIX."rewards_points where `webmaster`='$this->id'";
$this->points = $conn->GetOne($sql);
if($this->points != '') $this->wm_points_exist = true;
$query = "SELECT distinct(master_site) AS id FROM ".TBL_PREFIX."sites WHERE owner='$this->id'";
$result = $conn->GetAll($query);
foreach($result as $row) $this->owner_sites .= $row['id'].",";
$this->owner_sites = @substr($this->owner_sites,0,-1);
$this->gl_key = md5(serialize($this).PROGRAM_URL.$_SERVER["REMOTE_ADDR"].PROGRAM_PATH.date("Y-m-d H"));
if(isset($_SESSION['lang'])) {
if (is_file(XMLS_PATH.'lang/'.$_SESSION['lang'].'/container.xml')) {
$this->xml_container = simplexml_load_file(XMLS_PATH.'lang/'.$_SESSION['lang']."/container.xml");
}
else {
$this->xml_container = simplexml_load_file(XMLS_PATH."lang/en/container.xml");
}
}
else {
$this->xml_container = simplexml_load_file(XMLS_PATH."lang/en/container.xml");
}
if (strlen($minpayoutsteps)>10)
{
$this->minpay_array=explode(',',$minpayoutsteps);
}
return 1;
}
public function read()
{
return $this->Webmaster($this->id, 'id');
}
public function read_username($username)
{
if (!$username) return 0;
return $this->Webmaster($username, 'username');
}
public function save()
{
global $conn;
$sql = "SELECT * FROM $this->table WHERE id = ".$this->id;
$result = $conn->Execute($sql);
$obj_vars = $result->FetchObj();
foreach($obj_vars as $var=>$val) if (! isset($this->$var)) $this->$var = '';
$this->password = encdec($this->password);
$this->email = encdec($this->email);
$updateSQL = $conn->GetUpdateSQL($result, get_object_vars($this), true);
if ($updateSQL) $conn->Execute($updateSQL);
$this->password = encordec($this->password);
$this->email = encordec($this->email);
}
public function update_wm_points()
{
global $conn;
$sql = "UPDATE `".TBL_PREFIX."rewards_points` SET `points`= '$this->points' WHERE `webmaster`='$this->id'";
$conn->Execute($sql);
return 1;
}
public function create_wm_points()
{
global $conn;
$sql = "INSERT INTO `".TBL_PREFIX."rewards_points` (`webmaster`, `points`) VALUES('$this->id', '$this->points')";
$conn->Execute($sql);
$this->wm_points_exist = true;
return 1;
}
public function update($properties,$save_it=1)
{
global $conn;
unset($properties['id']);
$ret = array();
$sql = "SELECT COUNT(*) FROM $this->table WHERE username='$properties[username]'";
$username_used = $conn->GetOne($sql);
if ((int)$username_used>0)
{
unset($properties['username']);
$ret[] = -2;
}
$this->verify_payment_info($properties);
$columns = $conn->MetaColumns($this->table);
foreach($columns as $column) if ($column->type=='timestamp')$this->{$column->name} = '';
foreach($properties as $property=>$value)
{
if ($property == 'allowed_products')
{
if (in_array(strval(0), $value))
{
foreach ($value as $k=>$v)
{
if ($k!='0') $allowed_products_arr[]=$v;
}
$value = $allowed_products_arr;
}
}
if (is_array($value)) $value = implode(",", $value);
if (@$this->$property != $value)
{
$this->$property = $value;
}
}
if ($save_it)
{
$this->save();
if($this->wm_points_exist) $this->update_wm_points();
elseif($this->points != '') $this->create_wm_points();
$this->registerIPayoutEmail();
}
return $ret;
}
public function create($properties)
{
global $conn,$auto_approve;
//adding date_registered to the passed $_POST variables
$properties ["date_registered"] = date("Y-m-d");
$this->approved = $auto_approve;
$sql = "SELECT * FROM $this->table WHERE id = -1";
$result = $conn->Execute($sql);
$obj_vars = $result->FetchObj();
foreach($obj_vars as $var=>$val) if (! isset($this->$var)) $this->$var = '';
if ($conn->no_autoincrement) $this->id = $conn->GenID("seq_".$this->table,100001);
$insertSQL = $conn->GetInsertSQL($result, get_object_vars($this));
$conn->Execute($insertSQL);
if (! $this->id) {$this->id = $conn->Insert_ID();}
$this->update($properties);
//$this->setPayRates();
}
public function printForm($new=1)
{
global $conn;
require_once(FUNCTIONS_PATH."lists_funcs.php");
if ($new) $form = implode('',file(self::fixLangTemplate("new_webmaster.html")));
$form = implode('',file(self::fixLangTemplate("update_webmaster.html")));
$asArray = get_object_vars($this);
foreach($asArray as $field=>$value) $form = str_replace('{'.$field.'}',$this->$field,$form);
$form = str_replace('{ID}',"",$form);
if ($this->active) $form = str_replace('{active_select}',"\n\n",$form);
else $form = str_replace('{active_select}',"\n\n",$form);
if ($new) $form = str_replace('{submit}',"",$form);
else $form = str_replace('{submit}',"",$form);
echo "$form";
}
public function verify_payment_info($properties)
{
$email = '';
foreach ($this->monitored_fields as $key)
{
if($key == 'email' or $key == 'password') $key = encordec($key);
if (isset($properties[$key]) && $this->$key!=$properties[$key]) $email .="$key field changed from '".$this->$key."' to '".$properties[$key]."' \n";
$this->{"old_".$key} = $this->$key;
$this->{"new_".$key} = $properties[$key];
}
if ($email!='' && $this->ch_details)
{
$this->message = $email;
$this->subject = 'Payment Details Change';
$this->send_email($this->ch_details_email_template);
}
}
/**
* headers can be set at the top of the template like this:
* {header}
* Subject: Welcome to program_name.com!
* Return-Path: support@program_name.com
* From: "Program Name.com"
* {/header}
*
* @param string $email_html
* @return string
*/
public function parse_headers($email_html)
{
preg_match_all("/{(header)}([\s\S.]*){\/(header)}/", $email_html, $arr_header);
preg_match_all("/([^:]*):(.*)/",$arr_header[2][0], $arr_mail_headers);
foreach ($arr_mail_headers[1] as $key=>$value) $this->mailHeaders[trim($value)] = trim($arr_mail_headers[2][$key]);
return str_replace($arr_header[0][0], '', $email_html);
}
/**
* Sends email to the webmster. It gets the webmaster parameters, and replaces the tags named as the parameters.
* For example {id} tag will be replaced by the $webmaster->id parameter
*
* @param string $template
* @param boolean $instant
*/
public function send_email($template, $instant = 0)
{
global $program_name;
require_once(CLASSES_PATH."mail_to_db.class.php");
@include(CONFIG_PATH."payout_config.php");
$email_html = @implode("", @file(OUTER_TEMPLATES_PATH.$template));
$asArray = get_object_vars($this);
foreach($asArray as $field=>$value) $email_html = str_replace('{'.$field.'}', $this->$field, $email_html);
$this->subject = "$this->subject for $program_name";
$email_html = $this->parse_headers($email_html);
if ($this->mailHeaders['From']=='' && $this->mailHeaders['from']=='') $this->mailHeaders['From'] = "\"".PROGRAM_NAME."\" <$webmasters_support_email>";
if ($this->mailHeaders['Subject']!='' || $this->mailHeaders['subject']!='') $this->subject = $this->mailHeaders['Subject'].$this->mailHeaders['subject'];
foreach ($this->mailHeaders as $key=>$value) if (!preg_match("/subject|from$/i", $key)) $mailHeader .="$key: $value\n";
$mailHeader = "From: ".$this->mailHeaders['From'].$this->mailHeaders['from']."\n".$mailHeader;
$to = "\"$this->fname $this->lname\" <$this->email>";
//if ($this->mailHeaders['From'].$this->mailHeaders['from']!='') $to=''; // what is this for? i see no logic in this - i had problems in ticket 8394
// "Changed payment info Notifications" and "Brute Force Notifications" were not working because of this
if ($instant)
{
mail($to, $this->subject, $email_html,"$mailHeader"."Content-type: text/html; charset=iso-8859-1");
}
else
{
$mail = new MailDB($to, $this->subject,$email_html,"$mailHeader"."X-Priority: 1",time());
}
}
/**
* Sends confirmation email to the webmster, and adds "confirm_link" as class property,
* which will be later replace the {confirm_link} tag in the conmfirmation template.
* The method also defines the email subject accordingly.
*
*/
public function send_confirmation_email()
{
$hash = md5($this->id.$this->username.$this->password.$this->email.$this->fname.$this->lname);
$this->confirm_link = PROGRAM_URL.'/wmreg/confirm.php?w='.$this->id.'&hash='.$hash;
$this->subject = 'Confirmation email';
$this->send_email($this->wm_join_confirmation_mail_template, 1);
}
public function verify_registration($array)
{
global $conn;
foreach($array as $public => $value)
{
$this->$public = $value;
$$public = $value;
$len = $public.'_len';
$$len = @strlen($value);
}
$reg_errors = '';
if(isset($_SESSION['lang'])) {
if (is_file(XMLS_PATH.'lang/'.$_SESSION['lang'].'/container.xml')) {
$this->_xml_container = simplexml_load_file(XMLS_PATH.'lang/'.$_SESSION['lang']."/container.xml");
}
else {
$this->_xml_container = simplexml_load_file(XMLS_PATH."lang/en/container.xml");
}
}
else {
$this->_xml_container = simplexml_load_file(XMLS_PATH."lang/en/container.xml");
}
## Company name check
if($company_len < 3)
{
$this->company = '';
$reg_errors .= $this->_xml_container->errors->company_name_short." \n";
}
## Website URL check
if(!preg_match("/^(http|https):\/\/(([A-Z0-9][A-Z0-9_-]*)(\.[A-Z0-9][A-Z0-9_-]*)+)(:(\d+))?\/*/i", $this->website))
{
$this->website = '';
$reg_errors .= $this->_xml_container->errors->incorrect_url." \n";
}
## Email check
if(!eregi("^[_\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,6}$", $email))
{
$this->email = '';
$reg_errors .= $this->_xml_container->errors->incorrect_email." \n";
}
## First name check
if(!preg_match("/^.{2,}$/", $fname))
{
$this->fname = '';
$reg_errors .= $this->_xml_container->errors->invalid_fname." \n";
}
## Last name check
if(!preg_match("/^.{2,}$/", $lname))
{
$this->lname = '';
$reg_errors .= $this->_xml_container->errors->invalid_lname." \n";
}
## Phone number check
if($phone_len < 3)
{
$this->phone = '';
$reg_errors .= $this->_xml_container->errors->invalid_phone." \n";
}
## icq check
if(strlen($icq) && !preg_match("/^\d*$/", $icq))
{
$this->icq = '';
$reg_errors .= $this->_xml_container->errors->invalid_icq." \n";
}
## Beneficiary check
if($payto_len < 3)
{
$this->payto = '';
$reg_errors .= $this->_xml_container->errors->invalid_beneficiary.". \n";
}
## Addreess check
if($address_len < 3)
{
$this->address = '';
$reg_errors .= $this->_xml_container->errors->incorrect_address." \n";
}
## City check
if($city_len < 3)
{
$this->city = '';
$reg_errors .= $this->_xml_container->errors->incorrect_city." \n";
}
if($country == 'US')
{
if(!eregi("^[A-Z]{2}$", $state)) $reg_errors .= $this->_xml_container->errors->select_state." \n";
if(!eregi("^[0-9]{5}$", $zip))
{
$this->zip = '';
$reg_errors .= "Invalid ZIP code. \n";
}
if($taxid_len < 9) $reg_errors .= $this->_xml_container->errors->invalid_taxid." \n";
}
else
{
if($zip_len < 2)
{
$this->zip = '';
$reg_errors .= $this->_xml_container->errors->invalid_zip." \n";
}
}
$payment_methods = array('paxum', 'cheque', 'ipayout', 'epassporte', 'wire', 'paypal', 'revupcard');
## Check payment method
if(!in_array(strtolower($payment_method), $payment_methods)) $reg_errors .= $this->_xml_container->errors->select_payment_method." \n";
## Check i-Payout
if(preg_match("/ipayout/i",$payment_method) && !eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $wm_ipayout_email))
{
$this->wm_ipayout_email = '';
$reg_errors .= $this->_xml_container->errors->invalid_ipayout." \n";
}
## Check Paxum
if(preg_match("/paxum/i",$payment_method) && !eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $wm_paxum_email))
{
$this->wm_paxum_email = '';
$reg_errors .= $this->_xml_container->errors->invalid_paxum." \n";
}
## Check ePassporte
if(preg_match("/Epassporte/i",$payment_method) && !eregi("^[_\.0-9a-z-]+(@epassporte\.com)$", $wm_epassporte_email))
{
$this->wm_epassporte_email = '';
$reg_errors .= $this->_xml_container->errors->invalid_epassporte." \n";
}
## Check RevUpCard
if(preg_match("/revupcard/i",$payment_method) && strlen($revupcardid)<15)
{
$this->revupcardid = '';
$reg_errors .= $this->_xml_container->errors->invalid_revup." \n";
}
## Check Wire
if(preg_match("/Wire/i",$payment_method))
{
if(!eregi("^[0-9]{1,}$", $wire_account_number))
{
$this->wire_account_number = '';
$reg_errors .= $this->_xml_container->errors->invalid_account_number." \n";
}
/* if($wire_swift_len < 3) {
$this->wire_swift = '';
$reg_errors .= "Invalid SWIFT code. \n";
}
if($wire_aba_len < 3) {
$this->wire_aba = '';
$reg_errors .= "Invalid ABA code. \n";
}*/
if($wire_bank_name_len < 3)
{
$this->wire_bank_name = '';
$reg_errors .= $this->_xml_container->errors->invalid_bank_name." \n";
}
if($wire_bank_city_len < 3)
{
$this->wire_bank_city = '';
$reg_errors .= $this->_xml_container->errors->invalid_bank_city." \n";
}
if($wire_bank_country_len < 3)
{
$this->wire_bank_country = '';
$reg_errors .= $this->_xml_container->errors->invalid_bank_country." \n";
}
}
if ($day!='' && $month!='' && $year!='')
{
$this->datebirth = date("Y-m-d", strtotime("$year-$month-$day"));
if (strtotime("$year-$month-$day")>strtotime("-18 year"))
{
$reg_errors .= $this->_xml_container->errors->invalid_birthdate." \n";
}
}
if($minpay+0 < 50) $reg_erros .= $this->_xml_container->errors->invalid_amount." \n";
## Username check
$sql = "SELECT COUNT(*) FROM $this->table WHERE username='$username'";
$username_used = $conn->GetOne($sql);
if($username_used+0 > 0)
{
$this->username = '';
$reg_errors .= $this->_xml_container->errors->username_used." \n";
}
elseif($username_len < 4 || $username_len > 12)
{
$this->username = '';
$reg_errors .= $this->_xml_container->errors->username_lenght." \n";
}
## Password check
if($password_len < 6 || $password_len > 12)
{
$this->password = '';
$this->password2 = '';
$reg_errors .= $this->_xml_container->errors->password_lenght." \n";
## Password match
}
elseif ($password != $password2)
{
$this->password = '';
$this->password2 = '';
$reg_errors .= $this->_xml_container->errors->passwords_match." \n";
}
if($reg_errors == '')
{
$this->data_correct = true;
}
else
{
$this->reg_errors = $reg_errors;
}
}
public function fix_address()
{
require_once(CLASSES_PATH."state.class.php");
require_once(CLASSES_PATH."country.class.php");
$country = new Country($this->country,'iso_2');
$state = new State($this->state);
$this->update(array('full_country' => $country->name, 'full_state' => $state->name, 'name' => "$this->fname $this->lname"));
unset($country);
unset($state);
}
/**
* Register i-Payout email
*
*/
public function registerIPayoutEmail()
{
global $conn;
if ($this->payment_method != 'ipayout' OR !$this->wm_ipayout_email OR $this->wm_ipayout_email == $this->wm_ipayout_registered) {
return false;
}
require_once(CLASSES_PATH . 'ipayout.class.php');
$iPayout = new IPayout();
$result = $iPayout->registerWebmaster($this);
if ($result) {
$this->wm_ipayout_registered = $this->wm_ipayout_email;
$this->save();
}
}
public function adminForm($by_admin='1')
{
global $conn, $fraud_fields;
require_once(FUNCTIONS_PATH."lists_funcs.php");
$form = @implode('',@file(self::fixLangTemplate($this->form_template_file)));
$payment_history_template = @implode("", @file(self::fixLangTemplate($this->payment_history_template_file)));
$this->countries_select = wm_countries_select($this->country, '');
$this->states_select = states_select($this->state);
if (!in_array($this->minpay, $this->minpay_array)) $this->minpay_array[] = $this->minpay;
$this->minpay_select = minpay_select($this->minpay, $this->minpay_array);
(!empty($this->xml_container->masscontainer->yes))?$yes = $this->xml_container->masscontainer->yes : $yes = 'Yes';
(!empty($this->xml_container->masscontainer->no))?$no = $this->xml_container->masscontainer->no : $no = 'No';
(!empty($this->xml_container->masscontainer->none))?$none = $this->xml_container->masscontainer->none : $none = 'None';
$this->massmail_select = custom_select(array(1=>$yes, 0=>$no), $this->massmail, null);
$this->signup_mails_select = custom_select(array(1=>$yes, 0=>$no), $this->signup_mails, null);
$this->ch_details_select = custom_select(array(1=>$yes, 0=>$no), $this->ch_details, null);
$this->brute_force_select = custom_select(array(1=>$yes, 0=>$no), $this->brute_force, null);
$this->webmaster_id = $this->id;
$this->password = encordec($this->password);
$this->email = encordec($this->email);
//data
global $doc;
$make_xml = new Make_Xml($doc, 'data');
$asArray = get_object_vars($this);
foreach($asArray as $field=>$value)
{
if (is_array($this->$field)) continue;
$node = $make_xml->addRow($make_xml->ext_node, $field);
@$make_xml->addValue($node, $this->$field);
}
//listing the payment history
$titles = array('th_collected_since','th_payout_period', 'th_payout');
$widths = array(80,180,'');
$alignment = array('left','left','left');
$totals = array();
$sql = "select * from `". TBL_PREFIX ."payout` where webmaster='$this->id' order by end_date";
$res = $conn->GetAll($sql);
// hide payout for last period (#8698)
$q = "SELECT start_date, end_date, processed FROM ".$tbl_prefix."payout_dates where end_dateSelectLimit($q, 1);
$hide_start = $hide_date->fields[start_date];
$hide_end = $hide_date->fields[end_date];
foreach ($res as $row)
{
// hide payout for last period (#8698)
if($row['start_date']==$hide_start || $row['end_date']==$hide_end) continue;
$sql = "select ADDDATE(max(end_date), INTERVAL 1 DAY) from ". TBL_PREFIX ."payout where webmaster='$this->id' and start_date<'$row[start_date]'";
$sql_trn = "select min(trn_date) from ". TBL_PREFIX ."transactions where webmaster='$this->id' and trn_date>'0000-00-00'";
$table_row = array();
$first_date = $conn->GetOne($sql);
if (!$first_date) $first_date = $conn->GetOne($sql_trn);
if (strtotime($first_date)>strtotime($row['start_date'])) $first_date = $row['start_date'];
$table_row[] = $first_date;
$prefix = "";
if ($by_admin) $prefix = "";
$suffix = "";
$table_row[] = $prefix.$row['start_date']." -- ".$row['end_date'].$suffix;
$table_row[] = $row['payout'];
if (array_key_exists("payment_method", $row))
{
$table_row[] = ''.$row['payment_method'];
$titles[3] = 'th_payment_method';
$widths[3] = 80;
$alignment[3] = 'right';
$totals[3]='';
}
if (array_key_exists("min_payout", $row))
{
$table_row[] = ''.$row['min_payout'];
$titles[4] = 'th_minimum_payout';
$widths[4] = 60;
$alignment[4] = 'right';
$totals[4]='';
}
$totals[0]='';
$totals[1]='';
$totals[2]+=0+$row['payout'];
$table[] = $table_row;
}
ksort($totals);
include_once(FUNCTIONS_PATH."tables_funcs.php");
$payment_history = build_xml_data($table,$widths,$alignment,$titles,$totals,'100%','wm_payment_history');
if ($payment_history=='') $payment_history = "No payments have been calculated yet.";
if ($by_admin)
{
(!empty($this->xml_container->masscontainer->activate))?$activate = $this->xml_container->masscontainer->activate : $activate = 'Activate';
(!empty($this->xml_container->masscontainer->freeze))?$freeze = $this->xml_container->masscontainer->freeze : $freeze = 'Freeze';
if ($this->frozen) $this->freeze_activate = '';
else $this->freeze_activate = '';
$this->sites_select = sites_select(null,null,null,null,null,1);
$form = str_replace('onSubmit="return validate(this)"','',$form); // Removes javascript form check
$allowed_products_array = array();
$allowed_products_array = explode(",", $this->allowed_products);
$q = "select t1.*, t2.id as siteId, t2.title as siteTitle from ". TBL_PREFIX ."products as t1 left join ". TBL_PREFIX ."sites as t2 on t1.site=t2.id where t1.active='1' and t1.deleted='0' order by t1.site, t1.id";
$res = $conn->GetAll($q);
$products[0]=(!empty($this->xml_container->masscontainer->defaults))?$this->xml_container->masscontainer->defaults :'Defaults';
foreach ($res as $key=>$value)
{
$products[$value['id']] = $value['siteId']."-".$value['siteTitle']." / ".$value['id']."-".$value['title'];
if ($value['visible']) $visible_products[] = $value['id'];
}
if (!(count($allowed_products_array)>0 && $allowed_products_array[0]!='')) $allowed_products_array['Defaults'] = '0';
$this->allowed_products_select = custom_checkbox_new($products, $allowed_products_array, "allowed_products");
$this->allowed_products_height = (count($products)>100)?"100":count($products)+1;
$aff_reps = get_aff_reps();
foreach ($aff_reps as $key=>$value)$aff_reps[$key] = $key." - ".$value;
$this->aff_rep_select = custom_select($aff_reps, $this->aff_rep, null, $none);
$this->ma_select = webmasters_select($this->ma, null, $none);
$this->consoles_select = custom_select(array(1=>$yes, 0=>$no), $this->consoles);
// hiperlink to referred webmaster
if ($this->ma > 0) {
$form = str_replace('{ma}',''.$this->ma.'',$form);
} else {
$form = str_replace('{ma}','',$form);
}
$asArray = get_object_vars($this);
$fraud_array = explode('|',$fraud_fields);
foreach($fraud_array as $id=>$field)
{
$form = str_replace('{'.$field.'_wm_fraud}', 'wm_fraud', $form);
$node = $make_xml->addRow($make_xml->ext_node, $field.'_wm_fraud');
$make_xml->addValue($node, 1);
}
foreach($asArray as $field=>$value)
{
//$form = str_replace('{'.$field.'}', $this->$field,$form);
//$form = str_replace('{'.$field.'_wm_fraud}', '',$form);
if (is_array($this->$field)) continue;
$node = $make_xml->addRow($make_xml->ext_node, $field);
$make_xml->addValue($node, $this->$field);
if(!in_array($field, $fraud_array))
{
$node = $make_xml->addRow($make_xml->ext_node, $field.'_wm_fraud');
$make_xml->addValue($node, '');
}
}
}
/*
else
{
$admin_tags = get_object_vars($this);
foreach ($admin_tags as $tag=>$variable) {
//$form = str_replace($tag,'',$form);
$node = $make_xml->addRow($make_xml->ext_node, $tag);
$make_xml->addValue($node, '');
}
}
*/
//$form=str_replace('{payment_history}',$payment_history,$form);
//payment history
$node = $make_xml->addRow($make_xml->ext_node, 'payment_history');
$make_xml->addValue($node, $payment_history);
//show the form
$node = $make_xml->addRow($make_xml->ext_node, 'edit_webmaster');
$make_xml->addValue($node, 1);
//return $form;
}
public function rightsForm()
{
global $conn;
include_once (CLASSES_PATH."wm_rights.class.php");
$rights = new wm_rights($this->id);
$form = $rights->rightsForm();
return $form;
}
public function updateRights($wm_rights)
{
global $conn;
include_once (CLASSES_PATH."wm_rights.class.php");
$rights = new wm_rights($this->id);
$form = $rights->rightsForm();
$form = $rights->update($wm_rights);
return $form;
}
public function toString($delimiter = "\n")
{
$asArray = get_object_vars($this);
foreach ($asArray as $key=>$val) $str.="$key = $val".$delimiter;
return $str;
}
/**
*
* Checks if the program is allowed for this webmaster and if not replaces it with the default one
*
* @return array
*/
public function getPrograms($site='all', $tour='all', $console=-1)
{
global $conn;
if (!$site) $site='all';
if (!$tour) $tour='all';
$query = "SELECT * FROM ".TBL_PREFIX."programs WHERE bonus_program=0 AND visible=1 order by id";
$programs = $conn->GetAll($query);
$allowed_programs = array();
$special_programs = array();
foreach ($programs as $program)
{
$is_good = 1;
$current = $program;
$current['webmaster'] = explode(',',$current['webmaster']);
$current['site'] = explode(',', $current['site']);
$current['tour'] = explode(',', $current['tour']);
if (! is_array($current)) $is_good=0; // No such program in the database
if (! in_array($this->id,$current['webmaster']) and ! in_array('all',$current['webmaster'])) $is_good=0; // Webmaster is not in the list and program not for everyone
if (! in_array($site,$current['site']) and ! in_array('all',$current['site'])) $is_good=0; // Site not in the program and program not for all sites
if (! in_array($tour,$current['tour']) and ! in_array('all',$current['tour'])) $is_good=0; // Tour not in the program and program not for all tours
//if ($current['consoles']>=0 and (($current['consoles']==0 and $console>0) || ($current['consoles']==1 and $console==0))) $is_good=0; // There is special console conditions that does not match the link code
if ($current['replace_with']) $is_good=0; // Program deactivated and replaced
if ($is_good)
{
$allowed_programs[$program['id']]=$program;
//after all previous checks - check whether this webmaster has special program assigned and hide other programs
if(in_array($this->id,$current['webmaster'])) $special_programs[$program['id']]=$program;
}
}
if(is_array($special_programs) && sizeof($special_programs)>=1) $allowed_programs = $special_programs;
return $allowed_programs;
}
public function validateProgram($program, $site='all', $tour='all', $console=-1, $trn_date='CURRENT_DATE')
{
global $conn, $default_program;
$old_mode = $conn->fetchMode;
$conn->fetchMode = 2;
//$this->aff_rep_table is defined in transaction.class.php in method get_config()
$prefix = "";
if($this->aff_rep_table) $prefix = "aff_rep_";
/* Checking for a bonus program available for this combination of input parameters */
if ($trn_date!='CURRENT_DATE') $trn_date = "'".$trn_date."'";
$query = "SELECT * from ".TBL_PREFIX.$prefix."programs WHERE bonus_program=1 and $trn_date between start_date and end_date ORDER BY id";
$bonus_programs = $conn->GetAssoc($query);
if (is_array($bonus_programs) and count($bonus_programs)>0)
{
foreach ($bonus_programs as $bprogram=>$properties)
{
if ($properties['replace_program']>0 and $properties['replace_program']!=$program) continue;
$bonus_program = $properties;
$bonus_program['id'] = $bprogram;
$bonus_program['webmaster'] = explode(',',$properties['webmaster']);
$bonus_program['site'] = explode(',',$properties['site']);
$bonus_program['tour'] = explode(',',$properties['tour']);
if (! in_array($this->id,$bonus_program['webmaster']) and ! in_array('all',$bonus_program['webmaster'])) continue; // Webmaster is not in the list and program not for everyone
if (! in_array($site,$bonus_program['site']) and ! in_array('all',$bonus_program[site])) continue; // Site not in the program and program not for all sites
if (! in_array($tour,$bonus_program['tour']) and ! in_array('all',$bonus_program[tour])) continue; // Tour not in the program and program not for all tours
//if ($bonus_program['consoles']>=0 and (($bonus_program['consoles']==0 and $console>0) || ($bonus_program['consoles']==1 and $console==0))) continue; // There is special console conditions that does not match the link code
$conn->fetchMode = $old_mode;
$program = $bonus_program['id'];
return $program; // Bonus program is returned
}
}
/* End of bonus program checking */
$query = "SELECT * FROM ".TBL_PREFIX.$prefix."programs WHERE bonus_program=0 order by id";
$programs = $conn->GetAssoc($query);
$conn->fetchMode = $old_mode;
if ($programs[$program]['replace_with']>0) $program = $programs[$program]['replace_with']; // If a program is disabled and replaced the new one will be used
$current = $programs[$program];
$current['webmaster'] = explode(',',$current['webmaster']);
$current['site'] = explode(',', $current['site']);
$current['tour'] = explode(',', $current['tour']);
if (! is_array($current)) return $default_program; // No such program in the database
if (! in_array($this->id,$current[webmaster]) and ! in_array('all',$current['webmaster'])) return $default_program; // Webmaster is not in the list and program not for everyone
if (! in_array($site,$current['site']) and ! in_array('all',$current['site'])) return $default_program; // Site not in the program and program not for all sites
if (! in_array($tour,$current['tour']) and ! in_array('all',$current['tour'])) return $default_program; // Tour not in the program and program not for all tours
//if ($current['consoles']>=0 and (($current['consoles']==0 and $console>0) || ($current['consoles']==1 and $console==0))) return $default_program; // There is special console conditions that does not match the link code
if ($current['replace_with']) return $current['replace_with']; // Program deactivated and replaced
return $program; // Program is good
}
public function getRates($program, $site='all', $tour='all', $console=-1, $original_program, $product, $trn_date='CURRENT_DATE')
{
global $conn, $twotier_percent;
if (! $product or ! $program) return array();
$old_mode = $conn->fetchMode;
$conn->fetchMode = 2;
//$this->aff_rep_table is defined in transaction.class.php in method get_config()
$prefix = "";
if($this->aff_rep_table)
{
$prefix = "aff_rep_";
//get the proper program id from the mpa3_aff_rep_programs, ad it may differ from the sale's program id, which is valid for mpa3_programs table only
$sql = "SELECT id from ".TBL_PREFIX.$prefix."programs WHERE bonus_program=1 and CURRENT_DATE between start_date and end_date ORDER BY id";
$program = $conn->GetOne($sql);
if (!$program)
{
$sql = "select id from ".TBL_PREFIX.$prefix."programs where webmaster='$this->id' and site='$site' and tour='$tour'";
$program = $conn->GetOne($sql);
}
if (!$program)
{
$sql = "select id from ".TBL_PREFIX.$prefix."programs where webmaster='$this->id' and site='$site' and tour='all'";
$program = $conn->GetOne($sql);
}
if (!$program)
{
$sql = "select id from ".TBL_PREFIX.$prefix."programs where webmaster='$this->id' and site='all' and tour='all'";
$program = $conn->GetOne($sql);
}
if (!$program)
{
$sql = "select id from ".TBL_PREFIX.$prefix."programs where site='$site' and tour='$tour' and webmaster='all'";
$program = $conn->GetOne($sql);
}
if (!$program)
{
$sql = "select id from ".TBL_PREFIX.$prefix."programs where site='$site' and tour='all' and webmaster='all'";
$program = $conn->GetOne($sql);
}
if (!$program)
{
$sql = "select id from ".TBL_PREFIX.$prefix."programs where site='all' and webmaster='all' and tour='all'";
$program = $conn->GetOne($sql);
}
$original_program = $program;
}
// We should validate the program again in case of cheating or in case bonus program was assogned and expired at the time of sign up
// or When the sign up appened we have a bonus program active
if ($original_program!=$program and $original_program>0) $program = $this->validateProgram($original_program, $site, $tour, $console, $trn_date);
else $program = $this->validateProgram($program, $site, $tour, $console, $trn_date);
//$products_programs = unserialize($conn->GetOne("select products_programs from ".TBL_PREFIX."programs where id=$program"));
$sql = "select * from ".TBL_PREFIX.$prefix."programs where id=$program";
$programs = $conn->GetRow($sql);
$products_programs = unserialize(stripslashes($programs['products_programs']));
unset($programs['id']);
unset($programs['title']);
unset($programs['description']);
unset($programs['webmaster']);
unset($programs['site']);
unset($programs['tour']);
unset($programs['consoles']);
unset($programs['insert_time']);
if ($products_programs['all']>0) $product = 'all';
$rates = $conn->GetAll("SELECT * from ".TBL_PREFIX."basic_programs where id=".($products_programs[$product]+0));
if ($rates[0]['console_payrate']>0 && $console>0)$rates = $conn->GetAll("SELECT * from ".TBL_PREFIX."basic_programs where id=".$rates[0]['console_payrate']);
$rates[0]['program'] = $program;
$conn->fetchMode = $old_mode;
$rate_2tier = $conn->GetOne("select twotier_percent from ".TBL_PREFIX."webmasters where id=".$this->ma);
if ($rate_2tier < 0) $rate_2tier = $twotier_percent;
$return_array = array_merge(array('rate_2tier' => $rate_2tier), $rates[0], $programs);
$empty_array = array();
foreach ($return_array as $key=>$value) if ($key!='program') $empty_array[$key]=0; else $empty_array[$key]=$return_array[$key];
$empty_array['program'] = $return_array['program'];
$empty_array['original_program'] = $return_array['original_program'];
//check if webmaster account is inhouse and if yes - set payout to 0
if($this->inhouse==1)
{
$empty_array['insert_time'] = date("Y-m-d H:i:s");
return $empty_array;
}
if (is_array($rates[0])) return $return_array;
else return $empty_array;
}
public function getPayRates($site=0, $table='config')
{
global $conn;
if ($table == 'config')
{
$query = "SELECT * from ". TBL_PREFIX ."config_bonus where bsdate<=now() and bedate>=now()";
$result = $conn->GetAll($query);
$source = 'bonus';
}
if (! is_array($result[0]))
{
$query = "SELECT * from ".TBL_PREFIX."$table where siteid=$site and webmaster=".$this->id;
$result = $conn->GetAll($query);
$source = 'site_webmaster_specific';
}
if (! is_array($result[0]))
{
$query = "SELECT * from ".TBL_PREFIX."$table where siteid=0 and wm_common='0' and webmaster=".$this->id;
$result = $conn->GetAll($query);
$source = 'webmaster_global';
}
if (! is_array($result[0]))
{
$query = "SELECT * from ".TBL_PREFIX."$table where siteid=$site and webmaster=100000";
$result = $conn->GetAll($query);
$source = 'site_global';
}
if (! is_array($result[0]))
{
$query = "SELECT * from ".TBL_PREFIX."$table where siteid=0 and webmaster=100000";
$result = $conn->GetAll($query);
$source = 'global';
}
$row = $result[0];
unset($row['webmaster']);
$rates = array();
foreach($row as $key=>$val) $rates[$key] = $val;
$rates['source'] = $source;
return $rates;
}
public function getAffRepPayRates($site=0)
{
return $this->getPayRates($site, 'aff_rep_config');
}
public function updatePayRates($rates, $site=0, $table='config')
{
global $conn;
require_once(CLASSES_PATH."rates.class.php");
$rates['wm_common'] = 0;
$wrates = new Rates($site,$this->id, $table);
$wrates->update($rates,0);
$wrates->fetchNumbersForSave();
$wrates->save();
if ($site==0)
{
$query = "select id from ".TBL_PREFIX."sites";
$result = $conn->GetAll($query);
foreach ($result as $s)
{
$wrates->siteid = $s[id];
$wrates->save();
}
}
}
public function updateAffRepPayRates($rates, $site=0)
{
$this->updatePayRates($rates, $site, 'aff_rep_config');
}
public function setPayRates($table='config')
{
global $conn;
$query = "SELECT * from ".TBL_PREFIX."$table where webmaster=100000";
$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
$res = $conn->GetAll($query);
foreach ($res as $row)
{
$rates = array();
$sql = "SELECT * FROM ".TBL_PREFIX."$table WHERE siteid=-1 and webmaster=0";
$result = $conn->Execute($sql);
$row[webmaster] = $this->id;
$insertSQL = $conn->GetInsertSQL($result, $row);
$conn->Execute($insertSQL);
}
}
public function setAffRepPayRates()
{
$this->setPayRates('aff_rep_config');
}
public function clearPayRates($site, $table='config')
{
global $conn;
include_once (CLASSES_PATH."rates.class.php");
$wrates = new Rates($site,$this->id, $table);
return $wrates->del();
}
public function clearAffRepPayRates($site)
{
global $conn;
if ($site) $site_criteria = "and siteid='$site'";
$sql = "DELETE FROM ". TBL_PREFIX ."aff_rep_programs WHERE webmaster='$this->id' $site_criteria";
$conn->Execute($sql);
return $conn->Affected_Rows();
}
public function payRatesForm($site, $table='config')
{
global $conn;
include_once (CLASSES_PATH."rates.class.php");
$rates = new Rates($site, $this->id, $table);
//load the payrates with the getPayRates method as this is the one that is used on signup,
//and is showing the actual rates that the signup will credit the webmaster with
foreach ($this->getPayRates($site, $table) as $key => $value) $rates->$key = $value;
$form = $rates->Form();
$misc = "\n\n\nid>";
//custom node
global $doc;
$make_xml = new Make_Xml($doc, 'data');
$node = $make_xml->addRow($make_xml->ext_node, 'edit_payrates');
$make_xml->addValue($node, 1);
$node = $make_xml->addRow($make_xml->ext_node, 'misc');
$make_xml->addValue($node, $misc);
}
public function affRepPayRatesForm($site, $table='aff_rep_config')
{
global $conn;
include_once (CLASSES_PATH."rates.class.php");
include_once (FUNCTIONS_PATH."lists_funcs.php");
$aff_rep_program_selector = @implode("", @file(self::fixLangTemplate("admin_aff_rep_program_selector.html")));
$programsArr = array
(
'-1'=> ($this->xml_container->masscontainer->none)?$this->xml_container->masscontainer->none :"None",
'0' => ($this->xml_container->masscontainer->per_unique)?$this->xml_container->masscontainer->per_unique :"Per Unique",
'1' => ($this->xml_container->masscontainer->per_signup)?$this->xml_container->masscontainer->per_signup :"Per Signup",
'2' => ($this->xml_container->masscontainer->partnership)?$this->xml_container->masscontainer->partnership :"Partnership",
'3' => ($this->xml_container->masscontainer->per_activ_member)?$this->xml_container->masscontainer->per_activ_member :"Per Active Member"
);
$rates = new Rates($site, $this->id, $table);
//load the payrates with the getPayRates method as this is the one that is used on signup,
//and is showing the actual rates that the signup will credit the webmaster with
foreach ($this->getPayRates($site, $table) as $key => $value) $rates->$key = $value;
$form = $rates->Form();
$aff_rep_program_selector = str_replace("{use_program_select}",custom_select($programsArr, $rates->use_program),$aff_rep_program_selector);
$misc = $aff_rep_program_selector."\n\n\nid>";
//custom node
global $doc;
$make_xml = new Make_Xml($doc, 'data');
$node = $make_xml->addRow($make_xml->ext_node, 'aff_rates');
$make_xml->addValue($node, 1);
$node = $make_xml->addRow($make_xml->ext_node, 'misc');
$make_xml->addValue($node, $misc);
}
public function XSellRatesForm()
{
global $conn;
include_once (CLASSES_PATH."xsell_pay_rates.class.php");
$rates = new XSellPayRate($this->id);
$rates->Form();
//custom node
global $doc;
$make_xml = new Make_Xml($doc, 'data');
$node = $make_xml->addRow($make_xml->ext_node, 'xsell_payrates');
$make_xml->addValue($node, 1);
}
public function updateXSellRates($ez_rates)
{
global $conn;
require_once(CLASSES_PATH."xsell_pay_rates.class.php");
$rates = new XSellPayRate($this->id);
$rates->update($ez_rates);
}
public function getXSellRates()
{
global $conn;
require_once(CLASSES_PATH."xsell_pay_rates.class.php");
$rates = new XSellPayRate($this->id);
return $rates;
}
public function CascadingOrderForm()
{
global $conn;
include_once (CLASSES_PATH."cascading_order.class.php");
$c_order = new CascadingOrder($this->id);
//custom node
global $doc;
$make_xml = new Make_Xml($doc, 'data');
$node = $make_xml->addRow($make_xml->ext_node, 'wm_cascading_order');
$make_xml->addValue($node, 1);
$node = $make_xml->addRow($make_xml->ext_node, 'cascading_order');
$make_xml->addValue($node, $c_order->order_select());
$node = $make_xml->addRow($make_xml->ext_node, 'geo_cascading_order');
$make_xml->addValue($node, $c_order->geo_order_select());
$node = $make_xml->addRow($make_xml->ext_node, 'misc');
$make_xml->addValue($node, "id>");
}
public function updateCascadingOrder($order)
{
global $conn;
require_once(CLASSES_PATH."cascading_order.class.php");
$co = array();
$gco = array();
$alt_co = array();
$alt_gco = array();
foreach ($_POST as $key=>$value)
{
if (!preg_match("/.*order_\d+.*$/", $key)) continue;
$alt = preg_replace("/.*order_(\d+).*$/", "$1", $key);
$processor = preg_replace("/.*order_\d+_(.*)$/", "$1", $key);
/*
$co = explode('|','|'.$_POST['order_'.$alt]); unset($co[0]);
$gco = explode('|','|'.$_POST['geo_order_'.$alt]); unset($gco[0]);
*/
if ($alt)
{
if (preg_match("/geo_order/", $key))$alt_gco[$processor] = $value;
else $alt_co[$processor] = $value;
}
else
{
if (preg_match("/geo_order/", $key))$gco[$processor] = $value;
else $co[$processor] = $value;
}
}
$c_order = new CascadingOrder($this->id);
$c_order->update(
array(
'order'=>$co,
'geo_order'=>$gco
)
);
if ($order['clear']!='')
{
$c_order->clear();
}
if (count($alt_co)>0)
{
//updating the alt_cascading
$c_order = new CascadingOrder($this->id,0,1);
$c_order->update(
array(
'order'=>$co,
'geo_order'=>$gco
)
);
if ($order['clear']!='')
{
$c_order->clear();
}
}
}
public function authenticate()
{
global $conn;
global $_COOKIE;
global $_POST;
if ($this->disabled || $this->frozen)
{
$this->reason_deny = 'disabled_or_frozen';
return 0;
}
if ($this->username=='' || $this->password=='')
{
$this->reason_deny = 'rejected';
return 0;
}
if ($this->brute_force>=$this->brute_force_attempts && strtotime($this->date_edited." + $this->lock_time seconds")>time())
{
$this->reason_deny = 'brute_force';
return 0;
}
if (@$_COOKIE['wm_username'] == $this->username and @$_COOKIE['wm_password']==$this->password and !$this->disabled and !$this->frozen)
{
return 1;
}
// Customized to recognize md5 encrypted passwords in the database
if ($_POST['wm_username'] == $this->username and ($_POST['wm_password']==$this->password or md5($_POST['wm_password'])==$this->password) and !$this->disabled and !$this->frozen)
{
if (!$this->id || !$this->approved)
{
$this->reason_deny = 'not_approved';
return 0;
}
setcookie ("wm_id", $this->id,0);
setcookie ("wm_username", $_POST['wm_username'],0);
setcookie ("wm_password", $_POST['wm_password'],0);
if($this->brute_force) $this->brute_force=1;
$this->update(array('password' => $_POST['wm_password']));
return 1;
}
$this->logout(0);
if($this->brute_force) $this->brute_force++;
if($this->brute_force>=$this->brute_force_attempts)
{
$this->subject = 'Brute force attack';
$this->send_email($this->brute_force_email_template);
}
$this->save();
$this->reason_deny = "not_authorized";
return 0;
}
public function logout($redirect = 1)
{
setcookie ("wm_id", '',time()-3600);
setcookie ("wm_username",'',time()-3600);
setcookie ("wm_password", '',time()-3600);
if ($redirect) header("Location: webmasters.php?action=login_default&logout=1");
}
public function remember($action)
{
global $_POST;
if($action == "set")
{
$cookie = $_POST['wm_username']."|".$_POST['wm_password']."|".'checked';
setcookie("remember", $cookie, time()+2678400, '/');
}
else
{
setcookie("remember", "", time()-3600, '/');
}
}
public function getPayout()
{
}
public function disabled($w)
{
// Checks if webmaster is disabled, returns TRUE if yes.
// Used in hit.phpchecks if webmaster is disabled
// Peter
global $conn;
$sql = "SELECT disabled from $this->table where id=$w";
$res = $conn->GetRow($sql);
if($res[0]==1) return true;
else return false;
}
public function fixLangTemplate($fileName)
{
if(isset($_SESSION['lang'])) {
if ($_SESSION['lang'] != 'en') {
if (is_file(INNER_TEMPLATES_PATH.$_SESSION['lang'].'/'.$fileName))
{
$exportFormFile = INNER_TEMPLATES_PATH.$_SESSION['lang'].'/'.$fileName;
}
else {
$exportFormFile = INNER_TEMPLATES_PATH.$fileName;
}
}
else {
$exportFormFile = INNER_TEMPLATES_PATH.$fileName;
}
}
else {
$exportFormFile = INNER_TEMPLATES_PATH.$fileName;
}
return $exportFormFile;
}
}
?>
require_once(CLASSES_PATH."niche.class.php");
require_once(CLASSES_PATH."file_storage.class.php");
//hostname_check
class Site
{
public $id = ''; // Site ID
public $master_site = ''; // Master site ID
public $title = ''; // Site title
public $url = ''; // Main URL
public $postback_url = ''; // Postback URL
public $alternate_url = ''; // Alternative URL
public $use_alternate = ''; // Use alternative YES/NO flag
public $htpasswd = ''; // Path to PWD file on member server
public $adp = ''; // URL to adp.cgi
public $welcome = ''; // Successful signup - Welcome page URL
public $deny = ''; // Unsuccessful signup - Denial page URL
public $members = ''; // Member area URL
public $active = ''; // Active YES/NO flag
public $visible = ''; // Visible YES/NO flag
public $deleted = ''; // Deleted YES/NO flag
public $trials = ''; // Offer trials to non affiliated YES/NO flag
public $owner = ''; // Owner ID
public $overhead = ''; // Overhaed % deducted for fees and expenses before calculating the payout for the owner
public $payout = ''; // Payout % after fees of the profit of the site
public $nb_access_key = ''; // Netbilling access key
public $gxb_site_id = ''; // GXB site ID
public $netcash_site_id = ''; // NetCash site ID
public $commercegate_site_id = ''; // CommerceGate site ID
public $localbilling_site_id = ''; // LocalBilling site ID
public $localbilling_package_id = ''; // LocalBilling package ID
public $localbilling_vat_package_id = ''; // LocalBilling VAT package ID
public $dhd_site_id = ''; // DHD site ID
public $dhd_eudebit = ''; // DHD EU Debit URL
public $dhd_checks = ''; // DHD Checks URL
public $mpush_cid = '';
public $niche;
public $cml_product = '';
public $cml_banner = 'http://';
public $pbp_package = '';
public $pbp_layout='';
public $enc_method ='ENCRYPT';
public $p2e_productid = "";
public $p2e_siteid = "";
public $clearcard_site_id = 0;
public $ncc_site_id = '';
public $post_action = "";
public $post_method = "POST";
// CUSTOMIZATION //
public $default_console = ''; // Default exit console for the site
// CUSTOMIZATION //
public function Site($id = null)
{
// if site is specified it will read and set all the properties for this site
if (!preg_match("/^\d+$/", $id)) $id = 0;
if ($id) $this->read($id);
return 1;
}
public function read($id=null)
{
// Reads the info from the database and sets the properties, if no id reads for the current $this->id
global $conn;
if ($id) {
$this->id = $id;
}
if (DB_IS_DOWN === true) {
$objSite = FileStorage::getSiteObject($this->id);
if (!is_null($objSite)) {
$objVars = get_object_vars($objSite);
foreach($objVars as $key => $value) {
$this->$key = $value;
}
}
} else {
$query = "SELECT * from ".TBL_PREFIX."sites where id=".$this->id;
$result = $conn->GetAll($query);
if (! is_array($result[0])) {
return null;
}
$row = array_change_key_case($result[0], CASE_LOWER);
foreach ($row as $property_name=>$value) {
$this->$property_name = $value;
}
}
if ($this->master_site == 0 && $this->id > 0) {
$this->master_site = $this->id;
}
}
public function save()
{
// Saves into the database
global $conn;
if (!$this->id) {
$this->id = $this->siteID;
}
$sql = "SELECT * FROM ".TBL_PREFIX."sites WHERE id = ".$this->id;
$result = $conn->Execute($sql);
$obj_vars = $result->FetchObj();
foreach ($obj_vars as $var=>$val) {
if (!isset($this->$var)) {
$this->$var = '';
}
}
$updateSQL = $conn->GetUpdateSQL($result, get_object_vars($this), true, true, true);
if ($updateSQL) {
$conn->Execute($updateSQL);
}
//Store sites data to a php file
FileStorage::storeSitesData();
}
public function update($properties,$save_it=1)
{
global $conn;
// array of pairs property=>value to be updated, always use with caution,
// the update form is the preferred method
foreach($properties as $property=>$value)
{
$this->$property = $value;
}
if ($save_it) $this->save();
}
public function create($properties)
{
// sets the properties, saves into the database, gets the id and sets it
global $conn;
require_once(FUNCTIONS_PATH."execute_funcs.php");
$asArray = get_object_vars($this);
foreach ($asArray as $property_name=>$value)
{
$this->$property_name = $properties[$property_name].'';
}
$sql = "SELECT * FROM ".TBL_PREFIX."sites WHERE id = -1";
$result = $conn->Execute($sql);
$obj_vars = $result->FetchObj();
foreach($obj_vars as $var=>$val) if (! isset($this->$var)) $this->$var = '';
$this->deleted = 0;
if ($conn->no_autoincrement) $this->id = $conn->GenID("seq_".TBL_PREFIX."sites",1);
$signup_dir = SIGNUP_PATH.$this->id;
if(!is_dir($signup_dir))
{
$templates_dir = SIGNUP_PATH.'templates';
if(!is_dir($signup_dir)) $command = execute("cp -rf $templates_dir $signup_dir");
@chmod($signup_dir, 0777);
}
$insertSQL = $conn->GetInsertSQL($result, get_object_vars($this));
$conn->Execute($insertSQL);
if (! $this->id) {$this->id = $conn->Insert_ID();}
if (! $this->master_site) {$this->master_site = $this->id; $this->save();}
}
public function addMember($username,$password,$email=null)
{
// Self explanatory
global $conn;
//if there is no member management script set, act as if it's all ok
if ($this->adp=='' || $username=='' || $password=='') return 1;
//checks if the adp url is on the same server where mpa3 is and connects directly to the db
if (!(strpos($this->adp, PROGRAM_URL)===false) && strstr($this->htpasswd,'|'))
{
$conn_adp = &$this->build_conn();
$sql = "delete from $this->adp_tablename where $this->adp_username_field='$username'";
$res = $conn_adp->GetOne($sql);
$sql = "insert into $this->adp_tablename ($this->adp_username_field,$this->adp_password_field) values('$username',$this->enc_method('$password'))";
$res = $conn_adp->GetOne($sql);
return 1;
}
require_once(FUNCTIONS_PATH."http_post.php");
if (strstr($this->htpasswd,'|')) $command = "data=ADD,$this->htpasswd,$username,$password,$email";
else $command = "ADD,$this->htpasswd,$username,$password";
if ($conn->debug) $conn->outp('curl -k -d \''.$command.'\' '.$this->adp."\n");
//CURL ." -k -d 'ADD,$this->htpasswd,$username,$password' $this->adp
$res = http_post($this->adp,$command);
if ($conn->debug) $conn->outp($res."\n");
if (strstr($res,'ADDED')) return 1;
else return 0;
}
public function deleteMember($username)
{
// Self explanatory
global $conn;
//if there is no member management script set, act as if it's all ok
if ($this->adp=='') return 1;
//checks if the adp url is on the same server where mpa3 is and connects directly to the db
if (!(strpos($this->adp, PROGRAM_URL)===false) && strstr($this->htpasswd,'|'))
{
$conn_adp = &$this->build_conn();
$sql = "delete from $this->adp_tablename where $this->adp_username_field='$username'";
$res = $conn_adp->GetOne($sql);
return 1;
}
require_once(FUNCTIONS_PATH."http_post.php");
if (strstr($this->htpasswd,'|')) $command = "data=DELETE,$this->htpasswd,$username";
else $command = "DELETE,$this->htpasswd,$username";
if ($conn->debug) $conn->outp($command."\n");
$res = http_post($this->adp,$command);
if ($res=="DELETED $username") return 1;
else return 0;
}
public function &build_conn()
{
global $conn;
$credentials = explode("|", $this->htpasswd);
$this->adp_host=$credentials[0];
$this->adp_user=$credentials[1];
$this->adp_pass=$credentials[2];
$this->adp_db=$credentials[3];
$this->adp_tablename=$credentials[4];
$this->adp_username_field=$credentials[5];
$this->adp_password_field=$credentials[6];
$conn_adp = &NewADOConnection('mysql');
$conn_adp->debug=$conn->debug;
$conn_adp->Connect($this->adp_host, $this->adp_user, $this->adp_pass, $this->adp_db);
return $conn_adp;
}
public function checkMember($username)
{
// Self explanatory
global $conn;
//if there is no member management script set, act as if it's all ok
if ($this->adp=='') return 0;
//checks if the adp url is on the same server where mpa3 is and connects directly to the db
if (!(strpos($this->adp, PROGRAM_URL)===false) && strstr($this->htpasswd,'|'))
{
$conn_adp = &$this->build_conn();
$sql = "select count(*) from $this->adp_tablename where $this->adp_username_field='$username'";
$res = $conn_adp->GetOne($sql);
if ($res) return 1;
else return 0;
}
require_once(FUNCTIONS_PATH."http_post.php");
if (strstr($this->htpasswd,'|')) $command = "data=CHECK,$this->htpasswd,$username";
else $command = "CHECK,$this->htpasswd,$username";
if ($conn->debug) $conn->outp($command."\n");
$res = http_post($this->adp,$command);
//if theere is no FOUND string, it means the password management script is not accessible.
//Act as if the username was not found, or the member won't be able to proceed and signup
if (!preg_match("/FOUND/", $res)) return 0;
if ( strstr($res,'NOT_FOUND')) return 0;
else return 1;
}
public function refreshMemberAccess($username,$password,$email=null)
{
$this->addMember($username,$password,$email);
}
function refreshAll()
{
global $conn, $ADODB_FETCH_MODE;
$query = "SELECT username,password,email from ".TBL_PREFIX."members where site=".$this->id." or site=0";
$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
$result = $conn->GetAll($query);
foreach ($result as $row)
{
$this->refreshMemberAccess($row[username],$row[password],$row[email]);
}
}
public function deleteExpired()
{
global $conn, $ADODB_FETCH_MODE;
$query = "SELECT username from ".TBL_PREFIX."members where (site=".$this->id." or site=0) and edate=date_add(now(),interval -3 day)";
$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
$result = $conn->GetAll($query);
foreach ($result as $row)
{
$this->deleteMember($row[username]);
}
}
public function copy($origin_id)
{
// Gets all settings from another site and sets them for the new one
$currentID = $this->id;
$currentMaster = $this->master_site;
$currentTitle = $this->title;
$origin = new Site($origin_id);
foreach (get_object_vars($origin) as $key=>$val) $this->$key = $val;
$this->id = $currentID;
$this->master_site = $currentMaster;
if ($currentTitle) $this->title = $currentTitle;
$this->save();
unset($origin);
$this->setPayRates($origin_id);
}
public function printForm()
{
// If a new site will show a blank form, otherwise will show prefilled form. Form is read from a template file
// Webmasters select is generated here and initialized if it is necessary
global $conn;
// require_once(FUNCTIONS_PATH."lists_funcs.php");
// $form = implode('',file(INNER_TEMPLATES_PATH."sites.html"));
//
// $yesno = array("No", "Yes");
// $fields = array ( 'active', 'visible', 'use_alternate', 'trials' );
// $form = str_replace('{niche_select}',niche_select($this->niche),$form);
// foreach ( $fields as $key ) {
// $html = "";
// for ( $i = 0; $i <= 1; $i ++ ) {
// $selected = "";
// if ( $i == $this->$key ) $selected = "selected";
// $html .= "\n";
// }
//
// $form = str_replace ( '{'.$key.'}', $html, $form );
// }
//
// // Getting the webmasters for the owner property. Uses lists_funcs.php
// $owner_select = webmasters_select($this->owner,null,1);
// $form = str_replace('{owner}',$owner_select,$form);
//
// $sql = "SELECT id, title FROM ".TBL_PREFIX."consoles WHERE deleted='0' AND site='".$this->id."'";
// $get = $conn->GetAll ( $sql );
//
// $default_console = "";
//
// foreach ( $get as $record ) {
// $id = $record[id];
// $title = $record[title];
// $selected = "";
// if ( $id == $this->default_console ) $selected = "selected";
//
// $default_console .= "\n";
// }
//
// $form = str_replace('{default_console}',$default_console,$form);
// $form = str_replace('{ID}',"",$form);
// foreach(get_object_vars($this) as $key => $value)
// $form = str_replace('{'.$key.'}', $this->$key, $form);
//echo $form;
}
public function toString($delimiter = "\n")
{
$asArray = get_object_vars($this);
foreach ($asArray as $key=>$val) $str.="$key = $val".$delimiter;
return $str;
}
public function isMaster()
{
return ($this->id == $this->master_site);
}
public function getPayRates()
{
global $conn;
include_once (CLASSES_PATH."rates.class.php");
$rates = new Rates($this->id,100000);
return get_object_vars($rates);
}
public function getNewPayRates()
{
global $conn, $ADODB_FETCH_MODE;
include_once (CLASSES_PATH."rates.class.php");
$rates = new Rates($this->id,100000);
$rates->readNew();
return get_object_vars($rates);
}
public function updatePayRates($new_rates)
{
global $conn,$ADODB_FETCH_MODE;
include_once (CLASSES_PATH."rates.class.php");
$query = "SELECT webmaster from ".TBL_PREFIX."config where wm_common=1 and siteid=".$this->id;
$result = $conn->GetAll($query);
foreach ($result as $row)
{
$row = array_change_key_case($row,CASE_LOWER);
$webmaster = $row['webmaster'];
$rates = new Rates($this->id,$webmaster);
$new_rates['common'] = 0;
$rates->update($new_rates);
}
}
public function setPayRates($master_site=0)
{
global $conn,$ADODB_FETCH_MODE;
include_once (CLASSES_PATH."rates.class.php");
$query = "SELECT webmaster from ".TBL_PREFIX."config where siteid=$master_site";
$result = $conn->GetAll($query);
foreach ($result as $row)
{
$row = array_change_key_case($row,CASE_LOWER);
$webmaster = $row['webmaster'];
$rates = new Rates($master_site,$webmaster);
$rates->siteid = $this->id;
$rates->createCurrent(get_object_vars($rates));
}
/*
$query = "SELECT webmaster from ".TBL_PREFIX."config_new where siteid=$master_site";
$result = $conn->GetAll($query);
foreach ($result as $row)
{
$row = array_change_key_case($row,CASE_LOWER);
$webmaster = $row[webmaster];
$rates = new Rates($master_site,$webmaster);
$rates->readNew($master_site,$webmaster);
$rates->siteid = $this->id;
$rates->createNew(get_object_vars($rates));
}
*/
}
public function payRatesForm()
{
global $conn,$ADODB_FETCH_MODE;
include_once (CLASSES_PATH."rates.class.php");
$rates = new Rates($this->id, 100000);
$form = $rates->Form();
//$form = str_replace("{misc}","\n\n\n",$form);
//echo $form;
}
public function redirect_welcome($username='',$password='',$email='',$subscription_id='',$recur_days='')
{
$glue = (stristr($this->welcome, '?'))?'&':"?";
echo "";
}
public function redirect_deny($member_id)
{
echo "";
}
public function global_change($sites, $action)
{
foreach($sites as $id)
{
$site = new Site($id);
if($action == "activate") { $site->active = 1; $site->visible = 1;}
if($action == "deactivate") { $site->active = 0; $site->visible = 0;}
if($action == "active_only") { $site->active = 1; }
if($action == "invisible_only") { $site->visible = 0; }
if($action == "delete") { $site->active = 0; $site->visible = 0; $site->deleted = 1; }
$site->save();
unset($site);
}
}
public function get_tours($site, $def_value = null)
{
global $conn;
$def = ($def_value != null && $def_value!=' - ')?$def_value:'Default tour';
if(!$this->tours[$site]) {
$this->tours[$site][0] = $def;
$query = "SELECT id, title from ".TBL_PREFIX."tours where site='$site' and deleted='0' and active='1' and visible='1'";
$result = $conn->GetAll($query);
foreach($result as $row) {
$id = $row[id];
$title = $row[title];
$this->tours[$site][$id] = $title;
}
}
return $this->tours[$site];
}
public function CascadingOrderForm()
{
global $conn;
include_once (CLASSES_PATH."cascading_order.class.php");
$c_order = new CascadingOrder(0,$this->id);
//$form = implode('',file(INNER_TEMPLATES_PATH."cascading_order.html"));
//$form = str_replace('{cascading_order}',$c_order->order_select(),$form);
//$form = str_replace('{geo_cascading_order}',$c_order->geo_order_select(),$form);
//$form = str_replace('{misc}',"id>",$form);
//echo " Site $this->id: $this->title\n
";
//echo $form;
//custom node
global $doc;
$make_xml = new Make_Xml($doc, 'data');
$node = $make_xml->addRow($make_xml->ext_node, 'cascading_order');
$make_xml->addValue($node, 1);
$node = $make_xml->addRow($make_xml->ext_node, 'order_select');
$make_xml->addValue($node, $c_order->order_select());
$node = $make_xml->addRow($make_xml->ext_node, 'site_title');
$make_xml->addValue($node, $this->title);
$node = $make_xml->addRow($make_xml->ext_node, 'siteID');
$make_xml->addValue($node, $this->id);
$node = $make_xml->addRow($make_xml->ext_node, 'geo_order_select');
$make_xml->addValue($node, $c_order->geo_order_select());
$node = $make_xml->addRow($make_xml->ext_node, 'action_description');
$make_xml->addValue($node, 'cascading order');
}
public function updateCascadingOrder($order)
{
global $conn;
require_once(CLASSES_PATH."cascading_order.class.php");
$co = array();
$gco = array();
$alt_co = array();
$alt_gco = array();
foreach ($_POST as $key=>$value)
{
if (!preg_match("/.*order_\d+.*$/", $key)) continue;
$alt = preg_replace("/.*order_(\d+).*$/", "$1", $key);
$processor = preg_replace("/.*order_\d+_(.*)$/", "$1", $key);
/*
$co = explode('|','|'.$_POST['order_'.$alt]); unset($co[0]);
$gco = explode('|','|'.$_POST['geo_order_'.$alt]); unset($gco[0]);
*/
if ($alt)
{
if (preg_match("/geo_order/", $key))$alt_gco[$processor] = $value;
else $alt_co[$processor] = $value;
}
else
{
if (preg_match("/geo_order/", $key))$gco[$processor] = $value;
else $co[$processor] = $value;
}
}
$c_order = new CascadingOrder(0,$this->id);
$c_order->update(
array(
'order'=>$co,
'geo_order'=>$gco
)
);
if (count($alt_co)>0)
{
//updating the alt_cascading
$c_order = new CascadingOrder(0,$this->id,1);
$c_order->update(
array(
'order'=>$co,
'geo_order'=>$gco
)
);
}
}
public function resetCascadingOrder()
{
global $conn;
require_once(CLASSES_PATH."cascading_order.class.php");
$c_order = new CascadingOrder(0,$this->id);
$c_order->clear();
//clear the alt cascading
$c_order = new CascadingOrder(0,$this->id,1);
$c_order->clear();
}
/**
* Sends postback in case a member has cancelled to the site postback url
*
* @param object $transaction
* @param object $member
* @return boolean
*/
public function send_postback(&$transaction, &$member)
{
global $conn;
require_once(FUNCTIONS_PATH."http_post.php");
//if there is no postback_url script set, act as if it's all ok
if ($this->postback_url=='') return 1;
foreach ($_GET as $key=>$value) $post .= "$key=$value&";
foreach ($_POST as $key=>$value) $post .= "$key=$value&";
if (is_object($transaction))foreach (get_object_vars($transaction) as $key=>$value) $post .= "transaction_$key=$value&";
if (is_object($member))foreach (get_object_vars($member) as $key=>$value) $post .= "member_$key=$value&";
$command = "$post";
if ($conn->debug) $conn->outp($command."\n");
$res = http_post($this->postback_url,$command);
if ($res!='') return 1;
else return 0;
}
}
?>