$bContinue = false; } } else { $errMessage .= "SQL Connection Error in Selecting Account<br />\n"; $bContinue = false; } } // Now, here, we perform our GLOBAL list operations - look in the OPERATION_QUEUE // for a SELL_SORT event. If none exists, throw it on the end. if ($bContinue) { if (!operationQueueSearch("SELL_SORT")) { operationQueuePush("SELL_SORT"); } // Finally, if the user is offering to sell at less than 96% of the current price, execute it right now. if ($_POST['btcs_btc_price'] <= 0.96 * getCurrentBTCPrice()) { operationQueuePush("SELL{" . $tradeID . "}"); } } } else { if ("cancel" == $_POST['action']) { // Make sure required data exists if (!isset($_POST['type']) || !isset($_POST['ID_to_cancel'])) { $errMessage .= "Cancel operation failed - missing required data!<br />\n"; $bContinue = false; } else { if ("" == $_POST['ID_to_cancel']) { $errMessage .= "Cancel operation failed - data not correctly sent!<br />\n"; $bContinue = false; } } // Set variables depending on if it is a BUY or SELL transaction we are cancelling
} $i++; } // Trim here if ($trimFile == true) { // So, just erase the file, and write from lines $trimEndLine to the end back into the file. file_put_contents($fName, "", LOCK_EX); for ($j = $trimEndLine + 1; isset($fileLines[$j + 1]); $j++) { file_put_contents($fName, $fileLines[$j] . "\n", FILE_APPEND | LOCK_EX); } } echo $i . " entries processed."; } else { $toAdd = "NO VALUE SENT.\n"; } } file_put_contents($fName, $toAdd, FILE_APPEND | LOCK_EX); file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/backup.dat", $toAdd, FILE_APPEND | LOCK_EX); // Just for now, until you're sure this works. echo "File Write Successful\n"; // Now, here, we perform our GLOBAL list operations - add bitcoin price to our global array, // and also look in the OPERATION_QUEUE to see if a TRADE_CHECK event exists. If not, add it. // If the arr_bitcoin_price doesn't exist, add it anyways. Same for operation_queue if ('true' == $_POST['dataSend']) { $lineData = explode("-", $_POST['value']); // TODO This bit needs to be uncommented ONLY in development OR active launch - otherwise large amounts of data can be used! btcPricePush($lineData[2] / 100000); if (!operationQueueSearch("TRADE_CHECK")) { operationQueuePush("TRADE_CHECK"); } }
// Update our sell_low to reflect the new low price: the first one to NOT make the cut. if ($nextLine != NULL) { $_SESSION['sell_low'] = $nextLineData[3]; } else { $_SESSION['sell_low'] = 999999; } } } // Ask the computer to perform all of the requested buys... foreach ($buyList as $buy) { operationQueuePush("BUY{" . $buy . "}"); $tradeCounter++; } // Ask the computer to perform all of the requested sales... foreach ($sellList as $sell) { operationQueuePush("SELL{" . $sell . "}"); $tradeCounter++; } echo "Time elapsed: " . (time() - $exitTime + 5) . "<br />\n"; echo "Trades Added: {$tradeCounter}<br />\n"; } else { if ("BUY" == $_POST['request']) { // bContinue - set at false at any point to abort with message. Check before proceeding to next step. $bContinue = true; // Make sure that we've been given an ID to perform an action on... if (!isset($_POST['data'])) { echo "No buy ID given - abort<br />\n"; $bContinue = false; } // Find the trade in buy.dat if ($bContinue) {