config var to dis/allow autoexchange

This commit is contained in:
Tanguy Pruvot 2015-07-10 10:41:17 +02:00
parent 721bedbda7
commit 6b819c3be1
3 changed files with 51 additions and 1 deletions

View file

@ -19,6 +19,8 @@ define('YAAMP_FEES_EXCHANGE', 2);
define('YAAMP_FEES_RENTING', 2);
define('YAAMP_PAYMENTS_FREQ', 3*60*60);
define('YAAMP_ALLOW_EXCHANGE', false);
define('YAAMP_BTCADDRESS', '1Auhps1mHZQpoX4mCcVL8odU81VakZQ6dR');
define('YAAMP_SITE_URL', 'yiimp.ccminer.org');
define('YAAMP_ADMIN_EMAIL', 'yiimp@spam.la');

View file

@ -43,6 +43,9 @@ class CheckupCommand extends CConsoleCommand
self::autolinkCoinsImages();
if (YAAMP_ALLOW_EXCHANGE == false)
self::cleanUserBalancesBTC();
echo "ok\n";
return 0;
}
@ -193,4 +196,49 @@ class CheckupCommand extends CConsoleCommand
}
}
/**
* Drop BTC user balances if YAAMP_ALLOW_EXCHANGE is false
*/
public function cleanUserBalancesBTC()
{
$modelsPath = $this->basePath.'/yaamp/models';
if(!is_dir($modelsPath))
echo "Directory $modelsPath is not a directory\n";
require_once($modelsPath.'/db_accountsModel.php');
$obj = CActiveRecord::model('db_accounts');
$table = $obj->getTableSchema()->name;
try{
$users = new $obj;
} catch (Exception $e) {
echo "Error Model: $table \n";
echo $e->getMessage();
continue;
}
if ($users instanceof CActiveRecord)
{
echo "$table: ".$users->count()." records\n";
$nbUpdated = 0;
foreach ($users->findAll() as $user)
{
if ($user->coinid != 6)
continue;
$user->balance = 0;
dborun("DELETE FROM balanceuser WHERE userid=".$user->id);
dborun("DELETE FROM hashuser WHERE userid=".$user->id);
dborun("DELETE FROM shares WHERE userid=".$user->id);
dborun("DELETE FROM workers WHERE userid=".$user->id);
dborun("UPDATE earnings SET userid=0 WHERE userid=".$user->id);
dborun("UPDATE blocks SET userid=0 WHERE userid=".$user->id);
$nbUpdated += $user->save();
}
echo "$nbUpdated users cleaned\n";
}
}
}

View file

@ -26,7 +26,7 @@ if(!$refcoin)
$refcoin = getdbosql('db_coins', "symbol='BTC'");
} elseif ($user->coinid == 6 && $defaultalgo != 'sha256') {
} elseif (!YAAMP_ALLOW_EXCHANGE && $user->coinid == 6 && $defaultalgo != 'sha256') {
echo "<div style='color: red; padding: 10px; '>This pool does not convert/trade currencies.
You will not receive payments using this BTC address.</div>";