01,11,21,31,41,51 * * * * wget -qO- http://yoursite.com/MarginBot/TenMinuteCron.php >/dev/null 2>&1 ////////////////////////////////*/ // file configs // require_once "../inc/config.php"; // db connectors and functions // require_once "../inc/database.php"; $db = new Database(); // account functions // require_once "../inc/Accounts.php"; $act = new Accounts(); require_once '../inc/ExchangeAPIs/bitfinex.php'; // * Get All Active BFX Accounts * // // * Create Account Objects for them * // // check that the crons database exists // $cronsTableSQL = ' CREATE TABLE IF NOT EXISTS `' . $config['db']['prefix'] . 'CronRuns` ( `id` int(11) NOT NULL AUTO_INCREMENT, `cron_id` tinyint(1) NOT NULL, `lastrun` datetime NOT NULL, `details` varchar(256) NOT NULL, PRIMARY KEY (`id`) )'; $rt = $db->iquery($cronsTableSQL); $userIds = $db->query("SELECT id from `" . $config['db']['prefix'] . "Users` WHERE status >= '1' AND ( status != '2' AND status != '8' ) ORDER BY id ASC"); foreach ($userIds as $uid) { $accounts[$uid['id']] = new $act($uid['id']); /* Run the bot to update all pending loans according to account settings */ $accounts[$uid['id']]->bfx->bitfinex_updateMyLends(); // mark it in the crons table so we know its working $cronUpdates = $db->iquery("INSERT into `" . $config['db']['prefix'] . "CronRuns` (`cron_id`, `lastrun`, `details`) VALUES ('2', NOW(), 'Updated User " . $uid['id'] . " Current Loans')"); }
<?php // Ajax Handler // file configs // require_once "../inc/config.php"; // db connectors and functions // require_once "../inc/database.php"; $db = new Database(); // account functions // require_once "../inc/Accounts.php"; $act = new Accounts(); require_once '../inc/ExchangeAPIs/bitfinex.php'; if ($_REQUEST['doPause'] == 1) { // flip the pause/unpause setting on an account // $userP = $db->iquery("UPDATE `" . $config['db']['prefix'] . "Users` set status = (CASE\n\t\tWHEN status = 1 THEN 2\n\t\t\tWHEN status = 2 THEN 1\n\t\t\tWHEN status = 9 THEN 8\n\t\t\tWHEN status = 8 THEN 9\n\t\tEND)\n\tWHERE id = '" . $db->escapeStr($_REQUEST['uid']) . "' LIMIT 1"); if ($userP['num'] > 0) { echo '1'; } else { echo '0'; } }
$warning[] = 'This bitfinex key already exists in our database'; } } } if (count($warning) == 0) { // test their bfx key and sec to see if we can pull data // $bfxTest = new Bitfinex(0, $_REQUEST['installAdminBFXKey'], $_REQUEST['installAdminBFXSec']); $bt = $bfxTest->bitfinex_get('account_infos'); if ($bt[0]['fees'][0]['pairs'] != '') { // looks good // // Create The Account // // hash the password $passEnc = $hasher->HashPassword($_REQUEST['installAdminPassword']); // write account to db $sql = "INSERT into `" . $config['db']['prefix'] . "Users` (`name`,`email`,`password`,`bfxapikey`,`bfxapisec`,`status` )\n\t\t\t\t VALUES\n\t\t\t\t ( '" . $db->escapeStr($_REQUEST['installAdminUser']) . "', '" . $db->escapeStr($_REQUEST['installAdminEmail']) . "', '" . $db->escapeStr($passEnc) . "',\n\t\t\t\t '" . $db->escapeStr($_REQUEST['installAdminBFXKey']) . "', '" . $db->escapeStr($_REQUEST['installAdminBFXSec']) . "', '9' )"; $newUser = $db->iquery($sql); if ($newUser['id'] != 0) { // Set default settings for the account // $sql = "INSERT into `" . $config['db']['prefix'] . "Vars` (`id`,`minlendrate`,`spreadlend`,`USDgapBottom`,`USDgapTop`,`thirtyDayMin`,`highholdlimit`,`highholdamt` )\n\t\t\t\t\t VALUES\n\t\t\t\t\t ( '" . $newUser['id'] . "', '0.0650', '3', '25000', '100000', '0.1500', '0.3500', '0' )"; $newActSettings = $db->iquery($sql); // Success, tell them they need to login now // $alert[] = '<strong>User ' . $_REQUEST['new_name'] . '</strong> Account Created'; $_REQUEST['doInstall'] = 3; } } } else { // something wasn't right, make them fixe it.... $_REQUEST['doInstall'] == 2; } } }