function AutoLendByUserId($userid) { global $database, $session; $GLOBALS['loanArray'] = array(); $fullyFundedAll = array(); $lenders = $database->getAllLenderForAutoLend($userid); $GLOBALS['loanArray'] = $database->getAllLoansForAutoLend($userid); foreach ($GLOBALS['loanArray'] as $key => $row) { $status = $session->getStatusBar($row['borrowerid'], $row['loanid'], 5); if ($status >= 100) { unset($GLOBALS['loanArray'][$key]); } } if (!empty($GLOBALS['loanArray'])) { shuffle($GLOBALS['loanArray']); } if (!empty($lenders)) { shuffle($lenders); foreach ($lenders as $lender) { Logger_Array("AutoBid---LOG", 'lender ID', $lender['lender_id']); $possibleLoans = 0; $loansToAutolend = array(); $availAmount = $session->amountToUseForBid($lender['lender_id']); if ($availAmount >= AUTO_LEND_AMT) { if ($lender['current_allocated'] == 0) { $amounToAutoLend = bcsub($availAmount, $lender['lender_credit'], 2); if ($amounToAutoLend >= AUTO_LEND_AMT) { $possibleLoans = floor($amounToAutoLend / AUTO_LEND_AMT); } } else { $possibleLoans = floor($availAmount / AUTO_LEND_AMT); } Logger_Array("AutoBid---LOG", '$possibleLoans =', $possibleLoans); if ($possibleLoans) { $loansToAutolend = $database->getSortedLoanForAutoBid($lender['preference'], $GLOBALS['loanArray'], $lender['desired_interest'], $lender['max_desired_interest'], $fullyFundedAll); Logger_Array("AutoBid---LOG", 'Possible loan', 'sorted Loan' . $possibleLoans, count($loansToAutolend)); if ($possibleLoans < count($loansToAutolend)) { $loansToAutolend = array_slice($loansToAutolend, 0, $possibleLoans); } Logger_Array("AutoBid---LOG", '$loansToAutolend', 'loanid', 'reqdamt', 'interest', 'interest', 'WebFee', 'applydate', 'borrowerid', 'intOffer', $loansToAutolend); if (!empty($loansToAutolend)) { $fullyFundedAll = placeAutobid($lender['preference'], $loansToAutolend, $possibleLoans, $lender['lender_id'], $lender['desired_interest'], $lender['max_desired_interest']); } } } } } }
$peak = tools::isPeakNow(true); if (strtotime($peak['peak_start']) < time()) { $peak['peak_start'] = date('Y-m-d H:i:s', strtotime($peak['peak_start']) + 86400); } $seconds_after_peak = strtotime($auction['end_time']) - strtotime($peak['peak_end']); $time = strtotime($peak['peak_start']) + $seconds_after_peak; $endTime = date('Y-m-d H:i:s', $time); if (strtotime($endTime) < time()) { $endTime = date('Y-m-d H:i:s', strtotime($endTime) + 86400); } $db->update('auctions', "end_time = '{$endTime}'", "id = {$auction['id']}"); } else { $data['auction_peak_start'] = get('auction_peak_start'); $data['auction_peak_end'] = get('auction_peak_end'); $data['isPeakNow'] = $isPeakNow; $data['time_increment'] = get('time_increment', $auction['id'], 0); $data['bid_debit'] = get('bid_debit', $auction['id'], 0); $data['price_increment'] = get('price_increment', $auction['id'], 0); placeAutobid($auction['id'], $data, false, 3); } } else { closeAuction($auction); } } } } usleep(500000); } tools::deleteCache('close.pid'); break; }
function check($auction_id, $end_time, $data) { $db = Database::getInstance(); $extend = $db->getRow("SELECT * FROM " . DB_PREFIX . "extends WHERE auction_id = {$auction_id}"); if (!empty($extend)) { if ($extend['end_time'] == $end_time) { if ($extend['deploy'] <= date('Y-m-d H:i:s')) { placeAutobid($auction_id, $data, time() - $end_time); $db->delete("extends", "auction_id = {$auction_id}"); $auction = $db->getRow("SELECT end_time FROM " . DB_PREFIX . "auctions WHERE id = {$auction_id}"); $end_time = $auction['end_time']; } else { return false; } } else { $db->delete("extends", "auction_id = {$auction_id}"); } } $str_end_time = strtotime($end_time); $timeDifference = $str_end_time - time(); $randomTime = rand(3, $timeDifference); $deploy = date('Y-m-d H:i:s', $str_end_time - $randomTime); $db->insert("extends", array("auction_id" => $auction_id, "deploy" => $deploy, "end_time" => $end_time)); return $data; }