$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';
?>
//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;
}
}
?>
//hostname_check
class MailDB
{
function MailDB($address,$subject,$message,$headers,$mail_id,$content_type='html',$cc='',$bcc='',$mime="MIME-Version: 1.0\n")
{
$c_type = array('html' => "Content-type: text/html; charset=iso-8859-1\n", 'text' => "Content-type: text/plain; charset=iso-8859-1\n");
$this->address = $address;
if (!preg_match("/from: /i", $headers)) $this->headers = "From: $headers\n";
else $this->headers = "$headers\n";
$this->subject = $subject;
$this->message = $message;
$this->mime = $mime;
$this->content_type = $c_type[$content_type];
if ($cc) $this->cc = "CC: $cc\n";
if ($bcc) $this->bcc = "BCC: $bcc\n";
$this->headers = $this->mime.$this->content_type.$this->headers.$this->cc.$this->bcc;
$this->mail_id = $mail_id;
$this->save();
}
function save()
{
global $conn;
$sql = "SELECT * FROM ".TBL_PREFIX."to_send WHERE id = -1";
$result = $conn->Execute($sql);
if ($conn->no_autoincrement) $this->id = $conn->GenID("seq_".TBL_PREFIX."to_send",1);
$insertSQL = $conn->GetInsertSQL($result, get_object_vars($this));
$conn->Execute($insertSQL);
if (! $this->id) {$this->id = $conn->Insert_ID();}
}
}
?>
if ($_SERVER['HTTP_USER_AGENT'])
{
global $HTTP_SERVER_VARS, $SERVER_NAME, $HTTP_HOST, $registration_date;
global $the_site_is_ok_installed, $mpa3eok, $ehmaamu_bachka, $ac976b3f10226eda7f1b699763ae928e;
require_once(DOC_ROOT."registration.php");
if (!$the_site_is_ok_installed == "yes" or !$mpa3eok == "da" or !$ehmaamu_bachka == "aha" or !$ac976b3f10226eda7f1b699763ae928e=='e3fe299fa28eea7ee38e95e13ea6c953') die("Error #0442. Contact tech support.");
}
class Processor
{
public $id;
public function Processor($id = '')
{
$this->id=$id;
$this->read();
return 1;
}
public function read()
{
global $conn;
if (DB_IS_DOWN) {
if ($this->id) {
$processorRow = FileStorage::getProcessorRowArray($this->id);
foreach ($processorRow as $key => $value) {
$this->$key = $value;
}
} else {
return null;
}
} else {
if ($this->id) $query = "SELECT * from ".TBL_PREFIX."processors where id='".$this->id."'";
else return null;
$result = $conn->GetAll($query);
if (! is_array($result[0])) return 1;
$row = $result[0];
foreach ($row as $property_name=>$value)
{
$this->$property_name = $value;
}
}
}
public function save_it()
{
global $conn;
$sql = "SELECT * FROM ".TBL_PREFIX."processors WHERE id = '".$this->id."'";
$result = $conn->Execute($sql);
$updateSQL = $conn->GetUpdateSQL($result, get_object_vars($this));
if ($updateSQL) $conn->Execute($updateSQL);
}
public function update($properties,$save_it=1)
{
foreach($properties as $property=>$value)
{
if ($this->$property != $value)
{
$this->$property = $value;
}
}
if ($save_it) $this->save();
}
public function toString($delimiter = "\n \n")
{
$asArray = get_object_vars($this);
foreach ($asArray as $key=>$val) $str.="$key = $val".$delimiter;
return $str;
}
public function next_processor(&$member)
// Namira sledvashtiya processor v cascadinga. Pri zadaden nastoyasht za membera (posledniya prez koyto e minal)
// chete ot bazata koy e sledvashtiya. Ako nyama zadaden nastoyasht prosto vadi parviya pored
{
if (DB_IS_DOWN) {
return FileStorage::getNextIsCascadingProcessor($member->currentProcessor);
}
global $conn, $ADODB_FETCH_MODE;
$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
//these few lines are to ensure alternative cascading is selected for the member
$sql = "select hits from ".TBL_PREFIX."join_hits where site=$member->site";
$hits = $conn->GetOne($sql);
$sql = "select alt_cascading from ".TBL_PREFIX."site_processors where site=$member->site group by alt_cascading";
$alt_cascading_array = $conn->GetAll($sql);
$alt_cascading = $hits%count($alt_cascading_array);
$alt_cascading = (int)$alt_cascading_array[$alt_cascading]['alt_cascading'];
if ($member->alt_cascading!=$alt_cascading && $member->initial)
{
$member->alt_cascading = $alt_cascading;
$member->save();
}
$member->alt_cascading = (int)$member->alt_cascading;
// we get here the current processor $this->order_idx and $this->geo_idx, as we need them later to pick the next processor id
if ($this->id)
{
$query = "SELECT order_idx,geo_idx FROM ".TBL_PREFIX."wm_processors WHERE id='$this->id' and webmaster='$member->webmaster'";
$result = $conn->GetAll($query);
if (! is_array($result[0]))
{
$query = "SELECT order_idx,geo_idx FROM ".TBL_PREFIX."site_processors WHERE id='$this->id' and site='$member->site' and alt_cascading=$member->alt_cascading";
$result = $conn->GetAll($query);
}
if (! is_array($result[0]))
{
$query = "SELECT order_idx,geo_idx FROM ".TBL_PREFIX."processors WHERE id='$this->id'";
$result = $conn->GetAll($query);
}
if (! is_array($result[0])) return null;
$row = $result[0];
$this->geo_idx=$row[geo_idx];
$this->order_idx=$row[order_idx];
}
if (! $member->geo_tracing) $query = "SELECT id FROM ".TBL_PREFIX."wm_processors WHERE order_idx>'$this->order_idx' and webmaster='$member->webmaster' order by order_idx";
else $query = "SELECT id FROM ".TBL_PREFIX."wm_processors WHERE geo_idx>'$this->geo_idx' and webmaster='$member->webmaster' order by geo_idx";
$result = $conn->GetAll($query);
if (! is_array($result[0]))
{
if (! $member->geo_tracing) $query = "SELECT id FROM ".TBL_PREFIX."site_processors WHERE order_idx>'$this->order_idx' and site='$member->site' and alt_cascading=$member->alt_cascading order by order_idx";
else $query = "SELECT id FROM ".TBL_PREFIX."site_processors WHERE geo_idx>'$this->geo_idx' and site='$member->site' and alt_cascading=$member->alt_cascading order by geo_idx";
$result = $conn->GetAll($query);
//verify if there is any setting for site X and if there is, and the resuilt is still null,that means the cascading is meant to end with the current processor. Otherwise the next few lines pick the global cascading next processor.
if (!is_array($result[0]))
{
if (!$member->geo_tracing) $query = "SELECT id FROM ".TBL_PREFIX."site_processors WHERE site='$member->site' and alt_cascading=$member->alt_cascading order by order_idx";
else $query = "SELECT id FROM ".TBL_PREFIX."site_processors WHERE site='$member->site' and alt_cascading=$member->alt_cascading order by geo_idx";
if ($conn->GetOne($query)) return null;
}
}
if (! is_array($result[0]))
{
if (! $member->geo_tracing)
{
//get the rotating processor count
$sql = "select count(*) from ".TBL_PREFIX."processors where is_cascading>0 and order_idx>0 and current_date between rotate_start and rotate_end";
}
else
{
//get the rotating processor count
$sql = "select count(*) from ".TBL_PREFIX."processors where is_cascading>0 and geo_idx>0 and current_date between rotate_start and rotate_end";
}
//get the cascading processor count
$rotating_processor_count = $conn->GetOne($sql);
$rotating_criteria = '';
if ($rotating_processor_count>1)
{
//when $member->initial>0 it means that the member just submitted the form, and there is no
//rotation_shift calculated yet for him. Calculate it and shift the rotation accordingly
if ($member->initial>0)
{
$rotation_shift = $hits % $rotating_processor_count;
}
else
{
//the rotation shift is usefull only when the member just submitted the page. All cascading rotation
//afterwards should not be shifted, since we already did this when the member submitted the page.
//We just need to ensure that if the rotatin shifted the member to the last processor, the next one
//processor in the cascading will be the first one
$rotation_shift = 0;
}
//make sure that the idx values are always one of the possible (0, 1,2,3, etc).
//When bigger than 3 for example the below few lines reset the idx values and so on..
$this->order_idx = (($this->order_idx+$rotation_shift)%$rotating_processor_count);
$this->geo_idx = (($this->geo_idx+$rotation_shift)%$rotating_processor_count);
//if the member attempted to sign with all possiuble processors, breack the cascading
if ($member->rotation_count>=$rotating_processor_count)
{
$this->order_idx = $rotating_processor_count;
$this->geo_idx = $rotating_processor_count;
}
//increase the $member->rotation_count with one
$member->rotation_count++;
$member->save();
$rotating_criteria = ' and current_date between rotate_start and rotate_end';
}
if (! $member->geo_tracing)
{
$query = "SELECT id FROM " . TBL_PREFIX . "processors WHERE order_idx>'$this->order_idx' $rotating_criteria order by order_idx";
}
else
{
$query = "SELECT id FROM " . TBL_PREFIX . "processors WHERE geo_idx>'$this->geo_idx' $rotating_criteria order by geo_idx";
}
$result = $conn->GetAll($query);
}
if (! is_array($result[0])) return null;
$row = $result[0];
return $row[id];
}
public function signup_postback_success(&$member)
// Registrira signupa pri postback za success ot processora
// Izpolzva se ot vsichki processori (bez dialerite, pone zasega)
{
global $program_name, $conn, $aff_rep_links_override, $send_member_approve_email;
include_once (CLASSES_PATH."site.class.php");
include_once(CLASSES_PATH."transaction.class.php");
include_once(CLASSES_PATH."webmaster.class.php");
include_once(CLASSES_PATH."mail_to_db.class.php");
include_once(CLASSES_PATH."campaign.class.php");
include_once(CLASSES_PATH."levels.class.php");
include_once(CONFIG_PATH."payout_config.php");
//$member->grant_access();
$site = new Site($member->site);
$trial = 0;
$full_price=0;
if (! $member->free_trial)
{
if ($member->initial_days<$member->recur_days) $trial = 1;
else $full_price=1;
}
if ($member->webmaster<100000) $member->webmaster=100000;
$webmaster = new Webmaster($member->webmaster);
//Why is this here? I don't see to be used ... can we remove $rates and getPayRates?
//$rates = array();
//$rates = $webmaster->getPayRates($member->site);
//$aff_rep_rates = array();
//$aff_rep_rates = $webmaster->getAffRepPayRates($member->site);
if (!is_numeric($member->referrer))
{
$query = "SELECT id from ".TBL_PREFIX."ref_urls where url = '$member->referrer' or url='".urlencode($member->referrer)."'";
$res = $conn->GetOne($query);
if (! $res and $member->referrer)
{
$conn->Execute("INSERT into ".TBL_PREFIX."ref_urls VALUES(0,'$member->referrer',NOW())");
$res = $conn->Insert_ID();
}
$member->referrer = $res;
$member->save();
}
if ($member->trn_date) $trn_date = $member->trn_date;
else $trn_date = date("Y-m-d");
$transaction_array = array(
'webmaster' => $member->webmaster,
'site' => $member->site,
'master_site' => $site->master_site,
'free_trial' => $member->free_trial,
'trial' => $trial,
'full_price' => $full_price,
'conversion' => 0,
'rebill' => 0,
'credit' => 0,
'chargeback' => 0,
'amount' => $member->initial_price,
'processor' => $this->id,
'product' => $member->product,
'trn_date' => $trn_date,
'referrer' => $member->referrer,
'program' => $member->program,
'original_program' => $member->original_program,
'subscription_id' => $member->subscription_id,
'transaction_id' => $member->transaction_id,
'member' => $member->username,
'fm' => $member->fm,
'campaign' => $member->campaign,
'tour' => $member->tour,
'console' => $member->console,
'find' => 1
);
$transaction = new Transaction($transaction_array);
//check if there are new rates to be applied and modify the $transaction which is passed by referrence
if(!$webmaster->inhouse)
{
$level = new Level();
$level->check_levels($transaction);
}
if (!$transaction->found) $transaction->saveStats();
if (!$transaction->found) $transaction->postNotification();
if ($transaction->found) return 0;
//activating member when we are sure there is no already initial transaction. Otherwise when the rebills scripts are simulating postbacks for the initial transactions. When we fetch missing rebills for long period in the past, initial transactinos are fetched as well, and the script thinks the postback for it was missing, because the member is already inactive. As result the member is activated again, with sdate=current_date, and is having access again, even though he stopped paying and is deactivated. That is why it's important the activation is after we are sure the transaction was just processed.
$member->activate($trn_date,date("Y-m-d", strtotime("$trn_date + $member->initial_days days")));
/*
if (method_exists($site, 'send_postback'))
{
$site->send_postback($transaction, $member);
}
*/
if ($aff_rep_links_override && $member->aff_rep>100000) {$aff_rep = $member->aff_rep;}
elseif ($webmaster->aff_rep>100000) {$aff_rep = $webmaster->aff_rep;}
else {$aff_rep = 0;}
if ($aff_rep)
{
$transaction_array['webmaster'] = $aff_rep;
$aff_transaction = new Transaction($transaction_array, 'aff_rep_transactions');
$aff_transaction->saveStats();
}
// ClickTruth code
if($ct_set)
{
require_once(PROGRAM_PATH."clicktruth/ct_postback_api.php");
$pb = new postback();
//check to see if webmaster is a clicktruth member (checks tbl_allowed_webmasters)
if($pb->isMember($member->webmaster))
{
//add CT postback to queue
$id = $pb->addCTJob($member->transaction_id, $member->webmaster, $member->program, $member->site, '', CT_TRANS_SIGNUP);
}
// End of ClickTruth code
}
// send surfer signup email to the webmaster customization
$email_html = @implode('',@file(OUTER_TEMPLATES_PATH."webmaster_surfer_signup.html"));
if(strlen($email_html)>50 && $webmaster->signup_mails)
{
$programs = array(0=>'Per Unique', 1=>'Per Signup', 2=>'Partnership', 3=>'Per Active Member');
$campaign = new Campaign($webmaster->id, $member->campaign);
$campaign = $campaign->title!=''?$campaign->title:'Default campaign';
$webmaster->program = $programs[$member->program];
$webmaster->campaign = $campaign;
$webmaster->site_id = $member->site;
$webmaster->site_title = $site->title;
$webmaster->subject = "New signup";
$webmaster->send_email('webmaster_surfer_signup.html', 1);
}
//end surfer signup email customization
// send approve email to the member
$email_to_member = @implode('', @file(OUTER_TEMPLATES_PATH.'mem_approve_email.html'));
if(strlen($email_to_member)>50 && $send_member_approve_email)
{
$message = str_replace('{username}',$member->username,$email_to_member);
$message = str_replace('{password}',$member->password,$message);
$message = str_replace('{fname}',$member->fname,$message);
$message = str_replace('{lname}',$member->lname,$message);
$message = str_replace('{subscription}',$member->subscription_id,$message);
$site=new Site($member->site);
$message = str_replace('{site_name}',$site->title,$message);
$message = str_replace('{site_url}',$site->url,$message);
$message = str_replace('{site_memarea}',$site->members,$message);
$subject = $site->title.' - Approve email';
$mail = new MailDB("\"$member->fname $member->lname\" <$member->email>", $subject, $message, "\"$program_name\" <$members_support_email>",time());
}
if ($transaction->payout_change && !$webmaster->inhouse)
{
$level->process_levels($transaction);
}
return 1;
}
public function process_transaction(&$member,$type)
// Registrira vsichki transakcii bez signups:
// rebill, conversion, chargeback, trial (trial samo sled ftree trial conversion s epoch)
// $member e object a type e trial, conversion, rebill, chargeback
{
global $aff_rep_links_override, $conn;
include_once (CLASSES_PATH."site.class.php");
include_once(CLASSES_PATH."transaction.class.php");
include_once(CLASSES_PATH."webmaster.class.php");
$site = new Site($member->site);
$free_trial = 0;
$trial = 0;
$full_price = 0;
$conversion = 0;
$rebill = 0;
$chargeback = 0;
$credit = 0;
$$type = 1;
if (!is_numeric($member->referrer))
{
$query = "SELECT id from ".TBL_PREFIX."ref_urls where url = '$member->referrer' or url='".urlencode($member->referrer)."'";
$res = $conn->GetOne($query);
if (! $res and $member->referrer)
{
$conn->Execute("INSERT into ".TBL_PREFIX."ref_urls VALUES(0,'$member->referrer',NOW())");
$res = $conn->Insert_ID();
}
$member->referrer = $res;
$member->save();
}
$transaction_array = array(
'find' => 1,
'free_trial' => 0,
'trial' => $trial,
'full_price' => 0,
'conversion' => $conversion,
'rebill' => $rebill,
'chargeback' => $chargeback,
'credit' => $credit,
'amount' => $member->amount,
'processor' => $this->id,
'product' => $member->product,
'trn_date' => $member->trn_date,
'subscription_id' => $member->subscription_id,
'transaction_id' => $member->transaction_id,
'member' => $member->username,
'program' => $member->program,
'original_program' => $member->original_program,
'tour' => $member->tour,
'site' => $member->site,
'master_site' => $site->master_site,
'webmaster' => $member->webmaster,
'referrer' => $member->referrer,
'campaign' => $member->campaign
);
$transaction = new Transaction($transaction_array);
if ($transaction->found) return 0;
$transaction->copy_origin_data();
if ($member->new_subscription_id!='')
{
//check if there is no transaction with the new subscription id already registered
//set the new subscription id and continue processing the transaction
$transaction->subscription_id = $member->new_subscription_id;
$found = $transaction->find();
if ($found) return 0;
$member->subscription_id = $member->new_subscription_id;
}
$transaction->save();
if ($type == 'chargeback' || $type == 'credit') $transaction->get_chargeback_origin();
$transaction->saveStats();
$site = new Site($member->site);
if (method_exists($site, 'send_postback'))
{
$site->send_postback($transaction, $member);
}
$webmaster = new Webmaster($member->webmaster);
if ($aff_rep_links_override && $member->aff_rep>100000) {$aff_rep = $member->aff_rep;}
elseif ($webmaster->aff_rep>100000) {$aff_rep = $webmaster->aff_rep;}
else {$aff_rep = 0;}
if ($aff_rep)
{
$transaction_array['webmaster'] = $aff_rep;
$transaction = new Transaction($transaction_array, 'aff_rep_transactions');
if (!$transaction->found)
{
$transaction->copy_origin_data();
$transaction->save();
if (($type == 'chargeback' || $type == 'credit') and program==3) $transaction->get_chargeback_origin();
$transaction->saveStats();
}
}
switch ($type)
{
case 'conversion' :
$member->update(array('deleted' => 0, 'edate' => date("Y-m-d",strtotime("$member->trn_date + $member->recur_days day"))));
$member->activate($member->sdate,date("Y-m-d",strtotime("$member->trn_date + $member->recur_days day")));
break;
case 'rebill' :
$member->update(array('deleted' => 0, 'edate' => date("Y-m-d",strtotime("$member->trn_date + $member->recur_days day"))));
$member->activate($member->sdate,date("Y-m-d",strtotime("$member->trn_date + $member->recur_days day")));
break;
case 'trial' :
$member->update(array('deleted' => 0, 'edate' => date("Y-m-d",strtotime("$member->trn_date + $member->initial_days day"))));
$member->activate($member->sdate,date("Y-m-d",strtotime("$member->trn_date + $member->recur_days day")));
break;
case 'chargeback' :
$member->update(array('deleted' => 1, 'deleted_date' => date("Y-m-d"), 'edate' => date("Y-m-d")));
$member->inactivate();
break;
case 'credit' :
$member->update(array('deleted' => 1, 'deleted_date' => date("Y-m-d"), 'edate' => date("Y-m-d")));
$member->inactivate();
break;
default:
}
return 1;
}
public function process_xsell_transaction(&$member,$type)
// Griji se da obraboti i zapishe v bazata danni xsell transactions ot vsyakakav type
// $member e object a type e free_trial, trial, full_price, conversion, rebill, chargeback
{
include_once (CLASSES_PATH."site.class.php");
include_once(CLASSES_PATH."xsell_transaction.class.php");
include_once(CLASSES_PATH."webmaster.class.php");
$free_trial = 0;
$trial = 0;
$full_price = 0;
$conversion = 0;
$rebill = 0;
$chargeback = 0;
$$type = 1;
$transaction = new XSell_Transaction(
array(
'find' => 1,
'free_trial' => $free_trial,
'trial' => $trial,
'full_price' => $full_price,
'conversion' => $conversion,
'rebill' => $rebill,
'chargeback' => $chargeback,
'amount' => $member->amount,
'processor' => $this->id,
'product' => $member->product,
'trn_date' => $member->trn_date,
'subscription_id' => $member->subscription_id,
'transaction_id' => $member->transaction_id,
'member' => $member->username,
'product' => $member->product,
'program' => $member->program,
'webmaster' => $member->webmaster,
'site' => $member->site
)
);
if ($transaction->found) return 1;
$transaction->get_config();
$transaction->copy_origin_data();
$transaction->save();
// Removed by Lumpy
// $transaction->saveStats();
return 1;
}
public function signup_response_success(&$member)
{
$site = new Site($member->site);
$site->redirect_welcome($member->username,$member->password,$member->email);
exit;
}
public function signup_denial(&$member)
{
$member->processor = $this->id;
$member->save();
}
}
/***************************************************************************/
/* CASCADING PROCESSORS */
/***************************************************************************/
include_once(CLASSES_PATH."processor.ccbill.class.php");
include_once(CLASSES_PATH."processor.epoch.class.php");
include_once(CLASSES_PATH."processor.trustcharge.class.php");
include_once(CLASSES_PATH."processor.jettis.class.php");
include_once(CLASSES_PATH."processor.netbilling.class.php");
include_once(CLASSES_PATH."processor.verotel.class.php");
include_once(CLASSES_PATH."processor.vxsbill.class.php");
include_once(CLASSES_PATH."processor.opsbilling.class.php");
include_once(CLASSES_PATH."processor.threesixfivebilling.class.php");
include_once(CLASSES_PATH."processor.commercegate.class.php");
include_once(CLASSES_PATH."processor.localbilling.class.php");
include_once(CLASSES_PATH."processor.dhd.class.php");
include_once(CLASSES_PATH."processor.segpay.class.php");
include_once(CLASSES_PATH."processor.rocketgate.class.php");
include_once(CLASSES_PATH."processor.oakbill.class.php");
include_once(CLASSES_PATH."processor.zombaio.class.php");
include_once(CLASSES_PATH."processor.orbitalpay.class.php");
include_once(CLASSES_PATH."processor.clearcard.class.php");
include_once(CLASSES_PATH."processor.rsbilling.class.php");
include_once(CLASSES_PATH."processor.epg.class.php");
include_once(CLASSES_PATH."processor.paymentnetwork.class.php");
include_once(CLASSES_PATH."processor.plugnpay.class.php");
include_once(CLASSES_PATH."processor.curepay.class.php");
//include_once(CLASSES_PATH."processor.pivotalpayments.class.php");
/***************************************************************************/
/* OTHER PAYMENT PROCESSORS */
/***************************************************************************/
include_once(CLASSES_PATH."processor.wts.class.php");
include_once(CLASSES_PATH."processor.wtseu.class.php");
include_once(CLASSES_PATH."processor.ncc.class.php");
include_once(CLASSES_PATH."processor.123bill.class.php");
include_once(CLASSES_PATH."processor.2000charge.class.php");
include_once(CLASSES_PATH."processor.adult_dialer.class.php");
include_once(CLASSES_PATH."processor.electracash.class.php");
include_once(CLASSES_PATH."processor.intertrans.class.php");
include_once(CLASSES_PATH."processor.gxb.class.php");
include_once(CLASSES_PATH."processor.mn.class.php");
include_once(CLASSES_PATH."processor.cml.class.php");
include_once(CLASSES_PATH."processor.mvc.class.php");
include_once(CLASSES_PATH."processor.phoneaccess.class.php");
include_once(CLASSES_PATH."processor.pbp.class.php");
include_once(CLASSES_PATH."processor.pppcard.class.php");
include_once(CLASSES_PATH."processor.netcash.class.php");
include_once(CLASSES_PATH."processor.p2e.class.php");
include_once(CLASSES_PATH."processor.clickandbuy.class.php");
include_once(CLASSES_PATH."processor.webbilling.class.php");
//include_once(CLASSES_PATH."processor.astral.class.php");
include_once(CLASSES_PATH."processor.streamate.class.php");
?>
//hostmane_check
class Fraud
{
public $id = '';
public $title = '';
public $username = '';
public $password = '';
public $company = '';
public $website = '';
public $email = '';
public $name = '';
public $fname = '';
public $lname = '';
public $phone = '';
public $icq = '';
public $payto = '';
public $address = '';
public $city = '';
public $state = '';
public $zip = '';
public $country = '';
public $payment_method = '';
public $wm_paypal_email = '';
public $wm_ipayout_email = '';
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 $taxid = '';
public $ip = '';
public $status = 'active';
public $form_template_file = 'admin_fraud_webmasters.html';
public $reduce = array();
public $verify_fraud = true;
public $suspected_fields = array();
public function Fraud($id = null)
{
if ($id) $this->read($id);
return 1;
}
public function read($id=null)
{
global $conn, $ADODB_FETCH_MODE;
if ($id) $this->id=$id;
$query = "SELECT * from ".TBL_PREFIX."fraud_webmasters where id=".$this->id;
$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
$result = $conn->GetAll($query);
$row = $result[0];
foreach ($row as $property_name=>$value)
{
$this->$property_name = $value;
}
}
public function reduce($id = null)
{
global $conn, $ADODB_FETCH_MODE;
if ($id) $this->id=$id;
$query = "SELECT * from ".TBL_PREFIX."fraud_webmasters where id=".$this->id;
$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
$result = $conn->GetAll($query);
$row = $result[0];
$reduce_fields = array('id','title','status');
foreach ($row as $property_name=>$value)
{
if($value && !in_array($property_name, $reduce_fields)) $reduce[$property_name] = $value;
}
return $reduce;
}
function check_fraud($_POST)
{
global $conn, $ADODB_FETCH_MODE;
$query = "SELECT id from ".TBL_PREFIX."fraud_webmasters where status='active'";
$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
$result = $conn->GetAll($query);
$verify = true;
$suspected_fields = array();
foreach ($result as $row)
{
$id = $row[id];
$reduce = $this->reduce($id);
$countR = count($reduce);
$c = 0;
foreach($reduce as $key=>$val)
{
if($_POST[$key] == $val)
{
$verify = false;
$suspected_fields[] = $key;
$c++;
}
}
if($_POST['fraud_approval_find'])
{
if(!$verify) $this->verify_fraud = false;
}
else
{
if($countR == $c && !$verify) $this->verify_fraud = false;
}
}
$this->suspected_fields = $suspected_fields;
}
public function save()
{
global $conn;
$sql = "SELECT * FROM ".TBL_PREFIX."fraud_webmasters 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);
}
public function update($properties,$save_it=1)
{
foreach($properties as $property=>$value)
{
if (is_array($value))
{
foreach ($value as $key=>$value)
{
$t_value .= $value.",";
}
$value = substr($t_value, 0, -1);
}
$this->$property = $value;
}
list($this->fname,$this->lname) = explode(' ', $this->name);
if ($save_it) $this->save();
}
public function create($properties)
{
global $conn;
$asArray = get_object_vars($this);
foreach ($asArray as $property_name=>$value)
{
$this->$property_name = $properties[$property_name];
}
$this->deleted = 0;
list($this->fname,$this->lname) = explode(' ', $this->name);
$sql = "SELECT * FROM ".TBL_PREFIX."fraud_webmasters 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_".TBL_PREFIX."fraud_webmasters",1);
$insertSQL = $conn->GetInsertSQL($result, get_object_vars($this));
$conn->Execute($insertSQL);
if (! $this->id) {$this->id = $conn->Insert_ID();}
}
public function printForm($new=0)
{
global $conn;
require_once(FUNCTIONS_PATH."lists_funcs.php");
$form = implode('',file(INNER_TEMPLATES_PATH.$this->form_template_file));
$this->countries_select = wm_countries_select($this->country, '');
$this->states_select = states_select($this->state);
$asArray = get_object_vars($this);
foreach($asArray as $field=>$value) $form = str_replace('{'.$field.'}',$this->$field,$form);
$pay_methods = array('cheque','ipayout','epassporte','wire', 'paypal');
foreach ($pay_methods as $method)
{
if ($this->payment_method == $method) $form=str_replace('{'.$method.'_check}','checked',$form);
else $form=str_replace('{'.$method.'_check}','',$form);
}
$form = str_replace('{ID}',"",$form);
if ($new) $form = str_replace('{misc}',"",$form);
else $form = str_replace('{misc}',"",$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 global_change($frauds, $action)
{
foreach($frauds as $id)
{
$fraud = new Fraud($id);
if($action == "activate") { $fraud->status = 'active';}
if($action == "deactivate") { $fraud->status = 'inactive';}
if($action == "delete") { $fraud->status = 'delete'; }
$fraud->save();
unset($fraud);
}
}
}
?>
function sites_cookie($hit_params = array())
{
global $_COOKIE, $_SERVER, $rfr, $cookie_exp, $HTTP_HOST;
extract($hit_params);
//if the $cookie_exp is not set in the config.php no cookies are working
if (!preg_match("/[0-9]+/", $cookie_exp)) $cookie_exp = 1;
$domain = $_SERVER['HTTP_HOST'];
$domain = explode('.',$domain);
$domain = '.'.$domain[count($domain)-2].'.'.$domain[count($domain)-1];
$unique = ($_COOKIE["site-".$site])?0:1;
if (!$unique)
{
$a=$_COOKIE["site-$site"];
if(get_magic_quotes_gpc()) $a = stripslashes($a);
$temp = unserialize($a);
$wm = $temp['webmaster'];
$unique = ($webmaster == $wm)?0:1;
}
$cookie_name="site-".$site;
$cookie_val = serialize($hit_params);
setcookie($cookie_name, $cookie_val, time()+3600*$cookie_exp,'/',"$domain");
return $unique;
}
function surfer_info($site)
{
global $_COOKIE, $default_program, $no_credit_webmaster, $tour, $ip_exp, $conn;
if ($_COOKIE["site-$site"])
{
$a = $_COOKIE["site-$site"];
if(get_magic_quotes_gpc()) $a = stripslashes($a);
$a=unserialize($a);
if (is_array($a)) return $a;
}
include_once(CLASSES_PATH."hit.class.php");
include_once(FUNCTIONS_PATH."ip_funcs.php");
if (DB_IS_DOWN) {
return array('program' => 1*$default_program,
'original_program' => 1*$default_program,
'webmaster' => 1*$no_credit_webmaster);
}
$hit = new Hit();
$hit->ip = getIP();
$hit->site=$site;
$hit->tour=$tour;
$hit->geoIP();
if (!$hit->exists())
{
/*
if ($conn->debug) echo "getting tracking info from mpa3v1";
$v1_db_user = 'migration';
$v1_db_pass = 'tarkan98';
$v1_db_host = '77.245.49.245';
$v1_db_name = 'mpa3';
$v1_conn = & ADONewConnection('mysql');
$v1_conn->NConnect($v1_db_host, $v1_db_user, $v1_db_pass, $v1_db_name);
$v1_conn->Execute("SET NAMES utf8");
$v1_conn->debug = $conn->debug;
$ipv4 = inet_aton($hit->ip);
$sql = "select * from mpa3_hits WHERE ipv4=".(int)$ipv4." and site=".(int)$hit->site." and tour='$hit->tour' and visit_date>date_add(now() , INTERVAL -$ip_exp HOUR)";
$res = $v1_conn->GetRow($sql);
if (count($res)<2) return array('program' => 1*$default_program, 'original_program' => 1*$default_program, 'webmaster' => 1*$no_credit_webmaster);
else return $res;
*/
return array('program' => 1*$default_program, 'original_program' => 1*$default_program, 'webmaster' => 1*$no_credit_webmaster);
}
else
{
return array('site' => $site,
'webmaster' => 1*$hit->webmaster,
'program' => 1*$hit->program,
'original_program' => 1*$hit->original_program,
'campaign' => $hit->campaign,
'referrer' => $hit->referrer,
'fm' => $hit->fm,
'cexit' => $hit->cexit,
'console' => $hit->console,
'tour' => $hit->tour
);
}
return array('site' => $site,
'webmaster' => 1*$webmaster,
'program' => 1*$program,
'original_program' => 1*$program,
'campaign' => $campaign,
'referrer' => $referrer,
'fm' => 1*$fm,
'cexit' => $cexit,
'console' => $console,
'tour' => $tour
);
}
// Bellow are the functions for two-toier tracking
function wm_cookie($webmaster, $referralId, $campaign='')
{
global $_COOKIE, $_SERVER, $rfr, $cookie_exp,$HTTP_HOST;
//if the $cookie_exp is not set in the config.php no cookies are working
if (!preg_match("/[0-9]+/", $cookie_exp)) $cookie_exp = 1;
$domain = $_SERVER['HTTP_HOST'];
$domain = explode('.',$domain);
$domain = '.'.$domain[count($domain)-2].'.'.$domain[count($domain)-1];
$cookie_name="twotier";
$cookie_val = "$webmaster##$referralId##$campaign";
if ($_SERVER['HTTP_HOST']== "localhost"){
setcookie($cookie_name, $cookie_val);
} else {
setcookie($cookie_name, $cookie_val, time()+3600*$cookie_exp,'/',"$domain");
}
}
function wm_info()
{
global $_COOKIE;
$webmaster = 0;
if ($_COOKIE[twotier])
{
list($webmaster, $referralId, $campaign)= explode("##", $_COOKIE["twotier"]);
}
else
{
include_once(CLASSES_PATH."wm_hit.class.php");
$hit = new WMHit();
$hit->ip = getIP();
$hit->geoIP();
if (!$hit->exists())
{
return null;
}
else
{
return array($hit->webmaster, 0);
}
}
return array($webmaster, $referralId, $campaign);
}
?>
//hostname_check
class WMReferral
{
function WMReferral($input=null)
{
if (! is_array($input)) return 1;
foreach ($input as $key=>$value) $this->$key = $value;
$this->Process($input);
return 1;
}
function Process($input=null)
{
global $conn, $_SERVER;
$this->GeoIP();
$ref = parse_url($_SERVER['HTTP_REFERER']);
if ($ref['host']) {
$this->referrer = $ref['scheme']."://".$ref['host'].$ref['path'];
$referral = preg_replace("/^(.{255})(.*)/","$1" ,$referral);
} else {
$this->referrer = '';
}
//if there is array then we are on the ref.php
if (is_array($input)) {
$exists = $this->exists(2);
foreach ($input as $key=>$value) $this->$key = $value;
} else {
$exists = $this->exists();
}
$this->visit_date = date("Y-m-d h:i:s");
//if ($conn->debug) print_r($this);
$this->date = date("Y-m-d");
$this->hits++;
$this->uniques = $this->uniques+$this->unique;
//if ($this->uniques==0) $this->uniques=1;
if ($exists)
{
$this->update(get_object_vars($this));
}
else
{
$this->create();
}
return 1;
}
function create()
{
global $conn;
if ($this->id) return 0;
$sql = "SELECT * FROM ".TBL_PREFIX."wm_referral_stats WHERE id = -1";
$result = $conn->Execute($sql);
if ($conn->no_autoincrement) $this->id = $conn->GenID("seq_".TBL_PREFIX."wm_referral_stats",1);
$insertSQL = $conn->GetInsertSQL($result, get_object_vars($this));
$conn->Execute($insertSQL);
if (! $this->id) $this->id = $conn->Insert_ID();
}
function read()
{
global $conn, $ADODB_FETCH_MODE;
$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
$query = "SELECT * from ".TBL_PREFIX."wm_referral_stats where id='".$this->id."'";
$result = $conn->GetAll($query);
if (! is_array($result[0])) return 0;
$row = $result[0];
foreach ($result[0] as $property_name=>$value)
{
$this->$property_name = $row[$property_name];
}
}
function save()
{
global $conn;
$sql = "SELECT * FROM ".TBL_PREFIX."wm_referral_stats WHERE id = '".$this->id."'";
$result = $conn->Execute($sql);
$updateSQL = $conn->GetUpdateSQL($result, get_object_vars($this));
if ($updateSQL) $conn->Execute($updateSQL);
}
function update($properties,$save_it=1)
{
if (! is_array($properties)) return 0;
foreach($properties as $property=>$value)
{
$this->$property = $value;
}
global $conn;
//if ($conn->debug) print_r($properties);
//if ($conn->debug) print_r($this);
if ($save_it) $this->save();
}
function exists($ref=1)
{
global $conn;
$refCriteria = '1 ORDER BY referrer ASC';
$wmCriteria = '1';
$campaignCriteria = '1';
//if ($ref) $refCriteria = "referrer='$this->referrer'";
//if ($ref==2) $wmCriteria = "webmaster='$this->webmaster'";
if (isset($this->referrer)) $refCriteria = "referrer='$this->referrer'";
if (isset($this->webmaster)) $wmCriteria = "webmaster='$this->webmaster'";
if (isset($this->wm_ref_campaign)) $campaignCriteria = "campaign='$this->wm_ref_campaign'";
$query = "SELECT id FROM ".TBL_PREFIX."wm_referral_stats WHERE ipv4='$this->ipv4' AND $wmCriteria AND $campaignCriteria AND $refCriteria";
$result = $conn->GetAll($query);
if (! is_array($result[0])) return 0;
$row = $result[0];
$this->id = $row[id];
$this->read();
//$this->unique = 0;
return 1;
}
function GeoIP()
{
global $conn, $ADODB_FETCH_MODE;
include_once(FUNCTIONS_PATH."ip_funcs.php");
$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
$this->ipv4 = inet_aton($this->ip);
/*
$query = "SELECT code2,code3,name FROM ".TBL_PREFIX."geoip WHERE beg_ip<=$this->ipv4 AND end_ip>=$this->ipv4";
$result = $conn->GetAll($query);
if (! is_array($result[0])) $result[0] = array('code2'=>'XX','code3'=>'XXX','name'=>'UNKNOWN');
$row = $result[0];
foreach ($row as $property_name=>$value)
{
$this->$property_name = $value;
}
*/
}
function getCountry($code='code2')
{
return $this->$code;
}
function toString($delimiter = "\n \n")
{
$asArray = get_object_vars($this);
foreach ($asArray as $key=>$val) $str.="\$$key='$val'".$delimiter;
return $str;
}
}
/*
TEST PLAN
(WMRL)
http://localhost/mpa3/ref.php?w=100011
(WMJP)
http://localhost/mpa3/wmreg/index.php
1)Direct hits to WMJP
Not counting anything.
2)Direct hit to WMRL
Should count hit and unique in case there is no such ip and not setting referral.
If there is no referral for this webmaster the script should add
additional row with ip, webmaster id, and blank referral field
3)Redirected to WMRL via third party web page
First check if there is already such ip, referrer
If there is it should count hit and unique in case there is no suh ip and set referral url in case there isn't
If there isn't it should create a new row with the current ip and referral.
4)If 2) or 3) and then to WMJP
Checking if there is a cookie
If there isn't try to find the hit in the database. If there is such hit, it gets the webmster id and referral id
If there isn't this is obviously a case 1)
*/
?>
/////////////////////////////////////////////////////////////////////////////////////////////////
// SITE SELECT DROP DOWN MENU
/////////////////////////////////////////////////////////////////////////////////////////////////
function sites_select ( $site = null, $active = null, $master = null, $visible = null, $name = null, $none = null)
{
global $ADODB_FETCH_MODE;
global $conn;
$site = explode (",",$site);
$query = "SELECT id,title from ". TBL_PREFIX ."sites WHERE 1=1";
if ($active) $query.=" and active='1'";
if ($master) $query.=" and id=master_site";
if ($visible) $query.=" and visible='1'";
$query .= " and deleted='0'";
$query .= " order by id";
$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
$result = $conn->GetAll($query);
$select = '';
if ($none) $select.="\n";
foreach ($result as $row)
{
$select.="\n";
else $select.=">$row[id] - $row[title]\n";
}
if ($name) $select = "\n";
return $select;
}
/////////////////////////////////////////////////////////////////////////////////////////////////
// WEBMASTER SELECT DROP DOWN MENU
/////////////////////////////////////////////////////////////////////////////////////////////////
function webmasters_select($webmaster=0,$name=null,$none=null)
{
global $ADODB_FETCH_MODE;
global $conn;
$query = "SELECT id,name from ". TBL_PREFIX ."webmasters order by id";
$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
$result = $conn->GetAll($query);
$select = '';
if ($none) $select.="\n";
foreach ($result as $row)
{
$select.="\n";
else $select.=">$row[id] - $row[name]\n";
}
if ($name) $select = "\n";
return $select;
}
/////////////////////////////////////////////////////////////////////////////////////////////////
// WEBMASTER SELECT COUNTRY DROP DOWN MENU
/////////////////////////////////////////////////////////////////////////////////////////////////
function wm_countries_select($country=null,$name)
{
global $ADODB_FETCH_MODE;
global $conn;
$query = "SELECT iso_2,name from ". TBL_PREFIX ."countries WHERE wm_accept='1'";
$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
$result = $conn->GetAll($query);
$select = '';
if ($country=='') $select='';
foreach ($result as $row)
{
$select.="\n";
else $select.=">$row[name]\n";
}
if ($name) $select = "\n";
return $select;
}
function wm_countries_select_all($country=null,$name)
{
global $ADODB_FETCH_MODE;
global $conn;
$query = "SELECT iso_2,name from ". TBL_PREFIX ."countries";
$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
$result = $conn->GetAll($query);
$select = '';
if ($country=='') $select='';
foreach ($result as $row)
{
$select.="\n";
else $select.=">$row[name]\n";
}
if ($name) $select = "\n";
return $select;
}
/////////////////////////////////////////////////////////////////////////////////////////////////
// YES/NO DROP DOWN MENU
/////////////////////////////////////////////////////////////////////////////////////////////////
function yes_no($selected=1)
{
if ($selected) return "\n\n";
else return "\n\n";
}
/////////////////////////////////////////////////////////////////////////////////////////////////
// COLS AS ARRAY
/////////////////////////////////////////////////////////////////////////////////////////////////
function cols_asArray($columns,$table)
{
global $conn;
if (! is_array($columns)) $cols = $columns;
else $cols = implode(",",$columns);
$query = "SELECT $cols from $table";
$result = $conn->GetAll($query);
$res = array();
foreach ($result as $row)
{
if (is_array($columns)) array_push($res,$row);
}
return $res;
}
/////////////////////////////////////////////////////////////////////////////////////////////////
// PROCESSOR SELECT DROP DOWN MENU
/////////////////////////////////////////////////////////////////////////////////////////////////
function processors_select($proc=null,$none=1)
{
global $conn;
$query = "SELECT id,title from ". TBL_PREFIX ."processors order by id";
$result = $conn->GetAll($query);
$select = '';
if ($none) $select.="\n";
foreach ($result as $row)
{
$select.="\n";
else $select.=">$row[title]\n";
}
return $select;
}
/////////////////////////////////////////////////////////////////////////////////////////////////
// MEMBERS COUNTRY SELECT DROP DOWN MENU
/////////////////////////////////////////////////////////////////////////////////////////////////
function members_countries_select($country=null,$user_criteria=null)
{
global $conn;
if (isset($user_criteria)) $user_accept = "where user_accept=$user_criteria";
$query = "SELECT iso_2,name from ". TBL_PREFIX ."countries $user_accept order by name";
$result = $conn->GetAll($query);
$select = '';
foreach ($result as $row)
{
$select.="\n";
else $select.="> $row[name] \n";
}
return $select;
}
/////////////////////////////////////////////////////////////////////////////////////////////////
// SITES PRODUCTS SELECT
/////////////////////////////////////////////////////////////////////////////////////////////////
function sites_products_select ( $visible=1, $active=1, $product=null)
{
global $conn;
global $ADODB_FETCH_MODE;
$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
$criteria = "where t1.active=$active and t2.active=1 and t1.site=t2.id";
$query = "SELECT t1.id,concat(concat(t2.title,' - '),t1.title) from ". TBL_PREFIX ."products t1, ". TBL_PREFIX ."sites t2 $criteria";
$result = $conn->GetAll($query);
$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
$select = "\n";
if (!is_array($result)) return '';
foreach ($result as $row)
{
$selected = ($row[0] == $product)?" selected":"";
$select.="\n";
}
return $select;
}
/////////////////////////////////////////////////////////////////////////////////////////////////
// STATE SELECT DROP DOWN MENU
/////////////////////////////////////////////////////////////////////////////////////////////////
function states_select ($state = '--')
{
global $conn;
$query = "SELECT code,name from ". TBL_PREFIX ."states";
$result = $conn->GetAll($query);
$select = '';
foreach ($result as $row)
{
$select.="\n";
else $select.="> $row[name] \n";
}
return $select;
}
/////////////////////////////////////////////////////////////////////////////////////////////////
// SITES PRODUCTS TEXT
/////////////////////////////////////////////////////////////////////////////////////////////////
function sites_products_text($product)
{
global $conn;
global $ADODB_FETCH_MODE;
$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
$criteria = "where t1.site=t2.id and t1.id=$product";
$query = "SELECT t1.id,concat(concat(t2.title,' - '),t1.title) from ". TBL_PREFIX ."products t1, ". TBL_PREFIX ."sites t2 $criteria";
$result = $conn->GetAll($query);
$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
$row = $result[0];
return $row[1];
}
/////////////////////////////////////////////////////////////////////////////////////////////////
// GALLERY TYPE SELECT DROP DOWN MENU
/////////////////////////////////////////////////////////////////////////////////////////////////
function gtype_select($gtype)
{
global $gallery_conn;
$query = "SELECT * from ". TBL_PREFIX ."gtypes";
$result = $gallery_conn->GetAll($query);
$select = '';
foreach ($result as $row)
{
$select.="\n";
else $select.="> $row[title] \n";
}
return $select;
}
/////////////////////////////////////////////////////////////////////////////////////////////////
// MINPAY SELECT DROP DOWN MENU
/////////////////////////////////////////////////////////////////////////////////////////////////
function minpay_select($minpay,$amounts)
{
$select = '';
foreach($amounts as $amount)
{
$select.="\n";
else $select.=">$amount\n";
}
return $select;
}
/////////////////////////////////////////////////////////////////////////////////////////////////
// PROGRAM SELECT DROP DOWN MENU
/////////////////////////////////////////////////////////////////////////////////////////////////
function programs_select($program,$name=null,$none=null)
{
global $conn;
$query = "SELECT id,title from ". TBL_PREFIX ."programs";
$result = $conn->GetAll($query);
$select = '';
/* $programsArr = array (
0 => "Per Unique",
1 => "Per Signup",
2 => "Partnership",
3 => "Per Active Member"
);*/
if ($none) $select.="\n";
foreach ($result as $value){
$select .= '\n";
}
if ($name) $select = "\n";
return $select;
}
/////////////////////////////////////////////////////////////////////////////////////////////////
// CUSTOM