Jump to content


davidsonnet

Member Since 05/08/2004
Offline Last Active 18/02/2008, 11:53
-----

Posts I've Made

In Topic: Problema Com Php

23/02/2006, 16:01

Abaixo o codigo!





<?
/***********************************************************************/
/* */
/* This file is created by deZender */
/* */
/* deZender (Decoder for Zend Encoder/SafeGuard): */
/* Version: 0.9.3.0 */
/* Author: qinvent.com */
/* Release on: 2005.11.12 */
/* */
/***********************************************************************/


function shop_pin_html ()
{
print '<html><body>Enter pin:<br>
<form method=post>
<input type=hidden name=a value=enter_pin>
<input type=text name=pin value=""><br>
<input type=submit value="Go">
</form></body></html>';
}

$arr = get_defined_vars ();
while (list ($kk, $vv) = each ($arr))
{
if (gettype ($$kk) != 'array')
{
$$kk = '';
continue;
}
}

if (file_exists ('install.php'))
{
print 'Delete install.php file for security reason please!';
exit ();
}

$settings = array ();
$userinfo = array ();
$frm['a'] = '';
include 'inc/config.inc.php';
global $frm;
if (preg_match ('/^https.*/i', $frm_env['SCRIPT_URI']))
{
$frm_env['HTTPS'] = 1;
}

$userinfo = array ();
$userinfo['logged'] = 0;
$dbconn = db_open ();
if (!$dbconn)
{
print 'Cannot connect mysql';
exit ();
}

$q = 'select * from hm2_processings';
($sth = mysql_query ($q) OR print mysql_error ());
while ($row = mysql_fetch_array ($sth))
{
$sfx = strtolower ($row['name']);
$sfx = preg_replace ('/([^\\w])/', '_', $sfx);
$exchange_systems[$row['id']] = array ('name' => $row['name'], 'sfx' => $sfx, status => $row['status'], 'has_account' => 0);
}

define ('THE_GC_SCRIPT_V2005_04_01', 'answer');
$acsent_settings = get_accsent ();
if ($frm['a'] == 'showprogramstat')
{
$login = quote ($frm['login']);
$q = '' . 'select * from hm2_users where id = 1 and username = \'' . $login . '\' and stat_password <> \'\'';
($sth = mysql_query ($q) OR print mysql_error ());
$flag = 0;
while ($row = mysql_fetch_array ($sth))
{
if ($row['stat_password'] == md5 ($frm['password']))
{
$flag = 1;
continue;
}
}

if ($flag == 0)
{
print '<center>Wrong login or password</center>';
}
else
{
if ($frm['page'] == 'members')
{
include 'inc/admin/members_program.inc.php';
}
else
{
if ($frm['page'] == 'pendingwithdrawal')
{
include 'inc/admin/pending_program.inc.php';
}
else
{
if ($frm['page'] == 'whoonline')
{
include 'inc/admin/whoonline_program.inc.php';
}
else
{
if ($frm['page'] == 'TrayInfo')
{
include 'inc/admin/tray_info.php';
}
else
{
include 'inc/admin/main_program.inc.php';
}
}
}
}
}

db_close ($dbconn);
exit ();
}

if ($frm['a'] == 'logout')
{
setcookie ('password', '', time () - 86400);
header ('Location: indexbr.php');
db_close ($dbconn);
exit ();
}

$username = quote ($frm_cookie['username']);
$password = $frm_cookie['password'];
$ip = $frm_env['REMOTE_ADDR'];
$add_login_check = '' . ' and last_access_time + interval 30 minute > now() and last_access_ip = \'' . $ip . '\'';
if ($settings['demomode'] == 1)
{
$add_login_check = '';
}

list ($user_id, $chid) = split ('-', $password, 2);
$user_id = sprintf ('%d', $user_id);
$chid = quote ($chid);
if ($settings['htaccess_authentication'] == 1)
{
$login = $frm_env['PHP_AUTH_USER'];
$password = $frm_env['PHP_AUTH_PW'];
$q = 'select * from hm2_users where id = 1';
($sth = mysql_query ($q) OR print mysql_error ());
while ($row = mysql_fetch_array ($sth))
{
if (($login == $row['username'] AND md5 ($password) == $row['password']))
{
$userinfo = $row;
$userinfo[logged] = 1;
continue;
}
}

if ($userinfo[logged] != 1)
{
header ('WWW-Authenticate: Basic realm="Authorization Required!"');
header ('HTTP/1.0 401 Unauthorized');
echo 'Authorization Required!';
exit ();
}
}
else
{
if ($settings['htpasswd_authentication'] == 1)
{
if ((file_exists ('./.htpasswd') AND file_exists ('./.htaccess')))
{
$q = 'select * from hm2_users where id = 1';
($sth = mysql_query ($q) OR print mysql_error ());
while ($row = mysql_fetch_array ($sth))
{
$userinfo = $row;
$userinfo[logged] = 1;
}
}
}
else
{
$q = 'select *, date_format(date_register + interval ' . $settings['time_dif'] . ('' . ' day, \'%b-%e-%Y\') as create_account_date, l_e_t + interval 15 minute < now() as should_count from hm2_users where id = ' . $user_id . ' and (status=\'on\' or status=\'suspended\') ' . $add_login_check . ' and id = 1');
($sth = mysql_query ($q) OR print mysql_error ());
while ($row = mysql_fetch_array ($sth))
{
if (($settings['brute_force_handler'] == 1 AND $row['activation_code'] != ''))
{
header ('Location: indexbr.php?a=login&say=invalid_login&username=' . $frm['username']);
db_close ($dbconn);
exit ();
}

$qhid = $row['hid'];
$hid = substr ($qhid, 5, 20);
if ($chid == md5 ($hid))
{
$userinfo = $row;
$userinfo['logged'] = 1;
$q = 'update hm2_users set last_access_time = now() where id = 1';
(mysql_query ($q) OR print mysql_error ());
continue;
}
else
{
$q = 'update hm2_users set bf_counter = bf_counter + 1 where id = ' . $row['id'];
mysql_query ($q);
if (($settings['brute_force_handler'] == 1 AND $row['bf_counter'] == $settings['brute_force_max_tries']))
{
$activation_code = get_rand_md5 (50);
$q = '' . 'update hm2_users set bf_counter = bf_counter + 1, activation_code = \'' . $activation_code . '\' where id = ' . $row['id'];
mysql_query ($q);
$info = array ();
$info['activation_code'] = $activation_code;
$info['username'] = $row['username'];
$info['name'] = $row['name'];
$info['ip'] = $frm_env['REMOTE_ADDR'];
$info['max_tries'] = $settings['brute_force_max_tries'];
send_mail ('brute_force_activation', $row['email'], $settings['system_email'], $info);
header ('Location: indexbr.php?a=login&say=invalid_login&username=' . $frm['username']);
db_close ($dbconn);
exit ();
continue;
}

continue;
}
}
}
}

if ($userinfo['logged'] != 1)
{
header ('Location: indexbr.php');
db_close ($dbconn);
exit ();
}

if ((time () - 900 < $acsent_settings[timestamp] AND $acsent_settings[pin] != ''))
{
if ($frm[a] == 'enter_pin')
{
if ($frm[pin] == $acsent_settings[pin])
{
$acsent_settings[last_ip] = $frm_env['REMOTE_ADDR'];
$acsent_settings[last_browser] = $frm_env['HTTP_USER_AGENT'];
$acsent_settings[timestamp] = 0;
$acsent_settings[pin] = '';
set_accsent ();
}

header ('Location: adminbr.php');
exit ();
}

shop_pin_html ();
exit ();
}

$NEWPIN = get_rand_md5 (7);
$message = '' . 'Hello,

Someone tried login admin area
ip: ' . $frm_env['REMOTE_ADDR'] . '
browser: ' . $frm_env['HTTP_USER_AGENT'] . '

Pin code for entering admin area is:
' . $NEWPIN . '

This code will be expired in 15 minutes.
';
if ($acsent_settings[detect_ip] == 'disabled')
{
}
else
{
if ($acsent_settings[detect_ip] == 'medium')
{
$z1 = preg_replace ('' . '/\\.(\\d+)$/', '', $acsent_settings[last_ip]);
$z2 = preg_replace ('' . '/\\.(\\d+)$/', '', $frm_env['REMOTE_ADDR']);
if ($z1 != $z2)
{
$acsent_settings['pin'] = $NEWPIN;
$acsent_settings['timestamp'] = time ();
mail ($acsent_settings['email'], 'Pin code', $message);
set_accsent ();
header ('Location: adminbr.php');
db_close ($dbconn);
exit ();
}
}
else
{
if ($acsent_settings[detect_ip] == 'high')
{
if ($acsent_settings['last_ip'] != $frm_env['REMOTE_ADDR'])
{
$acsent_settings['pin'] = $NEWPIN;
$acsent_settings['timestamp'] = time ();
mail ($acsent_settings['email'], 'Pin code', $message);
set_accsent ();
header ('Location: adminbr.php');
db_close ($dbconn);
exit ();
}
}
else
{
print 'Settings broken. Contact script developer please';
exit ();
}
}
}

if ($acsent_settings[detect_browser] == 'disabled')
{
}
else
{
if ($acsent_settings[detect_browser] == 'enabled')
{
if ($acsent_settings['last_browser'] != $frm_env['HTTP_USER_AGENT'])
{
$acsent_settings['pin'] = $NEWPIN;
$acsent_settings['timestamp'] = time ();
mail ($acsent_settings['email'], 'Pin code', $message);
set_accsent ();
header ('Location: adminbr.php');
db_close ($dbconn);
exit ();
}
}
else
{
print 'Settings broken. Contact script developer please';
exit ();
}
}

if ($frm['a'] == 'encrypt_mysql')
{
if ($settings['demomode'] != 1)
{
if (($userinfo['transaction_code'] != '' AND $userinfo['transaction_code'] != $frm['alternative_passphrase']))
{
header ('Location: ?a=security&say=invalid_passphrase');
db_close ($dbconn);
exit ();
}

if (!file_exists ('./tmpl_c/.htdata'))
{
$fp = fopen ('./tmpl_c/.htdata', 'w');
fclose ($fp);
save_settings ();
}

header ('Location: adminbr.php?a=security&say=done');
db_close ($dbconn);
exit ();
}

header ('Location: adminbr.php?a=security');
db_close ($dbconn);
exit ();
}

if (($frm['a'] == 'change_login_security' AND $frm['act'] == 'change'))
{
$acsent_settings['detect_ip'] = $frm['ip'];
$acsent_settings['detect_browser'] = $frm['browser'];
$acsent_settings['last_browser'] = $frm_env['HTTP_USER_AGENT'];
$acsent_settings['last_ip'] = $frm_env['REMOTE_ADDR'];
$acsent_settings['email'] = $frm['email'];
set_accsent ();
header ('Location: ?a=security');
db_close ($dbconn);
exit ();
}

if (($frm['a'] == 'startup_bonus' AND $frm['act'] == 'set'))
{
$settings['startup_bonus'] = sprintf ('%0.2f', $frm['startup_bonus']);
$settings['startup_bonus_ec'] = sprintf ('%d', $frm['ec']);
$settings['forbid_withdraw_before_deposit'] = ($frm['forbid_withdraw_before_deposit'] ? 1 : 0);
$settings['activation_fee'] = sprintf ('%0.2f', $frm['activation_fee']);
save_settings ();
header ('Location: ?a=startup_bonus&say=yes');
db_close ($dbconn);
exit ();
}

if (($frm['a'] == 'exchange_rates' AND $frm['action'] == 'save'))
{
if ($settings['demomode'])
{
header ('Location: ?a=exchange_rates&say=demo');
db_close ($dbconn);
exit ();
}

$exch = $frm['exch'];
if (is_array ($exch))
{
foreach ($exchange_systems as $id_from => $value)
{
foreach ($exchange_systems as $id_to => $value)
{
if ($id_to == $id_from)
{
continue;
}

$percent = sprintf ('%.02f', $exch[$id_from][$id_to]);
if ($percent < 0)
{
$percent = 0;
}

if (100 < $percent)
{
$percent = 100;
}

$q = '' . 'select count(*) as cnt from hm2_exchange_rates where `sfrom` = ' . $id_from . ' and `sto` = ' . $id_to;
$sth = mysql_query ($q);
$row = mysql_fetch_array ($sth);
if (0 < $row['cnt'])
{
$q = '' . 'update hm2_exchange_rates set percent = ' . $percent . ' where `sfrom` = ' . $id_from . ' and `sto` = ' . $id_to;
}
else
{
$q = '' . 'insert into hm2_exchange_rates set percent = ' . $percent . ', `sfrom` = ' . $id_from . ', `sto` = ' . $id_to;
}

mysql_query ($q);
}
}
}

header ('Location: ?a=exchange_rates');
db_close ($dbconn);
exit ();
}

if ($frm['a'] == 'test_egold_settings')
{
include 'inc/admin/auto_pay_settings_test.inc.php';
db_close ($dbconn);
exit ();
}

if ($frm['a'] == 'test_evocash_settings')
{
include 'inc/admin/auto_pay_settings_evocash_test.inc.php';
db_close ($dbconn);
exit ();
}

if ($frm['a'] == 'test_intgold_settings')
{
include 'inc/admin/auto_pay_settings_intgold_test.inc.php';
db_close ($dbconn);
exit ();
}

if ($frm['a'] == 'test_eeecurrency_settings')
{
include 'inc/admin/auto_pay_settings_eeecurrency_test.inc.php';
db_close ($dbconn);
exit ();
}

if ($frm['a'] == 'test_ebullion_settings')
{
include 'inc/admin/auto_pay_settings_ebullion_test.inc.php';
db_close ($dbconn);
exit ();
}

if ($userinfo['should_count'] == 1)
{
$q = '' . 'update hm2_users set last_access_time = now() where username=\'' . $username . '\'';
if (!(mysql_query ($q)))
{
exit (mysql_error ());
;
}

count_earning (-1);
}

if (($frm['a'] == 'affilates' AND $frm['action'] == 'remove_ref'))
{
$u_id = sprintf ('%d', $frm['u_id']);
$ref = sprintf ('%d', $frm['ref']);
$q = '' . 'update hm2_users set ref = 0 where id = ' . $ref;
(mysql_query ($q) OR print mysql_error ());
header ('' . 'Location: ?a=affilates&u_id=' . $u_id);
db_close ($dbconn);
exit ();
}

if (($frm[a] == 'affilates' AND $frm['action'] == 'change_upline'))
{
$u_id = sprintf ('%d', $frm['u_id']);
$upline = quote ($frm['upline']);
$q = '' . 'select * from hm2_users where username=\'' . $upline . '\'';
($sth = mysql_query ($q) OR print mysql_error ());
$id = 0;
while ($row = mysql_fetch_array ($sth))
{
$id = $row['id'];
}

$q = '' . 'update hm2_users set ref = ' . $id . ' where id = ' . $u_id;
(mysql_query ($q) OR print mysql_error ());
header ('' . 'Location: ?a=affilates&u_id=' . $u_id);
db_close ($dbconn);
exit ();
}

if (($frm['a'] == 'pending_deposit_details' AND $frm['action'] == 'movetoproblem'))
{
$id = sprintf ('%d', $frm['id']);
$q = '' . 'update hm2_pending_deposits set status=\'problem\' where id = ' . $id;
(mysql_query ($q) OR print mysql_error ());
header ('Location: ?a=pending_deposits');
db_close ($dbconn);
exit ();
}

if (($frm['a'] == 'pending_deposit_details' AND $frm['action'] == 'movetonew'))
{
$id = sprintf ('%d', $frm['id']);
$q = '' . 'update hm2_pending_deposits set status=\'new\' where id = ' . $id;
(mysql_query ($q) OR print mysql_error ());
header ('Location: ?a=pending_deposits&type=problem');
db_close ($dbconn);
exit ();
}

if (($frm['a'] == 'pending_deposit_details' AND $frm['action'] == 'delete'))
{
$id = sprintf ('%d', $frm['id']);
$q = '' . 'delete from hm2_pending_deposits where id = ' . $id;
(mysql_query ($q) OR print mysql_error ());
header ('Location: ?a=pending_deposits&type=' . $frm['type']);
db_close ($dbconn);
exit ();
}

if ((($frm['a'] == 'pending_deposit_details' AND ($frm['action'] == 'movetodeposit' OR $frm['action'] == 'movetoaccount')) AND $frm['confirm'] == 'yes'))
{
$deposit_id = $id = sprintf ('%d', $frm['id']);
$q = '' . 'select
hm2_pending_deposits.*,
hm2_users.username
from
hm2_pending_deposits,
hm2_users
where
hm2_pending_deposits.user_id = hm2_users.id and
hm2_pending_deposits.id = ' . $id . ' and
hm2_pending_deposits.status != \'processed\'
';
($sth = mysql_query ($q) OR print mysql_error ());
$amount = sprintf ('%0.2f', $frm['amount']);
while ($row = mysql_fetch_array ($sth))
{
$ps = $row['ec'];
$username = $row['username'];
$compound = sprintf ('%d', $row['compound']);
$fields = $row['fields'];
$user_id = $row['user_id'];
if ((100 < $compound OR $compound < 0))
{
$compound = 0;
}

$q = 'insert into hm2_history set
user_id = ' . $row['user_id'] . ('' . ',
date = now(),
amount = ' . $amount . ',
actual_amount = ' . $amount . ',
type=\'add_funds\',
description=\'') . quote ($exchange_systems[$row['ec']]['name']) . ' transfer received\',
ec = ' . $row['ec'];
mysql_query ($q);
if (($frm['action'] == 'movetodeposit' AND 0 < $row[type_id]))
{
$q = 'select name, delay from hm2_types where id = ' . $row['type_id'];
($sth1 = mysql_query ($q) OR print mysql_error ());
$row1 = mysql_fetch_array ($sth1);
$delay = $row1[delay];
if (0 < $delay)
{
--$delay;
}

$q = 'insert into hm2_deposits set
user_id = ' . $row['user_id'] . ',
type_id = ' . $row['type_id'] . ('' . ',
deposit_date = now(),
last_pay_date = now() + interval ' . $delay . ' day,
status = \'on\',
q_pays = 0,
amount = ' . $amount . ',
actual_amount = ' . $amount . ',
ec = ' . $ps . ',
compound = ' . $compound);
mysql_query ($q);
$deposit_id = mysql_insert_id ();
$q = 'insert into hm2_history set
user_id = ' . $row['user_id'] . ('' . ',
date = now(),
amount = -' . $amount . ',
actual_amount = -' . $amount . ',
type=\'deposit\',
description=\'Deposit to ') . quote ($row1[name]) . ('' . '\',
ec = ' . $ps . ',
deposit_id = ' . $deposit_id . '
');
mysql_query ($q);
$ref_sum = referral_commission ($row['user_id'], $amount, $ps);
}

$info = array ();
$q = 'select * from hm2_users where id = ' . $user_id;
$sth1 = mysql_query ($q);
$userinfo = mysql_fetch_array ($sth1);
$q = 'select * from hm2_types where id = ' . $row['type_id'];
$sth1 = mysql_query ($q);
$type = mysql_fetch_array ($sth1);
$info['username'] = $userinfo['username'];
$info['name'] = $userinfo['name'];
$info['amount'] = number_format ($row['amount'], 2);
$info['currency'] = $exchange_systems[$ps]['name'];
$info['compound'] = number_format ($type['compound'], 2);
$info['plan'] = (0 < $row[type_id] ? $type['name'] : 'Deposit to Account');
$q = 'select * from hm2_processings where id = ' . $row['ec'];
$sth = mysql_query ($q);
$processing = mysql_fetch_array ($sth);
$pfields = unserialize ($processing['infofields']);
$infofields = unserialize ($fields);
$f = '';
foreach ($pfields as $id => $name)
{
$f .= '' . $name . ': ' . stripslashes ($infofields[$id]) . '
';
}

$info['fields'] = $f;
$q = 'select date_format(date + interval ' . $settings['time_dif'] . ' hour, \'%b-%e-%Y %r\') as dd from hm2_pending_deposits where id = ' . $row['id'];
($sth1 = mysql_query ($q) OR print mysql_error ());
$row1 = mysql_fetch_array ($sth1);
$info['deposit_date'] = $row1['dd'];
$q = 'select email from hm2_users where id = 1';
$sth1 = mysql_query ($q);
$admin_row = mysql_fetch_array ($sth1);
send_mail ('deposit_approved_admin_notification', $admin_row['email'], $settings['opt_in_email'], $info);
send_mail ('deposit_approved_user_notification', $userinfo['email'], $settings['opt_in_email'], $info);
}

$id = sprintf ('%d', $frm['id']);
$q = '' . 'update hm2_pending_deposits set status=\'processed\' where id = ' . $id;
(mysql_query ($q) OR print mysql_error ());
header ('Location: ?a=pending_deposits');
db_close ($dbconn);
exit ();
}

if ($frm['a'] == 'mass')
{
if ($frm['action2'] == 'massremove')
{
$ids = $frm['pend'];
reset ($ids);
while (list ($kk, $vv) = each ($ids))
{
$q = '' . 'delete from hm2_history where id = ' . $kk;
(mysql_query ($q) OR print mysql_error ());
}

header ('Location: ?a=thistory&ttype=withdraw_pending&say=massremove');
db_close ($dbconn);
exit ();
}

if ($frm['action2'] == 'masssetprocessed')
{
$ids = $frm['pend'];
reset ($ids);
while (list ($kk, $vv) = each ($ids))
{
$q = '' . 'select * from hm2_history where id = ' . $kk;
$sth = mysql_query ($q);
while ($row = mysql_fetch_array ($sth))
{
$q = 'insert into hm2_history set
user_id = ' . $row['user_id'] . ',
amount = -' . abs ($row['actual_amount']) . ',
actual_amount = -' . abs ($row['actual_amount']) . ',
type = \'withdrawal\',
date = now(),
description = \'Withdrawal processed\',
ec = ' . $row['ec'];
(mysql_query ($q) OR print mysql_error ());
$q = 'delete from hm2_history where id = ' . $row['id'];
(mysql_query ($q) OR print mysql_error ());
$userinfo = array ();
$q = 'select * from hm2_users where id = ' . $row['user_id'];
$sth1 = mysql_query ($q);
$userinfo = mysql_fetch_array ($sth1);
$info = array ();
$info['username'] = $userinfo['username'];
$info['name'] = $userinfo['name'];
$info['amount'] = number_format (abs ($row['amount']), 2);
$info['currency'] = $exchange_systems[$row['ec']]['name'];
$info['account'] = 'n/a';
$info['batch'] = 'n/a';
$info['paying_batch'] = 'n/a';
$info['receiving_batch'] = 'n/a';
send_mail ('withdraw_user_notification', $userinfo['email'], $settings['opt_in_email'], $info);
$q = 'select email from hm2_users where id = 1';
$sth = mysql_query ($q);
$admin_row = mysql_fetch_array ($sth);
send_mail ('withdraw_admin_notification', $admin_row['email'], $settings['opt_in_email'], $info);
}
}

header ('Location: ?a=thistory&ttype=withdraw_pending&say=massprocessed');
db_close ($dbconn);
exit ();
}

if ($frm['action2'] == 'masscsv')
{
$ids = $frm['pend'];
if (!$ids)
{
print 'Nothing selected.';
db_close ($dbconn);
exit ();
}

reset ($ids);
header ('Content-type: text/plain');
$ec = -1;
$s = '-1';
while (list ($kk, $vv) = each ($ids))
{
$s .= '' . ',' . $kk;
}

$q = '' . 'select
h.*,
u.egold_account,
u.evocash_account,
u.intgold_account,
u.stormpay_account,
u.ebullion_account,
u.paypal_account,
u.goldmoney_account,
u.eeecurrency_account
from hm2_history as h, hm2_users as u where h.id in (' . $s . ') and u.id = h.user_id order by ec';
$sth = mysql_query ($q);
while ($row = mysql_fetch_array ($sth))
{
if (100 < $row['ec'])
{
continue;
}

if ($ec != $row['ec'])
{
print '#' . $exchange_systems[$row['ec']]['name'] . ' transactions (account, amount)
';
$ec = $row['ec'];
}

if ($row['ec'] == 0)
{
$ac = $row['egold_account'];
}
else
{
if ($row['ec'] == 1)
{
$ac = $row['evocash_account'];
}
else
{
if ($row['ec'] == 2)
{
$ac = $row['intgold_account'];
}
else
{
if ($row['ec'] == 4)
{
$ac = $row['stormpay_account'];
}
else
{
if ($row['ec'] == 5)
{
$ac = $row['ebullion_account'];
}
else
{
if ($row['ec'] == 6)
{
$ac = $row['paypal_account'];
}
else
{
if ($row['ec'] == 7)
{
$ac = $row['goldmoney_account'];
}
else
{
if ($row['ec'] == 8)
{
$ac = $row['eeecurrency_account'];
}
}
}
}
}
}
}
}

$amount = abs ($row['amount']);
$fee = floor ($amount * $settings['withdrawal_fee']) / 100;
if ($fee < $settings['withdrawal_fee_min'])
{
$fee = $settings['withdrawal_fee_min'];
}

$to_withdraw = $amount - $fee;
if ($to_withdraw < 0)
{
$to_withdraw = 0;
}

$to_withdraw = sprintf ('%.02f', floor ($to_withdraw * 100) / 100);
print $ac . ',' . abs ($to_withdraw) . '
';
}

db_close ($dbconn);
exit ();
}

if (($frm['action2'] == 'masspay' AND $frm['action3'] == 'masspay'))
{
if ($settings['demomode'] == 1)
{
exit ();
}

$ids = $frm['pend'];
if ($frm['e_acc'] == 1)
{
$egold_account = $frm['egold_account'];
$egold_password = $frm['egold_password'];
$settings['egold_from_account'] = $egold_account;
}
else
{
$q = 'select v from hm2_pay_settings where n=\'egold_account_password\'';
($sth = mysql_query ($q) OR print mysql_error ());
while ($row = mysql_fetch_array ($sth))
{
$egold_account = $settings['egold_from_account'];
$egold_password = decode_pass_for_mysql ($row['v']);
}
}

if ($frm['evo_acc'] == 1)
{
$evocash_account = $frm['evocash_account'];
$evocash_password = $frm['evocash_password'];
$evocash_code = $frm['evocash_code'];
$settings['evocash_username'] = $frm[evocash_name];
$settings['evocash_from_account'] = $evocash_account;
}
else
{
$q = 'select v from hm2_pay_settings where n=\'evocash_account_password\'';
($sth = mysql_query ($q) OR print mysql_error ());
while ($row = mysql_fetch_array ($sth))
{
$evocash_account = $settings['evocash_from_account'];
$evocash_password = decode_pass_for_mysql ($row['v']);
}

$q = 'select v from hm2_pay_settings where n=\'evocash_transaction_code\'';
($sth = mysql_query ($q) OR print mysql_error ());
while ($row = mysql_fetch_array ($sth))
{
$evocash_code = decode_pass_for_mysql ($row['v']);
}
}

if ($frm['intgold_acc'] == 1)
{
$intgold_account = $frm['intgold_account'];
$intgold_password = $frm['intgold_password'];
$intgold_code = $frm['intgold_code'];
$settings['intgold_from_account'] = $intgold_account;
}
else
{
$q = 'select v from hm2_pay_settings where n=\'intgold_password\'';
($sth = mysql_query ($q) OR print mysql_error ());
while ($row = mysql_fetch_array ($sth))
{
$intgold_account = $settings['intgold_from_account'];
$intgold_password = decode_pass_for_mysql ($row['v']);
}

$q = 'select v from hm2_pay_settings where n=\'intgold_transaction_code\'';
($sth = mysql_query ($q) OR print mysql_error ());
while ($row = mysql_fetch_array ($sth))
{
$intgold_code = decode_pass_for_mysql ($row['v']);
}
}

if ($frm['eeecurrency_acc'] == 1)
{
$eeecurrency_account = $frm['eeecurrency_account'];
$eeecurrency_password = $frm['eeecurrency_password'];
$eeecurrency_code = $frm['eeecurrency_code'];
$settings['eeecurrency_from_account'] = $eeecurrency_account;
}
else
{
$q = 'select v from hm2_pay_settings where n=\'eeecurrency_password\'';
($sth = mysql_query ($q) OR print mysql_error ());
while ($row = mysql_fetch_array ($sth))
{
$eeecurrency_account = $settings['eeecurrency_from_account'];
$eeecurrency_password = decode_pass_for_mysql ($row['v']);
}

$q = 'select v from hm2_pay_settings where n=\'eeecurrency_transaction_code\'';
($sth = mysql_query ($q) OR print mysql_error ());
while ($row = mysql_fetch_array ($sth))
{
$eeecurrency_code = decode_pass_for_mysql ($row['v']);
}
}

@set_time_limit (9999999);
reset ($ids);
while (list ($kk, $vv) = each ($ids))
{
$q = '' . 'select h.*, u.egold_account, u.evocash_account, u.intgold_account, u.ebullion_account, u.eeecurrency_account, u.username, u.name, u.email from hm2_history as h, hm2_users as u where h.id = ' . $kk . ' and u.id = h.user_id and h.ec in (0, 1, 2, 5, 8, 9)';
$sth = mysql_query ($q);
while ($row = mysql_fetch_array ($sth))
{
$amount = abs ($row['actual_amount']);
$fee = floor ($amount * $settings['withdrawal_fee']) / 100;
if ($fee < $settings['withdrawal_fee_min'])
{
$fee = $settings['withdrawal_fee_min'];
}

$to_withdraw = $amount - $fee;
if ($to_withdraw < 0)
{
$to_withdraw = 0;
}

$to_withdraw = sprintf ('%.02f', floor ($to_withdraw * 100) / 100);
$success_txt = 'Withdrawal to ' . $row['username'] . ' from ' . $settings['site_name'];
if ($row['ec'] == 0)
{
$error_txt = '' . 'Error, tried to send ' . $to_withdraw . ' to e-gold account # ' . $row['egold_account'] . '. Error:';
list ($res, $text, $batch) = send_money_to_egold ($egold_password, $to_withdraw, $row['egold_account'], $success_txt, $error_txt);
}

if ($row['ec'] == 1)
{
$error_txt = '' . 'Error, tried to send ' . $to_withdraw . ' to evocash account # ' . $row['evocash_account'] . '. Error:';
list ($res, $text, $batch) = send_money_to_evocash ('' . $evocash_password . '|' . $evocash_code, $to_withdraw, $row['evocash_account'], $success_txt, $error_txt);
}

if ($row['ec'] == 2)
{
$error_txt = '' . 'Error, tried to send ' . $to_withdraw . ' to IntGold account # ' . $row['intgold_account'] . '. Error:';
list ($res, $text, $batch) = send_money_to_intgold ('' . $intgold_password . '|' . $intgold_code, $to_withdraw, $row['intgold_account'], $success_txt, $error_txt);
}

if ($row['ec'] == 5)
{
$error_txt = '' . 'Error, tried to send ' . $to_withdraw . ' to e-Bullion account # ' . $row['ebullion_account'] . '. Error:';
list ($res, $text, $batch) = send_money_to_ebullion ('', $to_withdraw, $row['ebullion_account'], $success_txt, $error_txt);
}

if ($row['ec'] == 8)
{
$error_txt = '' . 'Error, tried to send ' . $to_withdraw . ' to eeeCurrency account # ' . $row['eeecurrency_account'] . '. Error:';
list ($res, $text, $batch) = send_money_to_eeecurrency ('' . $eeecurrency_password . '|' . $eeecurrency_code, $to_withdraw, $row['eeecurrency_account'], $success_txt, $error_txt);
}

if ($res == 1)
{
$q = '' . 'delete from hm2_history where id = ' . $kk;
mysql_query ($q);
$d_account = array ($row[egold_account], $row[evocash_account], $row[intgold_account], '', $row[stormpay_account], $row[ebullion_account], $row[paypal_account], $row[goldmoney_account], $row[eeecurrency_account]);
$q = 'insert into hm2_history set
user_id = ' . $row['user_id'] . ('' . ',
amount = -' . $amount . ',
actual_amount = -' . $amount . ',
type=\'withdrawal\',
date = now(),
ec = ') . $row['ec'] . ',
description = \'Withdrawal to account ' . $d_account[$row[ec]] . ('' . '. Batch is ' . $batch . '\'');
(mysql_query ($q) OR print mysql_error ());
$info = array ();
$info['username'] = $row['username'];
$info['name'] = $row['name'];
$info['amount'] = sprintf ('%.02f', 0 - $row['amount']);
$info['account'] = $d_account[$row[ec]];
$info['batch'] = $batch;
$info['currency'] = $exchange_systems[$row['ec']]['name'];
send_mail ('withdraw_user_notification', $row['email'], $settings['system_email'], $info);
print '' . 'Sent $ ' . $to_withdraw . ' to account' . $d_account[$row[ec]] . ' on ' . $exchange_systems[$row['ec']]['name'] . ('' . '. Batch is ' . $batch . '<br>');
}
else
{
print '' . $text . '<br>';
}

flush ();
}
}

db_close ($dbconn);
exit ();
}
}

if (($frm['a'] == 'auto-pay-settings' AND $frm['action'] == 'auto-pay-settings'))
{
if ($settings['demomode'] != 1)
{
if (($userinfo['transaction_code'] != '' AND $userinfo['transaction_code'] != $frm['alternative_passphrase']))
{
header ('Location: ?a=auto-pay-settings&say=invalid_passphrase');
db_close ($dbconn);
exit ();
}

$settings['use_auto_payment'] = $frm['use_auto_payment'];
$settings['egold_from_account'] = $frm['egold_from_account'];
$settings['evocash_from_account'] = $frm['evocash_from_account'];
$settings['evocash_username'] = $frm['evocash_username'];
if ($frm['evocash_account_password'] != '')
{
$evo_pass = quote (encode_pass_for_mysql ($frm['evocash_account_password']));
$q = 'delete from hm2_pay_settings where n=\'evocash_account_password\'';
mysql_query ($q);
$q = '' . 'insert into hm2_pay_settings set n=\'evocash_account_password\', v=\'' . $evo_pass . '\'';
mysql_query ($q);
}

if ($frm['evocash_transaction_code'] != '')
{
$evo_code = quote (encode_pass_for_mysql ($frm['evocash_transaction_code']));
$q = 'delete from hm2_pay_settings where n=\'evocash_transaction_code\'';
mysql_query ($q);
$q = '' . 'insert into hm2_pay_settings set n=\'evocash_transaction_code\', v=\'' . $evo_code . '\'';
mysql_query ($q);
}

$settings['intgold_from_account'] = $frm['intgold_from_account'];
if ($frm['intgold_password'] != '')
{
$intgold_pass = quote (encode_pass_for_mysql ($frm['intgold_password']));
$q = 'delete from hm2_pay_settings where n=\'intgold_password\'';
mysql_query ($q);
$q = '' . 'insert into hm2_pay_settings set n=\'intgold_password\', v=\'' . $intgold_pass . '\'';
mysql_query ($q);
}

if ($frm['intgold_transaction_code'] != '')
{
$intgold_code = quote (encode_pass_for_mysql ($frm['intgold_transaction_code']));
$q = 'delete from hm2_pay_settings where n=\'intgold_transaction_code\'';
mysql_query ($q);
$q = '' . 'insert into hm2_pay_settings set n=\'intgold_transaction_code\', v=\'' . $intgold_code . '\'';
mysql_query ($q);
}

$settings['eeecurrency_from_account'] = $frm['eeecurrency_from_account'];
if ($frm['eeecurrency_password'] != '')
{
$eeecurrency_pass = quote (encode_pass_for_mysql ($frm['eeecurrency_password']));
$q = 'delete from hm2_pay_settings where n=\'eeecurrency_password\'';
mysql_query ($q);
$q = '' . 'insert into hm2_pay_settings set n=\'eeecurrency_password\', v=\'' . $eeecurrency_pass . '\'';
mysql_query ($q);
}

if ($frm['eeecurrency_transaction_code'] != '')
{
$eeecurrency_code = quote (encode_pass_for_mysql ($frm['eeecurrency_transaction_code']));
$q = 'delete from hm2_pay_settings where n=\'eeecurrency_transaction_code\'';
mysql_query ($q);
$q = '' . 'insert into hm2_pay_settings set n=\'eeecurrency_transaction_code\', v=\'' . $eeecurrency_code . '\'';
mysql_query ($q);
}

$settings['min_auto_withdraw'] = $frm['min_auto_withdraw'];
$settings['max_auto_withdraw'] = $frm['max_auto_withdraw'];
$settings['max_auto_withdraw_user'] = $frm['max_auto_withdraw_user'];
save_settings ();
if ($frm['egold_account_password'] != '')
{
$e_pass = quote (encode_pass_for_mysql ($frm['egold_account_password']));
$q = 'delete from hm2_pay_settings where n=\'egold_account_password\'';
mysql_query ($q);
$q = '' . 'insert into hm2_pay_settings set n=\'egold_account_password\', v=\'' . $e_pass . '\'';
mysql_query ($q);
}
}

header ('Location: ?a=auto-pay-settings&say=done');
db_close ($dbconn);
exit ();
}

if (($frm['a'] == 'referal' AND $frm['action'] == 'change'))
{
if ($settings['demomode'] == 1)
{
}
else
{
$q = 'delete from hm2_referal where level = 1';
(mysql_query ($q) OR print mysql_error ());
for ($i = 0; $i < 300; ++$i)
{
if ($frm['active'][$i] == 1)
{
$qname = quote ($frm['ref_name'][$i]);
$from = sprintf ('%d', $frm['ref_from'][$i]);
$to = sprintf ('%d', $frm['ref_to'][$i]);
$percent = sprintf ('%0.2f', $frm['ref_percent'][$i]);
$percent_daily = sprintf ('%0.2f', $frm['ref_percent_daily'][$i]);
$percent_weekly = sprintf ('%0.2f', $frm['ref_percent_weekly'][$i]);
$percent_monthly = sprintf ('%0.2f', $frm['ref_percent_monthly'][$i]);
$q = '' . 'insert into hm2_referal set
level = 1,
name= \'' . $qname . '\',
from_value = ' . $from . ',
to_value= ' . $to . ',
percent = ' . $percent . ',
percent_daily = ' . $percent_daily . ',
percent_weekly = ' . $percent_weekly . ',
percent_monthly = ' . $percent_monthly;
(mysql_query ($q) OR print mysql_error ());
continue;
}
}

$settings['use_referal_program'] = sprintf ('%d', $frm['usereferal']);
$settings['force_upline'] = sprintf ('%d', $frm['force_upline']);
$settings['get_rand_ref'] = sprintf ('%d', $frm['get_rand_ref']);
$settings['use_active_referal'] = sprintf ('%d', $frm['useactivereferal']);
$settings['pay_active_referal'] = sprintf ('%d', $frm['payactivereferal']);
$settings['use_solid_referral_commission'] = sprintf ('%d', $frm['use_solid_referral_commission']);
$settings['solid_referral_commission_amount'] = sprintf ('%.02f', $frm['solid_referral_commission_amount']);
$settings['ref2_cms'] = sprintf ('%0.2f', $frm['ref2_cms']);
$settings['ref3_cms'] = sprintf ('%0.2f', $frm['ref3_cms']);
$settings['ref4_cms'] = sprintf ('%0.2f', $frm['ref4_cms']);
$settings['ref5_cms'] = sprintf ('%0.2f', $frm['ref5_cms']);
$settings['ref6_cms'] = sprintf ('%0.2f', $frm['ref6_cms']);
$settings['ref7_cms'] = sprintf ('%0.2f', $frm['ref7_cms']);
$settings['ref8_cms'] = sprintf ('%0.2f', $frm['ref8_cms']);
$settings['ref9_cms'] = sprintf ('%0.2f', $frm['ref9_cms']);
$settings['ref10_cms'] = sprintf ('%0.2f', $frm['ref10_cms']);
$settings['show_referals'] = sprintf ('%d', $frm['show_referals']);
$settings['show_refstat'] = sprintf ('%d', $frm['show_refstat']);
save_settings ();
}

header ('Location: ?a=referal');
db_close ($dbconn);
exit ();
}

if ($frm['a'] == 'deleterate')
{
$id = sprintf ('%d', $frm['id']);
if (($id < 3 AND $settings['demomode'] == 1))
{
}
else
{
$q = '' . 'delete from hm2_types where id = ' . $id;
(mysql_query ($q) OR print mysql_error ());
$q = '' . 'delete from hm2_plans where parent = ' . $id;
(mysql_query ($q) OR print mysql_error ());
}

header ('Location: ?a=rates');
db_close ($dbconn);
exit ();
}

if (($frm['a'] == 'newsletter' AND $frm['action'] == 'newsletter'))
{
if ($frm['to'] == 'user')
{
$q = 'select * from hm2_users where username = \'' . quote ($frm['username']) . '\'';
}
else
{
if ($frm['to'] == 'all')
{
$q = 'select * from hm2_users where id > 1';
}
else
{
if ($frm['to'] == 'active')
{
$q = 'select hm2_users.* from hm2_users, hm2_deposits where hm2_users.id > 1 and hm2_deposits.user_id = hm2_users.id group by hm2_users.id';
}
else
{
if ($frm['to'] == 'passive')
{
$q = 'select u.* from hm2_users as u left outer join hm2_deposits as d on u.id = d.user_id where u.id > 1 and d.user_id is NULL';
}
else
{
header ('Location: ?a=newsletter&say=someerror');
db_close ($dbconn);
exit ();
}
}
}
}

($sth = mysql_query ($q) OR print mysql_error ());
$flag = 0;
$total = 0;
echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>HYIP Manager Pro. Auto-payment, mass payment included.</title>
<link href="images/adminstyle.css" rel="stylesheet" type="text/css">
</head>
<body bgcolor="#FFFFF2" link="#666699" vlink="#666699" alink="#666699" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" >
<center>
';
print '<br><br><br><br><br><div id=\'newsletterplace\'></div>';
print '<div id=self_menu0></div>';
$description = $frm['description'];
if ($settings['demomode'] != 1)
{
set_time_limit (9999999);
while ($row = mysql_fetch_array ($sth))
{
$flag = 1;
++$total;
$mailcont = $description;
$mailcont = ereg_replace ('#username#', $row['username'], $mailcont);
$mailcont = ereg_replace ('#name#', $row['name'], $mailcont);
$mailcont = ereg_replace ('#date_register#', $row['date_register'], $mailcont);
$mailcont = ereg_replace ('#egold_account#', $row['egold_account'], $mailcont);
$mailcont = ereg_replace ('#email#', $row['email'], $mailcont);
mail ($row['email'], $frm['subject'], $mailcont, 'From: ' . $settings['system_email'] . '
Reply-To: ' . $settings['system_email']);
print '<script>var obj = document.getElementById(\'newsletterplace\');
var menulast = document.getElementById(\'self_menu' . ($total - 1) . '\');
menulast.style.display=\'none\';</script>';
print '' . '<div id=\'self_menu' . $total . '\'>Just sent to ' . $row[email] . ('' . '<br>Total ' . $total . ' messages sent.</div>');
print '' . '<script>var menu = document.getElementById(\'self_menu' . $total . '\');
obj.appendChild(menu);
</script>
';
flush ();
}
}

if ($flag == 1)
{
}

db_close ($dbconn);
print '' . '<br><br><br>Sent ' . $total . '.</center></body></html>';
exit ();
}

if (($frm['a'] == 'edit_emails' AND $frm['action'] == 'update_statuses'))
{
$q = 'update hm2_emails set status = 0';
mysql_query ($q);
$update_emails = $frm['emails'];
if (is_array ($update_emails))
{
foreach ($update_emails as $email_id => $tmp)
{
$q = '' . 'update hm2_emails set status = 1 where id = \'' . $email_id . '\'';
mysql_query ($q);
}
}

header ('Location: ?a=edit_emails');
db_close ($dbconn);
exit ();
}

if (($frm['a'] == 'send_bonuce' AND ($frm['action'] == 'send_bonuce' OR $frm['action']

IPB Skin By Virteq