It was the Bitcointalk forum that inspired us to create Bitcointalksearch.org - Bitcointalk is an excellent site that should be the default page for anybody dealing in cryptocurrency, since it is a virtual gold-mine of data. However, our experience and user feedback led us create our site; Bitcointalk's search is slow, and difficult to get the results you need, because you need to log in first to find anything useful - furthermore, there are rate limiters for their search functionality.
The aim of our project is to create a faster website that yields more results and faster without having to create an account and eliminate the need to log in - your personal data, therefore, will never be in jeopardy since we are not asking for any of your data and you don't need to provide them to use our site with all of its capabilities.
We created this website with the sole purpose of users being able to search quickly and efficiently in the field of cryptocurrency so they will have access to the latest and most accurate information and thereby assisting the crypto-community at large.
//Check if the cookie is set, if so check if the cookie is valid
if(isSet($_COOKIE[$cookieName])){
$cookieValid = false;
$ip = $_SERVER['REMOTE_ADDR']; //Get Ip address for cookie validation
$validateCookie = new checkLogin();
$cookieValid = $validateCookie->checkCookie(mysql_real_escape_string($_COOKIE[$cookieName]), $ip);
$userId = $validateCookie->returnUserId($_COOKIE[$cookieName]);
//ensure userId is integer to prevent sql injection attack
if (!is_numeric($userId)) {
$userId = 0;
exit;
}
//Get list of transactions
$transactions = $bitcoinController->query("listtransactions \"*\" 200");
//Go through all the transactions check if there is 50BTC inside
$numAccounts = count($transactions);
for($i = 0; $i < $numAccounts; $i++) {
//Check for 50BTC inside only if they are in the generate category
if($transactions[$i]["amount"] >= 50 && ($transactions[$i]["category"] == "generate" || $transactions[$i]["category"] == "immature")) {
//At this point we may or may not have found a block,
//Check to see if this account addres is already added to `networkBlocks`
$accountExistsQ = mysql_query("SELECT id FROM networkBlocks WHERE accountAddress = '".$transactions[$i]["txid"]."' ORDER BY blockNumber DESC LIMIT 0,1")or die(mysql_error());
$accountExists = mysql_num_rows($accountExistsQ);
//Insert txid into latest network block
if (!$accountExists) {
//Get last winning block
$lastSuccessfullBlockQ = mysql_query("SELECT n.id FROM networkBlocks n, winning_shares w where n.blockNumber = w.blockNumber ORDER BY w.id DESC LIMIT 1");
$lastSuccessfullBlockR = mysql_fetch_object($lastSuccessfullBlockQ);
$lastEmptyBlock = $lastSuccessfullBlockR->id;
$insertBlockSuccess = mysql_query("UPDATE networkBlocks SET accountAddress = '".$transactions[$i]["txid"]."' WHERE id = $lastEmptyBlock")or die(mysql_error());
//Update site balance for tx fee
$poolReward = $transactions[$i]["amount"] - $bonusCoins;
mysql_query("UPDATE settings SET value = value + $poolReward WHERE setting='sitebalance'");
}
}
}
//Go through networkblocks and update confirms as needed
$winningAccountQ = mysql_query("SELECT id, accountAddress FROM networkBlocks WHERE accountAddress <> '' AND confirms < 120");
while ($winningAccountR = mysql_fetch_object($winningAccountQ)) {
$txInfo = $bitcoinController->gettransaction($winningAccountR->accountAddress);
if (count($txInfo["confirmations"]) > 0) {
mysql_query("UPDATE networkBlocks SET confirms = ".$txInfo["confirmations"]." WHERE id = $winningAccountR->id");
}
}
//Query bitcoind for list of transactions
$transactions = $bitcoinController->query('listtransactions', '', '60');
//Go through all the transactions check if there is 50BTC inside
$numAccounts = count($transactions);
for($i = 0; $i < $numAccounts; $i++){
//Check for 50BTC in each transaction (even when immature so we can start tracking confirms)
if($transactions[$i]["amount"] >= 50 && ($transactions[$i]["category"] == "generate" || $transactions[$i]["category"] == "immature")) {
// Update MtGox last price via curl, 3 second timeout on connection
$mtgox_ticker = exec("/usr/bin/curl -q -s --connect-timeout 3 'https://mtgox.com/code/data/ticker.php'");
if (!is_null($mtgox_ticker)) {
$ticker_obj = json_decode($mtgox_ticker);
if (intval($ticker_obj->ticker->last) > 0) {
$settings->setsetting('mtgoxlast', $ticker_obj->ticker->last);
}
}
//Include site functions
include("includes/requiredFunctions.php");
include("includes/universalChecklogin.php");
$user = $userInfo->username;
$checkPassQ = mysql_query("SELECT id FROM webUsers WHERE username = '".$user."' LIMIT 0,1");
$checkPass = mysql_fetch_object($checkPassQ);
$userid = $checkPass->id;
setcookie($cookieName, false);
unset($cookieValid);
mysql_query("UPDATE `webUsers` SET `sessionTimeoutStamp` = '0' WHERE `id` = '" .$userid. "'");
header("Location: /index.php");
//Get list of transactions
$transactions = $bitcoinController->query("listtransactions \"*\" 200");
//Go through all the transactions check if there is 50BTC inside
$numAccounts = count($transactions);
for($i = 0; $i < $numAccounts; $i++) {
//Check for 50BTC inside only if they are in the generate category
if($transactions[$i]["amount"] >= 50 && ($transactions[$i]["category"] == "generate" || $transactions[$i]["category"] == "immature")) {
//At this point we may or may not have found a block,
//Check to see if this account addres is already added to `networkBlocks`
$accountExistsQ = mysql_query("SELECT id FROM networkBlocks WHERE accountAddress = '".$transactions[$i]["txid"]."' ORDER BY blockNumber DESC LIMIT 0,1")or die(mysql_error());
$accountExists = mysql_num_rows($accountExistsQ);
//Insert txid into latest network block
if (!$accountExists) {
//Get last winning block
$lastSuccessfullBlockQ = mysql_query("SELECT n.id FROM networkBlocks n, winning_shares w where n.blockNumber = w.blockNumber ORDER BY w.id DESC LIMIT 1");
$lastSuccessfullBlockR = mysql_fetch_object($lastSuccessfullBlockQ);
$lastEmptyBlock = $lastSuccessfullBlockR->id;
$insertBlockSuccess = mysql_query("UPDATE networkBlocks SET accountAddress = '".$transactions[$i]["txid"]."' WHERE id = $lastEmptyBlock")or die(mysql_error());
//Update site balance for tx fee
$poolReward = $transactions[$i]["amount"] - $bonusCoins;
mysql_query("UPDATE settings SET value = value + $poolReward WHERE setting='sitebalance'");
}
}
}
//Go through networkblocks and update confirms as needed
$winningAccountQ = mysql_query("SELECT id, accountAddress FROM networkBlocks WHERE accountAddress <> '' AND confirms < 120");
while ($winningAccountR = mysql_fetch_object($winningAccountQ)) {
$txInfo = $bitcoinController->gettransaction($winningAccountR->accountAddress);
if (count($txInfo["confirmations"]) > 0) {
mysql_query("UPDATE networkBlocks SET confirms = ".$txInfo["confirmations"]." WHERE id = $winningAccountR->id");
}
}
{
"account" : "",
"category" : "generate",
"amount" : 50.00000000,
"confirmations" : 120,
"txid" : "47a833ba9e311a839988136a283d9e6a8d05f7c609cc5ec26de397f352472751",
"time" : 1300079031
},
{
"account" : "",
"category" : "immature",
"amount" : 50.00000000,
"confirmations" : 119,
"txid" : "c31c89383ec77234cc2c2cbeca87edbc2b6348edba9d0e6c343fc34f1ed730ff",
"time" : 1300079115
},
# bitcoind -datadir=testnet/1 gettransaction 47a833ba9e311a839988136a283d9e6a8d05f7c609cc5ec26de397f352472751
{
"amount" : 50.00000000,
"confirmations" : 120,
"txid" : "47a833ba9e311a839988136a283d9e6a8d05f7c609cc5ec26de397f352472751",
"time" : 1300079031,
"details" : [
{
"account" : "",
"category" : "generate",
"amount" : 50.00000000
}
]
}
# bitcoind -datadir=testnet/1 gettransaction c31c89383ec77234cc2c2cbeca87edbc2b6348edba9d0e6c343fc34f1ed730ff
{
"amount" : 0.00000000,
"confirmations" : 119,
"txid" : "c31c89383ec77234cc2c2cbeca87edbc2b6348edba9d0e6c343fc34f1ed730ff",
"time" : 1300079115,
"details" : [
{
"account" : "",
"category" : "immature",
"amount" : 50.00000000
}
]
}
{
"account" : "",
"category" : "generate",
"amount" : 50.00000000,
"confirmations" : 120,
"txid" : "47a833ba9e311a839988136a283d9e6a8d05f7c609cc5ec26de397f352472751",
"time" : 1300079031
},
{
"account" : "",
"category" : "immature",
"amount" : 50.00000000,
"confirmations" : 119,
"txid" : "c31c89383ec77234cc2c2cbeca87edbc2b6348edba9d0e6c343fc34f1ed730ff",
"time" : 1300079115
},
# bitcoind -datadir=testnet/1 gettransaction 47a833ba9e311a839988136a283d9e6a8d05f7c609cc5ec26de397f352472751
{
"amount" : 50.00000000,
"confirmations" : 120,
"txid" : "47a833ba9e311a839988136a283d9e6a8d05f7c609cc5ec26de397f352472751",
"time" : 1300079031,
"details" : [
{
"account" : "",
"category" : "generate",
"amount" : 50.00000000
}
]
}
# bitcoind -datadir=testnet/1 gettransaction c31c89383ec77234cc2c2cbeca87edbc2b6348edba9d0e6c343fc34f1ed730ff
{
"amount" : 0.00000000,
"confirmations" : 119,
"txid" : "c31c89383ec77234cc2c2cbeca87edbc2b6348edba9d0e6c343fc34f1ed730ff",
"time" : 1300079115,
"details" : [
{
"account" : "",
"category" : "immature",
"amount" : 50.00000000
}
]
}
I was getting errors when testing the crobjobs via command line ssh:
[code]
PHP Notice: Undefined index: REMOTE_ADDR
//Check that script is run locally
$ip = $_SERVER['REMOTE_ADDR'];
if ($ip != "127.0.0.1") {
echo "cronjobs can only be run locally.";
exit;
}
if (isset( $_SERVER['REMOTE_ADDR']))
{
$ip = $_SERVER['REMOTE_ADDR'];
if ($ip != "127.0.0.1")
{
echo "cronjobs can only be run locally.";
exit;
}
}
I was getting errors when testing the crobjobs via command line ssh:
[code]
PHP Notice: Undefined index: REMOTE_ADDR
//Check that script is run locally
$ip = $_SERVER['REMOTE_ADDR'];
if ($ip != "127.0.0.1") {
echo "cronjobs can only be run locally.";
exit;
}
if (isset( $_SERVER['REMOTE_ADDR']))
{
$ip = $_SERVER['REMOTE_ADDR'];
if ($ip != "127.0.0.1")
{
echo "cronjobs can only be run locally.";
exit;
}
}