Example #1
0
 function FindNewGenerations($bitcoinController)
 {
     $blockcount = 0;
     $username = '';
     //Get list of last 200 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]["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 sqlerr(__FILE__, __LINE__);
             $accountExists = mysql_num_rows($accountExistsQ);
             //Insert txid into latest network block
             if (!$accountExists) {
                 //Get last winning block
                 $lastSuccessfullBlockQ = mysql_query("SELECT blockNumber, id, username FROM winning_shares ORDER BY id DESC LIMIT 1") or sqlerr(__FILE__, __LINE__);
                 $lastSuccessfullBlockR = mysql_fetch_object($lastSuccessfullBlockQ);
                 $timestamp = $transactions[$i]["time"];
                 $id = $lastSuccessfullBlockR->id;
                 $rpcType = "http";
                 // http or https
                 $rpcUsername = "******";
                 // username
                 $rpcPassword = "******";
                 // password
                 $rpcHost = "localhost";
                 $rpcPort = 9000;
                 $bitcoinController = new BitcoinClient($rpcType, $rpcUsername, $rpcPassword, $rpcHost, $rpcPort);
                 $currentBlockNumber = $bitcoinController->getblocknumber();
                 $confirms = $transactions[$i]["confirmations"];
                 $lastBlockNumber = $currentBlockNumber + 1 - $confirms;
                 $stats = new Stats();
                 mysql_query("INSERT INTO networkBlocks (blockNumber, timestamp, accountAddress, confirms) " . "VALUES ('{$lastBlockNumber}', '{$timestamp}', '" . $transactions[$i]["txid"] . "', '" . $transactions[$i]["confirmations"] . "')") or sqlerr(__FILE__, __LINE__);
                 $stats = new Stats();
                 $lastwinningid = $stats->lastWinningShareId();
                 $shareQ = mysql_query("SELECT sum(shares) as total from rounddetails WHERE blockNumber = {$lastBlockNumber}");
                 $shareC = mysql_fetch_object($shareQ);
                 $winningShareQ = mysql_query("SELECT id, username FROM shares where upstream_result = 'Y' AND id > {$lastwinningid}") or sqlerr(__FILE__, __LINE__);
                 while ($winningShareR = mysql_fetch_object($winningShareQ)) {
                     mysql_query("INSERT INTO winning_shares (blockNumber, username, share_id) VALUES ({$lastBlockNumber},'{$winningShareR->username}',{$winningShareR->id})") or sqlerr(__FILE__, __LINE__);
                     removeCache("last_winning_share_id");
                 }
                 //					$q = "UPDATE winning_shares SET amount = " . $transactions[$i]["amount"] . ", timestamp = " . $timestamp . ", txid = '".$transactions[$i]["txid"] . "', type = '" . $transactions[$i]["category"] . "', shares = ". $shareC->total . " WHERE blockNumber = $lastBlockNumber";
                 $q = "UPDATE winning_shares SET amount = " . $transactions[$i]["amount"] . ", timestamp = " . $timestamp . ", txid = '" . $transactions[$i]["txid"] . "', type = '" . $transactions[$i]["category"] . "' WHERE blockNumber = {$lastBlockNumber}";
                 echo $q;
                 mysql_query($q) or sqlerr(__FILE__, __LINE__);
                 $username = $lastSuccessfullBlockR->username;
                 $splitUsername = explode(".", $username);
                 $realUsername = $splitUsername[0];
                 $blockcount = $blockcount + 1;
                 $username .= $realUsername . ' ';
             }
         }
     }
 }
Example #2
0
 function InsertNetworkBlocks($lastBlockNumber, $lastwinningid)
 {
     //Check to see if last block number exists in the db.
     $inDatabaseQ = mysql_query("SELECT id FROM networkBlocks WHERE blockNumber = {$lastBlockNumber} LIMIT 0,1");
     if ($inDatabaseQ) {
         $inDatabase = mysql_num_rows($inDatabaseQ);
     }
     if (isset($inDatabase)) {
         if (!$inDatabase) {
             //If not, insert it.
             $currentTime = time();
             mysql_query("INSERT INTO networkBlocks (blockNumber, timestamp) VALUES ({$lastBlockNumber}, {$currentTime})");
             //Save winning share (if there is one)
             $winningShareQ = mysql_query("SELECT id, username FROM shares where upstream_result = 'Y' AND id > {$lastwinningid}");
             if ($winningShareQ) {
                 while ($winningShareR = mysql_fetch_object($winningShareQ)) {
                     mysql_query("INSERT INTO winning_shares (blockNumber, username, share_id) VALUES ({$lastBlockNumber},'{$winningShareR->username}',{$winningShareR->id})");
                     removeCache("last_winning_share_id");
                 }
             }
         }
     }
 }
function setCache($key, $contents, $timeout = 60)
{
    if (defined('MEMCACHE') && MEMCACHE == 0 || empty($contents) || empty($key)) {
        return false;
    }
    removeCache($key);
    if (!empty($GLOBALS['cookiePrefix'])) {
        $key .= $GLOBALS['cookiePrefix'];
    }
    if (!empty($GLOBALS['chromeReorderFix'])) {
        $key .= $GLOBALS['chromeReorderFix'];
    }
    $GLOBALS['memcache']->set($key, $contents, $timeout);
}
Example #4
0
function newannouncementprocess()
{
    global $ts;
    $announcement = $_POST['announcement'];
    $zero = '0';
    if ($_POST['sli'] == 0) {
        $zero = '-1';
    }
    $message = mysqli_real_escape_string($GLOBALS['dbh'], $announcement);
    $sent = mysqli_real_escape_string($GLOBALS['dbh'], getTimeStamp());
    $zero = mysqli_real_escape_string($GLOBALS['dbh'], $zero);
    $sql = "insert into cometchat_announcements (announcement,time,`to`) values ('" . $message . "', '" . $sent . "','" . $zero . "')";
    $query = mysqli_query($GLOBALS['dbh'], $sql);
    $insertedid = mysqli_insert_id($GLOBALS['dbh']);
    parsePusherAnn($zero, $sent, $message, 1, $insertedid);
    removeCache('latest_announcement');
    header("Location: ?module=announcements&ts={$ts}");
}
Example #5
0
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//    GNU General Public License for more details.
//
//    You should have received a copy of the GNU General Public License
//    along with this program.  If not, see <http://www.gnu.org/licenses/>.
// 	  BTC Donations: 163Pv9cUDJTNUbadV4HMRQSSj3ipwLURRc
include dirname(__FILE__) . "/../includes/requiredFunctions.php";
include $includedir . "stats.php";
$stats = new Stats();
//Check that script is run locally
ScriptIsRunLocally();
//Remove cached items (in case they get stuck)
removeCache("worker_hashrates");
removeCache("pool_hashrate");
removeCache("user_hashrates");
//Hashrate by user
$hashrates = $stats->userhashratesbyid();
mysql_query("BEGIN");
$i = 0;
$sql = "";
foreach ($hashrates as $userid => $hashrate) {
    if ($i == 0) {
        $sql = "INSERT INTO userHashrates (userId, hashrate) VALUES ";
    } else {
        $sql .= ",";
    }
    $i++;
    $sql .= "({$userid}, {$hashrate})";
    if ($i > 20) {
        mysql_query($sql);
Example #6
0
function banUser()
{
    global $cookiePrefix;
    $banid = $_REQUEST['banid'];
    $id = $_REQUEST['currentroom'];
    $popoutmode = $_REQUEST['popoutmode'];
    if (empty($_REQUEST['ban']) && empty($_SESSION['cometchat']['isModerator'])) {
        echo 0;
        exit;
    }
    if ($_REQUEST['ban'] != '0') {
        $sql = "delete from cometchat_chatroommessages where id='" . mysqli_real_escape_string($GLOBALS['dbh'], $_REQUEST['ban']) . "'";
        $query = mysqli_query($GLOBALS['dbh'], $sql);
    }
    $sql = "update cometchat_chatrooms_users set isbanned = '1' where userid = '" . mysqli_real_escape_string($GLOBALS['dbh'], $banid) . "' and chatroomid = '" . mysqli_real_escape_string($GLOBALS['dbh'], $id) . "'";
    $query = mysqli_query($GLOBALS['dbh'], $sql);
    $controlparameters = array('type' => 'modules', 'name' => 'chatroom', 'method' => 'banned', 'params' => array('id' => $banid));
    $controlparameters = json_encode($controlparameters);
    sendChatroomMessage($id, 'CC^CONTROL_' . $controlparameters, 0);
    removeCache('chatrooms_users' . $id);
    removeCache('chatroom_list');
    echo 1;
}
Example #7
0
function setCache($key, $contents, $timeout = 30)
{
    if (MEMCACHE == 0) {
        return false;
    }
    removeCache($key);
    $contentstarray = unserialize($contents);
    if (!empty($contentstarray)) {
        global $memcache;
        $memcache->set($key, $contents, $timeout);
    } else {
        $_SESSION['cometchat']['memcache'][$key] = time();
    }
}
Example #8
0
function moderatorprocess()
{
    global $ts;
    $_SESSION['cometchat']['error'] = 'Moderator list successfully modified.';
    if (!empty($_POST['moderatorUserIDs'])) {
        $moderators = explode(',', $_POST['moderatorUserIDs']);
    } else {
        $moderators = array();
    }
    configeditor(array('moderatorUserIDs' => $moderators));
    removeCache('chatroom_list');
    header("Location:?module=chatrooms&action=moderator&ts={$ts}");
}
function newannouncementprocess()
{
    global $ts;
    $zero = '0';
    if ($_POST['sli'] == 0) {
        $zero = '-1';
    }
    $message = mysqli_real_escape_string($GLOBALS['dbh'], $_POST['announcement']);
    $sent = mysqli_real_escape_string($GLOBALS['dbh'], getTimeStamp());
    $zero = mysqli_real_escape_string($GLOBALS['dbh'], $zero);
    $message = preg_replace("/<a(.*?)>/", "<a\$1 target=\"_blank\">", $message);
    if (strpos($message, '<img') === false) {
        $img = strpos($message, "<img") + strlen("<img");
        $img = strpos(substr($message, $img, strpos($message, ">", $img) - $img), "http");
        if ($img === false) {
            $reg_exUrl = "/<a.*?<\\/a>(*SKIP)(*F)|(http|https|ftp|ftps)\\:\\/\\/[a-zA-Z0-9\\-\\.]+\\.[a-zA-Z]{2,3}(\\/\\S*)?/";
            if (preg_match($reg_exUrl, $message, $url)) {
                $message = preg_replace($reg_exUrl, "<a href=" . $url[0] . " target=\"_blank\">{$url['0']}</a>", $message);
            }
        }
    }
    $sql = "insert into cometchat_announcements (announcement,time,`to`) values ('" . $message . "', '" . $sent . "','" . $zero . "')";
    $query = mysqli_query($GLOBALS['dbh'], $sql);
    $insertedid = mysqli_insert_id($GLOBALS['dbh']);
    pushMobileAnnouncement($zero, $sent, $message, 1, $insertedid);
    removeCache('latest_announcement');
    header("Location: ?module=announcements&ts={$ts}");
}
} elseif (!empty($_GET['action']) && $_GET['action'] == 'unblock') {
    $id = intval($_GET['id']);
    $embed = '';
    $embedcss = '';
    if (!empty($_GET['embed']) && $_GET['embed'] == 'web') {
        $embed = 'web';
        $embedcss = 'embed';
    }
    if (!empty($_GET['embed']) && $_GET['embed'] == 'desktop') {
        $embed = 'desktop';
        $embedcss = 'embed';
    }
    $sql = "delete from cometchat_block where toid = '" . mysqli_real_escape_string($GLOBALS['dbh'], $id) . "' and fromid = '" . mysqli_real_escape_string($GLOBALS['dbh'], $userid) . "'";
    $query = mysqli_query($GLOBALS['dbh'], $sql);
    removeCache($cookiePrefix . 'blocked_id_of_' . $userid);
    removeCache($cookiePrefix . 'blocked_id_of_' . $id);
    if (defined('DEV_MODE') && DEV_MODE == '1') {
        echo mysqli_error($GLOBALS['dbh']);
    }
    $ts = time();
    header("Location: index.php?basedata={$_REQUEST['basedata']}&embed={$embed}&ts={$ts}\r\n");
    exit;
} else {
    $embed = '';
    $embedcss = '';
    if (!empty($_GET['embed']) && $_GET['embed'] == 'web') {
        $embed = 'web';
        $embedcss = 'embed';
    }
    if (!empty($_GET['embed']) && $_GET['embed'] == 'desktop') {
        $embed = 'desktop';
function getCache($key, $timeout = 30)
{
    $contents = false;
    if (MEMCACHE != 0) {
        if (MEMCACHE == 1 || MEMCACHE == 3) {
            global $memcache;
            $contents = $memcache->get($key);
        } elseif (MEMCACHE == 2) {
            $file = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR . $key . '.txt';
            if (file_exists($file) && time() - filemtime($file) < $timeout) {
                $handle = fopen($file, "rb");
                $contents = fread($handle, filesize($file));
                fclose($handle);
            } else {
                removeCache($key);
            }
        }
    }
    if (empty($contents)) {
        return false;
    }
    return $contents;
}
Example #12
0
function newannouncementprocess()
{
    global $ts;
    $announcement = $_POST['announcement'];
    $zero = '0';
    if ($_POST['sli'] == 0) {
        $zero = '-1';
    }
    $sql = "insert into cometchat_announcements (announcement,time,`to`) values ('" . mysqli_real_escape_string($GLOBALS['dbh'], $announcement) . "', '" . getTimeStamp() . "','" . $zero . "')";
    $query = mysqli_query($GLOBALS['dbh'], $sql);
    removeCache('latest_announcement');
    header("Location: ?module=announcements&ts={$ts}");
}
function newannouncementprocess()
{
    checktoken();
    $announcement = $_POST['announcement'];
    $zero = '0';
    if ($_POST['sli'] == 0) {
        $zero = '-1';
    }
    $sql = "insert into cometchat_announcements (announcement,time,`to`) values ('" . mysql_real_escape_string($announcement) . "', '" . getTimeStamp() . "','" . $zero . "')";
    $query = mysql_query($sql);
    removeCache('latest_announcement');
    header("Location: ?module=announcements");
}
Example #14
0
function banUser()
{
    global $cookiePrefix;
    $banid = $_REQUEST['banid'];
    $id = $_REQUEST['currentroom'];
    $popoutmode = $_REQUEST['popoutmode'];
    if (empty($_REQUEST['ban']) && empty($_SESSION['cometchat']['isModerator'])) {
        echo 0;
        exit;
    }
    if ($_REQUEST['ban'] != '0') {
        $sql = "delete from cometchat_chatroommessages where id='" . mysqli_real_escape_string($GLOBALS['dbh'], $_REQUEST['ban']) . "'";
        $query = mysqli_query($GLOBALS['dbh'], $sql);
    }
    $sql = "update cometchat_chatrooms_users set isbanned = '1' where userid = '" . mysqli_real_escape_string($GLOBALS['dbh'], $banid) . "' and chatroomid = '" . mysqli_real_escape_string($GLOBALS['dbh'], $id) . "'";
    $query = mysqli_query($GLOBALS['dbh'], $sql);
    sendChatroomMessage($id, 'CC^CONTROL_banned_' . $banid);
    removeCache($cookiePrefix . 'chatrooms_users' . $id);
    removeCache($cookiePrefix . 'chatroom_list');
    echo 1;
}
Example #15
0
function moderatorprocess()
{
    global $ts;
    global $cookiePrefix;
    include_once dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR . 'chatrooms' . DIRECTORY_SEPARATOR . 'config.php';
    $_SESSION['cometchat']['error'] = 'Moderator list successfully modified.';
    $data = '$moderatorUserIDs = array(' . trim($_POST['moderatorids']) . ');' . "\r\n";
    configeditor('MODERATOR', $data, 0, dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR . 'chatrooms' . DIRECTORY_SEPARATOR . 'config.php');
    removeCache('chatroom_list');
    header("Location:?module=chatrooms&action=moderator&ts={$ts}");
}
Example #16
0
 }
 $embed = '';
 $embedcss = '';
 if (!empty($_REQUEST['embed']) && $_REQUEST['embed'] == 'web') {
     $embed = 'web';
     $embedcss = 'embed';
 }
 if (!empty($_REQUEST['embed']) && $_REQUEST['embed'] == 'desktop') {
     $embed = 'desktop';
     $embedcss = 'embed';
 }
 $sql = "delete from cometchat_block where toid = '" . mysqli_real_escape_string($GLOBALS['dbh'], $id) . "' and fromid = '" . mysqli_real_escape_string($GLOBALS['dbh'], $userid) . "'";
 $query = mysqli_query($GLOBALS['dbh'], $sql);
 $affectedRows = mysqli_affected_rows($GLOBALS['dbh']);
 removeCache('blocked_id_of_' . $userid);
 removeCache('blocked_id_of_' . $id);
 $response = array();
 $response['id'] = $id;
 $error = mysqli_error($GLOBALS['dbh']);
 if (empty($_REQUEST['v3'])) {
     if (defined('DEV_MODE') && DEV_MODE == '1') {
         echo mysqli_error($GLOBALS['dbh']);
     }
     $ts = time();
     header("Location: index.php?basedata={$_REQUEST['basedata']}&embed={$embed}&ts={$ts}\r\n");
     exit;
 } else {
     header('content-type: application/json; charset=utf-8');
     if (!empty($error)) {
         $response['result'] = "0";
         $response['error'] = mysqli_error($GLOBALS['dbh']);
Example #17
0
function banUser()
{
    global $cookiePrefix;
    $banid = $_REQUEST['banid'];
    $id = $_REQUEST['currentroom'];
    if ($_REQUEST['ban'] != '0') {
        $sql = "delete from cometchat_chatroommessages where id='" . mysql_real_escape_string($_REQUEST['ban']) . "'";
        $query = mysql_query($sql);
        exit;
    }
    sendChatroomMessage($id, 'CC^CONTROL_banned_' . $banid);
    $sql = "update cometchat_chatrooms_users set isbanned=1 where userid = '" . mysql_real_escape_string($banid) . "' and chatroomid = '" . mysql_real_escape_string($id) . "'";
    $query = mysql_query($sql);
    removeCache($cookiePrefix . 'chatrooms_users' . $id);
    echo 1;
}
Example #18
0
 $embedcss = '';
 if (!empty($_REQUEST['embed']) && $_REQUEST['embed'] == 'web') {
     $embed = 'web';
     $embedcss = 'embed';
 }
 if (!empty($_REQUEST['embed']) && $_REQUEST['embed'] == 'desktop') {
     $embed = 'desktop';
     $embedcss = 'embed';
 }
 $sql = "delete from cometchat_block where toid = '" . mysqli_real_escape_string($GLOBALS['dbh'], $id) . "' and fromid = '" . mysqli_real_escape_string($GLOBALS['dbh'], $userid) . "'";
 $query = mysqli_query($GLOBALS['dbh'], $sql);
 $affectedRows = mysqli_affected_rows($GLOBALS['dbh']);
 removeCache('blocked_id_of_' . $userid);
 removeCache('blocked_id_of_' . $id);
 removeCache('blocked_id_of_receive_' . $userid);
 removeCache('blocked_id_of_receive_' . $id);
 $response = array();
 $response['id'] = $id;
 $error = mysqli_error($GLOBALS['dbh']);
 if (empty($_REQUEST['callbackfn']) || $_REQUEST['callbackfn'] != 'mobileapp') {
     if (defined('DEV_MODE') && DEV_MODE == '1') {
         echo mysqli_error($GLOBALS['dbh']);
     }
     $ts = time();
     header("Location: index.php?basedata={$_REQUEST['basedata']}&embed={$embed}&ts={$ts}\r\n");
     exit;
 } else {
     header('content-type: application/json; charset=utf-8');
     if (!empty($error)) {
         $response['result'] = "0";
         $response['error'] = mysqli_error($GLOBALS['dbh']);