Esempio n. 1
0
            }
            $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");
    }
}
Esempio n. 2
0
                 // Update SQL also.
                 $_SESSION['user']['ActivePortfolio']['Pending'] = $updatedPendingTrades;
                 $_SESSION['user']['PracticeAcct'][$_SESSION['user']['ActivePortfolio']['ID']]['Pending'] = $updatedPendingTrades;
             } else {
                 $errMessage .= "SQL Connection Error in Updating Account<br />\n";
                 $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']) {