From f2d5dc30b6cc09b7fa851d9e291e35b3f499518f Mon Sep 17 00:00:00 2001 From: William waisse Date: Sun, 4 Mar 2012 23:47:03 +0100 Subject: [PATCH 01/17] preparing better include system, configured in config.php --- api.php | 6 +- cronjobs/archive.php | 6 +- cronjobs/backupwallet.php | 7 +- cronjobs/cronjob.php | 7 +- cronjobs/hashrate.php | 6 +- cronjobs/payout.php | 4 +- cronjobs/shares.php | 6 +- includes/config.php.example | 64 +++++++++++++ includes/requiredFunctions.php | 165 ++------------------------------- includes/stats.php | 4 +- transactionlog.php | 6 +- 11 files changed, 90 insertions(+), 191 deletions(-) create mode 100644 includes/config.php.example diff --git a/api.php b/api.php index f1185f4..4548586 100644 --- a/api.php +++ b/api.php @@ -19,9 +19,7 @@ if (!isset($_GET["api_key"])) exit; -$includeDirectory = "/var/www/includes/"; - -include($includeDirectory."requiredFunctions.php"); +include(dirname(__FILE__) . "/include/requiredFunctions.php"); include($includeDirectory."stats.php"); $stats = new Stats(); @@ -87,4 +85,4 @@ class Worker { echo json_encode($user); -?> \ No newline at end of file +?> diff --git a/cronjobs/archive.php b/cronjobs/archive.php index f078e3f..28319ae 100644 --- a/cronjobs/archive.php +++ b/cronjobs/archive.php @@ -18,10 +18,8 @@ // BTC Donations: 163Pv9cUDJTNUbadV4HMRQSSj3ipwLURRc //Set page starter variables// -$includeDirectory = "/var/www/includes/"; - //Include hashing functions -include($includeDirectory."requiredFunctions.php"); +include(dirname(__FILE__) . "/../includes/requiredFunctions.php"); //Check that script is run locally ScriptIsRunLocally(); @@ -35,4 +33,4 @@ if ($block->NeedsArchiving($siterewardtype, $bitcoinDifficulty)) $block->Archive($siterewardtype, $bitcoinDifficulty); -?> \ No newline at end of file +?> diff --git a/cronjobs/backupwallet.php b/cronjobs/backupwallet.php index 788ba58..63af268 100644 --- a/cronjobs/backupwallet.php +++ b/cronjobs/backupwallet.php @@ -1,12 +1,9 @@ backupwallet("/home/simplecoin/walletbackup/wallet.dat.".date("Ymd")); -?> \ No newline at end of file +?> diff --git a/cronjobs/cronjob.php b/cronjobs/cronjob.php index 68662fd..af02d2c 100644 --- a/cronjobs/cronjob.php +++ b/cronjobs/cronjob.php @@ -18,10 +18,7 @@ //Set page starter variables// -$includeDirectory = "/var/www/includes/"; - -//Include site functions -include($includeDirectory."requiredFunctions.php"); +include(dirname(__FILE__) . "/../includes/requiredFunctions.php"); //Include Reward class include($includeDirectory.'reward.php'); @@ -101,4 +98,4 @@ } -?> \ No newline at end of file +?> diff --git a/cronjobs/hashrate.php b/cronjobs/hashrate.php index c83b9ff..cd913aa 100644 --- a/cronjobs/hashrate.php +++ b/cronjobs/hashrate.php @@ -16,9 +16,7 @@ // BTC Donations: 163Pv9cUDJTNUbadV4HMRQSSj3ipwLURRc -$includeDirectory = "/var/www/includes/"; - -include($includeDirectory."requiredFunctions.php"); +include(dirname(__FILE__) . "/../includes/requiredFunctions.php"); include($includeDirectory."stats.php"); $stats = new Stats(); @@ -56,4 +54,4 @@ $currentTime = time(); $settings->setsetting("statstime", $currentTime); -?> \ No newline at end of file +?> diff --git a/cronjobs/payout.php b/cronjobs/payout.php index d485496..0f35075 100644 --- a/cronjobs/payout.php +++ b/cronjobs/payout.php @@ -17,9 +17,7 @@ // BTC Donations: 163Pv9cUDJTNUbadV4HMRQSSj3ipwLURRc -$includeDirectory = "/var/www/includes/"; - -include($includeDirectory."requiredFunctions.php"); +include(dirname(__FILE__) . "/../includes/requiredFunctions.php"); //Check that script is run locally ScriptIsRunLocally(); diff --git a/cronjobs/shares.php b/cronjobs/shares.php index 29d65ba..304ff73 100644 --- a/cronjobs/shares.php +++ b/cronjobs/shares.php @@ -16,9 +16,7 @@ // BTC Donations: 163Pv9cUDJTNUbadV4HMRQSSj3ipwLURRc -$includeDirectory = "/var/www/includes/"; - -include($includeDirectory."requiredFunctions.php"); +include(dirname(__FILE__) . "/../includes/requiredFunctions.php"); //Check that script is run locally ScriptIsRunLocally(); @@ -39,4 +37,4 @@ "SET shares_this_round = a.id WHERE u.id = a.associatedUserId "; mysql_query($sql); -?> \ No newline at end of file +?> diff --git a/includes/config.php.example b/includes/config.php.example new file mode 100644 index 0000000..118f0aa --- /dev/null +++ b/includes/config.php.example @@ -0,0 +1,64 @@ + diff --git a/includes/requiredFunctions.php b/includes/requiredFunctions.php index d01e227..aca882f 100644 --- a/includes/requiredFunctions.php +++ b/includes/requiredFunctions.php @@ -18,70 +18,23 @@ Website Reference:http://www.gnu.org/licenses/gpl-2.0.html */ +include( dirname(__FILE__) . "/config.php"); -//RPC Bitcoind Client Information -$rpcType = "http"; // http or https -$rpcUsername = "pool"; // username -$rpcPassword = "pass"; // password -$rpcHost = "localhost"; -$rpcPort = 8332; +include(dirname(__FILE__) . "/bitcoinController/bitcoin.inc.php"); - -//Login to Mysql with the following -$dbHost = "localhost"; -$dbUsername = "pushpool"; -$dbPassword = "pass"; -$dbPort = "3306"; -$dbDatabasename = "simplecoin"; - -//Replicated Database calls for read intensive queries (set to above if only 1 database) -$readOnlyDbHost = "1.1.1.1"; -$readOnlyDbUsername = "pushpool"; -$readOnlyDbPassword = "pass"; -$readOnlyDbPort = "3306"; -$readOnlyDbName = "simplecoin"; - -//Cookie settings | More Info @ http://us.php.net/manual/en/function.setcookie.php -$cookieName = "simplecoinus"; //Set this to what ever you want "Cheesin?" -$cookiePath = "/"; //Choose your path! -$cookieDomain = ""; //Set this to your domain - -//Number of bonus coins to award -$bonusCoins = 50; - -//Include bitcoind controller -include("bitcoinController/bitcoin.inc.php"); - -//Setup Memcached +$cookieValid = false; //Don't touch leave as: false global $memcache; $memcache = new Memcached(); -$memcache->addServer("localhost",11212); +$memcache->addServer($memcache_host,$memcache_port); -//Encrypt settings -$salt = "123483jd7Dg6h5s92k"; //Just type a random series of numbers and letters; set it to anything or any length you want. "You can never have enough salt." - -/////////////////////////////////////////////////////////////////////NO NEED TO MESS WITH THE FOLLOWING | FOR DEVELOPERS ONLY/////////////////////////////////////////////////////////////////// - -$cookieValid = false; //Don't touch leave as: false - -//Connect to Main Db connectToDb(); - -//New PDO connection for readaccess (fallback to local if unavailable) -try { - $read_only_db = new PDO('mysql:dbname='.$readOnlyDbName.';host='.$readOnlyDbHost.';port='.$readOnlyDbPort, $readOnlyDbUsername, $readOnlyDbPassword); -} catch (Exception $e) { - $read_only_db = new PDO('mysql:dbname='.$dbDatabasename.';host='.$dbHost.';port='.$dbPort, $dbUsername, $dbPassword); -} - include('settings.php'); + $settings = new Settings(); -//Open a bitcoind connection -$bitcoinController = new BitcoinClient($rpcType, $rpcUsername, $rpcPassword, $rpcHost, $rpcPort); +/////////////////////////////////////////////////////////////////////NO NEED TO MESS WITH THE FOLLOWING | FOR DEVELOPERS ONLY/////////////////////////////////////////////////////////////////// -//setup bitcoinDifficulty cache object -$bitcoinDifficulty = GetCachedBitcoinDifficulty(); +$timeoutStamp=1; function connectToDb(){ //Set variables to global retireve outside of the scope @@ -141,6 +94,8 @@ function returnUserId($input){ } } + + function outputPageTitle(){ if (!isset($settings)) { @@ -177,106 +132,4 @@ function antiXss($input) { //strip HTML tags from input data return htmlentities(strip_tags($input), ENT_QUOTES); } - -function sqlerr($file = '', $line = '') -{ - print("" . - "

SQL Error

\n" . - "" . mysql_error() . ($file != '' && $line != '' ? "

in $file, line $line

" : "") . "
"); - die; -} - -$_current_lock = null; - -function islocked($name) { - $result = mysql_query("SELECT locked FROM locks WHERE name ='$name' and locked=1 LIMIT 1"); - if (!$result || mysql_numrows($result) == 0) - return false; - return true; -} - -function unlock() { - global $_current_lock; - mysql_query("UNLOCK TABLES"); - $sql = "UPDATE locks SET locked = 0 WHERE name = '" . mysql_real_escape_string($_current_lock) . "'"; - mysql_query($sql); -} - -function lock($name) { - global $_current_lock; - mysql_query("LOCK TABLES locks WRITE"); - $q = mysql_query("SELECT locked FROM locks WHERE name = '" . mysql_real_escape_string($name) . "'"); - - $lock = mysql_fetch_object($q); - if ($lock === false) { - mysql_query("INSERT INTO locks (name, locked) VALUES ('".mysql_real_escape_string($name)."', 1)"); - } elseif ($lock->locked) { - echo("Lock already held, exiting. (".$name.")"); - mysql_query("UNLOCK TABLES"); - exit(); - return; - } else { - mysql_query("UPDATE locks SET locked = 1 WHERE name = '" . mysql_real_escape_string($name) . "'"); - } - - //mysql_query("UNLOCK TABLES"); - $_current_lock = $name; - register_shutdown_function('unlock'); -} - -function ScriptIsRunLocally() { - if (isset($_SERVER['REMOTE_ADDR']) && $_SERVER['REMOTE_ADDR'] != "127.0.0.1") { - echo "This script can only be run locally."; - exit; - } -} - -//Cache functions - -# Gets key / value pair into memcache ... called by mysql_query_cache() -function getCache($key) { - global $memcache; - return ($memcache) ? $memcache->get($key) : false; -} - -# Puts key / value pair into memcache ... called by mysql_query_cache() -function setCache($key, $object, $timeout = 600) { - global $memcache; - return ($memcache) ? $memcache->set($key, $object, $timeout) : false; -} - -function removeCache($key) { - global $memcache; - $memcache->delete($key); -} - -function removeSqlCache($key) { - global $memcache; - $memcache->delete(md5("mysql_query".$key)); -} - -# Caching version of mysql_query() -function mysql_query_cache($sql, $timeout = 600) { - if($objResultset = unserialize(getCache(md5("mysql_query".$sql)))) { - return $objResultset; - } - $objResultSet = mysql_query($sql); - $objarray = Array(); - while ($row = mysql_fetch_object($objResultSet)) { - $objarray[] = $row; - } - setCache(md5("mysql_query".$sql), serialize($objarray), $timeout); - return $objarray; -} - -function GetCachedBitcoinDifficulty() { - global $bitcoinController; - $difficulty = 0; - if (!($difficulty = getCache("bitcoinDifficulty"))) { - $difficulty = $bitcoinController->query("getdifficulty"); - setCache("bitcoinDifficulty", $difficulty, 60); - } - return $difficulty; -} - ?> diff --git a/includes/stats.php b/includes/stats.php index 4bb3dfb..9490ddc 100644 --- a/includes/stats.php +++ b/includes/stats.php @@ -79,7 +79,7 @@ function currenthashrate() { $currenthashrate = round((($currenthashrate*4294967296)/590)/1000000, 0); setCache("pool_hashrate", $currenthashrate, 300); try { - $fileName = "/var/www/api/pool/speed"; + $fileName = $apidir."pool/speed"; $fileHandle = fopen($fileName, 'w'); fwrite($fileHandle, ($currenthashrate/1000)); fclose($fileHandle); @@ -489,4 +489,4 @@ function get_server_load($windows = 0) { } } -?> \ No newline at end of file +?> diff --git a/transactionlog.php b/transactionlog.php index 90f294d..3958dcc 100644 --- a/transactionlog.php +++ b/transactionlog.php @@ -1,11 +1,9 @@ query("listtransactions"); echo print_r($transactions); -?> \ No newline at end of file +?> From b209eb0251af9bd5f5530592541ce07136b3ff68 Mon Sep 17 00:00:00 2001 From: William waisse Date: Sun, 4 Mar 2012 23:51:01 +0100 Subject: [PATCH 02/17] removing annoying wondows ctrl+M --- about.php | 70 +- adminPanel.php | 152 +- api.php | 176 +- cronjobs/archive.php | 72 +- cronjobs/hashrate.php | 108 +- cronjobs/payout.php | 134 +- cronjobs/shares.php | 80 +- gettingstarted.php | 118 +- includes/bitcoinController/bitcoin.inc.php | 1794 ++++++++++---------- includes/footer.php | 16 +- includes/header.php | 204 +-- includes/settings.php | 90 +- includes/stats.php | 978 +++++------ logout.php | 68 +- 14 files changed, 2030 insertions(+), 2030 deletions(-) diff --git a/about.php b/about.php index d370cbc..c759805 100644 --- a/about.php +++ b/about.php @@ -1,35 +1,35 @@ - -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// 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 . - -// BTC Donations: 163Pv9cUDJTNUbadV4HMRQSSj3ipwLURRc - -$pageTitle = "- About"; -include ("includes/header.php"); -?> - -About Bitcoins
-

-About This Site
-This site is run by completely opensource software.
-Hosted on a Xen Virtual Machine
-Running Ubuntu
-PHP pages served by Apache webserver
-Official Bitcoin server
-Pushpool Bitcoin pool
-Simplecoin front-end
- - - + +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// 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 . + +// BTC Donations: 163Pv9cUDJTNUbadV4HMRQSSj3ipwLURRc + +$pageTitle = "- About"; +include ("includes/header.php"); +?> + +About Bitcoins
+

+About This Site
+This site is run by completely opensource software.
+Hosted on a Xen Virtual Machine
+Running Ubuntu
+PHP pages served by Apache webserver
+Official Bitcoin server
+Pushpool Bitcoin pool
+Simplecoin front-end
+ + + diff --git a/adminPanel.php b/adminPanel.php index 998eda0..7cf7911 100644 --- a/adminPanel.php +++ b/adminPanel.php @@ -1,98 +1,98 @@ - -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// 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 . - -// BTC Donations: 163Pv9cUDJTNUbadV4HMRQSSj3ipwLURRc - + +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// 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 . + +// BTC Donations: 163Pv9cUDJTNUbadV4HMRQSSj3ipwLURRc + $pageTitle = "- Admin Panel"; -include ("includes/header.php"); +include ("includes/header.php"); + +$goodMessage = ""; +$returnError = ""; +//Scince this is the Admin panel we'll make sure the user is logged in and "isAdmin" enabled boolean; If this is not a logged in user that is enabled as admin, redirect to a 404 error page + +if(!$cookieValid || $isAdmin != 1) { + header('Location: /'); + exit; +} -$goodMessage = ""; -$returnError = ""; -//Scince this is the Admin panel we'll make sure the user is logged in and "isAdmin" enabled boolean; If this is not a logged in user that is enabled as admin, redirect to a 404 error page - -if(!$cookieValid || $isAdmin != 1) { - header('Location: /'); - exit; -} - if (isset($_POST["act"]) && isset($_POST["authPin"])) -{ +{ if (isset($_POST["authPin"])) { $inputAuthPin = hash("sha256", $_POST["authPin"].$salt); } else { $inputAuthPin = NULL; } - //Make sure an authPin is set and valid when $act is active + //Make sure an authPin is set and valid when $act is active if(isset($_POST["act"]) && $authPin == $inputAuthPin) { $act = $_POST["act"]; - //Update information if needed - if($act == "UpdateMainPageSettings"){ - try { - $settings->setsetting("sitepayoutaddress", mysql_real_escape_string($_POST["paymentAddress"])); - $settings->setsetting("sitepercent", mysql_real_escape_string($_POST["percentageFee"])); - $settings->setsetting("websitename", mysql_real_escape_string($_POST["headerTitle"])); - $settings->setsetting("pagetitle", mysql_real_escape_string($_POST["pageTitle"])); - $settings->setsetting("slogan", mysql_real_escape_string($_POST["headerSlogan"])); - $settings->setsetting("siterewardtype", mysql_real_escape_string($_POST["rewardType"])); + //Update information if needed + if($act == "UpdateMainPageSettings"){ + try { + $settings->setsetting("sitepayoutaddress", mysql_real_escape_string($_POST["paymentAddress"])); + $settings->setsetting("sitepercent", mysql_real_escape_string($_POST["percentageFee"])); + $settings->setsetting("websitename", mysql_real_escape_string($_POST["headerTitle"])); + $settings->setsetting("pagetitle", mysql_real_escape_string($_POST["pageTitle"])); + $settings->setsetting("slogan", mysql_real_escape_string($_POST["headerSlogan"])); + $settings->setsetting("siterewardtype", mysql_real_escape_string($_POST["rewardType"])); $settings->setsetting("sitetxfee", mysql_real_escape_string($_POST["transactionFee"])); - $settings->loadsettings(); //refresh settings - $goodMessage = "Successfully updated general settings"; - } catch (Exception $e) { - $returnError = "Database Failed - General settings was not updated"; - } - } - } else if($act && $authPin != $inputAuthPin){ - $returnError = "Authorization Pin # - Invalid"; - } -} - -//Display Error and Good Messages(If Any) -echo "".antiXss($goodMessage)."
"; -echo "".antiXss($returnError).""; - -?> - -
-

Welcome back admin


-

General Settings

+ $settings->loadsettings(); //refresh settings + $goodMessage = "Successfully updated general settings"; + } catch (Exception $e) { + $returnError = "Database Failed - General settings was not updated"; + } + } + } else if($act && $authPin != $inputAuthPin){ + $returnError = "Authorization Pin # - Invalid"; + } +} + +//Display Error and Good Messages(If Any) +echo "".antiXss($goodMessage)."
"; +echo "".antiXss($returnError).""; + +?> + +
+

Welcome back admin


+

General Settings


- -
- - Page Title ">
- Header Title ">
- Header Slogan ">
- Percentage Fee ">%
+ + + + Page Title ">
+ Header Title ">
+ Header Slogan ">
+ Percentage Fee ">%
Transaction Fee " /> BTC
Fee Address ">
- Default Reward Type - - -

- Authorization Pin
- -
-

+ + +

+ Authorization Pin
+ + +

Info


- + 0")or sqlerr(__FILE__, __LINE__); $sitewalletq = mysql_fetch_row($sitewallet); $usersbalance = $sitewalletq[0]; diff --git a/api.php b/api.php index 4548586..c635f0d 100644 --- a/api.php +++ b/api.php @@ -1,88 +1,88 @@ - -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// 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 . - -// BTC Donations: 163Pv9cUDJTNUbadV4HMRQSSj3ipwLURRc - -if (!isset($_GET["api_key"])) - exit; - -include(dirname(__FILE__) . "/include/requiredFunctions.php"); -include($includeDirectory."stats.php"); -$stats = new Stats(); - -class User { - var $confirmed_rewards = null; - var $hashrate = null; - var $payout_history = null; - var $estimated_rewards = null; - var $workers = array(); -} - -class Worker { - var $alive = null; - var $hashrate = null; -} - -$apikey = mysql_real_escape_string($_GET["api_key"]); - -$user = new User(); -$userid = 0; -$resultU = mysql_query_cache("SELECT u.id, b.balance, b.paid, u.username from webUsers u, accountBalance b WHERE u.id = b.userId AND u.api_key = '$apikey'", 300); -if (count($resultU) > 0) { - $userobj = $resultU[0]; - $username = $userobj->username; - $userid = $userobj->id; - $user->confirmed_rewards = $userobj->balance; - $user->hashrate = $stats->userhashrate($username); - $user->estimated_rewards = 0; - $user->payout_history = $userobj->paid; - - if (is_numeric($settings->getsetting("sitepercent"))) - $sitePercent = $settings->getsetting("sitepercent"); - - $totalUserShares = $stats->usersharecount($userid); - - //Get current round share information, estimated total earnings - $totalOverallShares = $stats->currentshares(); - - //Prevent divide by zero - if($totalUserShares > 0 && $totalOverallShares > 0){ - //Get site percentage - $sitePercent = 0; - if (is_numeric($settings->getsetting('sitepercent'))) - $sitePercent = $settings->getsetting('sitepercent')/100; - - if ($totalOverallShares > $bitcoinDifficulty) - $estimatedTotalEarnings = $totalUserShares/$totalOverallShares; - else - $estimatedTotalEarnings = $totalUserShares/$bitcoinDifficulty; - - $estimatedTotalEarnings *= $bonusCoins*(1-$sitePercent); //The expected BTC to be givin out - $user->estimated_rewards = round($estimatedTotalEarnings, 8); - } - -} -$resultW = mysql_query_cache("SELECT username FROM pool_worker WHERE associatedUserId = $userid", 300); -foreach ($resultW as $workerobj) { - $worker = new Worker(); - $worker->alive = ($stats->workerhashrate($workerobj->username) > 0); - $worker->hashrate = $stats->workerhashrate($workerobj->username); - $user->workers[$workerobj->username] = $worker; -} - -echo json_encode($user); - -?> + +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// 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 . + +// BTC Donations: 163Pv9cUDJTNUbadV4HMRQSSj3ipwLURRc + +if (!isset($_GET["api_key"])) + exit; + +include(dirname(__FILE__) . "/include/requiredFunctions.php"); +include($includeDirectory."stats.php"); +$stats = new Stats(); + +class User { + var $confirmed_rewards = null; + var $hashrate = null; + var $payout_history = null; + var $estimated_rewards = null; + var $workers = array(); +} + +class Worker { + var $alive = null; + var $hashrate = null; +} + +$apikey = mysql_real_escape_string($_GET["api_key"]); + +$user = new User(); +$userid = 0; +$resultU = mysql_query_cache("SELECT u.id, b.balance, b.paid, u.username from webUsers u, accountBalance b WHERE u.id = b.userId AND u.api_key = '$apikey'", 300); +if (count($resultU) > 0) { + $userobj = $resultU[0]; + $username = $userobj->username; + $userid = $userobj->id; + $user->confirmed_rewards = $userobj->balance; + $user->hashrate = $stats->userhashrate($username); + $user->estimated_rewards = 0; + $user->payout_history = $userobj->paid; + + if (is_numeric($settings->getsetting("sitepercent"))) + $sitePercent = $settings->getsetting("sitepercent"); + + $totalUserShares = $stats->usersharecount($userid); + + //Get current round share information, estimated total earnings + $totalOverallShares = $stats->currentshares(); + + //Prevent divide by zero + if($totalUserShares > 0 && $totalOverallShares > 0){ + //Get site percentage + $sitePercent = 0; + if (is_numeric($settings->getsetting('sitepercent'))) + $sitePercent = $settings->getsetting('sitepercent')/100; + + if ($totalOverallShares > $bitcoinDifficulty) + $estimatedTotalEarnings = $totalUserShares/$totalOverallShares; + else + $estimatedTotalEarnings = $totalUserShares/$bitcoinDifficulty; + + $estimatedTotalEarnings *= $bonusCoins*(1-$sitePercent); //The expected BTC to be givin out + $user->estimated_rewards = round($estimatedTotalEarnings, 8); + } + +} +$resultW = mysql_query_cache("SELECT username FROM pool_worker WHERE associatedUserId = $userid", 300); +foreach ($resultW as $workerobj) { + $worker = new Worker(); + $worker->alive = ($stats->workerhashrate($workerobj->username) > 0); + $worker->hashrate = $stats->workerhashrate($workerobj->username); + $user->workers[$workerobj->username] = $worker; +} + +echo json_encode($user); + +?> diff --git a/cronjobs/archive.php b/cronjobs/archive.php index 28319ae..70255f5 100644 --- a/cronjobs/archive.php +++ b/cronjobs/archive.php @@ -1,36 +1,36 @@ - -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// 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 . - -// BTC Donations: 163Pv9cUDJTNUbadV4HMRQSSj3ipwLURRc - -//Set page starter variables// -//Include hashing functions -include(dirname(__FILE__) . "/../includes/requiredFunctions.php"); - -//Check that script is run locally -ScriptIsRunLocally(); - -//Include Block class -include($includeDirectory."block.php"); -$block = new Block(); - -$siterewardtype = $settings->getsetting("siterewardtype"); - -if ($block->NeedsArchiving($siterewardtype, $bitcoinDifficulty)) - $block->Archive($siterewardtype, $bitcoinDifficulty); - -?> + +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// 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 . + +// BTC Donations: 163Pv9cUDJTNUbadV4HMRQSSj3ipwLURRc + +//Set page starter variables// +//Include hashing functions +include(dirname(__FILE__) . "/../includes/requiredFunctions.php"); + +//Check that script is run locally +ScriptIsRunLocally(); + +//Include Block class +include($includeDirectory."block.php"); +$block = new Block(); + +$siterewardtype = $settings->getsetting("siterewardtype"); + +if ($block->NeedsArchiving($siterewardtype, $bitcoinDifficulty)) + $block->Archive($siterewardtype, $bitcoinDifficulty); + +?> diff --git a/cronjobs/hashrate.php b/cronjobs/hashrate.php index cd913aa..2932c7c 100644 --- a/cronjobs/hashrate.php +++ b/cronjobs/hashrate.php @@ -1,57 +1,57 @@ -. - -// BTC Donations: 163Pv9cUDJTNUbadV4HMRQSSj3ipwLURRc - +. + +// BTC Donations: 163Pv9cUDJTNUbadV4HMRQSSj3ipwLURRc + include(dirname(__FILE__) . "/../includes/requiredFunctions.php"); -include($includeDirectory."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); - $sql = ""; - $i = 0; - } -} -if (strlen($sql) > 0) - mysql_query($sql); -mysql_query("COMMIT"); - -$currentTime = time(); +include($includeDirectory."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); + $sql = ""; + $i = 0; + } +} +if (strlen($sql) > 0) + mysql_query($sql); +mysql_query("COMMIT"); + +$currentTime = time(); $settings->setsetting("statstime", $currentTime); - + ?> diff --git a/cronjobs/payout.php b/cronjobs/payout.php index 0f35075..fe4dc9a 100644 --- a/cronjobs/payout.php +++ b/cronjobs/payout.php @@ -1,73 +1,73 @@ - -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// 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 . - -// BTC Donations: 163Pv9cUDJTNUbadV4HMRQSSj3ipwLURRc - - + +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// 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 . + +// BTC Donations: 163Pv9cUDJTNUbadV4HMRQSSj3ipwLURRc + + include(dirname(__FILE__) . "/../includes/requiredFunctions.php"); - -//Check that script is run locally -ScriptIsRunLocally(); - -$txfee = 0; -if ($settings->getsetting("sitetxfee") > 0) - $txfee = $settings->getsetting("sitetxfee"); - -$sitepercent = $settings->getsetting("sitepercent"); + +//Check that script is run locally +ScriptIsRunLocally(); + +$txfee = 0; +if ($settings->getsetting("sitetxfee") > 0) + $txfee = $settings->getsetting("sitetxfee"); + +$sitepercent = $settings->getsetting("sitepercent"); /////////Pay users who have reached their threshold payout - -$resultQ = mysql_query("SELECT b.userId, b.balance, IFNULL(b.paid, 0) as paid, IFNULL(b.sendAddress,'') as sendAddress, u.email, u.donate_percent FROM accountBalance b, webUsers u WHERE b.userId = u.id AND b.threshold >= 1 AND b.balance >= threshold"); -lock("money"); -try { - while ($resultR = mysql_fetch_object($resultQ)) { - $currentBalance = $resultR->balance; - $paid = $resultR->paid; - $paymentAddress = $resultR->sendAddress; - $userId = $resultR->userId; - $donatepercent = $resultR->donate_percent; - if ($paymentAddress != '') - { + +$resultQ = mysql_query("SELECT b.userId, b.balance, IFNULL(b.paid, 0) as paid, IFNULL(b.sendAddress,'') as sendAddress, u.email, u.donate_percent FROM accountBalance b, webUsers u WHERE b.userId = u.id AND b.threshold >= 1 AND b.balance >= threshold"); +lock("money"); +try { + while ($resultR = mysql_fetch_object($resultQ)) { + $currentBalance = $resultR->balance; + $paid = $resultR->paid; + $paymentAddress = $resultR->sendAddress; + $userId = $resultR->userId; + $donatepercent = $resultR->donate_percent; + if ($paymentAddress != '') + { $isValidAddress = $bitcoinController->validateaddress($paymentAddress); - if($isValidAddress){ - //Subtract TX fee, donation and site fees - $currentBalance = ($currentBalance*(1-$sitepercent/100)*(1-$donatepercent/100)) - $txfee; - $paid += $currentBalance; - //Send money// - mysql_query("BEGIN"); - try { - //Reduce balance amount to zero - //echo "UPDATE accountBalance SET balance = '0', paid = '$paid' WHERE userId = $userId\n"; + if($isValidAddress){ + //Subtract TX fee, donation and site fees + $currentBalance = ($currentBalance*(1-$sitepercent/100)*(1-$donatepercent/100)) - $txfee; + $paid += $currentBalance; + //Send money// + mysql_query("BEGIN"); + try { + //Reduce balance amount to zero + //echo "UPDATE accountBalance SET balance = '0', paid = '$paid' WHERE userId = $userId\n"; mysql_query("UPDATE accountBalance SET balance = '0', paid = '$paid' WHERE userId = $userId"); if($bitcoinController->sendtoaddress($paymentAddress, $currentBalance)) { mysql_query("INSERT INTO payoutHistory (userId, address, amount) VALUES ('".$resultR->userId."', '".$paymentAddress."', '".$currentBalance."')"); - mail($resultR->email, "Simplecoin.us Automatic Payout Notification", "Hello,\n\nYour balance of ".$currentBalance." BTC has exceeded your automatic payment threshold and has been sent to your payment address ".$paymentAddress.".", "From: Simplecoin.us Notifications "); - mysql_query("COMMIT"); - } else { - mysql_query("ROLLBACK"); - echo "Commodity $currentBalance failed to send to $paymentAddress for userid $userId\n"; - } - } catch (Exception $e) { - mysql_query("ROLLBACK"); - echo "Commodity $currentBalance failed to send to $paymentAddress for userid $userId\n"; - } - - } - } - } -} catch (Exception $ex) { - echo $ex-getMessage(); -} -unlock("money"); + mail($resultR->email, "Simplecoin.us Automatic Payout Notification", "Hello,\n\nYour balance of ".$currentBalance." BTC has exceeded your automatic payment threshold and has been sent to your payment address ".$paymentAddress.".", "From: Simplecoin.us Notifications "); + mysql_query("COMMIT"); + } else { + mysql_query("ROLLBACK"); + echo "Commodity $currentBalance failed to send to $paymentAddress for userid $userId\n"; + } + } catch (Exception $e) { + mysql_query("ROLLBACK"); + echo "Commodity $currentBalance failed to send to $paymentAddress for userid $userId\n"; + } + + } + } + } +} catch (Exception $ex) { + echo $ex-getMessage(); +} +unlock("money"); diff --git a/cronjobs/shares.php b/cronjobs/shares.php index 304ff73..d1985bb 100644 --- a/cronjobs/shares.php +++ b/cronjobs/shares.php @@ -1,40 +1,40 @@ - -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// 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 . - -// BTC Donations: 163Pv9cUDJTNUbadV4HMRQSSj3ipwLURRc - -include(dirname(__FILE__) . "/../includes/requiredFunctions.php"); - -//Check that script is run locally -ScriptIsRunLocally(); -////Update share counts - -//Update past shares -$sql = "UPDATE webUsers u, ". - " (SELECT DISTINCT userId, sum(count) AS valid, sum(invalid) AS invalid, id FROM shares_counted GROUP BY userId) s ". - "SET u.share_count = s.valid, u.stale_share_count = s.invalid WHERE u.id = s.userId"; -mysql_query ($sql); - -// -////Update current round shares -$sql = "UPDATE webUsers u, ". - " (SELECT IFNULL(count(s.id),0) AS id, p.associatedUserId FROM pool_worker p ". - " LEFT JOIN shares s ON p.username=s.username ". - " WHERE s.our_result='Y' GROUP BY p.associatedUserId) a ". - "SET shares_this_round = a.id WHERE u.id = a.associatedUserId "; -mysql_query($sql); - -?> + +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// 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 . + +// BTC Donations: 163Pv9cUDJTNUbadV4HMRQSSj3ipwLURRc + +include(dirname(__FILE__) . "/../includes/requiredFunctions.php"); + +//Check that script is run locally +ScriptIsRunLocally(); +////Update share counts + +//Update past shares +$sql = "UPDATE webUsers u, ". + " (SELECT DISTINCT userId, sum(count) AS valid, sum(invalid) AS invalid, id FROM shares_counted GROUP BY userId) s ". + "SET u.share_count = s.valid, u.stale_share_count = s.invalid WHERE u.id = s.userId"; +mysql_query ($sql); + +// +////Update current round shares +$sql = "UPDATE webUsers u, ". + " (SELECT IFNULL(count(s.id),0) AS id, p.associatedUserId FROM pool_worker p ". + " LEFT JOIN shares s ON p.username=s.username ". + " WHERE s.our_result='Y' GROUP BY p.associatedUserId) a ". + "SET shares_this_round = a.id WHERE u.id = a.associatedUserId "; +mysql_query($sql); + +?> diff --git a/gettingstarted.php b/gettingstarted.php index 3192d09..16a558e 100644 --- a/gettingstarted.php +++ b/gettingstarted.php @@ -1,59 +1,59 @@ - -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// 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 . - -// BTC Donations: 163Pv9cUDJTNUbadV4HMRQSSj3ipwLURRc - -$pageTitle = "- Getting Started"; -include ("includes/header.php"); - -?> - -Get a Bitcoin Address
-Download the client to your PC from: bitcoin.org

- -Setup a bitcoin miner

- -ATI/AMD Users
-You will need to download and install the AMD Stream SDK from HERE before you can begin mining

- -Advanced Windows & Linux (for best mining results)
- Download cgminer HERE
- Follow the directions for your operating system in the above link to install
- Run cgminer: cgminer -o http://pool.simplecoin.us:8337 -u username.1 -p x
- Run cgminer for max performance: cgminer -o http://pool.simplecoin.us:8337 -u username.1 -p x -I 8

- - Easy Windows
- Download GUIMiner: HERE
-
- GUIMiner options
- Server: Other
- Host: pool.simplecoin.us
- Port: 8337
- Username: <your user name>.<miner name (default is 1)>
- Password: <your miner password (default is 'x')>
- Device: Select the graphics card/cpu you would like to use
- Extra Flags: Can be blank, but I find "-v -w128 -f 60" to work well

- - Easy Linux
- Download hashkill: HERE
- Decompress (tar zxvf hashkill-0.2.4-x86.tar.gz)
- Change directory to hashkill
- Run: sudo ./install.sh
- Run hashkill: hashkill-gpu -p bitcoin minername:password:pool.simplecoin.us:8337 - - - - + +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// 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 . + +// BTC Donations: 163Pv9cUDJTNUbadV4HMRQSSj3ipwLURRc + +$pageTitle = "- Getting Started"; +include ("includes/header.php"); + +?> + +Get a Bitcoin Address
+Download the client to your PC from: bitcoin.org

+ +Setup a bitcoin miner

+ +ATI/AMD Users
+You will need to download and install the AMD Stream SDK from HERE before you can begin mining

+ +Advanced Windows & Linux (for best mining results)
+ Download cgminer HERE
+ Follow the directions for your operating system in the above link to install
+ Run cgminer: cgminer -o http://pool.simplecoin.us:8337 -u username.1 -p x
+ Run cgminer for max performance: cgminer -o http://pool.simplecoin.us:8337 -u username.1 -p x -I 8

+ + Easy Windows
+ Download GUIMiner: HERE
+
+ GUIMiner options
+ Server: Other
+ Host: pool.simplecoin.us
+ Port: 8337
+ Username: <your user name>.<miner name (default is 1)>
+ Password: <your miner password (default is 'x')>
+ Device: Select the graphics card/cpu you would like to use
+ Extra Flags: Can be blank, but I find "-v -w128 -f 60" to work well

+ + Easy Linux
+ Download hashkill: HERE
+ Decompress (tar zxvf hashkill-0.2.4-x86.tar.gz)
+ Change directory to hashkill
+ Run: sudo ./install.sh
+ Run hashkill: hashkill-gpu -p bitcoin minername:password:pool.simplecoin.us:8337 + + + + diff --git a/includes/bitcoinController/bitcoin.inc.php b/includes/bitcoinController/bitcoin.inc.php index b4aedc8..fa256c6 100644 --- a/includes/bitcoinController/bitcoin.inc.php +++ b/includes/bitcoinController/bitcoin.inc.php @@ -1,897 +1,897 @@ - hexdec($addressversion)) { - return false; - } - $check = substr($addr, 0, strlen($addr) - 8); - $check = pack("H*", $check); - $check = strtoupper(hash("sha256", hash("sha256", $check, true))); - $check = substr($check, 0, 8); - return $check == substr($addr, strlen($addr) - 8); - } - - /** - * Convert the input to its 160-bit Bitcoin hash - * - * @param string $data - * @return string - * @access private - */ - private function hash160($data) { - $data = pack("H*", $data); - return strtoupper(hash("ripemd160", hash("sha256", $data, true))); - } - - /** - * Convert a Bitcoin public key to a 160-bit Bitcoin hash - * - * @param string $pubkey - * @return string - * @access public - */ - public static function pubKeyToAddress($pubkey) { - return self::hash160ToAddress($this->hash160($pubkey)); - } - - /** - * Remove leading "0x" from a hex value if present. - * - * @param string $string - * @return string - * @access public - */ - public static function remove0x($string) { - if (substr($string, 0, 2) == "0x" || substr($string, 0, 2) == "0X") { - $string = substr($string, 2); - } - return $string; - } -} - -/** - * Exception class for BitcoinClient - * - * @author Mike Gogulski - * http://www.gogulski.com/ http://www.nostate.com/ - */ -class BitcoinClientException extends ErrorException { - // Redefine the exception so message isn't optional - public function __construct($message, $code = 0, $severity = E_USER_NOTICE, Exception $previous = null) { - parent::__construct($message, $code, $severity, $previous); - } - - public function __toString() { - return __CLASS__ . ": [{$this->code}]: {$this->message}\n"; - } -} - -require_once(dirname(__FILE__) . "/includes/xmlrpc.inc.php"); -require_once(dirname(__FILE__) . "/includes/jsonrpc.inc.php"); - -/** - * Bitcoin client class for access to a Bitcoin server via JSON-RPC-HTTP[S] - * - * Implements the methods documented at https://www.bitcoin.org/wiki/doku.php?id=api - * - * @version 0.3.19 - * @author Mike Gogulski - * http://www.gogulski.com/ http://www.nostate.com/ - */ -class BitcoinClient extends jsonrpc_client { - - /** - * Create a jsonrpc_client object to talk to the bitcoin server and return it, - * or false on failure. - * - * @param string $scheme - * "http" or "https" - * @param string $username - * User name to use in connection the Bitcoin server's JSON-RPC interface - * @param string $password - * Server password - * @param string $address - * Server hostname or IP address - * @param mixed $port - * Server port (string or integer) - * @param string $certificate_path - * Path on the local filesystem to server's PEM certificate (ignored if $scheme != "https") - * @param integer $debug_level - * 0 (default) = no debugging; - * 1 = echo JSON-RPC messages received to stdout; - * 2 = log transmitted messages also - * @return jsonrpc_client - * @access public - * @throws BitcoinClientException - */ - public function __construct($scheme, $username, $password, $address = "localhost", $port = 8332, $certificate_path = '', $debug_level = 0) { - $scheme = strtolower($scheme); - if ($scheme != "http" && $scheme != "https") - throw new BitcoinClientException("Scheme must be http or https"); - if (empty($username)) - throw new BitcoinClientException("Username must be non-blank"); - if (empty($password)) - throw new BitcoinClientException("Password must be non-blank"); - $port = (string) $port; - if (!$port || empty($port) || !is_numeric($port) || $port < 1 || $port > 65535 || floatval($port) != intval($port)) - throw new BitcoinClientException("Port must be an integer and between 1 and 65535"); - if (!empty($certificate_path) && !is_readable($certificate_path)) - throw new BitcoinClientException("Certificate file " . $certificate_path . " is not readable"); - $uri = $scheme . "://" . $username . ":" . $password . "@" . $address . ":" . $port . "/"; - parent::__construct($uri); - $this->setDebug($debug_level); - $this->setSSLVerifyHost(0); - if ($scheme == "https") - if (!empty($certificate_path)) - $this->setCaCertificate($certificate_path); - else - $this->setSSLVerifyPeer(false); - } - - /** - * Test if the connection to the Bitcoin JSON-RPC server is working - * - * The check is done by calling the server's getinfo() method and checking - * for a fault. - * - * @return mixed boolean TRUE if successful, or a fault string otherwise - * @access public - * @throws none - */ - public function can_connect() { - try { - $r = $this->getinfo(); - } catch (BitcoinClientException $e) { - return $e->getMessage(); - } - return true; - } - - /** - * Convert a Bitcoin server query argument to a jsonrpcval - * - * @param mixed $argument - * @return jsonrpcval - * @throws none - * @todo Make this method private. - */ - public function query_arg_to_parameter($argument) { - $type = "";// "string" is encoded as this default type value in xmlrpc.inc - if (is_numeric($argument)) { - if (intval($argument) != floatval($argument)) { - $argument = floatval($argument); - $type = "double"; - } else { - $argument = intval($argument); - $type = "int"; - } - } - if (is_bool($argument)) - $type = "boolean"; - if (is_int($argument)) - $type = "int"; - if (is_float($argument)) - $type = "double"; - if (is_array($argument)) - $type = "array"; - return new jsonrpcval($argument, $type); - } - - /** - * Send a JSON-RPC message and optional parameter arguments to the server. - * - * Use the API functions if possible. This method remains public to support - * changes being made to the API before this libarary can be updated. - * - * @param string $message - * @param mixed $args, ... - * @return mixed - * @throws BitcoinClientException - * @see xmlrpc.inc:php_xmlrpc_decode() - */ - public function query($message) { - if (!$message || empty($message)) - throw new BitcoinClientException("Bitcoin client query requires a message"); - $msg = new jsonrpcmsg($message); - if (func_num_args() > 1) { - for ($i = 1; $i < func_num_args(); $i++) { - $msg->addParam(self::query_arg_to_parameter(func_get_arg($i))); - } - } - $response = $this->send($msg); - if ($response->faultCode()) { - throw new BitcoinClientException($response->faultString()); - } - return php_xmlrpc_decode($response->value()); - } - - /* - * The following functions implement the Bitcoin RPC API as documented at https://www.bitcoin.org/wiki/doku.php?id=api - */ - - /** - * Safely copies wallet.dat to destination, which can be a directory or - * a path with filename. - * - * @param string $destination - * @return mixed Nothing, or an error array - * @throws BitcoinClientException - */ - public function backupwallet($destination) { - if (!$destination || empty($destination)) - throw new BitcoinClientException("backupwallet requires a destination"); - return $this->query("backupwallet", $destination); - } - - /** - * Returns the server's available balance, or the balance for $account with - * at least $minconf confirmations. - * - * @param string $account Account to check. If not provided, the server's - * total available balance is returned. - * @param integer $minconf If specified, only transactions with at least - * $minconf confirmations will be included in the returned total. - * @return float Bitcoin balance - * @throws BitcoinClientException - */ - public function getbalance($account = NULL, $minconf = 1) { - if (!is_numeric($minconf) || $minconf < 0) - throw new BitcoinClientException('getbalance requires a numeric minconf >= 0'); - if ($account == NULL) - return $this->query("getbalance"); - return $this->query("getbalance", $account, $minconf); - } - - /** - * Returns the number of blocks in the longest block chain. - * - * @return integer Current block count - * @throws BitcoinClientException - */ - public function getblockcount() { - return $this->query("getblockcount"); - } - - /** - * Returns the block number of the latest block in the longest block chain. - * - * @return integer Block number - * @throws BitcoinClientException - */ - public function getblocknumber() { - return $this->query("getblocknumber"); - } - - /** - * Returns the number of connections to other nodes. - * - * @return integer Connection count - * @throws BitcoinClientException - */ - public function getconnectioncount() { - return $this->query("getconnectioncount"); - } - - /** - * Returns the proof-of-work difficulty as a multiple of the minimum difficulty. - * - * @return float Difficulty - * @throws BitcoinClientException - */ - public function getdifficulty() { - return $this->query("getdifficulty"); - } - - /** - * Returns boolean true if server is trying to generate bitcoins, false otherwise. - * - * @return boolean Generation status - * @throws BitcoinClientException - */ - public function getgenerate() { - return $this->query("getgenerate"); - } - - /** - * Tell Bitcoin server to generate Bitcoins or not, and how many processors - * to use. - * - * @param boolean $generate - * @param integer $maxproc - * Limit generation to $maxproc processors, unlimited if -1 - * @return mixed Nothing if successful, error array if not - * @throws BitcoinClientException - */ - public function setgenerate($generate = TRUE, $maxproc = -1) { - if (!is_numeric($maxproc) || $maxproc < -1) - throw new BitcoinClientException('setgenerate: $maxproc must be numeric and >= -1'); - return $this->query("setgenerate", $generate, $maxproc); - } - - /** - * Returns an array containing server information. - * - * @return array Server information - * @throws BitcoinClientException - */ - public function getinfo() { - return $this->query("getinfo"); - } - - /** - * Returns the account associated with the given address. - * - * @param string $address - * @return string Account - * @throws BitcoinClientException - * @since 0.3.17 - */ - public function getaccount($address) { - if (!$address || empty($address)) - throw new BitcoinClientException("getaccount requires an address"); - return $this->query("getaccount", $address); - } - - /** - * Returns the label associated with the given address. - * - * @param string $address - * @return string Label - * @throws BitcoinClientException - * @deprecated Since 0.3.17 - */ - public function getlabel($address) { - if (!$address || empty($address)) - throw new BitcoinClientException("getlabel requires an address"); - return $this->query("getlabel", $address); - } - - /** - * Sets the account associated with the given address. - * $account may be omitted to remove an account from an address. - * - * @param string $address - * @param string $account - * @return NULL - * @throws BitcoinClientException - * @since 0.3.17 - */ - public function setaccount($address, $account = "") { - if (!$address || empty($address)) - throw new BitcoinClientException("setaccount requires an address"); - return $this->query("setaccount", $address, $account); - } - - /** - * Sets the label associated with the given address. - * $label may be omitted to remove a label from an address. - * - * @param string $address - * @param string $label - * @return NULL - * @throws BitcoinClientException - * @deprecated Since 0.3.17 - */ - public function setlabel($address, $label = "") { - if (!$address || empty($address)) - throw new BitcoinClientException("setlabel requires an address"); - return $this->query("setlabel", $address, $label); - } - - /** - * Returns a new bitcoin address for receiving payments. - * - * If $account is specified (recommended), it is added to the address book so - * payments received with the address will be credited to $account. - * - * @param string $account Label to apply to the new address - * @return string Bitcoin address - * @throws BitcoinClientException - */ - public function getnewaddress($account = NULL) { - if (!$account || empty($account)) - return $this->query("getnewaddress"); - return $this->query("getnewaddress", $account); - } - - /** - * Returns the total amount received by $address in transactions with at least - * $minconf confirmations. - * - * @param string $address - * Bitcoin address - * @param integer $minconf - * Minimum number of confirmations for transactions to be counted - * @return float Bitcoin total - * @throws BitcoinClientException - */ - public function getreceivedbyaddress($address, $minconf = 1) { - if (!is_numeric($minconf) || $minconf < 0) - throw new BitcoinClientException('getreceivedbyaddress requires a numeric minconf >= 0'); - if (!$address || empty($address)) - throw new BitcoinClientException("getreceivedbyaddress requires an address"); - return $this->query("getreceivedbyaddress", $address, $minconf); - } - - /** - * Returns the total amount received by addresses associated with $account - * in transactions with at least $minconf confirmations. - * - * @param string $account - * @param integer $minconf - * Minimum number of confirmations for transactions to be counted - * @return float Bitcoin total - * @throws BitcoinClientException - * @since 0.3.17 - */ - public function getreceivedbyaccount($account, $minconf = 1) { - if (!is_numeric($minconf) || $minconf < 0) - throw new BitcoinClientException('getreceivedbyaccount requires a numeric minconf >= 0'); - if (!$account || empty($account)) - throw new BitcoinClientException("getreceivedbyaccount requires an account"); - return $this->query("getreceivedbyaccount", $account, $minconf); - } - - /** - * Returns the total amount received by addresses with $label in - * transactions with at least $minconf confirmations. - * - * @param string $label - * @param integer $minconf - * Minimum number of confirmations for transactions to be counted - * @return float Bitcoin total - * @throws BitcoinClientException - * @deprecated Since 0.3.17 - */ - public function getreceivedbylabel($label, $minconf = 1) { - if (!is_numeric($minconf) || $minconf < 0) - throw new BitcoinClientException('getreceivedbylabel requires a numeric minconf >= 0'); - if (!$label || empty($label)) - throw new BitcoinClientException("getreceivedbylabel requires a label"); - return $this->query("getreceivedbylabel", $label, $minconf); - } - - /** - * Return a list of server RPC commands or help for $command, if specified. - * - * @param string $command - * @return string Help text - * @throws BitcoinClientException - */ - public function help($command = NULL) { - if (!$command || empty($command)) - return $this->query("help"); - return $this->query("help", $command); - } - - /** - * Return an array of arrays showing how many Bitcoins have been received by - * each address in the server's wallet. - * - * @param integer $minconf Minimum number of confirmations before payments are included. - * @param boolean $includeempty Whether to include addresses that haven't received any payments. - * @return array An array of arrays. The elements are: - * "address" => receiving address - * "account" => the account of the receiving address - * "amount" => total amount received by the address - * "confirmations" => number of confirmations of the most recent transaction included - * @throws BitcoinClientException - */ - public function listreceivedbyaddress($minconf = 1, $includeempty = FALSE) { - if (!is_numeric($minconf) || $minconf < 0) - throw new BitcoinClientException('listreceivedbyaddress requires a numeric minconf >= 0'); - return $this->query("listreceivedbyaddress", $minconf, $includeempty); - } - - /** - * Return an array of arrays showing how many Bitcoins have been received by - * each account in the server's wallet. - * - * @param integer $minconf - * Minimum number of confirmations before payments are included. - * @param boolean $includeempty - * Whether to include addresses that haven't received any payments. - * @return array An array of arrays. The elements are: - * "account" => the label of the receiving address - * "amount" => total amount received by the address - * "confirmations" => number of confirmations of the most recent transaction included - * @throws BitcoinClientException - * @since 0.3.17 - */ - public function listreceivedbyaccount($minconf = 1, $includeempty = FALSE) { - if (!is_numeric($minconf) || $minconf < 0) - throw new BitcoinClientException('listreceivedbyaccount requires a numeric minconf >= 0'); - return $this->query("listreceivedbyaccount", $minconf, $includeempty); - } - - /** - * Return an array of arrays showing how many Bitcoins have been received by - * each label in the server's wallet. - * - * @param integer $minconf Minimum number of confirmations before payments are included. - * @param boolean $includeempty Whether to include addresses that haven't received any payments. - * @return array An array of arrays. The elements are: - * "label" => the label of the receiving address - * "amount" => total amount received by the address - * "confirmations" => number of confirmations of the most recent transaction included - * @throws BitcoinClientException - * @deprecated Since 0.3.17 - */ - public function listreceivedbylabel($minconf = 1, $includeempty = FALSE) { - if (!is_numeric($minconf) || $minconf < 0) - throw new BitcoinClientException('listreceivedbylabel requires a numeric minconf >= 0'); - return $this->query("listreceivedbylabel", $minconf, $includeempty); - } - - /** - * Send amount from the server's available balance. - * - * $amount is a real and is rounded to the nearest 0.01. Returns string "sent" on success. - * - * @param string $address Destination Bitcoin address or IP address - * @param float $amount Amount to send. Will be rounded to the nearest 0.01. - * @param string $comment - * @param string $comment_to - * @return string Hexadecimal transaction ID on success. - * @throws BitcoinClientException - * @todo Document the comment arguments better. - */ - public function sendtoaddress($address, $amount, $comment = NULL, $comment_to = NULL) { - if (!$address || empty($address)) - throw new BitcoinClientException("sendtoaddress requires a destination address"); - if (!$amount || empty($amount)) - throw new BitcoinClientException("sendtoaddress requires an amount to send"); - if (!is_numeric($amount) || $amount <= 0) - throw new BitcoinClientException("sendtoaddress requires the amount sent to be a number > 0"); - $amount = floatval($amount); - if (!$comment && !$comment_to) - return $this->query("sendtoaddress", $address, $amount); - if (!$comment_to) - return $this->query("sendtoaddress", $address, $amount, $comment); - return $this->query("sendtoaddress", $address, $amount, $comment, $comment_to); - } - - /** - * Stop the Bitcoin server. - * - * @throws BitcoinClientException - */ - public function stop() { - return $this->query("stop"); - } - - /** - * Check that $address looks like a proper Bitcoin address. - * - * @param string $address String to test for validity as a Bitcoin address - * @return array An array containing: - * "isvalid" => true or false - * "ismine" => true if the address is in the server's wallet - * "address" => bitcoinaddress - * Note: ismine and address are only returned if the address is valid. - * @throws BitcoinClientException - */ - public function validateaddress($address) { - if (!$address || empty($address)) - throw new BitcoinClientException("validateaddress requires a Bitcoin address"); - return $this->query("validateaddress", $address); - } - - /** - * Return information about a specific transaction. - * - * @param string $txid 64-digit hexadecimal transaction ID - * @return array An error array, or an array containing: - * "amount" => float Transaction amount - * "fee" => float Transaction fee - * "confirmations" => integer Network confirmations of this transaction - * "txid" => string The transaction ID - * "message" => string Transaction "comment" message - * "to" => string Transaction "to" message - * @throws BitcoinClientException - * @since 0.3.18 - */ - public function gettransaction($txid) { - if (!$txid || empty($txid) || strlen($txid) != 64 || !preg_match('/^[0-9a-fA-F]+$/', $txid)) - throw new BitcoinClientException("gettransaction requires a valid hexadecimal transaction ID"); - return $this->query("getttransaction", $txid); - } - - /** - * Move bitcoins between accounts. - * - * @param string $fromaccount - * Account to move from. If given as an empty string ("") or NULL, bitcoins will - * be moved from the wallet balance to the target account. - * @param string $toaccount - * Account to move to - * @param float $amount - * Amount to move - * @param integer $minconf - * Minimum number of confirmations on bitcoins being moved - * @param string $comment - * Transaction comment - * @throws BitcoinClientException - * @since 0.3.18 - */ - public function move($fromaccount = "", $toaccount, $amount, $minconf = 1, $comment = NULL) { - if (!$fromaccount) - $fromaccount = ""; - if (!$toaccount || empty($toaccount) || !$amount || !is_numeric($amount) || $amount <= 0) - throw new BitcoinClientException("move requires a from account, to account and numeric amount > 0"); - if (!is_numeric($minconf) || $minconf < 0) - throw new BitcoinClientException('move requires a numeric $minconf >= 0'); - if (!$comment || empty($comment)) - return $this->query("move", $fromaccount, $toaccount, $amount, $minconf); - return $this->query("move", $fromaccount, $toaccount, $amount, $minconf, $comment); - } - - /** - * Send $amount from $account's balance to $toaddress. This method will fail - * if there is less than $amount bitcoins with $minconf confirmations in the - * account's balance (unless $account is the empty-string-named default - * account; it behaves like the sendtoaddress method). Returns transaction - * ID on success. - * - * @param string $account Account to send from - * @param string $toaddress Bitcoin address to send to - * @param float $amount Amount to send - * @param integer $minconf Minimum number of confirmations on bitcoins being sent - * @param string $comment - * @param string $comment_to - * @return string Hexadecimal transaction ID - * @throws BitcoinClientException - * @since 0.3.18 - */ - public function sendfrom($account, $toaddress, $amount, $minconf = 1, $comment = NULL, $comment_to = NULL) { - if (!$account || !$toaddress || empty($toaddress) || !$amount || !is_numeric($amount) || $amount <= 0) - throw new BitcoinClientException("sendfrom requires a from account, to account and numeric amount > 0"); - if (!is_numeric($minconf) || $minconf < 0) - throw new BitcoinClientException('sendfrom requires a numeric $minconf >= 0'); - if (!$comment && !$comment_to) - return $this->query("sendfrom", $account, $toaddress, $amount, $minconf); - if (!$comment_to) - return $this->query("sendfrom", $account, $toaddress, $amount, $minconf, $comment); - $this->query("sendfrom", $account, $toaddress, $amount, $minconf, $comment, $comment_to); - } - - /** - * Return formatted hash data to work on, or try to solve specified block. - * - * If $data is provided, tries to solve the block and returns true if successful. - * If $data is not provided, returns formatted hash data to work on. - * - * @param string $data Block data - * @return mixed - * boolean TRUE if $data provided and block solving successful - * array otherwise, containing: - * "midstate" => string, precomputed hash state after hashing the first half of the data - * "data" => string, block data - * "hash1" => string, formatted hash buffer for second hash - * "target" => string, little endian hash target - * @throws BitcoinClientException - * @since 0.3.18 - */ - public function getwork($data = NULL) { - if (!$data) - return $this->query("getwork"); - return $this->query("getwork", $data); - } - - /** - * Return the current bitcoin address for receiving payments to $account. - * The account and address will be created if $account doesn't exist. - * - * @param string $account Account name - * @return string Bitcoin address for $account - * @throws BitcoinClientException - * @since 0.3.18 - */ - public function getaccountaddress($account) { - if (!$account || empty($account)) - throw new BitcoinClientException("getaccountaddress requires an account"); - return $this->query("getaccountaddress", $account); - } - - /** - * Return a recent hashes per second performance measurement. - * - * @return integer Hashes per second - * @throws BitcoinClientException - */ - public function gethashespersec() { - return $this->query("gethashespersec"); - } - - /** - * Returns the list of addresses associated with the given account. - * - * @param string $account - * @return array - * A simple array of Bitcoin addresses associated with $account, empty - * if the account doesn't exist. - * @throws BitcoinClientException - */ - public function getaddressesbyaccount($account) { - if (!$account || empty($account)) - throw new BitcoinClientException("getaddressesbyaccount requires an account"); - return $this->query("getaddressesbyaccount", $account); - } - -} + hexdec($addressversion)) { + return false; + } + $check = substr($addr, 0, strlen($addr) - 8); + $check = pack("H*", $check); + $check = strtoupper(hash("sha256", hash("sha256", $check, true))); + $check = substr($check, 0, 8); + return $check == substr($addr, strlen($addr) - 8); + } + + /** + * Convert the input to its 160-bit Bitcoin hash + * + * @param string $data + * @return string + * @access private + */ + private function hash160($data) { + $data = pack("H*", $data); + return strtoupper(hash("ripemd160", hash("sha256", $data, true))); + } + + /** + * Convert a Bitcoin public key to a 160-bit Bitcoin hash + * + * @param string $pubkey + * @return string + * @access public + */ + public static function pubKeyToAddress($pubkey) { + return self::hash160ToAddress($this->hash160($pubkey)); + } + + /** + * Remove leading "0x" from a hex value if present. + * + * @param string $string + * @return string + * @access public + */ + public static function remove0x($string) { + if (substr($string, 0, 2) == "0x" || substr($string, 0, 2) == "0X") { + $string = substr($string, 2); + } + return $string; + } +} + +/** + * Exception class for BitcoinClient + * + * @author Mike Gogulski + * http://www.gogulski.com/ http://www.nostate.com/ + */ +class BitcoinClientException extends ErrorException { + // Redefine the exception so message isn't optional + public function __construct($message, $code = 0, $severity = E_USER_NOTICE, Exception $previous = null) { + parent::__construct($message, $code, $severity, $previous); + } + + public function __toString() { + return __CLASS__ . ": [{$this->code}]: {$this->message}\n"; + } +} + +require_once(dirname(__FILE__) . "/includes/xmlrpc.inc.php"); +require_once(dirname(__FILE__) . "/includes/jsonrpc.inc.php"); + +/** + * Bitcoin client class for access to a Bitcoin server via JSON-RPC-HTTP[S] + * + * Implements the methods documented at https://www.bitcoin.org/wiki/doku.php?id=api + * + * @version 0.3.19 + * @author Mike Gogulski + * http://www.gogulski.com/ http://www.nostate.com/ + */ +class BitcoinClient extends jsonrpc_client { + + /** + * Create a jsonrpc_client object to talk to the bitcoin server and return it, + * or false on failure. + * + * @param string $scheme + * "http" or "https" + * @param string $username + * User name to use in connection the Bitcoin server's JSON-RPC interface + * @param string $password + * Server password + * @param string $address + * Server hostname or IP address + * @param mixed $port + * Server port (string or integer) + * @param string $certificate_path + * Path on the local filesystem to server's PEM certificate (ignored if $scheme != "https") + * @param integer $debug_level + * 0 (default) = no debugging; + * 1 = echo JSON-RPC messages received to stdout; + * 2 = log transmitted messages also + * @return jsonrpc_client + * @access public + * @throws BitcoinClientException + */ + public function __construct($scheme, $username, $password, $address = "localhost", $port = 8332, $certificate_path = '', $debug_level = 0) { + $scheme = strtolower($scheme); + if ($scheme != "http" && $scheme != "https") + throw new BitcoinClientException("Scheme must be http or https"); + if (empty($username)) + throw new BitcoinClientException("Username must be non-blank"); + if (empty($password)) + throw new BitcoinClientException("Password must be non-blank"); + $port = (string) $port; + if (!$port || empty($port) || !is_numeric($port) || $port < 1 || $port > 65535 || floatval($port) != intval($port)) + throw new BitcoinClientException("Port must be an integer and between 1 and 65535"); + if (!empty($certificate_path) && !is_readable($certificate_path)) + throw new BitcoinClientException("Certificate file " . $certificate_path . " is not readable"); + $uri = $scheme . "://" . $username . ":" . $password . "@" . $address . ":" . $port . "/"; + parent::__construct($uri); + $this->setDebug($debug_level); + $this->setSSLVerifyHost(0); + if ($scheme == "https") + if (!empty($certificate_path)) + $this->setCaCertificate($certificate_path); + else + $this->setSSLVerifyPeer(false); + } + + /** + * Test if the connection to the Bitcoin JSON-RPC server is working + * + * The check is done by calling the server's getinfo() method and checking + * for a fault. + * + * @return mixed boolean TRUE if successful, or a fault string otherwise + * @access public + * @throws none + */ + public function can_connect() { + try { + $r = $this->getinfo(); + } catch (BitcoinClientException $e) { + return $e->getMessage(); + } + return true; + } + + /** + * Convert a Bitcoin server query argument to a jsonrpcval + * + * @param mixed $argument + * @return jsonrpcval + * @throws none + * @todo Make this method private. + */ + public function query_arg_to_parameter($argument) { + $type = "";// "string" is encoded as this default type value in xmlrpc.inc + if (is_numeric($argument)) { + if (intval($argument) != floatval($argument)) { + $argument = floatval($argument); + $type = "double"; + } else { + $argument = intval($argument); + $type = "int"; + } + } + if (is_bool($argument)) + $type = "boolean"; + if (is_int($argument)) + $type = "int"; + if (is_float($argument)) + $type = "double"; + if (is_array($argument)) + $type = "array"; + return new jsonrpcval($argument, $type); + } + + /** + * Send a JSON-RPC message and optional parameter arguments to the server. + * + * Use the API functions if possible. This method remains public to support + * changes being made to the API before this libarary can be updated. + * + * @param string $message + * @param mixed $args, ... + * @return mixed + * @throws BitcoinClientException + * @see xmlrpc.inc:php_xmlrpc_decode() + */ + public function query($message) { + if (!$message || empty($message)) + throw new BitcoinClientException("Bitcoin client query requires a message"); + $msg = new jsonrpcmsg($message); + if (func_num_args() > 1) { + for ($i = 1; $i < func_num_args(); $i++) { + $msg->addParam(self::query_arg_to_parameter(func_get_arg($i))); + } + } + $response = $this->send($msg); + if ($response->faultCode()) { + throw new BitcoinClientException($response->faultString()); + } + return php_xmlrpc_decode($response->value()); + } + + /* + * The following functions implement the Bitcoin RPC API as documented at https://www.bitcoin.org/wiki/doku.php?id=api + */ + + /** + * Safely copies wallet.dat to destination, which can be a directory or + * a path with filename. + * + * @param string $destination + * @return mixed Nothing, or an error array + * @throws BitcoinClientException + */ + public function backupwallet($destination) { + if (!$destination || empty($destination)) + throw new BitcoinClientException("backupwallet requires a destination"); + return $this->query("backupwallet", $destination); + } + + /** + * Returns the server's available balance, or the balance for $account with + * at least $minconf confirmations. + * + * @param string $account Account to check. If not provided, the server's + * total available balance is returned. + * @param integer $minconf If specified, only transactions with at least + * $minconf confirmations will be included in the returned total. + * @return float Bitcoin balance + * @throws BitcoinClientException + */ + public function getbalance($account = NULL, $minconf = 1) { + if (!is_numeric($minconf) || $minconf < 0) + throw new BitcoinClientException('getbalance requires a numeric minconf >= 0'); + if ($account == NULL) + return $this->query("getbalance"); + return $this->query("getbalance", $account, $minconf); + } + + /** + * Returns the number of blocks in the longest block chain. + * + * @return integer Current block count + * @throws BitcoinClientException + */ + public function getblockcount() { + return $this->query("getblockcount"); + } + + /** + * Returns the block number of the latest block in the longest block chain. + * + * @return integer Block number + * @throws BitcoinClientException + */ + public function getblocknumber() { + return $this->query("getblocknumber"); + } + + /** + * Returns the number of connections to other nodes. + * + * @return integer Connection count + * @throws BitcoinClientException + */ + public function getconnectioncount() { + return $this->query("getconnectioncount"); + } + + /** + * Returns the proof-of-work difficulty as a multiple of the minimum difficulty. + * + * @return float Difficulty + * @throws BitcoinClientException + */ + public function getdifficulty() { + return $this->query("getdifficulty"); + } + + /** + * Returns boolean true if server is trying to generate bitcoins, false otherwise. + * + * @return boolean Generation status + * @throws BitcoinClientException + */ + public function getgenerate() { + return $this->query("getgenerate"); + } + + /** + * Tell Bitcoin server to generate Bitcoins or not, and how many processors + * to use. + * + * @param boolean $generate + * @param integer $maxproc + * Limit generation to $maxproc processors, unlimited if -1 + * @return mixed Nothing if successful, error array if not + * @throws BitcoinClientException + */ + public function setgenerate($generate = TRUE, $maxproc = -1) { + if (!is_numeric($maxproc) || $maxproc < -1) + throw new BitcoinClientException('setgenerate: $maxproc must be numeric and >= -1'); + return $this->query("setgenerate", $generate, $maxproc); + } + + /** + * Returns an array containing server information. + * + * @return array Server information + * @throws BitcoinClientException + */ + public function getinfo() { + return $this->query("getinfo"); + } + + /** + * Returns the account associated with the given address. + * + * @param string $address + * @return string Account + * @throws BitcoinClientException + * @since 0.3.17 + */ + public function getaccount($address) { + if (!$address || empty($address)) + throw new BitcoinClientException("getaccount requires an address"); + return $this->query("getaccount", $address); + } + + /** + * Returns the label associated with the given address. + * + * @param string $address + * @return string Label + * @throws BitcoinClientException + * @deprecated Since 0.3.17 + */ + public function getlabel($address) { + if (!$address || empty($address)) + throw new BitcoinClientException("getlabel requires an address"); + return $this->query("getlabel", $address); + } + + /** + * Sets the account associated with the given address. + * $account may be omitted to remove an account from an address. + * + * @param string $address + * @param string $account + * @return NULL + * @throws BitcoinClientException + * @since 0.3.17 + */ + public function setaccount($address, $account = "") { + if (!$address || empty($address)) + throw new BitcoinClientException("setaccount requires an address"); + return $this->query("setaccount", $address, $account); + } + + /** + * Sets the label associated with the given address. + * $label may be omitted to remove a label from an address. + * + * @param string $address + * @param string $label + * @return NULL + * @throws BitcoinClientException + * @deprecated Since 0.3.17 + */ + public function setlabel($address, $label = "") { + if (!$address || empty($address)) + throw new BitcoinClientException("setlabel requires an address"); + return $this->query("setlabel", $address, $label); + } + + /** + * Returns a new bitcoin address for receiving payments. + * + * If $account is specified (recommended), it is added to the address book so + * payments received with the address will be credited to $account. + * + * @param string $account Label to apply to the new address + * @return string Bitcoin address + * @throws BitcoinClientException + */ + public function getnewaddress($account = NULL) { + if (!$account || empty($account)) + return $this->query("getnewaddress"); + return $this->query("getnewaddress", $account); + } + + /** + * Returns the total amount received by $address in transactions with at least + * $minconf confirmations. + * + * @param string $address + * Bitcoin address + * @param integer $minconf + * Minimum number of confirmations for transactions to be counted + * @return float Bitcoin total + * @throws BitcoinClientException + */ + public function getreceivedbyaddress($address, $minconf = 1) { + if (!is_numeric($minconf) || $minconf < 0) + throw new BitcoinClientException('getreceivedbyaddress requires a numeric minconf >= 0'); + if (!$address || empty($address)) + throw new BitcoinClientException("getreceivedbyaddress requires an address"); + return $this->query("getreceivedbyaddress", $address, $minconf); + } + + /** + * Returns the total amount received by addresses associated with $account + * in transactions with at least $minconf confirmations. + * + * @param string $account + * @param integer $minconf + * Minimum number of confirmations for transactions to be counted + * @return float Bitcoin total + * @throws BitcoinClientException + * @since 0.3.17 + */ + public function getreceivedbyaccount($account, $minconf = 1) { + if (!is_numeric($minconf) || $minconf < 0) + throw new BitcoinClientException('getreceivedbyaccount requires a numeric minconf >= 0'); + if (!$account || empty($account)) + throw new BitcoinClientException("getreceivedbyaccount requires an account"); + return $this->query("getreceivedbyaccount", $account, $minconf); + } + + /** + * Returns the total amount received by addresses with $label in + * transactions with at least $minconf confirmations. + * + * @param string $label + * @param integer $minconf + * Minimum number of confirmations for transactions to be counted + * @return float Bitcoin total + * @throws BitcoinClientException + * @deprecated Since 0.3.17 + */ + public function getreceivedbylabel($label, $minconf = 1) { + if (!is_numeric($minconf) || $minconf < 0) + throw new BitcoinClientException('getreceivedbylabel requires a numeric minconf >= 0'); + if (!$label || empty($label)) + throw new BitcoinClientException("getreceivedbylabel requires a label"); + return $this->query("getreceivedbylabel", $label, $minconf); + } + + /** + * Return a list of server RPC commands or help for $command, if specified. + * + * @param string $command + * @return string Help text + * @throws BitcoinClientException + */ + public function help($command = NULL) { + if (!$command || empty($command)) + return $this->query("help"); + return $this->query("help", $command); + } + + /** + * Return an array of arrays showing how many Bitcoins have been received by + * each address in the server's wallet. + * + * @param integer $minconf Minimum number of confirmations before payments are included. + * @param boolean $includeempty Whether to include addresses that haven't received any payments. + * @return array An array of arrays. The elements are: + * "address" => receiving address + * "account" => the account of the receiving address + * "amount" => total amount received by the address + * "confirmations" => number of confirmations of the most recent transaction included + * @throws BitcoinClientException + */ + public function listreceivedbyaddress($minconf = 1, $includeempty = FALSE) { + if (!is_numeric($minconf) || $minconf < 0) + throw new BitcoinClientException('listreceivedbyaddress requires a numeric minconf >= 0'); + return $this->query("listreceivedbyaddress", $minconf, $includeempty); + } + + /** + * Return an array of arrays showing how many Bitcoins have been received by + * each account in the server's wallet. + * + * @param integer $minconf + * Minimum number of confirmations before payments are included. + * @param boolean $includeempty + * Whether to include addresses that haven't received any payments. + * @return array An array of arrays. The elements are: + * "account" => the label of the receiving address + * "amount" => total amount received by the address + * "confirmations" => number of confirmations of the most recent transaction included + * @throws BitcoinClientException + * @since 0.3.17 + */ + public function listreceivedbyaccount($minconf = 1, $includeempty = FALSE) { + if (!is_numeric($minconf) || $minconf < 0) + throw new BitcoinClientException('listreceivedbyaccount requires a numeric minconf >= 0'); + return $this->query("listreceivedbyaccount", $minconf, $includeempty); + } + + /** + * Return an array of arrays showing how many Bitcoins have been received by + * each label in the server's wallet. + * + * @param integer $minconf Minimum number of confirmations before payments are included. + * @param boolean $includeempty Whether to include addresses that haven't received any payments. + * @return array An array of arrays. The elements are: + * "label" => the label of the receiving address + * "amount" => total amount received by the address + * "confirmations" => number of confirmations of the most recent transaction included + * @throws BitcoinClientException + * @deprecated Since 0.3.17 + */ + public function listreceivedbylabel($minconf = 1, $includeempty = FALSE) { + if (!is_numeric($minconf) || $minconf < 0) + throw new BitcoinClientException('listreceivedbylabel requires a numeric minconf >= 0'); + return $this->query("listreceivedbylabel", $minconf, $includeempty); + } + + /** + * Send amount from the server's available balance. + * + * $amount is a real and is rounded to the nearest 0.01. Returns string "sent" on success. + * + * @param string $address Destination Bitcoin address or IP address + * @param float $amount Amount to send. Will be rounded to the nearest 0.01. + * @param string $comment + * @param string $comment_to + * @return string Hexadecimal transaction ID on success. + * @throws BitcoinClientException + * @todo Document the comment arguments better. + */ + public function sendtoaddress($address, $amount, $comment = NULL, $comment_to = NULL) { + if (!$address || empty($address)) + throw new BitcoinClientException("sendtoaddress requires a destination address"); + if (!$amount || empty($amount)) + throw new BitcoinClientException("sendtoaddress requires an amount to send"); + if (!is_numeric($amount) || $amount <= 0) + throw new BitcoinClientException("sendtoaddress requires the amount sent to be a number > 0"); + $amount = floatval($amount); + if (!$comment && !$comment_to) + return $this->query("sendtoaddress", $address, $amount); + if (!$comment_to) + return $this->query("sendtoaddress", $address, $amount, $comment); + return $this->query("sendtoaddress", $address, $amount, $comment, $comment_to); + } + + /** + * Stop the Bitcoin server. + * + * @throws BitcoinClientException + */ + public function stop() { + return $this->query("stop"); + } + + /** + * Check that $address looks like a proper Bitcoin address. + * + * @param string $address String to test for validity as a Bitcoin address + * @return array An array containing: + * "isvalid" => true or false + * "ismine" => true if the address is in the server's wallet + * "address" => bitcoinaddress + * Note: ismine and address are only returned if the address is valid. + * @throws BitcoinClientException + */ + public function validateaddress($address) { + if (!$address || empty($address)) + throw new BitcoinClientException("validateaddress requires a Bitcoin address"); + return $this->query("validateaddress", $address); + } + + /** + * Return information about a specific transaction. + * + * @param string $txid 64-digit hexadecimal transaction ID + * @return array An error array, or an array containing: + * "amount" => float Transaction amount + * "fee" => float Transaction fee + * "confirmations" => integer Network confirmations of this transaction + * "txid" => string The transaction ID + * "message" => string Transaction "comment" message + * "to" => string Transaction "to" message + * @throws BitcoinClientException + * @since 0.3.18 + */ + public function gettransaction($txid) { + if (!$txid || empty($txid) || strlen($txid) != 64 || !preg_match('/^[0-9a-fA-F]+$/', $txid)) + throw new BitcoinClientException("gettransaction requires a valid hexadecimal transaction ID"); + return $this->query("getttransaction", $txid); + } + + /** + * Move bitcoins between accounts. + * + * @param string $fromaccount + * Account to move from. If given as an empty string ("") or NULL, bitcoins will + * be moved from the wallet balance to the target account. + * @param string $toaccount + * Account to move to + * @param float $amount + * Amount to move + * @param integer $minconf + * Minimum number of confirmations on bitcoins being moved + * @param string $comment + * Transaction comment + * @throws BitcoinClientException + * @since 0.3.18 + */ + public function move($fromaccount = "", $toaccount, $amount, $minconf = 1, $comment = NULL) { + if (!$fromaccount) + $fromaccount = ""; + if (!$toaccount || empty($toaccount) || !$amount || !is_numeric($amount) || $amount <= 0) + throw new BitcoinClientException("move requires a from account, to account and numeric amount > 0"); + if (!is_numeric($minconf) || $minconf < 0) + throw new BitcoinClientException('move requires a numeric $minconf >= 0'); + if (!$comment || empty($comment)) + return $this->query("move", $fromaccount, $toaccount, $amount, $minconf); + return $this->query("move", $fromaccount, $toaccount, $amount, $minconf, $comment); + } + + /** + * Send $amount from $account's balance to $toaddress. This method will fail + * if there is less than $amount bitcoins with $minconf confirmations in the + * account's balance (unless $account is the empty-string-named default + * account; it behaves like the sendtoaddress method). Returns transaction + * ID on success. + * + * @param string $account Account to send from + * @param string $toaddress Bitcoin address to send to + * @param float $amount Amount to send + * @param integer $minconf Minimum number of confirmations on bitcoins being sent + * @param string $comment + * @param string $comment_to + * @return string Hexadecimal transaction ID + * @throws BitcoinClientException + * @since 0.3.18 + */ + public function sendfrom($account, $toaddress, $amount, $minconf = 1, $comment = NULL, $comment_to = NULL) { + if (!$account || !$toaddress || empty($toaddress) || !$amount || !is_numeric($amount) || $amount <= 0) + throw new BitcoinClientException("sendfrom requires a from account, to account and numeric amount > 0"); + if (!is_numeric($minconf) || $minconf < 0) + throw new BitcoinClientException('sendfrom requires a numeric $minconf >= 0'); + if (!$comment && !$comment_to) + return $this->query("sendfrom", $account, $toaddress, $amount, $minconf); + if (!$comment_to) + return $this->query("sendfrom", $account, $toaddress, $amount, $minconf, $comment); + $this->query("sendfrom", $account, $toaddress, $amount, $minconf, $comment, $comment_to); + } + + /** + * Return formatted hash data to work on, or try to solve specified block. + * + * If $data is provided, tries to solve the block and returns true if successful. + * If $data is not provided, returns formatted hash data to work on. + * + * @param string $data Block data + * @return mixed + * boolean TRUE if $data provided and block solving successful + * array otherwise, containing: + * "midstate" => string, precomputed hash state after hashing the first half of the data + * "data" => string, block data + * "hash1" => string, formatted hash buffer for second hash + * "target" => string, little endian hash target + * @throws BitcoinClientException + * @since 0.3.18 + */ + public function getwork($data = NULL) { + if (!$data) + return $this->query("getwork"); + return $this->query("getwork", $data); + } + + /** + * Return the current bitcoin address for receiving payments to $account. + * The account and address will be created if $account doesn't exist. + * + * @param string $account Account name + * @return string Bitcoin address for $account + * @throws BitcoinClientException + * @since 0.3.18 + */ + public function getaccountaddress($account) { + if (!$account || empty($account)) + throw new BitcoinClientException("getaccountaddress requires an account"); + return $this->query("getaccountaddress", $account); + } + + /** + * Return a recent hashes per second performance measurement. + * + * @return integer Hashes per second + * @throws BitcoinClientException + */ + public function gethashespersec() { + return $this->query("gethashespersec"); + } + + /** + * Returns the list of addresses associated with the given account. + * + * @param string $account + * @return array + * A simple array of Bitcoin addresses associated with $account, empty + * if the account doesn't exist. + * @throws BitcoinClientException + */ + public function getaddressesbyaccount($account) { + if (!$account || empty($account)) + throw new BitcoinClientException("getaddressesbyaccount requires an account"); + return $this->query("getaddressesbyaccount", $account); + } + +} diff --git a/includes/footer.php b/includes/footer.php index 56249ca..21cd6fb 100644 --- a/includes/footer.php +++ b/includes/footer.php @@ -1,8 +1,8 @@ -
-
- -
- - + +
+ + + + diff --git a/includes/header.php b/includes/header.php index 98bd584..ee55860 100644 --- a/includes/header.php +++ b/includes/header.php @@ -1,43 +1,43 @@ - -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// 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 . - -// BTC Donations: 163Pv9cUDJTNUbadV4HMRQSSj3ipwLURRc - -//Set page starter variables// -$cookieValid = false; -$activeMiners = false; - -include("requiredFunctions.php"); - -include('includes/stats.php'); -$stats = new Stats(); - -include("universalChecklogin.php"); - -if (!isset($pageTitle)) $pageTitle = outputPageTitle(); -else $pageTitle = outputPageTitle(). " ". $pageTitle; - -?> - - - - <?php echo $pageTitle;?> - + +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// 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 . + +// BTC Donations: 163Pv9cUDJTNUbadV4HMRQSSj3ipwLURRc + +//Set page starter variables// +$cookieValid = false; +$activeMiners = false; + +include("requiredFunctions.php"); + +include('includes/stats.php'); +$stats = new Stats(); + +include("universalChecklogin.php"); + +if (!isset($pageTitle)) $pageTitle = outputPageTitle(); +else $pageTitle = outputPageTitle(). " ". $pageTitle; + +?> + + + + <?php echo $pageTitle;?> + - + - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
PoolHashrate: currenthashrate()/1000,1); ?> GH/sWorkers: currentworkers(); ?>Round Shares: currentshares();?>Server Load: get_server_load(); ?>MtGox (USD): $mtgoxlast(); ?>
username; ?> (logout)Hashrate: userhashrate($userInfo->username); ?> MH/sWorkers: workers($userInfo->id)); ?>Round Shares: (userstalecount($userId) / $totalUserShares * 100),1); ?>% stale)Estimate: BTCBalance: BTC
Login: - - - - Lost Password -
-
- - - -
+ + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
PoolHashrate: currenthashrate()/1000,1); ?> GH/sWorkers: currentworkers(); ?>Round Shares: currentshares();?>Server Load: get_server_load(); ?>MtGox (USD): $mtgoxlast(); ?>
username; ?> (logout)Hashrate: userhashrate($userInfo->username); ?> MH/sWorkers: workers($userInfo->id)); ?>Round Shares: (userstalecount($userId) / $totalUserShares * 100),1); ?>% stale)Estimate: BTCBalance: BTC
Login: + + + + Lost Password +
+
+ + + +
diff --git a/includes/settings.php b/includes/settings.php index 994c138..d9eecda 100644 --- a/includes/settings.php +++ b/includes/settings.php @@ -1,47 +1,47 @@ - -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// 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 . - -// BTC Donations: 163Pv9cUDJTNUbadV4HMRQSSj3ipwLURRc - -class Settings { - - var $settingsarray = array(); - - function Settings() { - $this->loadsettings(); - } - - function loadsettings() { - $settingsQ = mysql_query_cache("SELECT setting, value FROM settings"); - foreach ($settingsQ as$settingsR ) { - $setting = $settingsR->setting; - $value = $settingsR->value; - $this->settingsarray[$setting] = $value; - } - } - - function getsetting($settingname){ - if (isset($this->settingsarray[$settingname])) return $this->settingsarray[$settingname]; - } - - function setsetting($settingname, $value) { + +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// 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 . + +// BTC Donations: 163Pv9cUDJTNUbadV4HMRQSSj3ipwLURRc + +class Settings { + + var $settingsarray = array(); + + function Settings() { + $this->loadsettings(); + } + + function loadsettings() { + $settingsQ = mysql_query_cache("SELECT setting, value FROM settings"); + foreach ($settingsQ as$settingsR ) { + $setting = $settingsR->setting; + $value = $settingsR->value; + $this->settingsarray[$setting] = $value; + } + } + + function getsetting($settingname){ + if (isset($this->settingsarray[$settingname])) return $this->settingsarray[$settingname]; + } + + function setsetting($settingname, $value) { mysql_query("UPDATE settings SET value='$value' WHERE setting ='$settingname'"); - $this->settingsarray[$settingname] = $value; - removeSqlCache("SELECT setting, value FROM settings"); - } -} - + $this->settingsarray[$settingname] = $value; + removeSqlCache("SELECT setting, value FROM settings"); + } +} + ?> \ No newline at end of file diff --git a/includes/stats.php b/includes/stats.php index 9490ddc..402e645 100644 --- a/includes/stats.php +++ b/includes/stats.php @@ -1,492 +1,492 @@ -query($sql); - if ($row = $result->fetch()) - $retval = "old"; - setCache("previousRoundSharesInShares", $retval, 300); - } - //echo "prev shares: $retval"; - if ($retval == "old") - return true; - return false; - } - - function currentshares() { - global $read_only_db; - $currentshares = 0; - if (!($currentshares = getCache("pool_shares"))) { - $lastwinningshare = $this->lastWinningShareId(); - $sql = "SELECT count(*) FROM shares"; - if ($this->previousRoundSharesInShares()) - $sql = "SELECT count(*) FROM shares WHERE id > $lastwinningshare"; - $result = $read_only_db->query($sql); - if ($row = $result->fetch()) { - $currentshares = $row[0]; - setCache("pool_shares", $currentshares, 2); - } - } - return $currentshares; - } - - function currentUnconfirmedShares() { - global $read_only_db; - $currentshares = 0; - if (!($currentshares = getCache("unconfirmed_pool_shares"))) { - $lastwinningshare = $this->lastWinningShareId(); - $lastrewardedshare = $this->lastRewardedShareId(); - $sql = "SELECT count(*) FROM shares WHERE id < $lastwinningshare AND id > $lastrewardedshare"; - $result = $read_only_db->query($sql); - if ($row = $result->fetch()) { - $currentshares = $row[0]; - setCache("unconfirmed_pool_shares", $currentshares, 600); - } - } - return $currentshares; - } - - function currentstales() { - global $read_only_db; - $currentshares = 0; - $lastwinningshare = $this->lastWinningShareId(); - if (!($currentshares = getCache("pool_stales"))) { - $sql = "SELECT count(*) FROM shares WHERE our_result='N'"; - if ($this->previousRoundSharesInShares()) - $sql = "SELECT count(*) FROM shares WHERE id > $lastwinningshare AND our_result='N'"; - $result = $read_only_db->query($sql); - if ($row = $result->fetch()) { - $currentshares = $row[0]; - setCache("pool_stales", $currentshares, 300); - } - } - return $currentshares; - } - - function currenthashrate() { - global $read_only_db; - $currenthashrate = 0; - if (!($currenthashrate = getCache("pool_hashrate"))) { - $sql = "SELECT count(*) as id FROM shares WHERE time > DATE_SUB(now(), INTERVAL 10 MINUTE) "; - $result = mysql_query($sql); - if ($resultrow = mysql_fetch_array($result)) { - $currenthashrate = $resultrow[0]; - $currenthashrate = round((($currenthashrate*4294967296)/590)/1000000, 0); - setCache("pool_hashrate", $currenthashrate, 300); - try { - $fileName = $apidir."pool/speed"; - $fileHandle = fopen($fileName, 'w'); - fwrite($fileHandle, ($currenthashrate/1000)); - fclose($fileHandle); - } catch (Exception $e) { - //echo $e->getMessage(); - } - } - } - return $currenthashrate; - } - - function poolefficiency() { - global $totalUserShares; - global $read_only_db; - $efficiency = 0.0; - if (!($efficiency = getCache("pool_efficiency"))) { - $efficiency = (1 - ($this->currentstales()/$this->currentshares())) * 100; - if ($efficiency > 0) - setCache("pool_efficiency", $efficiency, 600); - } - return $efficiency; - } - - function currentworkers() { - $currentworkers = 0; - if (!($currentworkers = getCache("pool_workers"))) { - $uwa = $this->workerhashrates(); - foreach ($uwa as $key => $value) { - if ($value > 0) - $currentworkers += 1; - } - setCache("pool_workers", $currentworkers, 1800); - } - return $currentworkers; - } - - function lastRewardedShareId() { - global $read_only_db; - $shareid = 0; - if (!($shareid = getCache("last_rewarded_share_id"))) { - $result = $read_only_db->query("SELECT max(share_id) FROM winning_shares WHERE rewarded='Y'"); - if ($row = $result->fetch()) { - $shareid = $row[0]; - } - setCache("last_rewarded_share_id", $shareid, 600); - } - return $shareid; - } - - function lastWinningShareId() { - global $read_only_db; - $shareid = 0; - if (!($shareid = getCache("last_winning_share_id"))) { - $result = $read_only_db->query("SELECT max(share_id) FROM winning_shares"); - if ($row = $result->fetch()) { - $shareid = $row[0]; - } - setCache("last_winning_share_id", $shareid, 600); - } - if ($shareid == '') - return 0; - return $shareid; - } - - function onionwinners($limit) { - global $read_only_db; - $uwa = Array(); - if (!($uwa = getCache("onion_winners_array"))) { - $result = $read_only_db->query("SELECT username, (stale_share_count / share_count)*100 AS stale_percent FROM webUsers WHERE shares_this_round > 0 ORDER BY stale_percent DESC LIMIT ".$limit); - while ($row = $result->fetch()) { - $uwa[$row[0]] = $row[1]; - } - setCache("onion_winners_array", $uwa, 1800); - } - return $uwa; - } - - function lastwinningblocks($limit) { - global $read_only_db; - $i = 0; - $uwa = Array(); - if (!($uwa = getCache("last_winning_blocks"))) { - $result = $read_only_db->query("SELECT w.username, w.blockNumber, w.confirms, n.timestamp FROM winning_shares w, networkBlocks n WHERE w.blockNumber = n.blockNumber ORDER BY w.blockNumber DESC LIMIT ".$limit); - while ($row = $result->fetch()) { - $uwa[$i] = Array(); - $uwa[$i][0] = $row[0]; - $uwa[$i][1] = $row[1]; - $uwa[$i][2] = $row[2]; - $uwa[$i][3] = $row[3]; - $i += 1; - } - setCache("last_winning_blocks", $uwa, 600); - } - return $uwa; - } - - function unrewardedblocks() { - global $read_only_db; - $count = 0; - if (!($count = getCache("unrewarded_block_count"))) { - $result = mysql_query("SELECT count(*) FROM winning_shares WHERE rewarded = 'N'") or die(mysql_error()); - if ($row = mysql_fetch_row($result)) - $count = $row[0]; - setCache("unrewarded_block_count", $count, 600); - } - return $count; - } - - function workerhashrates() { - global $read_only_db; - $uwa = Array(); - if (!($uwa = getCache("worker_hashrates"))) { - $sql ="SELECT IFNULL(count(s.id),0) AS hashrate, p.username FROM pool_worker p LEFT JOIN ". - "shares s ON p.username = s.username ". - "WHERE s.time > DATE_SUB(now(), INTERVAL 10 MINUTE) ". - "GROUP BY username "; - $result = $read_only_db->query($sql); - while ($resultObj = $result->fetch()) { - $uwa[$resultObj[1]] = round((($resultObj[0]*4294967296)/590)/1000000, 0); - } - if (count($uwa) > 0) - setCache("worker_hashrates", $uwa, 600); - } - return $uwa; - } - - function workerhashrate($workername) { - $workerhashrate = 0; - $uwa = $this->workerhashrates(); - if (array_key_exists($workername, $uwa)) { - $workerhashrate = $uwa[$workername]; - } - return $workerhashrate; - } - - function userhashrates() { - global $read_only_db; - $uwa = Array(); - if (!($uwa = getCache("user_hashrates"))) { - $sql ="SELECT IFNULL(count(s.id),0) AS hashrate, u.username FROM webUsers u ". - "INNER JOIN pool_worker p ON p.associatedUserId = u.id ". - "LEFT JOIN shares s ON p.username = s.username ". - "WHERE s.time > DATE_SUB(now(), INTERVAL 10 MINUTE) ". - "GROUP BY username ". - "ORDER BY hashrate DESC"; - $result = $read_only_db->query($sql); - while ($resultObj = $result->fetch()) { - $uwa[$resultObj[1]] = round((($resultObj[0]*4294967296)/590)/1000000, 0); - } - if (count($uwa) > 0) - setCache("user_hashrates", $uwa, 600); - } - return $uwa; - } - - function stalecalc($roundstales, $roundshares) { - if ($roundshares > 0) - return round($roundstales/$roundshares*100,2); - return 0; - } - - function username_userid_array() { - $userarray = Array(); - $result = mysql_query("SELECT id, username from webUsers"); - while ($row = mysql_fetch_object($result)) { - $userarray[$row->username] = $row->id; - } - return $userarray; - } - - function userhashratesbyid() { - $uhr = Array(); - $uwa = $this->userhashrates(); - foreach ($this->username_userid_array() as $username => $userid) { - if (array_key_exists($username, $uwa)) - $uhr[$userid] = $uwa[$username]; - else - $uhr[$userid] = 0; - } - return $uhr; - } - - function userhashrate($username) { - $userhashrate = 0; - $uwa = $this->userhashrates(); - if (array_key_exists($username, $uwa)) { - $userhashrate = $uwa[$username]; - } - return $userhashrate; - } - - function userUnconfirmedEstimate($userid) { - global $read_only_db; - $estimate = 0; - $unrewardedblocks = $this->unrewardedblocks(); - if ($unrewardedblocks) { - if (!($estimate = getCache("user_unconfirmed_estimate_".$userid))) { - $sql = "SELECT IFNULL(sum(amount),0) FROM unconfirmed_rewards WHERE userId = $userid AND rewarded='N'"; - $result = mysql_query($sql) or die(mysql_error()); - if ($row = mysql_fetch_row($result)) { - $estimate = $row[0]; - } - setCache("user_unconfirmed_estimate_".$userid, $estimate, 600); - } - } - return $estimate; - } - - function userUnconfirmedShares($userid) { - global $read_only_db; - $shares = 0; - if ($unrewardedblocks) { - if (!($shares = getCache("user_unconfirmed_shares_".$userid))) { - $sql = "SELECT IFNULL(sum(shares),0) FROM unconfirmed_rewards WHERE userId = $userid AND rewarded='N'"; - $result = mysql_query($sql); - if ($row = mysql_fetch_row($result)) { - $shares = $row[0]; - } - setCache("user_unconfirmed_shares_".$userid, $shares, 600); - } - } - return $shares; - } - - function usersharecount($userId) { - global $read_only_db; - $totalUserShares = 0; - $workers = Array(); - $lastwinningshare = $this->lastWinningShareId(); - if (!($totalUserShares = getCache("user_shares_".$userId))) { - $workers = $this->workers($userId); - $sql = "SELECT sum(s.id) FROM (SELECT 'a' as username, 0 as id "; - foreach ($workers as $worker) { - if ($this->previousRoundSharesInShares()) - $sql .= "UNION SELECT username, count(id) as id FROM shares WHERE username = '$worker' AND id > $lastwinningshare "; +query($sql); + if ($row = $result->fetch()) + $retval = "old"; + setCache("previousRoundSharesInShares", $retval, 300); + } + //echo "prev shares: $retval"; + if ($retval == "old") + return true; + return false; + } + + function currentshares() { + global $read_only_db; + $currentshares = 0; + if (!($currentshares = getCache("pool_shares"))) { + $lastwinningshare = $this->lastWinningShareId(); + $sql = "SELECT count(*) FROM shares"; + if ($this->previousRoundSharesInShares()) + $sql = "SELECT count(*) FROM shares WHERE id > $lastwinningshare"; + $result = $read_only_db->query($sql); + if ($row = $result->fetch()) { + $currentshares = $row[0]; + setCache("pool_shares", $currentshares, 2); + } + } + return $currentshares; + } + + function currentUnconfirmedShares() { + global $read_only_db; + $currentshares = 0; + if (!($currentshares = getCache("unconfirmed_pool_shares"))) { + $lastwinningshare = $this->lastWinningShareId(); + $lastrewardedshare = $this->lastRewardedShareId(); + $sql = "SELECT count(*) FROM shares WHERE id < $lastwinningshare AND id > $lastrewardedshare"; + $result = $read_only_db->query($sql); + if ($row = $result->fetch()) { + $currentshares = $row[0]; + setCache("unconfirmed_pool_shares", $currentshares, 600); + } + } + return $currentshares; + } + + function currentstales() { + global $read_only_db; + $currentshares = 0; + $lastwinningshare = $this->lastWinningShareId(); + if (!($currentshares = getCache("pool_stales"))) { + $sql = "SELECT count(*) FROM shares WHERE our_result='N'"; + if ($this->previousRoundSharesInShares()) + $sql = "SELECT count(*) FROM shares WHERE id > $lastwinningshare AND our_result='N'"; + $result = $read_only_db->query($sql); + if ($row = $result->fetch()) { + $currentshares = $row[0]; + setCache("pool_stales", $currentshares, 300); + } + } + return $currentshares; + } + + function currenthashrate() { + global $read_only_db; + $currenthashrate = 0; + if (!($currenthashrate = getCache("pool_hashrate"))) { + $sql = "SELECT count(*) as id FROM shares WHERE time > DATE_SUB(now(), INTERVAL 10 MINUTE) "; + $result = mysql_query($sql); + if ($resultrow = mysql_fetch_array($result)) { + $currenthashrate = $resultrow[0]; + $currenthashrate = round((($currenthashrate*4294967296)/590)/1000000, 0); + setCache("pool_hashrate", $currenthashrate, 300); + try { + $fileName = $apidir."pool/speed"; + $fileHandle = fopen($fileName, 'w'); + fwrite($fileHandle, ($currenthashrate/1000)); + fclose($fileHandle); + } catch (Exception $e) { + //echo $e->getMessage(); + } + } + } + return $currenthashrate; + } + + function poolefficiency() { + global $totalUserShares; + global $read_only_db; + $efficiency = 0.0; + if (!($efficiency = getCache("pool_efficiency"))) { + $efficiency = (1 - ($this->currentstales()/$this->currentshares())) * 100; + if ($efficiency > 0) + setCache("pool_efficiency", $efficiency, 600); + } + return $efficiency; + } + + function currentworkers() { + $currentworkers = 0; + if (!($currentworkers = getCache("pool_workers"))) { + $uwa = $this->workerhashrates(); + foreach ($uwa as $key => $value) { + if ($value > 0) + $currentworkers += 1; + } + setCache("pool_workers", $currentworkers, 1800); + } + return $currentworkers; + } + + function lastRewardedShareId() { + global $read_only_db; + $shareid = 0; + if (!($shareid = getCache("last_rewarded_share_id"))) { + $result = $read_only_db->query("SELECT max(share_id) FROM winning_shares WHERE rewarded='Y'"); + if ($row = $result->fetch()) { + $shareid = $row[0]; + } + setCache("last_rewarded_share_id", $shareid, 600); + } + return $shareid; + } + + function lastWinningShareId() { + global $read_only_db; + $shareid = 0; + if (!($shareid = getCache("last_winning_share_id"))) { + $result = $read_only_db->query("SELECT max(share_id) FROM winning_shares"); + if ($row = $result->fetch()) { + $shareid = $row[0]; + } + setCache("last_winning_share_id", $shareid, 600); + } + if ($shareid == '') + return 0; + return $shareid; + } + + function onionwinners($limit) { + global $read_only_db; + $uwa = Array(); + if (!($uwa = getCache("onion_winners_array"))) { + $result = $read_only_db->query("SELECT username, (stale_share_count / share_count)*100 AS stale_percent FROM webUsers WHERE shares_this_round > 0 ORDER BY stale_percent DESC LIMIT ".$limit); + while ($row = $result->fetch()) { + $uwa[$row[0]] = $row[1]; + } + setCache("onion_winners_array", $uwa, 1800); + } + return $uwa; + } + + function lastwinningblocks($limit) { + global $read_only_db; + $i = 0; + $uwa = Array(); + if (!($uwa = getCache("last_winning_blocks"))) { + $result = $read_only_db->query("SELECT w.username, w.blockNumber, w.confirms, n.timestamp FROM winning_shares w, networkBlocks n WHERE w.blockNumber = n.blockNumber ORDER BY w.blockNumber DESC LIMIT ".$limit); + while ($row = $result->fetch()) { + $uwa[$i] = Array(); + $uwa[$i][0] = $row[0]; + $uwa[$i][1] = $row[1]; + $uwa[$i][2] = $row[2]; + $uwa[$i][3] = $row[3]; + $i += 1; + } + setCache("last_winning_blocks", $uwa, 600); + } + return $uwa; + } + + function unrewardedblocks() { + global $read_only_db; + $count = 0; + if (!($count = getCache("unrewarded_block_count"))) { + $result = mysql_query("SELECT count(*) FROM winning_shares WHERE rewarded = 'N'") or die(mysql_error()); + if ($row = mysql_fetch_row($result)) + $count = $row[0]; + setCache("unrewarded_block_count", $count, 600); + } + return $count; + } + + function workerhashrates() { + global $read_only_db; + $uwa = Array(); + if (!($uwa = getCache("worker_hashrates"))) { + $sql ="SELECT IFNULL(count(s.id),0) AS hashrate, p.username FROM pool_worker p LEFT JOIN ". + "shares s ON p.username = s.username ". + "WHERE s.time > DATE_SUB(now(), INTERVAL 10 MINUTE) ". + "GROUP BY username "; + $result = $read_only_db->query($sql); + while ($resultObj = $result->fetch()) { + $uwa[$resultObj[1]] = round((($resultObj[0]*4294967296)/590)/1000000, 0); + } + if (count($uwa) > 0) + setCache("worker_hashrates", $uwa, 600); + } + return $uwa; + } + + function workerhashrate($workername) { + $workerhashrate = 0; + $uwa = $this->workerhashrates(); + if (array_key_exists($workername, $uwa)) { + $workerhashrate = $uwa[$workername]; + } + return $workerhashrate; + } + + function userhashrates() { + global $read_only_db; + $uwa = Array(); + if (!($uwa = getCache("user_hashrates"))) { + $sql ="SELECT IFNULL(count(s.id),0) AS hashrate, u.username FROM webUsers u ". + "INNER JOIN pool_worker p ON p.associatedUserId = u.id ". + "LEFT JOIN shares s ON p.username = s.username ". + "WHERE s.time > DATE_SUB(now(), INTERVAL 10 MINUTE) ". + "GROUP BY username ". + "ORDER BY hashrate DESC"; + $result = $read_only_db->query($sql); + while ($resultObj = $result->fetch()) { + $uwa[$resultObj[1]] = round((($resultObj[0]*4294967296)/590)/1000000, 0); + } + if (count($uwa) > 0) + setCache("user_hashrates", $uwa, 600); + } + return $uwa; + } + + function stalecalc($roundstales, $roundshares) { + if ($roundshares > 0) + return round($roundstales/$roundshares*100,2); + return 0; + } + + function username_userid_array() { + $userarray = Array(); + $result = mysql_query("SELECT id, username from webUsers"); + while ($row = mysql_fetch_object($result)) { + $userarray[$row->username] = $row->id; + } + return $userarray; + } + + function userhashratesbyid() { + $uhr = Array(); + $uwa = $this->userhashrates(); + foreach ($this->username_userid_array() as $username => $userid) { + if (array_key_exists($username, $uwa)) + $uhr[$userid] = $uwa[$username]; + else + $uhr[$userid] = 0; + } + return $uhr; + } + + function userhashrate($username) { + $userhashrate = 0; + $uwa = $this->userhashrates(); + if (array_key_exists($username, $uwa)) { + $userhashrate = $uwa[$username]; + } + return $userhashrate; + } + + function userUnconfirmedEstimate($userid) { + global $read_only_db; + $estimate = 0; + $unrewardedblocks = $this->unrewardedblocks(); + if ($unrewardedblocks) { + if (!($estimate = getCache("user_unconfirmed_estimate_".$userid))) { + $sql = "SELECT IFNULL(sum(amount),0) FROM unconfirmed_rewards WHERE userId = $userid AND rewarded='N'"; + $result = mysql_query($sql) or die(mysql_error()); + if ($row = mysql_fetch_row($result)) { + $estimate = $row[0]; + } + setCache("user_unconfirmed_estimate_".$userid, $estimate, 600); + } + } + return $estimate; + } + + function userUnconfirmedShares($userid) { + global $read_only_db; + $shares = 0; + if ($unrewardedblocks) { + if (!($shares = getCache("user_unconfirmed_shares_".$userid))) { + $sql = "SELECT IFNULL(sum(shares),0) FROM unconfirmed_rewards WHERE userId = $userid AND rewarded='N'"; + $result = mysql_query($sql); + if ($row = mysql_fetch_row($result)) { + $shares = $row[0]; + } + setCache("user_unconfirmed_shares_".$userid, $shares, 600); + } + } + return $shares; + } + + function usersharecount($userId) { + global $read_only_db; + $totalUserShares = 0; + $workers = Array(); + $lastwinningshare = $this->lastWinningShareId(); + if (!($totalUserShares = getCache("user_shares_".$userId))) { + $workers = $this->workers($userId); + $sql = "SELECT sum(s.id) FROM (SELECT 'a' as username, 0 as id "; + foreach ($workers as $worker) { + if ($this->previousRoundSharesInShares()) + $sql .= "UNION SELECT username, count(id) as id FROM shares WHERE username = '$worker' AND id > $lastwinningshare "; else - $sql .= "UNION SELECT username, count(id) as id FROM shares WHERE username = '$worker' "; - } - $sql .= ") s"; - $currentSharesQ = $read_only_db->query($sql); - if ($currentSharesR = $currentSharesQ->fetch()) { - $totalUserShares = $currentSharesR[0]; - setCache("user_shares_".$userId, $totalUserShares,3); - } - } - return $totalUserShares; - } - - function userssharecount($limit) { - global $read_only_db; - $uwa = Array(); - if (!($uwa = getCache("users_sharecount"))) { - $sql = "SELECT username, share_count-stale_share_count+shares_this_round AS shares FROM webUsers ORDER BY shares DESC LIMIT ".$limit; - $result = $read_only_db->query($sql); - while ($row = $result->fetch()) { - $uwa[$row[0]] = $row[1]; - } - setCache("users_sharecount", $uwa, 1800); - } - return $uwa; - } - - function userstalecount($userId) { - global $read_only_db; - $totalUserShares = 0; - $workers = Array(); - $lastwinningshare = $this->lastWinningShareId(); - if (!($totalUserShares = getCache("user_stales_".$userId))) { - $workers = $this->workers($userId); - $sql = "SELECT sum(s.id) FROM (SELECT 'a' as username, 0 as id "; - foreach ($workers as $worker) { - if ($this->previousRoundSharesInShares()) - $sql .= "UNION SELECT username, count(id) as id FROM shares WHERE username = '$worker' AND id > $lastwinningshare AND our_result='N' "; + $sql .= "UNION SELECT username, count(id) as id FROM shares WHERE username = '$worker' "; + } + $sql .= ") s"; + $currentSharesQ = $read_only_db->query($sql); + if ($currentSharesR = $currentSharesQ->fetch()) { + $totalUserShares = $currentSharesR[0]; + setCache("user_shares_".$userId, $totalUserShares,3); + } + } + return $totalUserShares; + } + + function userssharecount($limit) { + global $read_only_db; + $uwa = Array(); + if (!($uwa = getCache("users_sharecount"))) { + $sql = "SELECT username, share_count-stale_share_count+shares_this_round AS shares FROM webUsers ORDER BY shares DESC LIMIT ".$limit; + $result = $read_only_db->query($sql); + while ($row = $result->fetch()) { + $uwa[$row[0]] = $row[1]; + } + setCache("users_sharecount", $uwa, 1800); + } + return $uwa; + } + + function userstalecount($userId) { + global $read_only_db; + $totalUserShares = 0; + $workers = Array(); + $lastwinningshare = $this->lastWinningShareId(); + if (!($totalUserShares = getCache("user_stales_".$userId))) { + $workers = $this->workers($userId); + $sql = "SELECT sum(s.id) FROM (SELECT 'a' as username, 0 as id "; + foreach ($workers as $worker) { + if ($this->previousRoundSharesInShares()) + $sql .= "UNION SELECT username, count(id) as id FROM shares WHERE username = '$worker' AND id > $lastwinningshare AND our_result='N' "; else - $sql .= "UNION SELECT username, count(id) as id FROM shares WHERE username = '$worker' AND our_result='N' "; - } - $sql .= ") s"; - $currentSharesQ = $read_only_db->query($sql); - if ($currentSharesR = $currentSharesQ->fetch()) { - $totalUserShares = $currentSharesR[0]; - setCache("user_stales_".$userId, $totalUserShares,1800); - } - } - return $totalUserShares; - } - - function userrankshares($userid) { - global $read_only_db; - $rank_shares = Array(); - if (!($rank_shares = getCache("user_rank_shares_".$userid))) { - $query_init = "SET @rownum := 0"; - $query_getrank = "SELECT rank, shares FROM ( - SELECT @rownum := @rownum + 1 AS rank, share_count-stale_share_count+shares_this_round AS shares, id - FROM webUsers ORDER BY shares DESC - ) as result WHERE id=" . $userid; - - $read_only_db->query($query_init); - $result = $read_only_db->query($query_getrank); - if ($row = $result->fetch()) { - $rank_shares[0] = $row[0]; - $rank_shares[1] = $row[1]; - } - } - return $rank_shares; - } - - function userrankhash($userid) { - global $read_only_db; - $rank = 1; - $uha = $this->userhashratesbyid(); - if (!($rank = getCache("user_rank_hash_".$userid))) { - foreach ($uha as $key => $value) { - if ($key == $userid) - break; - else - $rank += 1; - } - setCache("user_rank_hash_".$userid, $rank, 1800); - } - return $rank; - } - - function workers($userId) { - global $read_only_db; - $workers = Array(); - if (!($workers = getCache("user_workers_".$userId))) { - $sql = "SELECT username FROM pool_worker WHERE associatedUserId = ".$userId; - $workersQ = $read_only_db->query($sql); - while ($workersR = $workersQ->fetch()) { - $workers[] = $workersR[0]; - } - if (count($workers) > 0) - setCache("user_workers_".$userId, $workers, 300); - } - return $workers; - } - - function mtgoxlast () { - $last = "n/a"; - if (!($last = getCache("mtgox_last"))) { - include('includes/mtgox.php'); - try { - $mtgox = new mtgox("", ""); - $ticker = $mtgox->ticker(); - if (intval($ticker['last']) > 0) - $last = round(floatval($ticker['last']),2); - } catch (Exception $e) { } - setCache("mtgox_last", $last, 1800); - } - return $last; - } - - function get_server_load($windows = 0) { - $serverload = "n/a"; - if (!($serverload = getCache("pool_load"))) { - $numberOfCores = 8; - $avgLoad = 0; - $os = strtolower(PHP_OS); - if(strpos($os, "win") === false) { - if(file_exists("http://pool.simplecoin.us/loadavg.html")) { - $load = file_get_contents("http://pool.simplecoin.us/loadavg.html"); - $load = explode(' ', $load); - $avgLoad = $load[0]; - } elseif (function_exists("shell_exec")) { - $load = explode(' ', `uptime`); - $avgLoad = $load[count($load)-1]; - } - //This may need to be adjusted depending on your system. This is assuming a dual core setup. - if ($avgLoad > 1.9*$numberOfCores) { - $serverload = "critical"; - } else if ($avgLoad > 1.5*$numberOfCores) { - $serverload = "high"; - } else if ($avgLoad > .5*$numberOfCores) { - $serverload = "mid"; - } else if ($avgLoad > 0*$numberOfCores) { - $serverload = "low"; - } - } elseif ($windows) { - if(class_exists("COM")) { - $wmi = new COM("WinMgmts:\\\\."); - $cpus = $wmi->InstancesOf("Win32_Processor"); - - $cpuload = 0; - $i = 0; - while ($cpu = $cpus->Next()) { - $cpuload += $cpu->LoadPercentage; - $i++; - } - - $cpuload = round($cpuload / $i, 2); - $avgLoad = $cpuload; - } - if ($avgLoad > 90) { - $serverload = "critical"; - } else if ($avgLoad > 66) { - $serverload = "high"; - } else if ($avgLoad > 33) { - $serverload = "mid"; - } else if ($avgLoad > 0) { - $serverload = "low"; - } - } - if ($serverload != "n/a"); - setCache("pool_load", $serverload, 60); - } - return $serverload; - } -} - + $sql .= "UNION SELECT username, count(id) as id FROM shares WHERE username = '$worker' AND our_result='N' "; + } + $sql .= ") s"; + $currentSharesQ = $read_only_db->query($sql); + if ($currentSharesR = $currentSharesQ->fetch()) { + $totalUserShares = $currentSharesR[0]; + setCache("user_stales_".$userId, $totalUserShares,1800); + } + } + return $totalUserShares; + } + + function userrankshares($userid) { + global $read_only_db; + $rank_shares = Array(); + if (!($rank_shares = getCache("user_rank_shares_".$userid))) { + $query_init = "SET @rownum := 0"; + $query_getrank = "SELECT rank, shares FROM ( + SELECT @rownum := @rownum + 1 AS rank, share_count-stale_share_count+shares_this_round AS shares, id + FROM webUsers ORDER BY shares DESC + ) as result WHERE id=" . $userid; + + $read_only_db->query($query_init); + $result = $read_only_db->query($query_getrank); + if ($row = $result->fetch()) { + $rank_shares[0] = $row[0]; + $rank_shares[1] = $row[1]; + } + } + return $rank_shares; + } + + function userrankhash($userid) { + global $read_only_db; + $rank = 1; + $uha = $this->userhashratesbyid(); + if (!($rank = getCache("user_rank_hash_".$userid))) { + foreach ($uha as $key => $value) { + if ($key == $userid) + break; + else + $rank += 1; + } + setCache("user_rank_hash_".$userid, $rank, 1800); + } + return $rank; + } + + function workers($userId) { + global $read_only_db; + $workers = Array(); + if (!($workers = getCache("user_workers_".$userId))) { + $sql = "SELECT username FROM pool_worker WHERE associatedUserId = ".$userId; + $workersQ = $read_only_db->query($sql); + while ($workersR = $workersQ->fetch()) { + $workers[] = $workersR[0]; + } + if (count($workers) > 0) + setCache("user_workers_".$userId, $workers, 300); + } + return $workers; + } + + function mtgoxlast () { + $last = "n/a"; + if (!($last = getCache("mtgox_last"))) { + include('includes/mtgox.php'); + try { + $mtgox = new mtgox("", ""); + $ticker = $mtgox->ticker(); + if (intval($ticker['last']) > 0) + $last = round(floatval($ticker['last']),2); + } catch (Exception $e) { } + setCache("mtgox_last", $last, 1800); + } + return $last; + } + + function get_server_load($windows = 0) { + $serverload = "n/a"; + if (!($serverload = getCache("pool_load"))) { + $numberOfCores = 8; + $avgLoad = 0; + $os = strtolower(PHP_OS); + if(strpos($os, "win") === false) { + if(file_exists("http://pool.simplecoin.us/loadavg.html")) { + $load = file_get_contents("http://pool.simplecoin.us/loadavg.html"); + $load = explode(' ', $load); + $avgLoad = $load[0]; + } elseif (function_exists("shell_exec")) { + $load = explode(' ', `uptime`); + $avgLoad = $load[count($load)-1]; + } + //This may need to be adjusted depending on your system. This is assuming a dual core setup. + if ($avgLoad > 1.9*$numberOfCores) { + $serverload = "critical"; + } else if ($avgLoad > 1.5*$numberOfCores) { + $serverload = "high"; + } else if ($avgLoad > .5*$numberOfCores) { + $serverload = "mid"; + } else if ($avgLoad > 0*$numberOfCores) { + $serverload = "low"; + } + } elseif ($windows) { + if(class_exists("COM")) { + $wmi = new COM("WinMgmts:\\\\."); + $cpus = $wmi->InstancesOf("Win32_Processor"); + + $cpuload = 0; + $i = 0; + while ($cpu = $cpus->Next()) { + $cpuload += $cpu->LoadPercentage; + $i++; + } + + $cpuload = round($cpuload / $i, 2); + $avgLoad = $cpuload; + } + if ($avgLoad > 90) { + $serverload = "critical"; + } else if ($avgLoad > 66) { + $serverload = "high"; + } else if ($avgLoad > 33) { + $serverload = "mid"; + } else if ($avgLoad > 0) { + $serverload = "low"; + } + } + if ($serverload != "n/a"); + setCache("pool_load", $serverload, 60); + } + return $serverload; + } +} + ?> diff --git a/logout.php b/logout.php index 9155747..ffa49c4 100644 --- a/logout.php +++ b/logout.php @@ -1,36 +1,36 @@ - -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// 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 . - -// BTC Donations: 163Pv9cUDJTNUbadV4HMRQSSj3ipwLURRc - -//Include site functions -include("includes/requiredFunctions.php"); - + +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// 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 . + +// BTC Donations: 163Pv9cUDJTNUbadV4HMRQSSj3ipwLURRc + +//Include site functions +include("includes/requiredFunctions.php"); + setcookie($cookieName, 0, $timeoutStamp, $cookiePath, $cookieDomain); -?> - - - <?php echo antiXss(outputPageTitle());?> - - - - -
-

You have been logged out
- Click here if you continue to see this message

-
- +?> + + + <?php echo antiXss(outputPageTitle());?> + + + + +
+

You have been logged out
+ Click here if you continue to see this message

+
+ \ No newline at end of file From 68f2fc0ee1950c25f2bd120556632e656c906b66 Mon Sep 17 00:00:00 2001 From: William waisse Date: Sun, 4 Mar 2012 23:53:30 +0100 Subject: [PATCH 03/17] oups missing functions --- includes/requiredFunctions.php | 102 +++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) diff --git a/includes/requiredFunctions.php b/includes/requiredFunctions.php index aca882f..efd0ddc 100644 --- a/includes/requiredFunctions.php +++ b/includes/requiredFunctions.php @@ -132,4 +132,106 @@ function antiXss($input) { //strip HTML tags from input data return htmlentities(strip_tags($input), ENT_QUOTES); } + +function sqlerr($file = '', $line = '') +{ + print("" . + "

SQL Error

\n" . + "" . mysql_error() . ($file != '' && $line != '' ? "

in $file, line $line

" : "") . "
"); + die; +} + +$_current_lock = null; + +function islocked($name) { + $result = mysql_query("SELECT locked FROM locks WHERE name ='$name' and locked=1 LIMIT 1"); + if (!$result || mysql_numrows($result) == 0) + return false; + return true; +} + +function unlock() { + global $_current_lock; + mysql_query("UNLOCK TABLES"); + $sql = "UPDATE locks SET locked = 0 WHERE name = '" . mysql_real_escape_string($_current_lock) . "'"; + mysql_query($sql); +} + +function lock($name) { + global $_current_lock; + mysql_query("LOCK TABLES locks WRITE"); + $q = mysql_query("SELECT locked FROM locks WHERE name = '" . mysql_real_escape_string($name) . "'"); + + $lock = mysql_fetch_object($q); + if ($lock === false) { + mysql_query("INSERT INTO locks (name, locked) VALUES ('".mysql_real_escape_string($name)."', 1)"); + } elseif ($lock->locked) { + echo("Lock already held, exiting. (".$name.")"); + mysql_query("UNLOCK TABLES"); + exit(); + return; + } else { + mysql_query("UPDATE locks SET locked = 1 WHERE name = '" . mysql_real_escape_string($name) . "'"); + } + + //mysql_query("UNLOCK TABLES"); + $_current_lock = $name; + register_shutdown_function('unlock'); +} + +function ScriptIsRunLocally() { + if (isset($_SERVER['REMOTE_ADDR']) && $_SERVER['REMOTE_ADDR'] != "127.0.0.1") { + echo "This script can only be run locally."; + exit; + } +} + +//Cache functions + +# Gets key / value pair into memcache ... called by mysql_query_cache() +function getCache($key) { + global $memcache; + return ($memcache) ? $memcache->get($key) : false; +} + +# Puts key / value pair into memcache ... called by mysql_query_cache() +function setCache($key, $object, $timeout = 600) { + global $memcache; + return ($memcache) ? $memcache->set($key, $object, $timeout) : false; +} + +function removeCache($key) { + global $memcache; + $memcache->delete($key); +} + +function removeSqlCache($key) { + global $memcache; + $memcache->delete(md5("mysql_query".$key)); +} + +# Caching version of mysql_query() +function mysql_query_cache($sql, $timeout = 600) { + if($objResultset = unserialize(getCache(md5("mysql_query".$sql)))) { + return $objResultset; + } + $objResultSet = mysql_query($sql); + $objarray = Array(); + while ($row = mysql_fetch_object($objResultSet)) { + $objarray[] = $row; + } + setCache(md5("mysql_query".$sql), serialize($objarray), $timeout); + return $objarray; +} + +function GetCachedBitcoinDifficulty() { + global $bitcoinController; + $difficulty = 0; + if (!($difficulty = getCache("bitcoinDifficulty"))) { + $difficulty = $bitcoinController->query("getdifficulty"); + setCache("bitcoinDifficulty", $difficulty, 60); + } + return $difficulty; +} + ?> From d1c85782610cc5d07537df1076488299d55a7047 Mon Sep 17 00:00:00 2001 From: William waisse Date: Mon, 5 Mar 2012 01:02:59 +0100 Subject: [PATCH 04/17] fixing php warnings on empty set ans short open tags --- accountdetails.php | 4 ++-- adminPanel.php | 4 ++-- gettingstarted.php | 1 + includes/header.php | 2 +- includes/requiredFunctions.php | 16 +++++++++++++++- includes/stats.php | 11 +++++++++++ includes/universalChecklogin.php | 6 ++++-- stats.php | 6 +++++- users.php | 8 +++++--- 9 files changed, 46 insertions(+), 12 deletions(-) diff --git a/accountdetails.php b/accountdetails.php index c3dd1a0..b7323e7 100644 --- a/accountdetails.php +++ b/accountdetails.php @@ -288,8 +288,8 @@ while($worker = mysql_fetch_array($getWorkers)){ ?>
-"> -"> +Info
- 0")or sqlerr(__FILE__, __LINE__); $sitewalletq = mysql_fetch_row($sitewallet); @@ -115,4 +115,4 @@ Show USers
- \ No newline at end of file + diff --git a/gettingstarted.php b/gettingstarted.php index 16a558e..e6ed414 100644 --- a/gettingstarted.php +++ b/gettingstarted.php @@ -17,6 +17,7 @@ // BTC Donations: 163Pv9cUDJTNUbadV4HMRQSSj3ipwLURRc $pageTitle = "- Getting Started"; +include ("includes/config.php"); include ("includes/header.php"); ?> diff --git a/includes/header.php b/includes/header.php index ee55860..4ce5484 100644 --- a/includes/header.php +++ b/includes/header.php @@ -95,7 +95,7 @@ username; ?> (logout) Hashrate: userhashrate($userInfo->username); ?> MH/s Workers: workers($userInfo->id)); ?> - Round Shares: (userstalecount($userId) / $totalUserShares * 100),1); ?>% stale) + Round Shares: (0 ) echo round(($stats->userstalecount($userId) / $totalUserShares * 100),1); ?>% stale) Estimate: BTC Balance: BTC diff --git a/includes/requiredFunctions.php b/includes/requiredFunctions.php index efd0ddc..49c1ea2 100644 --- a/includes/requiredFunctions.php +++ b/includes/requiredFunctions.php @@ -30,11 +30,24 @@ connectToDb(); include('settings.php'); +//New PDO connection for readaccess (fallback to local if unavailable) +try { +$read_only_db = new PDO('mysql:dbname='.$readOnlyDbName.';host='.$readOnlyDbHost.';port='.$readOnlyDbPort, $readOnlyDbUsername, $readOnlyDbPassword); +} catch (Exception $e) { +$read_only_db = new PDO('mysql:dbname='.$dbDatabasename.';host='.$dbHost.';port='.$dbPort, $dbUsername, $dbPassword); +} + $settings = new Settings(); /////////////////////////////////////////////////////////////////////NO NEED TO MESS WITH THE FOLLOWING | FOR DEVELOPERS ONLY/////////////////////////////////////////////////////////////////// -$timeoutStamp=1; +//Open a bitcoind connection +$bitcoinController = new BitcoinClient($rpcType, $rpcUsername, $rpcPassword, $rpcHost, $rpcPort); + +//setup bitcoinDifficulty cache object +$bitcoinDifficulty = GetCachedBitcoinDifficulty(); + +//$timeoutStamp=1; function connectToDb(){ //Set variables to global retireve outside of the scope @@ -217,6 +230,7 @@ function mysql_query_cache($sql, $timeout = 600) { } $objResultSet = mysql_query($sql); $objarray = Array(); + if ( $objResultSet ) while ($row = mysql_fetch_object($objResultSet)) { $objarray[] = $row; } diff --git a/includes/stats.php b/includes/stats.php index 402e645..434a56f 100644 --- a/includes/stats.php +++ b/includes/stats.php @@ -1,5 +1,7 @@ query($sql); + if ( $result ) if ($row = $result->fetch()) $retval = "old"; setCache("previousRoundSharesInShares", $retval, 300); @@ -70,6 +73,7 @@ function currentstales() { function currenthashrate() { global $read_only_db; + global $apidir; $currenthashrate = 0; if (!($currenthashrate = getCache("pool_hashrate"))) { $sql = "SELECT count(*) as id FROM shares WHERE time > DATE_SUB(now(), INTERVAL 10 MINUTE) "; @@ -96,6 +100,7 @@ function poolefficiency() { global $read_only_db; $efficiency = 0.0; if (!($efficiency = getCache("pool_efficiency"))) { + if ( $this->currentshares() >0 ) $efficiency = (1 - ($this->currentstales()/$this->currentshares())) * 100; if ($efficiency > 0) setCache("pool_efficiency", $efficiency, 600); @@ -107,6 +112,7 @@ function currentworkers() { $currentworkers = 0; if (!($currentworkers = getCache("pool_workers"))) { $uwa = $this->workerhashrates(); + if ( $uwa ) foreach ($uwa as $key => $value) { if ($value > 0) $currentworkers += 1; @@ -134,6 +140,7 @@ function lastWinningShareId() { $shareid = 0; if (!($shareid = getCache("last_winning_share_id"))) { $result = $read_only_db->query("SELECT max(share_id) FROM winning_shares"); + if ( $result ) if ($row = $result->fetch()) { $shareid = $row[0]; } @@ -163,6 +170,7 @@ function lastwinningblocks($limit) { $uwa = Array(); if (!($uwa = getCache("last_winning_blocks"))) { $result = $read_only_db->query("SELECT w.username, w.blockNumber, w.confirms, n.timestamp FROM winning_shares w, networkBlocks n WHERE w.blockNumber = n.blockNumber ORDER BY w.blockNumber DESC LIMIT ".$limit); + if ( $result ) while ($row = $result->fetch()) { $uwa[$i] = Array(); $uwa[$i][0] = $row[0]; @@ -209,6 +217,7 @@ function workerhashrates() { function workerhashrate($workername) { $workerhashrate = 0; $uwa = $this->workerhashrates(); + if ( $uwa ) if (array_key_exists($workername, $uwa)) { $workerhashrate = $uwa[$workername]; } @@ -253,6 +262,7 @@ function username_userid_array() { function userhashratesbyid() { $uhr = Array(); $uwa = $this->userhashrates(); + if ( $uwa ) foreach ($this->username_userid_array() as $username => $userid) { if (array_key_exists($username, $uwa)) $uhr[$userid] = $uwa[$username]; @@ -265,6 +275,7 @@ function userhashratesbyid() { function userhashrate($username) { $userhashrate = 0; $uwa = $this->userhashrates(); + if ( $uwa ) if (array_key_exists($username, $uwa)) { $userhashrate = $uwa[$username]; } diff --git a/includes/universalChecklogin.php b/includes/universalChecklogin.php index f7d9dff..56d3b11 100644 --- a/includes/universalChecklogin.php +++ b/includes/universalChecklogin.php @@ -36,7 +36,9 @@ } //Get user information - $userInfoQ = mysql_query("SELECT id, username, email, pin, pass, admin, api_key, IFNULL(donate_percent, '0') as donate_percent, btc_lock FROM webUsers WHERE id = $userId LIMIT 0,1"); + $query="SELECT id, username, email, pin, pass, admin, api_key, IFNULL(donate_percent, '0') as donate_percent, btc_lock FROM webUsers WHERE id = $userId LIMIT 0,1"; + //echo $query; + $userInfoQ = mysql_query($query); if ($userInfo = mysql_fetch_object($userInfoQ)) { $authPin = $userInfo->pin; $hashedPass = $userInfo->pass; @@ -83,4 +85,4 @@ } } -?> \ No newline at end of file +?> diff --git a/stats.php b/stats.php index 588a6df..397f80a 100644 --- a/stats.php +++ b/stats.php @@ -24,6 +24,7 @@ // May the force be with you. $pageTitle = "- Stats"; +include ("includes/config.php"); include ("includes/header.php"); @@ -72,6 +73,7 @@ function CoinsPerDay ($time_per_block, $btc_block) { $rank = 1; $user_found = false; +if ( $result ) foreach ($result as $username => $user_hash_rate) { //$username = $resultrow->username; if ($cookieValid && $username == $userInfo->username) { @@ -209,6 +211,7 @@ function CoinsPerDay ($time_per_block, $btc_block) { $res = $stats->userhashrates(); $hashcount = 0; +if ( $res ) foreach ($res as $hash) if ($hash > 0) $hashcount++; @@ -274,6 +277,7 @@ function CoinsPerDay ($time_per_block, $btc_block) { echo "Last $last_no_blocks_found Blocks Found - All Blocks Found"; echo "BlockConfirmsFinderTime"; +if ( $lastblocks ) foreach ($lastblocks as $resultrow) { echo ""; $splitUsername = explode(".", $resultrow[0]); @@ -342,4 +346,4 @@ function CoinsPerDay ($time_per_block, $btc_block) { include("includes/footer.php"); -?> \ No newline at end of file +?> diff --git a/users.php b/users.php index 3b373d7..813d5cf 100644 --- a/users.php +++ b/users.php @@ -10,8 +10,10 @@ header('Location: /'); exit; } - $show = $_GET['show']; - $searchUsername = $_POST['searchUsername']; + if ( isset( $_GET['show'] ) ) { $show = $_GET['show']; } + else $show =""; + if ( isset( $_POST['searchUsername'] ) ) $searchUsername = $_POST['searchUsername']; + else $searchUsername=""; if($show == ""){ ?> @@ -79,7 +81,7 @@
From 8111f95f3fa8a17d6d0ec0a8940323bb2936ff83 Mon Sep 17 00:00:00 2001 From: William waisse Date: Mon, 5 Mar 2012 01:33:34 +0100 Subject: [PATCH 05/17] more warning fix for empty sets +backupwallet config file --- api.php | 2 +- cronjobs/archive.php | 2 +- cronjobs/backupwallet.php | 2 +- cronjobs/cronjob.php | 6 +++--- cronjobs/hashrate.php | 2 +- includes/block.php | 15 ++++++++++++--- includes/config.php.example | 1 + 7 files changed, 20 insertions(+), 10 deletions(-) diff --git a/api.php b/api.php index c635f0d..69702f7 100644 --- a/api.php +++ b/api.php @@ -20,7 +20,7 @@ exit; include(dirname(__FILE__) . "/include/requiredFunctions.php"); -include($includeDirectory."stats.php"); +include($includedir."stats.php"); $stats = new Stats(); class User { diff --git a/cronjobs/archive.php b/cronjobs/archive.php index 70255f5..ee518c8 100644 --- a/cronjobs/archive.php +++ b/cronjobs/archive.php @@ -25,7 +25,7 @@ ScriptIsRunLocally(); //Include Block class -include($includeDirectory."block.php"); +include($includedir."block.php"); $block = new Block(); $siterewardtype = $settings->getsetting("siterewardtype"); diff --git a/cronjobs/backupwallet.php b/cronjobs/backupwallet.php index 63af268..be049b1 100644 --- a/cronjobs/backupwallet.php +++ b/cronjobs/backupwallet.php @@ -5,5 +5,5 @@ //Check that script is run locally ScriptIsRunLocally(); -$bitcoinController->backupwallet("/home/simplecoin/walletbackup/wallet.dat.".date("Ymd")); +$bitcoinController->backupwallet($backupwalletfilename . ".".date("Ymd")); ?> diff --git a/cronjobs/cronjob.php b/cronjobs/cronjob.php index af02d2c..d43a356 100644 --- a/cronjobs/cronjob.php +++ b/cronjobs/cronjob.php @@ -21,7 +21,7 @@ include(dirname(__FILE__) . "/../includes/requiredFunctions.php"); //Include Reward class -include($includeDirectory.'reward.php'); +include($includedir.'reward.php'); $reward = new Reward(); //Check that script is run locally @@ -30,7 +30,7 @@ lock("shares"); //Include Block class - include($includeDirectory."block.php"); + include($includedir."block.php"); $block = new Block(); //Get current block number @@ -43,7 +43,7 @@ //Do block work if new block if ($latestDbBlock < $lastBlockNumber) { //Insert last block number into networkBlocks - include($includeDirectory."stats.php"); + include($includedir."stats.php"); $stats = new Stats(); $lastwinningid = $stats->lastWinningShareId(); $block->InsertNetworkBlocks($lastBlockNumber, $lastwinningid); diff --git a/cronjobs/hashrate.php b/cronjobs/hashrate.php index 2932c7c..76d7c1e 100644 --- a/cronjobs/hashrate.php +++ b/cronjobs/hashrate.php @@ -17,7 +17,7 @@ // BTC Donations: 163Pv9cUDJTNUbadV4HMRQSSj3ipwLURRc include(dirname(__FILE__) . "/../includes/requiredFunctions.php"); -include($includeDirectory."stats.php"); +include($includedir."stats.php"); $stats = new Stats(); //Check that script is run locally diff --git a/includes/block.php b/includes/block.php index 2814f31..ed5adfd 100644 --- a/includes/block.php +++ b/includes/block.php @@ -3,6 +3,7 @@ class Block { function getLatestDbBlockNumber() { $result = mysql_query("SELECT blockNumber FROM networkBlocks ORDER BY blockNumber DESC LIMIT 1"); + if ($result ) if ($row = mysql_fetch_row($result)) { if (count($row) > 0) return $row[0]; @@ -13,7 +14,9 @@ function getLatestDbBlockNumber() { 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(); @@ -21,6 +24,7 @@ function InsertNetworkBlocks($lastBlockNumber,$lastwinningid) { //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"); @@ -30,6 +34,7 @@ function InsertNetworkBlocks($lastBlockNumber,$lastwinningid) { function UpdateConfirms($bitcoinController) { $winningAccountQ = mysql_query("SELECT id, txid FROM winning_shares WHERE txid <> '' AND confirms < 120"); + if ( $winningAccountQ ) while ($winningAccountR = mysql_fetch_object($winningAccountQ)) { $txInfo = $bitcoinController->query("gettransaction", $winningAccountR->txid); if (count($txInfo["confirmations"]) > 0) { @@ -100,9 +105,13 @@ function NeedsArchiving($siterewardtype, $difficulty) { } } else { $result = mysql_query("SELECT count(s.id) FROM shares s, (SELECT max(share_id) as share_id FROM winning_shares WHERE rewarded='Y') w WHERE s.id < w.share_id"); - $row = mysql_fetch_row($result); - if ($row[0] > 0) + if ( $result ) + { + $row = mysql_fetch_row($result); + if ($row[0] > 0) return true; + } + else return false; } return false; } @@ -175,4 +184,4 @@ function Archive($siterewardtype, $difficulty) { } } } -?> \ No newline at end of file +?> diff --git a/includes/config.php.example b/includes/config.php.example index 118f0aa..df8a5b0 100644 --- a/includes/config.php.example +++ b/includes/config.php.example @@ -54,6 +54,7 @@ $bonusCoins = 1; $poolname="simplecoin.us"; $poolport="8337"; $includedir="/var/www/includes/"; +$backupwalletfilename="/home/simplecoin/walletbackup/wallet.dat"; //Encrypt settings $salt = "8fdsfdsfd76s54d777"; //Just type a random series of numbers and letters; set it to anything or any length you want. "You can never have enough salt." From 8b42f0f129f65320831eff6530ff39a4b7c5a247 Mon Sep 17 00:00:00 2001 From: William waisse Date: Mon, 5 Mar 2012 04:49:47 +0100 Subject: [PATCH 06/17] fixing completely broken news page and a warning in login page --- includes/requiredFunctions.php | 4 ++++ login.php | 6 ++++-- news.php | 12 +++++++++--- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/includes/requiredFunctions.php b/includes/requiredFunctions.php index 49c1ea2..01689c7 100644 --- a/includes/requiredFunctions.php +++ b/includes/requiredFunctions.php @@ -128,6 +128,10 @@ function outputHeaderTitle(){ return $settings->getsetting("websitename"); } +function sqlesc($x) { + return "'".mysql_escape_string($x)."'"; + } + //Helpfull functions function genRandomString($length=10) { $characters = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; diff --git a/login.php b/login.php index 28314a7..7280f0c 100644 --- a/login.php +++ b/login.php @@ -32,15 +32,16 @@ //Check the supplied username & password with the saved username & password $checkPassQ = mysql_query("SELECT id, secret, pass, accountLocked, accountFailedAttempts FROM webUsers WHERE username = '".$user."' LIMIT 0,1"); $checkPass = mysql_fetch_object($checkPassQ); -$userExists = $checkPass->id; +if ( $checkPass ) $userExists = $checkPass->id; -if($checkPass->accountFailedAttempts >= 5){ +if ( $checkPass ) if($checkPass->accountFailedAttempts >= 5){ echo "Account has been banned"; die(); } //Check if user exists before checking login data +if ( isset( $userExists ) ) if($userExists > 0){ //Check to see if this user has an `accountLocked` if($checkPass->accountLocked < time()){ @@ -76,6 +77,7 @@ }else{ $outputMessage = "User name dosent exist!"; } +if ( !isset( $outputMessage ) ) $outputMessage = "User name dosent exist!"; ?> diff --git a/news.php b/news.php index fe6ec6e..46f35fd 100644 --- a/news.php +++ b/news.php @@ -1,8 +1,11 @@ " . htmlspecialchars($row["message"]) . ""; echo "
"; echo ""; -?> \ No newline at end of file +?> From 852c099ae2eb6b6cff74ec95a35d94931f0cc075 Mon Sep 17 00:00:00 2001 From: William waisse Date: Mon, 5 Mar 2012 05:06:11 +0100 Subject: [PATCH 07/17] better with mysql_real_escape_string --- includes/requiredFunctions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/requiredFunctions.php b/includes/requiredFunctions.php index 01689c7..40dc760 100644 --- a/includes/requiredFunctions.php +++ b/includes/requiredFunctions.php @@ -129,7 +129,7 @@ function outputHeaderTitle(){ } function sqlesc($x) { - return "'".mysql_escape_string($x)."'"; + return "'".mysql_real_escape_string($x)."'"; } //Helpfull functions From babf576a13da7d141e7c41c3f5a5bcc5d1348192 Mon Sep 17 00:00:00 2001 From: William waisse Date: Tue, 6 Mar 2012 00:40:59 +0100 Subject: [PATCH 08/17] no autocomple on pin and password fields + typo in sql --- accountdetails.php | 12 ++++++------ sql/simplecoin-v5.sql | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/accountdetails.php b/accountdetails.php index b7323e7..8b23dde 100644 --- a/accountdetails.php +++ b/accountdetails.php @@ -248,7 +248,7 @@ Permanently lock Bitcoin address to this account Donation %: Automatic Payout:
(1-25 BTC, 0 for manual) - Authorize Pin: + Authorize Pin:
@@ -260,7 +260,7 @@ - +
Account Balance:
Payout to:
Authorize Pin:
Authorize Pin:

@@ -269,9 +269,9 @@ Change Password
- - - + + +
Current Password:
New Password:
New Password Repeat:
Current Password:
New Password:
New Password Repeat:
Authorize Pin:
(You will be redirected to the login screen upon success)
@@ -313,7 +313,7 @@ name="authPin" size="4" maxlength="4">
--> username);?>. ·

diff --git a/sql/simplecoin-v5.sql b/sql/simplecoin-v5.sql index 26402ee..070f79b 100644 --- a/sql/simplecoin-v5.sql +++ b/sql/simplecoin-v5.sql @@ -307,7 +307,7 @@ CREATE TABLE `webUsers` ( `admin` int(1) NOT NULL, `username` varchar(40) NOT NULL, `pass` varchar(255) NOT NULL, - `email` varchar(255) NOT NULL COMMENT 'Assocaited email: used for validating users, and re-setting passwords', + `email` varchar(255) NOT NULL COMMENT 'Associated email: used for validating users, and re-setting passwords', `emailAuthPin` varchar(10) NOT NULL COMMENT 'The pin required to authorize that email address', `secret` varchar(10) NOT NULL, `loggedIp` varchar(255) NOT NULL, From 435bad05c791b93f691acc5005e1e49a5f5d2151 Mon Sep 17 00:00:00 2001 From: William waisse Date: Tue, 6 Mar 2012 00:45:33 +0100 Subject: [PATCH 09/17] reporting small fixes from other forks --- includes/requiredFunctions.php | 2 +- users.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/includes/requiredFunctions.php b/includes/requiredFunctions.php index 40dc760..4635b0d 100644 --- a/includes/requiredFunctions.php +++ b/includes/requiredFunctions.php @@ -182,7 +182,7 @@ function lock($name) { $lock = mysql_fetch_object($q); if ($lock === false) { mysql_query("INSERT INTO locks (name, locked) VALUES ('".mysql_real_escape_string($name)."', 1)"); - } elseif ($lock->locked) { + } elseif ($lock->locked == 1 ) { echo("Lock already held, exiting. (".$name.")"); mysql_query("UNLOCK TABLES"); exit(); diff --git a/users.php b/users.php index 813d5cf..203651d 100644 --- a/users.php +++ b/users.php @@ -10,12 +10,12 @@ header('Location: /'); exit; } - if ( isset( $_GET['show'] ) ) { $show = $_GET['show']; } + $show = (isset($_GET['show']) ? $_GET['show'] : 'main'); else $show =""; if ( isset( $_POST['searchUsername'] ) ) $searchUsername = $_POST['searchUsername']; else $searchUsername=""; -if($show == ""){ +if($show == "main"){ ?>

Search for a user (% = Wildcard)

From 5ed18f5c1fb8b7bb8be429d6f52de56922ce8bd8 Mon Sep 17 00:00:00 2001 From: William waisse Date: Tue, 6 Mar 2012 04:04:52 +0100 Subject: [PATCH 10/17] edited README for warning --- README | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README b/README index 4d15448..d3b7881 100644 --- a/README +++ b/README @@ -1,3 +1,7 @@ +*warning* personal fork of simplecoin, work in progress, no guarantees it will work for you, just trying to fix php warnings for empty sets, short open tags . . . and make it more secure for my own use + +--- + Simplecoin Web Mining Framework Requirements: From ab3727062a5ac86f048c669fc61940586b9a2678 Mon Sep 17 00:00:00 2001 From: William waisse Date: Tue, 6 Mar 2012 22:26:04 +0100 Subject: [PATCH 11/17] small detail for div clear --- includes/footer.php | 2 +- my_stats.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/includes/footer.php b/includes/footer.php index 21cd6fb..ab527d5 100644 --- a/includes/footer.php +++ b/includes/footer.php @@ -1,5 +1,5 @@ -
+
diff --git a/my_stats.php b/my_stats.php index 13ffa69..3b320dc 100644 --- a/my_stats.php +++ b/my_stats.php @@ -123,8 +123,8 @@ //echo "
"; } -echo "
"; +echo "
"; include("includes/footer.php"); -?> \ No newline at end of file +?> From aefaee854d799b069628053cfea63afe88dfdd39 Mon Sep 17 00:00:00 2001 From: William waisse Date: Tue, 6 Mar 2012 23:17:42 +0100 Subject: [PATCH 12/17] config options for poolname, poolport, mailfrom . . . --- accountdetails.php | 2 +- chat.php | 2 +- gettingstarted.php | 10 +++++----- includes/config.php.example | 8 +++++++- includes/footer.php | 2 +- index.php | 2 +- lostpassword.php | 4 ++-- my_stats.php | 10 +++++----- stats.php | 4 ++-- 9 files changed, 25 insertions(+), 19 deletions(-) diff --git a/accountdetails.php b/accountdetails.php index 8b23dde..e24168d 100644 --- a/accountdetails.php +++ b/accountdetails.php @@ -87,7 +87,7 @@ mysql_query("UPDATE accountBalance SET balance = '0', paid = '$paid' WHERE userId = $userId"); if ($bitcoinController->sendtoaddress($paymentAddress, $currentBalance)) { $goodMessage = "You have successfully sent ".$currentBalance." to the following address:".$paymentAddress; - mail("$userEmail", "Simplecoin Manual Payout Notification", "Hello,\n\nYour requested manual payout of ". $currentBalance." BTC has been sent to your payment address ".$paymentAddress.".", "From: Simplecoin Notifications "); + mail("$userEmail", $poolname. "Manual Payout Notification", "Hello,\n\nYour requested manual payout of ". $currentBalance." BTC has been sent to your payment address : ".$paymentAddress.".", "From: ".$poolname. " Notifications <".$mailfrom.">"); //Set new variables so it appears on the page flawlessly $currentBalance = 0; mysql_query("COMMIT"); diff --git a/chat.php b/chat.php index 0ab50a2..c9fd185 100644 --- a/chat.php +++ b/chat.php @@ -2,4 +2,4 @@ $pageTitle = "- IRC Webchat"; include ("includes/header.php"); ?> - \ No newline at end of file + diff --git a/gettingstarted.php b/gettingstarted.php index e6ed414..4bfac3e 100644 --- a/gettingstarted.php +++ b/gettingstarted.php @@ -33,16 +33,16 @@ Advanced Windows & Linux (for best mining results)
Download cgminer HERE
Follow the directions for your operating system in the above link to install
- Run cgminer: cgminer -o http://pool.simplecoin.us:8337 -u username.1 -p x
- Run cgminer for max performance: cgminer -o http://pool.simplecoin.us:8337 -u username.1 -p x -I 8

+ Run cgminer: cgminer -o http://: -u username.1 -p x
+ Run cgminer for max performance: cgminer -o http://: -u username.1 -p x -I 8

Easy Windows
Download GUIMiner: HERE

GUIMiner options
Server: Other
- Host: pool.simplecoin.us
- Port: 8337
+ Host:
+ Port:
Username: <your user name>.<miner name (default is 1)>
Password: <your miner password (default is 'x')>
Device: Select the graphics card/cpu you would like to use
@@ -53,7 +53,7 @@ Decompress (tar zxvf hashkill-0.2.4-x86.tar.gz)
Change directory to hashkill
Run: sudo ./install.sh
- Run hashkill: hashkill-gpu -p bitcoin minername:password:pool.simplecoin.us:8337 + Run hashkill: hashkill-gpu -p bitcoin minername:password:: diff --git a/includes/config.php.example b/includes/config.php.example index df8a5b0..893ad26 100644 --- a/includes/config.php.example +++ b/includes/config.php.example @@ -51,8 +51,14 @@ $cookieDomain = "pool.domain.tld"; //Set this to your domain $bonusCoins = 1; //added config options -$poolname="simplecoin.us"; +$poolname="domain.tld"; $poolport="8337"; +$btcdonations="1B3e87Mq114UoYnWUtxRe4ua5oARYNSi4C"; +$mailfrom="yourmail@domain.tld"; +$chatroom="#channel"; +$ircserver="webchat.freenode.net"; + +#paths $includedir="/var/www/includes/"; $backupwalletfilename="/home/simplecoin/walletbackup/wallet.dat"; diff --git a/includes/footer.php b/includes/footer.php index ab527d5..e1e6fbe 100644 --- a/includes/footer.php +++ b/includes/footer.php @@ -1,7 +1,7 @@
diff --git a/index.php b/index.php index 0dabb59..2c1aaf1 100644 --- a/index.php +++ b/index.php @@ -23,7 +23,7 @@ If you are a new user, please create an account. Then click "Getting Started", and follow the instructions on that page.

-Simplecoin is run completely by opensource software. Even this website is opensource!

+ is run completely by opensource software. Even this website is opensource!

We currently have a fee of getsetting("sitepercent"))?>%, a transaction fee of getsetting("sitetxfee"))?> BTC per transaction and use diff --git a/lostpassword.php b/lostpassword.php index b772f22..a57c614 100644 --- a/lostpassword.php +++ b/lostpassword.php @@ -29,7 +29,7 @@ $result = mysql_query("SELECT email, emailAuthPin FROM webUsers WHERE username='$resetUsername'"); if ($row = mysql_fetch_row($result)) { $email = $row[0]; - mail("$email", "Simplecoin Password Reset Notification","Hello,\n\nTo complete your password reset, please click the following link or copy and paste it into your browser url location:\nhttps://simplecoin.us/lostpassword.php?username=".$resetUsername."&auth=".$row[1]."\n\nIf you have received this message in error or did not request a reset, please ignore this message and your account will remain unchanged.", "From: Simplecoin Notifications "); + mail("$email", $poolname." Password Reset Notification","Hello,\n\nTo complete your password reset, please click the following link or copy and paste it into your browser url location:\nhttps://".$poolname."/lostpassword.php?username=".$resetUsername."&auth=".$row[1]."\n\nIf you have received this message in error or did not request a reset, please ignore this message and your account will remain unchanged.", "From: ".$poolname." Notifications <".$mailfrom.">"); $goodMessage = "Your password reset information has been sent to ".$email; } else { $returnError = "We were unable to locate your records, please contact the site admin for further assistance."; @@ -102,4 +102,4 @@ - \ No newline at end of file + diff --git a/my_stats.php b/my_stats.php index 3b320dc..5d840fa 100644 --- a/my_stats.php +++ b/my_stats.php @@ -15,7 +15,7 @@ echo "
"; if( !$cookieValid ){ - echo "

Welcome to Simplecoin.us! Please login or join us to get detailed stats and graphs relating to your hashing!

"; + echo "

Welcome to ".$poolname."! Please login or join us to get detailed stats and graphs relating to your hashing!

"; } else { @@ -64,7 +64,7 @@ // http://www.filamentgroup.com/lab/update_to_jquery_visualize_accessible_charts_with_html5_from_designing_with/ // table is hidden, graph follows - echo ""; + echo "\n
"; echo ""; echo ""; @@ -87,7 +87,7 @@ echo ""; } - echo "
" . $userInfo->username . "'s Hashrate over the Last 24 Hours
".$resultrow->hashrate."
"; + echo "
\n"; //echo "
"; @@ -118,12 +118,12 @@ echo "" . $resultrow->hashrate . ""; } - echo ""; + echo "
\n"; //echo "
"; } -echo "
"; +echo "

\n"; include("includes/footer.php"); diff --git a/stats.php b/stats.php index 397f80a..0090444 100644 --- a/stats.php +++ b/stats.php @@ -58,7 +58,7 @@ function CoinsPerDay ($time_per_block, $btc_block) {

Welcome to Simplecoin.us! Please login or join us to get detailed stats and graphs relating to your hashing!

"; + echo "

Welcome to ".$poolname."! Please login or join us to get detailed stats and graphs relating to your hashing!

"; } ?>
@@ -328,7 +328,7 @@ function CoinsPerDay ($time_per_block, $btc_block) { echo "" . $resultrow->date . ""; } -echo "Simplecoin.us Pool"; +echo "".$poolname." Pool"; // re-iterate through results //mysql_data_seek($result, 0); From 408a04e7ec4bb7b454398f5369729187ba5abc4c Mon Sep 17 00:00:00 2001 From: William waisse Date: Tue, 6 Mar 2012 23:34:02 +0100 Subject: [PATCH 13/17] settings --- adminPanel.php | 5 +++-- includes/settings.php | 9 ++++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/adminPanel.php b/adminPanel.php index 34ea331..356b36d 100644 --- a/adminPanel.php +++ b/adminPanel.php @@ -18,6 +18,7 @@ $pageTitle = "- Admin Panel"; include ("includes/header.php"); +include ("includes/settings.php"); $goodMessage = ""; $returnError = ""; @@ -27,7 +28,7 @@ header('Location: /'); exit; } - +$settings= new Settings; if (isset($_POST["act"]) && isset($_POST["authPin"])) { if (isset($_POST["authPin"])) { @@ -35,7 +36,7 @@ } else { $inputAuthPin = NULL; } - + //Make sure an authPin is set and valid when $act is active if(isset($_POST["act"]) && $authPin == $inputAuthPin) { $act = $_POST["act"]; diff --git a/includes/settings.php b/includes/settings.php index d9eecda..a53202a 100644 --- a/includes/settings.php +++ b/includes/settings.php @@ -37,11 +37,14 @@ function getsetting($settingname){ if (isset($this->settingsarray[$settingname])) return $this->settingsarray[$settingname]; } - function setsetting($settingname, $value) { - mysql_query("UPDATE settings SET value='$value' WHERE setting ='$settingname'"); + function setsetting($settingname, $value) { + $query="UPDATE settings SET value='$value' WHERE setting ='$settingname'"; + //echo $query; + mysql_query($query); $this->settingsarray[$settingname] = $value; + var_dump($this->settingsarray); removeSqlCache("SELECT setting, value FROM settings"); } } -?> \ No newline at end of file +?> From 2f998c2f3595cb93a297b5fbd9488a20dcfac781 Mon Sep 17 00:00:00 2001 From: William waisse Date: Tue, 6 Mar 2012 23:36:32 +0100 Subject: [PATCH 14/17] settings debug --- includes/settings.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/settings.php b/includes/settings.php index a53202a..83c80a4 100644 --- a/includes/settings.php +++ b/includes/settings.php @@ -42,7 +42,7 @@ function setsetting($settingname, $value) { //echo $query; mysql_query($query); $this->settingsarray[$settingname] = $value; - var_dump($this->settingsarray); + //var_dump($this->settingsarray); removeSqlCache("SELECT setting, value FROM settings"); } } From 60b71410399721748db13e0da7730b086a358147 Mon Sep 17 00:00:00 2001 From: William waisse Date: Tue, 6 Mar 2012 23:51:00 +0100 Subject: [PATCH 15/17] config logo path and adding a generic pool image --- images/pool1.jpg | Bin 0 -> 17230 bytes includes/config.php.example | 1 + 2 files changed, 1 insertion(+) create mode 100755 images/pool1.jpg diff --git a/images/pool1.jpg b/images/pool1.jpg new file mode 100755 index 0000000000000000000000000000000000000000..302b0b18fcc60730bbb7c9700c5627bf9135560d GIT binary patch literal 17230 zcmb?>byQqW)8+t!CpZLmn;}4e;O@-egKKbtJHg$9yZbN^WP1+;gkD>UpYfcc0U@x*q2r*8l`i1&9IweP ztG-fom9>6rr{w2ut>vetZRzJ=DQv|iDS;#ABjV%a>SXO{PVeL7=uw(e6ry5@OAby z_u+K*V0uEpq5l_#oVACgyPd12os08-u&gZq3(D2Y-SJ;QR+ik>j@C}r&Ym7mL*w}; z0(yEeD@zeecWZM`7x#bEf8%LcyZuY~x8`Ukp(HOYN3Y@TV&!G|4~d5u_dlUOb^Oca zU&?=c#JK-=z<=wZ*BQ+?0|prQUF|2)y21c(9rN3bw3&@r&FaB#4( zu(5HT;XlK{#lywMeoput51)X5kO1cy5it<~@zXoOKOiXoc%lKZo*W5qv2mYT{~zVC z8$gH!@CJ;ap%4O42~p4pQ6BpMGynh!`ahcr@IM6u6%B}viGl^de(IJb0HC0u0)c24 zs87t8Pc|t3bQ1zFh!`-5d88RN&9O+_LQ_gedC8dgV0B-AoMOvZtdqNk^)RzorIt0E zJ%Lc608r8XI|Tp@h>DJZ0>FIglp}m%KzjnkdSXCFe~ROYfe-*>K<6Qn*2FM(OCe_D z4K1nrdP?#GlaxsYW|6v1#us+R>|Rvelhm(<$0`M8Pgml~%)ZT?xyuN%0xpX#SQkwMRhh%9xxZPC_i}@6N^d52^+B(_OBYLNO?; z?)2a2+Ql8y6A;7%0qJOc2y8IVmr4Z)wH#7Lvcel114E@_TD|ZU9wO!p$IMLLm3WB& zqAf)_1$`k}SRi7ymT_XdnCcSL8WxJd+5scqQG{7FCl+A8Aa_b9@#~4`Bn=DKVijh| zQg+^hM#f?bqTV>k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oce%gt6 zM?99U!D;&-qkePZd&r--iB@_XJ{h7kGo#>}Rf^+L0Cl_g(4V;vWTj5O&ONqsFNxjK z*HF})Rhy3zu#L6IcDaO5UjJ-_TQi87&gT=cN6#?pY3%#PLPJ~p@#fbdv7~EqiJVC1 z+Qwbf?cbOVE{V*#{N;c2-1}{l^YGpi0h1{&{E!45$9VA zU=Y%HFd~I>icr-+JdjkSqf&y6$6nq1@o}b-TjA+cnyE`ph3`9qwGJU#zzG(xzAVUt zR7zK^ic(i?I)&~)$B3_S8pZvgIICI9O(!bQ8xh=;(Q)|)sY$rfJvKKT_P*B#HLdGv zutJ!(1Ug5x{2~D*JovK!2;q5LVX$LkJ<}2IBPWpCCP$TC_m{w*A>!+@RHZ3v zQ7TdMQ9Vxh`FTm<3hPYqf})O;N0hQ}=?h`wG%}R91BvD8x_0Pq*L-Mne$TH|Y`PQx z20jzh@1+H96)2%QkFMT681bZL+>sM4DGnw|oI~ofU=PYYZ`9yAu8cItRM!;2kH5Tk i?^8?bCx@5E5%>2LE*c3I3Iq={{{X%zeH|N)Yya67mCg(R literal 0 HcmV?d00001 diff --git a/includes/config.php.example b/includes/config.php.example index 893ad26..967926c 100644 --- a/includes/config.php.example +++ b/includes/config.php.example @@ -61,6 +61,7 @@ $ircserver="webchat.freenode.net"; #paths $includedir="/var/www/includes/"; $backupwalletfilename="/home/simplecoin/walletbackup/wallet.dat"; +$logopath="images/logo.jpg" //Encrypt settings $salt = "8fdsfdsfd76s54d777"; //Just type a random series of numbers and letters; set it to anything or any length you want. "You can never have enough salt." From e53282ddeb874f1169092afeabf07b699bd23a25 Mon Sep 17 00:00:00 2001 From: William waisse Date: Wed, 7 Mar 2012 00:14:43 +0100 Subject: [PATCH 16/17] adding missing data and config for loadavg --- cronjobs/loadavg | 1 + includes/config.php.example | 2 +- includes/stats.php | 4 ++-- loadavg.html | 0 4 files changed, 4 insertions(+), 3 deletions(-) create mode 100644 cronjobs/loadavg create mode 100644 loadavg.html diff --git a/cronjobs/loadavg b/cronjobs/loadavg new file mode 100644 index 0000000..b9b739e --- /dev/null +++ b/cronjobs/loadavg @@ -0,0 +1 @@ +*/10 * * * * cat /proc/loadavg > /path/to/your/pool/html/loadavg.html diff --git a/includes/config.php.example b/includes/config.php.example index 967926c..c1077ca 100644 --- a/includes/config.php.example +++ b/includes/config.php.example @@ -61,7 +61,7 @@ $ircserver="webchat.freenode.net"; #paths $includedir="/var/www/includes/"; $backupwalletfilename="/home/simplecoin/walletbackup/wallet.dat"; -$logopath="images/logo.jpg" +$logopath="images/logo.jpg"; //Encrypt settings $salt = "8fdsfdsfd76s54d777"; //Just type a random series of numbers and letters; set it to anything or any length you want. "You can never have enough salt." diff --git a/includes/stats.php b/includes/stats.php index 434a56f..b268b63 100644 --- a/includes/stats.php +++ b/includes/stats.php @@ -450,8 +450,8 @@ function get_server_load($windows = 0) { $avgLoad = 0; $os = strtolower(PHP_OS); if(strpos($os, "win") === false) { - if(file_exists("http://pool.simplecoin.us/loadavg.html")) { - $load = file_get_contents("http://pool.simplecoin.us/loadavg.html"); + if(file_exists("http://".$poolname."/loadavg.html")) { + $load = file_get_contents("http://".$poolname."/loadavg.html"); $load = explode(' ', $load); $avgLoad = $load[0]; } elseif (function_exists("shell_exec")) { diff --git a/loadavg.html b/loadavg.html new file mode 100644 index 0000000..e69de29 From e231a6eba28f524e5c38e786229aabc61a35fc3f Mon Sep 17 00:00:00 2001 From: William waisse Date: Tue, 13 Mar 2012 15:14:56 -0500 Subject: [PATCH 17/17] Update README --- README | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README b/README index d3b7881..02c8ec8 100644 --- a/README +++ b/README @@ -26,3 +26,8 @@ Tom Lightspeed : tomlightspeed@gmail.com : 16p56JHwLna29dFhTRcTAurj4Zc2eScxTD Please remember to include credit from previous authors in all forks and derivative works. Thanks! + +[![endorse](http://api.coderwall.com/neofutur/endorsecount.png)](http://coderwall.com/neofutur) + +"!http://api.coderwall.com/neofutur/endorsecount.png!":http://coderwall.com/neofutur +