$db_host='localhost';
$db_user='mpa3_admin';
$db_pass='ilphyeb5';
$db_pass_backup='';
$tables_header='1';
$tables_odd='2';
$tables_even='3';
$cookie_exp='336';
$twotier_percent='5';
$ip_exp='336';
$local_wire_fee='0';
$international_wire_fee='30';
$local_check_fee='0';
$international_check_fee='0';
$local_ipayout_fee='0';
$international_ipayout_fee='0';
$local_epass_fee='0';
$international_epass_fee='0';
$processing_fees='0';
$curl='/usr/local/bin/curl';
$path_to_php='';
$program_name='Gunzblazing V5';
$eur_usd_rate='1.27';
$default_program='4';
$default_site='2';
$sms_params='11';
$f2g_min_payout='74';
$mpush_id='';
$mpush_password='';
$mpush_percent='';
$wm_ref_redirect_url='http://www.gunzblazing.com/';
$check_threshold='25';
$rebills_threshold='25';
$currency_sign='$';
$minpayoutsteps='50,100,150,200,250,500,1000,1500,2000,2500,3000,5000';
$vat='';
$localbilling_active='';
$hide_trials_days='35';
$ipayout_mid='0cdd515f-aa1a-4566-a87b-17197772f232';
$ipayout_username='brian@pistolmedia.com';
$ipayout_password='aebn23';
$ipayout_test_mode='0';
$ipayout_upload_automatically='0';
$table_heading='';
$table_dark='';
$table_light='';
$consoles_active='0';
$no_affiliate_no_trial='0';
$active_banlist='0';
$ct_set='';
$auto_approve='0';
$email_confirmations='0';
$auto_approve_on_email='0';
$irs_usa='0';
$enable_cexit='0';
$test_mode='1';
$links_to_mpa2='';
$use_sql='1';
$no_credit_webmaster='100002';
$webmasters_approval='';
$merge_follow_me='1';
$reduce_active_chargebacks='0';
$show_fees='0';
$use_eu='1';
$f2g_active='0';
$aff_rep_links_override='0';
$epoch_direct_jp='1';
$send_member_approve_email='0';
$ipayout_test_mode='0';
$ipayout_upload_automatically='0';
$paxum_email='';
$paxum_loginid='';
$paxum_test_mode='';
$paxum_upload_automatically='';
$local_paxum_fee='0';
$international_paxum_fee='0';
?>
?>
function Encrypt($string, $public_key)
{
$fp = fopen($public_key, "r");
$pkey = fread($fp, 8192);
fclose($fp);
openssl_get_publickey($pkey);
// encrypt
openssl_public_encrypt($string, $encrypted_string, $pkey);
return $encrypted_string;
}
function encdec($str_message, $dec=0)
{
return $str_message;
global $key_shift;
$passkey = ($key_shift*$key_shift-$key_shift)*($key_shift*$key_shift)*$key_shift;
$str_message = utf8_decode($str_message);
if($dec) {
$str_message = substr_replace($str_message,"",-strlen($passkey));
}
$len_str_message=strlen($str_message);
$str_encrypted_message="";
for ($position = 0;$position<$len_str_message;$position++)
{
//$key_to_use = (($len_str_message+$position)+1);
$key_to_use = $position*$position + $key_shift;
$key_to_use = (255+$key_to_use) % 255;
$byte_to_be_encrypted = substr($str_message, $position, 1);
$ascii_num_byte_to_encrypt = ord($byte_to_be_encrypted);
$xored_byte = $ascii_num_byte_to_encrypt ^ $key_to_use; //xor operation
$encrypted_byte = chr($xored_byte);
$str_encrypted_message .= $encrypted_byte;
}
if($dec == 0)
$str_encrypted_message .= $passkey;
return utf8_encode($str_encrypted_message);
}
function encordec($str) {
return $str;
global $key_shift;
$passkey = ($key_shift*$key_shift-$key_shift)*($key_shift*$key_shift)*$key_shift;
if( !preg_match("/$passkey/", $str ))
return $str;
else
return encdec($str,1);
}
?>
$gallery_db_host='';
$gallery_db_name='';
$gallery_db_user='';
$gallery_db_pass='';
$gallhits_path='';
$gallhit_url='';
$god_db_host='';
$god_db_name='';
$god_db_user='';
$god_db_pass='';
$godhits_path='';
$godhit_url='';
$hg_as_gotd_source='';
$hg_as_gotd_to_use='0';
$pod_db_host='';
$pod_db_name='';
$pod_db_user='';
$pod_db_pass='';
$podhits_path='';
$podhit_url='';
$no_commas='0';
?>
function 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 Hit
{
public function Hit($input=null,$sql=1)
{
if (! is_array($input)) return 1;
foreach ($input as $key=>$value) $this->$key = $value;
$this->sql= $sql;
$this->fm = 1*$this->fm;
include_once(CLASSES_PATH."site.class.php");
$site = new Site($this->site);
$this->master_site = $site->master_site;
unset($site);
$this->Process_SQL($input);
return 1;
}
public function Process_SQL($input=null)
{
$exists = $this->exists();
if (is_array($input)) foreach ($input as $key=>$value) $this->$key = $value;
$this->unique = !$exists;
$this->visit_date = date("Y-m-d H:i:s");
$this->date = date("Y-m-d");
if ($exists)
{
$this->update(get_object_vars($this));
}
else
{
$this->create();
}
if ($this->unique)
{
include_once(CLASSES_PATH."stats.class.php");
$stats = new PrgUniqueStats($this);
$stats->add_unique();
}
else
{
include_once(CLASSES_PATH."stats.class.php");
$stats = new PrgUniqueStats($this);
$stats->add_raw();
}
return 1;
}
public function create()
{
global $conn;
if ($this->id) return 0;
$sql = "SELECT * FROM ".TBL_PREFIX."hits 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."hits",1);
$insertSQL = $conn->GetInsertSQL($result, get_object_vars($this));
$conn->Execute($insertSQL);
if (! $this->id) $this->id = $conn->Insert_ID();
}
public function read()
{
global $conn, $ADODB_FETCH_MODE;
$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
$query = "SELECT * from ".TBL_PREFIX."hits 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];
}
}
public function save()
{
global $conn;
$sql = "SELECT * FROM ".TBL_PREFIX."hits 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));
if ($updateSQL) $conn->Execute($updateSQL);
}
public function update($properties,$save_it=1)
{
if (! is_array($properties)) return 0;
foreach($properties as $property=>$value)
{
if ($this->$property != $value)
{
$this->$property = $value;
}
}
if ($save_it) $this->save();
}
public function exists()
{
global $conn, $cookie_exp, $ip_exp;
if (!is_numeric($ip_exp)) $ip_exp = $cookie_exp;
if (!is_numeric($ip_exp)) $ip_exp = 1;
if ($this->webmaster) $wm_criteria = "webmaster='$this->webmaster'";
else $wm_criteria = "1";
$query = "SELECT max(id) as id FROM ".TBL_PREFIX."hits WHERE ipv4=".(int)$this->ipv4." and site=".(int)$this->site." and tour='$this->tour' and $wm_criteria and visit_date>date_add(now() , INTERVAL -$ip_exp HOUR)";
$result = $conn->GetAll($query);
if (! is_array($result[0])) return 0;
if ((int)$result[0]['id']==0) return 0;
$row = $result[0];
$this->id = $row[id];
$this->read();
$this->unique = 0;
return 1;
}
public 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,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;
}
}
public function is_unique()
{
return $this->unique;
}
public function getCountry($code='code2')
{
return $this->$code;
}
public function toString($delimiter = "\n
\n")
{
$asArray = get_object_vars($this);
foreach ($asArray as $key=>$val) $str.="\$$key='$val'".$delimiter;
return $str;
}
}
?>
require_once(CLASSES_PATH."niche.class.php");
require_once(CLASSES_PATH."file_storage.class.php");
//hostname_check
class Site
{
public $id = ''; // Site ID
public $master_site = ''; // Master site ID
public $title = ''; // Site title
public $url = ''; // Main URL
public $postback_url = ''; // Postback URL
public $alternate_url = ''; // Alternative URL
public $use_alternate = ''; // Use alternative YES/NO flag
public $htpasswd = ''; // Path to PWD file on member server
public $adp = ''; // URL to adp.cgi
public $welcome = ''; // Successful signup - Welcome page URL
public $deny = ''; // Unsuccessful signup - Denial page URL
public $members = ''; // Member area URL
public $active = ''; // Active YES/NO flag
public $visible = ''; // Visible YES/NO flag
public $deleted = ''; // Deleted YES/NO flag
public $trials = ''; // Offer trials to non affiliated YES/NO flag
public $owner = ''; // Owner ID
public $overhead = ''; // Overhaed % deducted for fees and expenses before calculating the payout for the owner
public $payout = ''; // Payout % after fees of the profit of the site
public $nb_access_key = ''; // Netbilling access key
public $gxb_site_id = ''; // GXB site ID
public $netcash_site_id = ''; // NetCash site ID
public $commercegate_site_id = ''; // CommerceGate site ID
public $localbilling_site_id = ''; // LocalBilling site ID
public $localbilling_package_id = ''; // LocalBilling package ID
public $localbilling_vat_package_id = ''; // LocalBilling VAT package ID
public $dhd_site_id = ''; // DHD site ID
public $dhd_eudebit = ''; // DHD EU Debit URL
public $dhd_checks = ''; // DHD Checks URL
public $mpush_cid = '';
public $niche;
public $cml_product = '';
public $cml_banner = 'http://';
public $pbp_package = '';
public $pbp_layout='';
public $enc_method ='ENCRYPT';
public $p2e_productid = "";
public $p2e_siteid = "";
public $clearcard_site_id = 0;
public $ncc_site_id = '';
public $post_action = "";
public $post_method = "POST";
// CUSTOMIZATION //
public $default_console = ''; // Default exit console for the site
// CUSTOMIZATION //
public function Site($id = null)
{
// if site is specified it will read and set all the properties for this site
if (!preg_match("/^\d+$/", $id)) $id = 0;
if ($id) $this->read($id);
return 1;
}
public function read($id=null)
{
// Reads the info from the database and sets the properties, if no id reads for the current $this->id
global $conn;
if ($id) {
$this->id = $id;
}
if (DB_IS_DOWN === true) {
$objSite = FileStorage::getSiteObject($this->id);
if (!is_null($objSite)) {
$objVars = get_object_vars($objSite);
foreach($objVars as $key => $value) {
$this->$key = $value;
}
}
} else {
$query = "SELECT * from ".TBL_PREFIX."sites where id=".$this->id;
$result = $conn->GetAll($query);
if (! is_array($result[0])) {
return null;
}
$row = array_change_key_case($result[0], CASE_LOWER);
foreach ($row as $property_name=>$value) {
$this->$property_name = $value;
}
}
if ($this->master_site == 0 && $this->id > 0) {
$this->master_site = $this->id;
}
}
public function save()
{
// Saves into the database
global $conn;
if (!$this->id) {
$this->id = $this->siteID;
}
$sql = "SELECT * FROM ".TBL_PREFIX."sites WHERE id = ".$this->id;
$result = $conn->Execute($sql);
$obj_vars = $result->FetchObj();
foreach ($obj_vars as $var=>$val) {
if (!isset($this->$var)) {
$this->$var = '';
}
}
$updateSQL = $conn->GetUpdateSQL($result, get_object_vars($this), true, true, true);
if ($updateSQL) {
$conn->Execute($updateSQL);
}
//Store sites data to a php file
FileStorage::storeSitesData();
}
public function update($properties,$save_it=1)
{
global $conn;
// array of pairs property=>value to be updated, always use with caution,
// the update form is the preferred method
foreach($properties as $property=>$value)
{
$this->$property = $value;
}
if ($save_it) $this->save();
}
public function create($properties)
{
// sets the properties, saves into the database, gets the id and sets it
global $conn;
require_once(FUNCTIONS_PATH."execute_funcs.php");
$asArray = get_object_vars($this);
foreach ($asArray as $property_name=>$value)
{
$this->$property_name = $properties[$property_name].'';
}
$sql = "SELECT * FROM ".TBL_PREFIX."sites WHERE id = -1";
$result = $conn->Execute($sql);
$obj_vars = $result->FetchObj();
foreach($obj_vars as $var=>$val) if (! isset($this->$var)) $this->$var = '';
$this->deleted = 0;
if ($conn->no_autoincrement) $this->id = $conn->GenID("seq_".TBL_PREFIX."sites",1);
$signup_dir = SIGNUP_PATH.$this->id;
if(!is_dir($signup_dir))
{
$templates_dir = SIGNUP_PATH.'templates';
if(!is_dir($signup_dir)) $command = execute("cp -rf $templates_dir $signup_dir");
@chmod($signup_dir, 0777);
}
$insertSQL = $conn->GetInsertSQL($result, get_object_vars($this));
$conn->Execute($insertSQL);
if (! $this->id) {$this->id = $conn->Insert_ID();}
if (! $this->master_site) {$this->master_site = $this->id; $this->save();}
}
public function addMember($username,$password,$email=null)
{
// Self explanatory
global $conn;
//if there is no member management script set, act as if it's all ok
if ($this->adp=='' || $username=='' || $password=='') return 1;
//checks if the adp url is on the same server where mpa3 is and connects directly to the db
if (!(strpos($this->adp, PROGRAM_URL)===false) && strstr($this->htpasswd,'|'))
{
$conn_adp = &$this->build_conn();
$sql = "delete from $this->adp_tablename where $this->adp_username_field='$username'";
$res = $conn_adp->GetOne($sql);
$sql = "insert into $this->adp_tablename ($this->adp_username_field,$this->adp_password_field) values('$username',$this->enc_method('$password'))";
$res = $conn_adp->GetOne($sql);
return 1;
}
require_once(FUNCTIONS_PATH."http_post.php");
if (strstr($this->htpasswd,'|')) $command = "data=ADD,$this->htpasswd,$username,$password,$email";
else $command = "ADD,$this->htpasswd,$username,$password";
if ($conn->debug) $conn->outp('curl -k -d \''.$command.'\' '.$this->adp."\n");
//CURL ." -k -d 'ADD,$this->htpasswd,$username,$password' $this->adp
$res = http_post($this->adp,$command);
if ($conn->debug) $conn->outp($res."\n");
if (strstr($res,'ADDED')) return 1;
else return 0;
}
public function deleteMember($username)
{
// Self explanatory
global $conn;
//if there is no member management script set, act as if it's all ok
if ($this->adp=='') return 1;
//checks if the adp url is on the same server where mpa3 is and connects directly to the db
if (!(strpos($this->adp, PROGRAM_URL)===false) && strstr($this->htpasswd,'|'))
{
$conn_adp = &$this->build_conn();
$sql = "delete from $this->adp_tablename where $this->adp_username_field='$username'";
$res = $conn_adp->GetOne($sql);
return 1;
}
require_once(FUNCTIONS_PATH."http_post.php");
if (strstr($this->htpasswd,'|')) $command = "data=DELETE,$this->htpasswd,$username";
else $command = "DELETE,$this->htpasswd,$username";
if ($conn->debug) $conn->outp($command."\n");
$res = http_post($this->adp,$command);
if ($res=="DELETED $username") return 1;
else return 0;
}
public function &build_conn()
{
global $conn;
$credentials = explode("|", $this->htpasswd);
$this->adp_host=$credentials[0];
$this->adp_user=$credentials[1];
$this->adp_pass=$credentials[2];
$this->adp_db=$credentials[3];
$this->adp_tablename=$credentials[4];
$this->adp_username_field=$credentials[5];
$this->adp_password_field=$credentials[6];
$conn_adp = &NewADOConnection('mysql');
$conn_adp->debug=$conn->debug;
$conn_adp->Connect($this->adp_host, $this->adp_user, $this->adp_pass, $this->adp_db);
return $conn_adp;
}
public function checkMember($username)
{
// Self explanatory
global $conn;
//if there is no member management script set, act as if it's all ok
if ($this->adp=='') return 0;
//checks if the adp url is on the same server where mpa3 is and connects directly to the db
if (!(strpos($this->adp, PROGRAM_URL)===false) && strstr($this->htpasswd,'|'))
{
$conn_adp = &$this->build_conn();
$sql = "select count(*) from $this->adp_tablename where $this->adp_username_field='$username'";
$res = $conn_adp->GetOne($sql);
if ($res) return 1;
else return 0;
}
require_once(FUNCTIONS_PATH."http_post.php");
if (strstr($this->htpasswd,'|')) $command = "data=CHECK,$this->htpasswd,$username";
else $command = "CHECK,$this->htpasswd,$username";
if ($conn->debug) $conn->outp($command."\n");
$res = http_post($this->adp,$command);
//if theere is no FOUND string, it means the password management script is not accessible.
//Act as if the username was not found, or the member won't be able to proceed and signup
if (!preg_match("/FOUND/", $res)) return 0;
if ( strstr($res,'NOT_FOUND')) return 0;
else return 1;
}
public function refreshMemberAccess($username,$password,$email=null)
{
$this->addMember($username,$password,$email);
}
function refreshAll()
{
global $conn, $ADODB_FETCH_MODE;
$query = "SELECT username,password,email from ".TBL_PREFIX."members where site=".$this->id." or site=0";
$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
$result = $conn->GetAll($query);
foreach ($result as $row)
{
$this->refreshMemberAccess($row[username],$row[password],$row[email]);
}
}
public function deleteExpired()
{
global $conn, $ADODB_FETCH_MODE;
$query = "SELECT username from ".TBL_PREFIX."members where (site=".$this->id." or site=0) and edate
Site $this->id: $this->title\n
";
//echo $form;
//custom node
global $doc;
$make_xml = new Make_Xml($doc, 'data');
$node = $make_xml->addRow($make_xml->ext_node, 'cascading_order');
$make_xml->addValue($node, 1);
$node = $make_xml->addRow($make_xml->ext_node, 'order_select');
$make_xml->addValue($node, $c_order->order_select());
$node = $make_xml->addRow($make_xml->ext_node, 'site_title');
$make_xml->addValue($node, $this->title);
$node = $make_xml->addRow($make_xml->ext_node, 'siteID');
$make_xml->addValue($node, $this->id);
$node = $make_xml->addRow($make_xml->ext_node, 'geo_order_select');
$make_xml->addValue($node, $c_order->geo_order_select());
$node = $make_xml->addRow($make_xml->ext_node, 'action_description');
$make_xml->addValue($node, 'cascading order');
}
public function updateCascadingOrder($order)
{
global $conn;
require_once(CLASSES_PATH."cascading_order.class.php");
$co = array();
$gco = array();
$alt_co = array();
$alt_gco = array();
foreach ($_POST as $key=>$value)
{
if (!preg_match("/.*order_\d+.*$/", $key)) continue;
$alt = preg_replace("/.*order_(\d+).*$/", "$1", $key);
$processor = preg_replace("/.*order_\d+_(.*)$/", "$1", $key);
/*
$co = explode('|','|'.$_POST['order_'.$alt]); unset($co[0]);
$gco = explode('|','|'.$_POST['geo_order_'.$alt]); unset($gco[0]);
*/
if ($alt)
{
if (preg_match("/geo_order/", $key))$alt_gco[$processor] = $value;
else $alt_co[$processor] = $value;
}
else
{
if (preg_match("/geo_order/", $key))$gco[$processor] = $value;
else $co[$processor] = $value;
}
}
$c_order = new CascadingOrder(0,$this->id);
$c_order->update(
array(
'order'=>$co,
'geo_order'=>$gco
)
);
if (count($alt_co)>0)
{
//updating the alt_cascading
$c_order = new CascadingOrder(0,$this->id,1);
$c_order->update(
array(
'order'=>$co,
'geo_order'=>$gco
)
);
}
}
public function resetCascadingOrder()
{
global $conn;
require_once(CLASSES_PATH."cascading_order.class.php");
$c_order = new CascadingOrder(0,$this->id);
$c_order->clear();
//clear the alt cascading
$c_order = new CascadingOrder(0,$this->id,1);
$c_order->clear();
}
/**
* Sends postback in case a member has cancelled to the site postback url
*
* @param object $transaction
* @param object $member
* @return boolean
*/
public function send_postback(&$transaction, &$member)
{
global $conn;
require_once(FUNCTIONS_PATH."http_post.php");
//if there is no postback_url script set, act as if it's all ok
if ($this->postback_url=='') return 1;
foreach ($_GET as $key=>$value) $post .= "$key=$value&";
foreach ($_POST as $key=>$value) $post .= "$key=$value&";
if (is_object($transaction))foreach (get_object_vars($transaction) as $key=>$value) $post .= "transaction_$key=$value&";
if (is_object($member))foreach (get_object_vars($member) as $key=>$value) $post .= "member_$key=$value&";
$command = "$post";
if ($conn->debug) $conn->outp($command."\n");
$res = http_post($this->postback_url,$command);
if ($res!='') return 1;
else return 0;
}
}
?>
require_once(CLASSES_PATH."file_storage.class.php");
//hostname_check
class Tour
{
function Tour($id = null)
{
if ($id)
{
$this->id=$id;
$this->read();
}
return 1;
}
function read()
{
// Reads the info from the database and sets the properties, if no id reads for the current $this->id
global $conn, $ADODB_FETCH_MODE;
if (DB_IS_DOWN === true) {
$objTour = FileStorage::getTourObject($this->id);
if (!is_null($objTour)) {
$objVars = get_object_vars($objTour);
foreach($objVars as $key => $value) {
$this->$key = $value;
}
}
} else {
$query = "SELECT * from ".TBL_PREFIX."tours 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;
}
}
}
function save()
{
// Saves into the database
global $conn;
$sql = "SELECT * FROM ".TBL_PREFIX."tours WHERE id = ".$this->id;
$result = $conn->Execute($sql);
$updateSQL = $conn->GetUpdateSQL($result, get_object_vars($this));
if ($updateSQL) $conn->Execute($updateSQL);
//Store tours data to a php file
FileStorage::storeToursData();
}
function update($properties,$save_it=1)
{
foreach($properties as $property=>$value)
{
if ($this->$property != $value)
{
$this->$property = $value;
}
}
if ($save_it) $this->save();
}
function create($properties)
{
global $conn;
foreach ($properties as $property_name=>$value)
{
$this->$property_name = $value;
}
$sql = "SELECT * FROM ".TBL_PREFIX."tours WHERE id = -1";
$result = $conn->Execute($sql);
if ($conn->no_autoincrement) $this->id = $conn->GenID("seq_".TBL_PREFIX."tours",1);
$this->deleted = 0;
$insertSQL = $conn->GetInsertSQL($result, get_object_vars($this));
$conn->Execute($insertSQL);
if (! $this->id) {$this->id = $conn->Insert_ID();}
}
function printForm()
{
global $conn;
require_once(FUNCTIONS_PATH.'lists_funcs.php');
$form = implode('',file(INNER_TEMPLATES_PATH."tours.html"));
$text_fields = array('id','title','url','site', 'wb_package_group', 'wb_package_id');
foreach($text_fields as $field) $form = str_replace('{'.$field.'}',$this->$field,$form);
if ($this->active) $active_select = "\n\n";
else $active_select = "\n\n";
$form = str_replace('{active}',$active_select,$form);
$form = str_replace('{price_model_select}',price_model_select($this->price_model),$form);
if ($this->visible) $visible_select = "\n\n";
else $visible_select = "\n\n";
$form = str_replace('{visible}',$visible_select,$form);
if ($this->id) $form = str_replace('{action}','update',$form);
else $form = str_replace('{action}','create',$form);
echo "$form";
}
function toString($delimiter = "\n")
{
$asArray = get_object_vars($this);
foreach ($asArray as $key=>$val) $str.="$key = $val".$delimiter;
return $str;
}
function global_change($tours, $action) {
foreach($tours as $id) {
$tour = new Tour($id);
if($action == "activate") { $tour->active = 1; $tour->visible = 1;}
if($action == "deactivate") { $tour->active = 0; $tour->visible = 0;}
if($action == "active_only") { $tour->active = 1; }
if($action == "invisible_only") { $tour->visible = 0; }
if($action == "delete") { $tour->active = 0; $tour->visible = 0; $tour->deleted = 1; }
$tour->save();
unset($tour);
}
}
}
?>
//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"
\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_date