├── favicon.ico ├── images ├── crown.png ├── logo.jpg ├── onion.png ├── bitcoin.png ├── favicon.png ├── guiminer.jpg ├── background.jpg ├── background.png ├── contentBg.png ├── menu_left.png ├── menu_right.png ├── chartbg-vanilla.png └── contentBg-header.png ├── chat.php ├── includes ├── footer.php ├── menu.php ├── settings.php ├── universalChecklogin.php ├── header.php ├── reward.php ├── block.php ├── mtgox.php └── requiredFunctions.php ├── js ├── EnhanceJS │ ├── authors.txt │ ├── license.txt │ └── enhance.js ├── login.js ├── ozcoin_graphs.js └── visualize.jQuery.js ├── transactionlog.php ├── cronjobs ├── backupwallet.php ├── archive.php ├── shares.php ├── hashrate.php ├── cronjob.php └── payout.php ├── robots.txt ├── asherbot.php ├── news.php ├── README ├── logout.php ├── about.php ├── css ├── visualize-light.css ├── visualize.css └── mainstyle.css ├── index.php ├── gettingstarted.php ├── api.php ├── blocks.php ├── users.php ├── login.php ├── jsonRPCClient.php ├── lostpassword.php ├── adminPanel.php ├── my_stats.php ├── register.php ├── sql └── simplecoin-v5.sql ├── stats.php └── accountdetails.php /favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikeallisonJS/simplecoin/HEAD/favicon.ico -------------------------------------------------------------------------------- /images/crown.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikeallisonJS/simplecoin/HEAD/images/crown.png -------------------------------------------------------------------------------- /images/logo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikeallisonJS/simplecoin/HEAD/images/logo.jpg -------------------------------------------------------------------------------- /images/onion.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikeallisonJS/simplecoin/HEAD/images/onion.png -------------------------------------------------------------------------------- /images/bitcoin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikeallisonJS/simplecoin/HEAD/images/bitcoin.png -------------------------------------------------------------------------------- /images/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikeallisonJS/simplecoin/HEAD/images/favicon.png -------------------------------------------------------------------------------- /images/guiminer.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikeallisonJS/simplecoin/HEAD/images/guiminer.jpg -------------------------------------------------------------------------------- /images/background.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikeallisonJS/simplecoin/HEAD/images/background.jpg -------------------------------------------------------------------------------- /images/background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikeallisonJS/simplecoin/HEAD/images/background.png -------------------------------------------------------------------------------- /images/contentBg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikeallisonJS/simplecoin/HEAD/images/contentBg.png -------------------------------------------------------------------------------- /images/menu_left.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikeallisonJS/simplecoin/HEAD/images/menu_left.png -------------------------------------------------------------------------------- /images/menu_right.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikeallisonJS/simplecoin/HEAD/images/menu_right.png -------------------------------------------------------------------------------- /images/chartbg-vanilla.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikeallisonJS/simplecoin/HEAD/images/chartbg-vanilla.png -------------------------------------------------------------------------------- /images/contentBg-header.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mikeallisonJS/simplecoin/HEAD/images/contentBg-header.png -------------------------------------------------------------------------------- /chat.php: -------------------------------------------------------------------------------- 1 | 5 | -------------------------------------------------------------------------------- /includes/footer.php: -------------------------------------------------------------------------------- 1 | 2 |
3 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /js/EnhanceJS/authors.txt: -------------------------------------------------------------------------------- 1 | EnhanceJS is developed and maintained by Filament Group, Inc (filamentgroup.com) 2 | with contributions of code and ideas by the following individuals: 3 | 4 | Brandon Aaron 5 | Scott Jehl 6 | Todd Parker 7 | Patty Toland 8 | Maggie Costello Wachs 9 | 10 | -------------------------------------------------------------------------------- /js/login.js: -------------------------------------------------------------------------------- 1 | function clearUsername(){ 2 | if(document.getElementById("userForm").value == "username"){ 3 | document.getElementById("userForm").value = ""; 4 | } 5 | } 6 | function clearPassword(){ 7 | if(document.getElementById("passForm").value == "password"){ 8 | document.getElementById("passForm").value = ""; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /transactionlog.php: -------------------------------------------------------------------------------- 1 | query("listtransactions"); 10 | echo print_r($transactions); 11 | ?> -------------------------------------------------------------------------------- /cronjobs/backupwallet.php: -------------------------------------------------------------------------------- 1 | backupwallet("/home/simplecoin/walletbackup/wallet.dat.".date("Ymd")); 12 | ?> -------------------------------------------------------------------------------- /js/ozcoin_graphs.js: -------------------------------------------------------------------------------- 1 | // Run the script on DOM ready: 2 | $(function(){ 3 | $('#blocks_over_week').visualize({type: 'area', width: '318px'}); 4 | $('#user_hashrate_lasthour').visualize({type: 'area', width: '889px', height: '250px'}); 5 | $('#user_hashrate_last24').visualize({type: 'area', width: '889px', height: '250px'}); 6 | $('#user_hashrate_lastmonth').visualize({type: 'area', width: '889px', height: '250px'}); 7 | }); -------------------------------------------------------------------------------- /robots.txt: -------------------------------------------------------------------------------- 1 | User-agent: * 2 | Disallow: /includes/ 3 | Disallow: /files/ 4 | Disallow: /cronjobs/ 5 | Disallow: /css/ 6 | Disallow: /js/ 7 | Disallow: /sql/ 8 | Disallow: /test/ 9 | Disallow: /wdb/ 10 | Disallow: /api.php 11 | Disallow: /accountdetails.php 12 | Disallow: /adminPanel.php 13 | Disallow: /asherbot.php 14 | Disallow: /blocks.php 15 | Disallow: /jsonRPCClient.php 16 | Disallow: /my_stats.php 17 | Disallow: /news.php 18 | Disallow: /transactionlog.php 19 | Disallow: /users.php 20 | -------------------------------------------------------------------------------- /includes/menu.php: -------------------------------------------------------------------------------- 1 | 22 |
23 | -------------------------------------------------------------------------------- /asherbot.php: -------------------------------------------------------------------------------- 1 | currenthashrate()/1000,1)or sqlerr(__FILE__,__LINE__); 18 | 19 | //Number of Users Mining 20 | $users = count($stats->userhashrates()); 21 | 22 | //Who Found Last Block + Last Time Block Found + Block Number 23 | $result = mysql_query("SELECT blockNumber, username, time FROM share WHERE upstream_result = 'Y' ORDER BY id DESC LIMIT 1"); 24 | if ($resultrow = mysql_fetch_object($result)) { 25 | $blocknumber = $resultrow->blockNumber; 26 | $blocktime = $resultrow->time; 27 | $solvedby = $resultrow->username; 28 | } 29 | $result = mysql_query("SELECT id,confirms FROM networkBlocks WHERE confirms >= 1 ORDER BY blockNumber DESC LIMIT 1"); 30 | if ($resultrow = mysql_fetch_object($result)) { 31 | $confirms = $resultrow->confirms; 32 | } 33 | 34 | 35 | $timediff = time() - strtotime($blocktime); 36 | $solved = explode(".", $solvedby); 37 | echo $hashrate."g-".$users."-".$blocknumber."-".$timediff."-".$solved[0]."-".$confirms; 38 | 39 | 40 | ?> -------------------------------------------------------------------------------- /news.php: -------------------------------------------------------------------------------- 1 | Edit news
"; 28 | echo "
"; 29 | echo ""; 30 | echo "Title
"; 31 | echo "
"; 32 | echo "News
"; 33 | echo ""; 34 | echo "
"; 35 | echo "
"; 36 | ?> -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | Simplecoin Web Mining Framework 2 | 3 | Requirements: 4 | Simplecoin relies on an existing and working bitcoin and pushpool installation. Before attempting to run simplecoin, please setup the following. 5 | Bitcoin: bitcoin.org 6 | Pushpool: http://forum.bitcoin.org/index.php?topic=8707.0 7 | 8 | 9 | Installation: 10 | 1. Extract files into web root directory 11 | 2. Create simplecoin database in you mysql instance 12 | 3. Run simplecoin.sql in your simplecoin database (This will be used for pushpool & simplcoin) 13 | 4. Edit includes/requiredFunctions.php and set the bitcoin & database login info 14 | 5. Edit all files in the cronjob folder, set $includesDirectory to the correct server path. 15 | 6. setup cronjobs on a staggered schedule. I recommend 10-30 minutes for most. I run payout twice daily. 16 | 17 | This project is the culmination of creation and contribution by the following Authors: 18 | Mike Allison (Simplecoin base): dj.mikeallison@gmail.com : 163Pv9cUDJTNUbadV4HMRQSSj3ipwLURRc 19 | Xenland (Miner Pool original fork): 12QY5HYbiT5Nx6fek8ss5pAywPsV3kqdu3 20 | Wayno (Ozco.in contributions): 1Gzcbs8dDYzf16qFWKHc5kWKuH8nji3pVt 21 | Tom Lightspeed : tomlightspeed@gmail.com : 16p56JHwLna29dFhTRcTAurj4Zc2eScxTD 22 | Please remember to include credit from previous authors in all forks and derivative works. 23 | 24 | Thanks! 25 | -------------------------------------------------------------------------------- /cronjobs/archive.php: -------------------------------------------------------------------------------- 1 | 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU General Public License 16 | // along with this program. If not, see . 17 | 18 | // BTC Donations: 163Pv9cUDJTNUbadV4HMRQSSj3ipwLURRc 19 | 20 | //Set page starter variables// 21 | $includeDirectory = "/var/www/includes/"; 22 | 23 | //Include hashing functions 24 | include($includeDirectory."requiredFunctions.php"); 25 | 26 | //Check that script is run locally 27 | ScriptIsRunLocally(); 28 | 29 | //Include Block class 30 | include($includeDirectory."block.php"); 31 | $block = new Block(); 32 | 33 | $siterewardtype = $settings->getsetting("siterewardtype"); 34 | 35 | if ($block->NeedsArchiving($siterewardtype, $bitcoinDifficulty)) 36 | $block->Archive($siterewardtype, $bitcoinDifficulty); 37 | 38 | ?> -------------------------------------------------------------------------------- /logout.php: -------------------------------------------------------------------------------- 1 | 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | 17 | // BTC Donations: 163Pv9cUDJTNUbadV4HMRQSSj3ipwLURRc 18 | 19 | //Include site functions 20 | include("includes/requiredFunctions.php"); 21 | 22 | setcookie($cookieName, 0, $timeoutStamp, $cookiePath, $cookieDomain); 23 | ?> 24 | 25 | 26 | <?php echo antiXss(outputPageTitle());?> 27 | 28 | 29 | 30 | 31 |
32 |

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

34 |
35 | 36 | -------------------------------------------------------------------------------- /about.php: -------------------------------------------------------------------------------- 1 | 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | 17 | // BTC Donations: 163Pv9cUDJTNUbadV4HMRQSSj3ipwLURRc 18 | 19 | $pageTitle = "- About"; 20 | include ("includes/header.php"); 21 | ?> 22 | 23 | About Bitcoins
24 |

25 | About This Site
26 | This site is run by completely opensource software.
27 | Hosted on a Xen Virtual Machine
28 | Running Ubuntu
29 | PHP pages served by Apache webserver
30 | Official Bitcoin server
31 | Pushpool Bitcoin pool
32 | Simplecoin front-end
33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /css/visualize-light.css: -------------------------------------------------------------------------------- 1 | /* page styles */ 2 | /* 3 | body { font-size:62.5%; } 4 | */ 5 | /*demo styles*//* 6 | table {width: 500px; height: 200px; margin-left: 30px; } 7 | table.accessHide { position: absolute; left: -999999px; } 8 | td, th { font-size: 1.2em; padding: 2px; width: 13%; } 9 | th { background-color:#f4f4f4; } 10 | caption { font-size: 1.5em; } 11 | */ 12 | /*visualize extension styles*/ 13 | .visualize { font-size:55%; margin:0px; margin-top:10px; padding: 70px 40px 90px; background: #ccc url(../images/chartbg-vanilla.png) top repeat-x; border: 1px solid #ddd; -moz-border-radius: 12px; -webkit-border-radius: 12px; border-radius: 12px; } 14 | .visualize canvas { border: 1px solid #aaa; margin: -1px; background: #fff; } 15 | .visualize-labels-x, .visualize-labels-y { top: 70px; left: 40px; z-index: 100; } 16 | .visualize-pie .visualize-labels { position: absolute; top: 70px; left: 40px; } 17 | .visualize-labels-x li span.label, .visualize-labels-y li span.label { color: #444; font-size: 1.3em; padding-right: 5px; } 18 | .visualize-labels-y li span.line { border-style: solid; opacity: .7; } 19 | .visualize .visualize-info { border: 0; position: static; opacity: 1; background: none; } 20 | .visualize .visualize-title { position: absolute; top: 20px; color: #333; margin-bottom: 0; left: 20px; font-size: 2.1em; font-weight: bold; } 21 | .visualize ul.visualize-key { position: absolute; bottom: 15px; background: #eee; z-index: 10; padding: 10px 0; color: #aaa; width: 100%; left: 0; } 22 | .visualize ul.visualize-key li { font-size: 1.2em; margin-left: 20px; padding-left: 18px; } 23 | .visualize ul.visualize-key .visualize-key-color { width: 10px; height: 10px; margin-top: -4px; } 24 | .visualize ul.visualize-key .visualize-key-label { color: #333; } -------------------------------------------------------------------------------- /includes/settings.php: -------------------------------------------------------------------------------- 1 | 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | 17 | // BTC Donations: 163Pv9cUDJTNUbadV4HMRQSSj3ipwLURRc 18 | 19 | class Settings { 20 | 21 | var $settingsarray = array(); 22 | 23 | function Settings() { 24 | $this->loadsettings(); 25 | } 26 | 27 | function loadsettings() { 28 | $settingsQ = mysql_query_cache("SELECT setting, value FROM settings"); 29 | foreach ($settingsQ as$settingsR ) { 30 | $setting = $settingsR->setting; 31 | $value = $settingsR->value; 32 | $this->settingsarray[$setting] = $value; 33 | } 34 | } 35 | 36 | function getsetting($settingname){ 37 | if (isset($this->settingsarray[$settingname])) return $this->settingsarray[$settingname]; 38 | } 39 | 40 | function setsetting($settingname, $value) { 41 | mysql_query("UPDATE settings SET value='$value' WHERE setting ='$settingname'"); 42 | $this->settingsarray[$settingname] = $value; 43 | removeSqlCache("SELECT setting, value FROM settings"); 44 | } 45 | } 46 | 47 | ?> -------------------------------------------------------------------------------- /cronjobs/shares.php: -------------------------------------------------------------------------------- 1 | 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | 17 | // BTC Donations: 163Pv9cUDJTNUbadV4HMRQSSj3ipwLURRc 18 | 19 | $includeDirectory = "/var/www/includes/"; 20 | 21 | include($includeDirectory."requiredFunctions.php"); 22 | 23 | //Check that script is run locally 24 | ScriptIsRunLocally(); 25 | ////Update share counts 26 | 27 | //Update past shares 28 | $sql = "UPDATE webUsers u, ". 29 | " (SELECT DISTINCT userId, sum(count) AS valid, sum(invalid) AS invalid, id FROM shares_counted GROUP BY userId) s ". 30 | "SET u.share_count = s.valid, u.stale_share_count = s.invalid WHERE u.id = s.userId"; 31 | mysql_query ($sql); 32 | 33 | // 34 | ////Update current round shares 35 | $sql = "UPDATE webUsers u, ". 36 | " (SELECT IFNULL(count(s.id),0) AS id, p.associatedUserId FROM pool_worker p ". 37 | " LEFT JOIN shares s ON p.username=s.username ". 38 | " WHERE s.our_result='Y' GROUP BY p.associatedUserId) a ". 39 | "SET shares_this_round = a.id WHERE u.id = a.associatedUserId "; 40 | mysql_query($sql); 41 | 42 | ?> -------------------------------------------------------------------------------- /js/EnhanceJS/license.txt: -------------------------------------------------------------------------------- 1 | The MIT License 2 | 3 | Copyright (c) 2007-2010 Filament Group, Inc 4 | 5 | This software consists of contributions made by many 6 | individuals (authors.txt) For exact contribution history, 7 | see the revision history and logs, available 8 | at http://enhancejs.googlecode.com/svn/ 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy 11 | of this software and associated documentation files (the "Software"), to deal 12 | in the Software without restriction, including without limitation the rights 13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | copies of the Software, and to permit persons to whom the Software is 15 | furnished to do so, subject to the following conditions: 16 | 17 | The above copyright notice and this permission notice shall be included in 18 | all copies or substantial portions of the Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | THE SOFTWARE. 27 | 28 | The end-user documentation included with the redistribution, if any, must 29 | include the following acknowledgment: "This product includes software 30 | developed by Filament Group, Inc (http://www.filamentgroup.com/) and its 31 | contributors", in the same place and form as other third-party acknowledgments. 32 | Alternately, this acknowledgment may appear in the software itself, in the same 33 | form and location as other such third-party acknowledgments. -------------------------------------------------------------------------------- /index.php: -------------------------------------------------------------------------------- 1 | 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | 17 | // BTC Donations: 163Pv9cUDJTNUbadV4HMRQSSj3ipwLURRc 18 | 19 | include ("includes/header.php"); 20 | ?> 21 | 22 |

Welcome to SimpleCoin.us


23 | 24 | If you are a new user, please create an account. Then click "Getting Started", and follow the instructions on that page.

25 | 26 | Simplecoin is run completely by opensource software. Even this website is opensource!

27 | 28 | We currently have a fee of getsetting("sitepercent"))?>%, 29 | a transaction fee of getsetting("sitetxfee"))?> BTC per transaction and use 30 | getsetting("siterewardtype") == 0) echo "Last N Shares (1/2 Difficulty)"; 32 | else if ($settings->getsetting("siterewardtype") == 2) echo "Max Pay per share"; 33 | else echo "proportional"; 34 | ?> 35 | round scoring to ensure payout of your hard work.

36 | 37 | If you have any issues, please note them in the forum.

38 | 39 | Thank you!
40 | 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /cronjobs/hashrate.php: -------------------------------------------------------------------------------- 1 | . 16 | 17 | // BTC Donations: 163Pv9cUDJTNUbadV4HMRQSSj3ipwLURRc 18 | 19 | $includeDirectory = "/var/www/includes/"; 20 | 21 | include($includeDirectory."requiredFunctions.php"); 22 | include($includeDirectory."stats.php"); 23 | $stats = new Stats(); 24 | 25 | //Check that script is run locally 26 | ScriptIsRunLocally(); 27 | 28 | //Remove cached items (in case they get stuck) 29 | removeCache("worker_hashrates"); 30 | removeCache("pool_hashrate"); 31 | removeCache("user_hashrates"); 32 | 33 | //Hashrate by user 34 | $hashrates = $stats->userhashratesbyid(); 35 | mysql_query("BEGIN"); 36 | $i = 0; 37 | $sql = ""; 38 | foreach ($hashrates as $userid => $hashrate) { 39 | if ($i == 0) 40 | $sql = "INSERT INTO userHashrates (userId, hashrate) VALUES "; 41 | else 42 | $sql .= ","; 43 | $i++; 44 | $sql .= "($userid, $hashrate)"; 45 | if ($i > 20) 46 | { 47 | mysql_query($sql); 48 | $sql = ""; 49 | $i = 0; 50 | } 51 | } 52 | if (strlen($sql) > 0) 53 | mysql_query($sql); 54 | mysql_query("COMMIT"); 55 | 56 | $currentTime = time(); 57 | $settings->setsetting("statstime", $currentTime); 58 | 59 | ?> -------------------------------------------------------------------------------- /css/visualize.css: -------------------------------------------------------------------------------- 1 | /*plugin styles*/ 2 | .visualize { border: 1px solid #888; position: relative; background: #fafafa; } 3 | .visualize canvas { position: absolute; } 4 | .visualize ul,.visualize li { margin: 0; padding: 0; font-size:6px} 5 | 6 | /*table title, key elements*/ 7 | .visualize .visualize-info { padding: 3px 5px; background: #fafafa; border: 1px solid #888; position: absolute; top: -20px; right: 10px; opacity: .8; } 8 | .visualize .visualize-title { display: block; color: #333; margin-bottom: 3px; font-size: 1.1em; } 9 | .visualize ul.visualize-key { list-style: none; } 10 | .visualize ul.visualize-key li { list-style: none; float: left; margin-right: 10px; padding-left: 10px; position: relative;} 11 | .visualize ul.visualize-key .visualize-key-color { width: 6px; height: 6px; left: 0; position: absolute; top: 50%; margin-top: -3px; } 12 | .visualize ul.visualize-key .visualize-key-label { color: #000; } 13 | 14 | /*pie labels*/ 15 | .visualize-pie .visualize-labels { list-style: none; } 16 | .visualize-pie .visualize-label-pos, .visualize-pie .visualize-label { position: absolute; margin: 0; padding:0; } 17 | .visualize-pie .visualize-label { display: block; color: #fff; font-weight: bold; font-size: 1em; } 18 | .visualize-pie-outside .visualize-label { color: #000; font-weight: normal; } 19 | 20 | /*line,bar, area labels*/ 21 | .visualize-labels-x,.visualize-labels-y { position: absolute; left: 0; top: 0; list-style: none; } 22 | .visualize-labels-x li, .visualize-labels-y li { position: absolute; bottom: 0; } 23 | .visualize-labels-x li span.label, .visualize-labels-y li span.label { position: absolute; color: #555; } 24 | .visualize-labels-x li span.line, .visualize-labels-y li span.line { position: absolute; border: 0 solid #ccc; } 25 | .visualize-labels-x li { height: 100%; } 26 | .visualize-labels-x li span.label { top: 100%; margin-top: 5px; } 27 | .visualize-labels-x li span.line { border-left-width: 1px; height: 100%; display: block; } 28 | .visualize-labels-x li span.line { border: 0;} /*hide vertical lines on area, line, bar*/ 29 | .visualize-labels-y li { width: 100%; } 30 | .visualize-labels-y li span.label { right: 100%; margin-right: 5px; display: block; width: 100px; text-align: right; } 31 | .visualize-labels-y li span.line { border-top-width: 1px; width: 100%; } 32 | .visualize-bar .visualize-labels-x li span.label { width: 100%; text-align: center; } -------------------------------------------------------------------------------- /gettingstarted.php: -------------------------------------------------------------------------------- 1 | 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | 17 | // BTC Donations: 163Pv9cUDJTNUbadV4HMRQSSj3ipwLURRc 18 | 19 | $pageTitle = "- Getting Started"; 20 | include ("includes/header.php"); 21 | 22 | ?> 23 | 24 | Get a Bitcoin Address
25 | Download the client to your PC from: bitcoin.org

26 | 27 | Setup a bitcoin miner

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

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

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

49 | 50 | Easy Linux
51 | Download hashkill: HERE
52 | Decompress (tar zxvf hashkill-0.2.4-x86.tar.gz)
53 | Change directory to hashkill
54 | Run: sudo ./install.sh
55 | Run hashkill: hashkill-gpu -p bitcoin minername:password:pool.simplecoin.us:8337 56 | 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /cronjobs/cronjob.php: -------------------------------------------------------------------------------- 1 | 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | 17 | // BTC Donations: 163Pv9cUDJTNUbadV4HMRQSSj3ipwLURRc 18 | 19 | 20 | //Set page starter variables// 21 | $includeDirectory = "/var/www/includes/"; 22 | 23 | //Include site functions 24 | include($includeDirectory."requiredFunctions.php"); 25 | 26 | //Include Reward class 27 | include($includeDirectory.'reward.php'); 28 | $reward = new Reward(); 29 | 30 | //Check that script is run locally 31 | ScriptIsRunLocally(); 32 | 33 | lock("shares"); 34 | 35 | //Include Block class 36 | include($includeDirectory."block.php"); 37 | $block = new Block(); 38 | 39 | //Get current block number 40 | $currentBlockNumber = $bitcoinController->getblocknumber(); 41 | $lastBlockNumber = $currentBlockNumber - 1; 42 | 43 | //Get latest block in database 44 | $latestDbBlock = $block->getLatestDbBlockNumber(); 45 | 46 | //Do block work if new block 47 | if ($latestDbBlock < $lastBlockNumber) { 48 | //Insert last block number into networkBlocks 49 | include($includeDirectory."stats.php"); 50 | $stats = new Stats(); 51 | $lastwinningid = $stats->lastWinningShareId(); 52 | $block->InsertNetworkBlocks($lastBlockNumber, $lastwinningid); 53 | 54 | //Find new generations 55 | $block->FindNewGenerations($bitcoinController); 56 | 57 | //Update confirms on unrewarded winning blocks 58 | $block->UpdateConfirms($bitcoinController); 59 | } 60 | unlock("shares"); 61 | 62 | //Check for unscored blocks() 63 | if ($block->CheckUnscoredBlocks()) { 64 | lock("money"); 65 | try { 66 | //Get Difficulty 67 | $difficulty = $bitcoinDifficulty; 68 | if(!$difficulty) 69 | { 70 | echo "no difficulty! exiting\n"; 71 | exit; 72 | } 73 | 74 | //Reward by selected type; 75 | if ($settings->getsetting("siterewardtype") == 0) { 76 | //LastNShares 77 | $reward->LastNShares($difficulty, $bonusCoins); 78 | //} else if ($settings->getsetting("siterewardtype") == 2) { 79 | ////MaxPPS 80 | //MaxPPS(); 81 | } else { 82 | //Proportional Scoring 83 | $reward->ProportionalScoring($bonusCoins); 84 | } 85 | } catch (Exception $e) { 86 | echo $e->getMessage(); 87 | } 88 | unlock("money"); 89 | } 90 | 91 | 92 | //Check for unrewarded blocks 93 | if ($block->CheckUnrewardedBlocks()) { 94 | lock("money"); 95 | try { 96 | $reward->MoveUnrewardedToBalance(); 97 | } catch (Exception $e) { 98 | echo $e->getMessage(); 99 | } 100 | unlock("money"); 101 | } 102 | 103 | 104 | ?> -------------------------------------------------------------------------------- /api.php: -------------------------------------------------------------------------------- 1 | 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | 17 | // BTC Donations: 163Pv9cUDJTNUbadV4HMRQSSj3ipwLURRc 18 | 19 | if (!isset($_GET["api_key"])) 20 | exit; 21 | 22 | $includeDirectory = "/var/www/includes/"; 23 | 24 | include($includeDirectory."requiredFunctions.php"); 25 | include($includeDirectory."stats.php"); 26 | $stats = new Stats(); 27 | 28 | class User { 29 | var $confirmed_rewards = null; 30 | var $hashrate = null; 31 | var $payout_history = null; 32 | var $estimated_rewards = null; 33 | var $workers = array(); 34 | } 35 | 36 | class Worker { 37 | var $alive = null; 38 | var $hashrate = null; 39 | } 40 | 41 | $apikey = mysql_real_escape_string($_GET["api_key"]); 42 | 43 | $user = new User(); 44 | $userid = 0; 45 | $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); 46 | if (count($resultU) > 0) { 47 | $userobj = $resultU[0]; 48 | $username = $userobj->username; 49 | $userid = $userobj->id; 50 | $user->confirmed_rewards = $userobj->balance; 51 | $user->hashrate = $stats->userhashrate($username); 52 | $user->estimated_rewards = 0; 53 | $user->payout_history = $userobj->paid; 54 | 55 | if (is_numeric($settings->getsetting("sitepercent"))) 56 | $sitePercent = $settings->getsetting("sitepercent"); 57 | 58 | $totalUserShares = $stats->usersharecount($userid); 59 | 60 | //Get current round share information, estimated total earnings 61 | $totalOverallShares = $stats->currentshares(); 62 | 63 | //Prevent divide by zero 64 | if($totalUserShares > 0 && $totalOverallShares > 0){ 65 | //Get site percentage 66 | $sitePercent = 0; 67 | if (is_numeric($settings->getsetting('sitepercent'))) 68 | $sitePercent = $settings->getsetting('sitepercent')/100; 69 | 70 | if ($totalOverallShares > $bitcoinDifficulty) 71 | $estimatedTotalEarnings = $totalUserShares/$totalOverallShares; 72 | else 73 | $estimatedTotalEarnings = $totalUserShares/$bitcoinDifficulty; 74 | 75 | $estimatedTotalEarnings *= $bonusCoins*(1-$sitePercent); //The expected BTC to be givin out 76 | $user->estimated_rewards = round($estimatedTotalEarnings, 8); 77 | } 78 | 79 | } 80 | $resultW = mysql_query_cache("SELECT username FROM pool_worker WHERE associatedUserId = $userid", 300); 81 | foreach ($resultW as $workerobj) { 82 | $worker = new Worker(); 83 | $worker->alive = ($stats->workerhashrate($workerobj->username) > 0); 84 | $worker->hashrate = $stats->workerhashrate($workerobj->username); 85 | $user->workers[$workerobj->username] = $worker; 86 | } 87 | 88 | echo json_encode($user); 89 | 90 | ?> -------------------------------------------------------------------------------- /blocks.php: -------------------------------------------------------------------------------- 1 | 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | 17 | // BTC Donations: 163Pv9cUDJTNUbadV4HMRQSSj3ipwLURRc 18 | $pageTitle = "- Block Info"; 19 | include ("includes/header.php"); 20 | 21 | echo ""; 22 | echo ""; 23 | echo ""; 24 | echo ""; 25 | echo ""; 26 | echo ""; 27 | //echo ""; 28 | //echo ""; 29 | //echo ""; 30 | 31 | 32 | $result = mysql_query("SELECT w.username, w.blockNumber, n.timestamp, w.confirms FROM networkBlocks n, winning_shares w WHERE n.blockNumber = w.blockNumber AND w.confirms > 1 ORDER BY w.blockNumber DESC"); 33 | 34 | while($resultrow = mysql_fetch_object($result)) { 35 | print(""); 36 | 37 | $resulta = mysql_query("SELECT userid, count FROM shares_counted WHERE blockNumber = $resultrow->blockNumber AND userid = $userId"); 38 | $resdssa = mysql_fetch_object($resulta); 39 | 40 | $blockNo = $resultrow->blockNumber; 41 | 42 | $splitUsername = explode(".", $resultrow->username); 43 | $realUsername = $splitUsername[0]; 44 | 45 | 46 | $confirms = $resultrow->confirms; 47 | 48 | if ($confirms > 120) { 49 | $confirms = 'Completed'; 50 | } 51 | 52 | if($resdssa == NULL){ 53 | 54 | // FIX THIS CODE IF MISSING DATA IS INSERTED ************************************************ 55 | if( $blockNo <= 131574 ) 56 | { 57 | $est = "Before Upgrade"; 58 | $users = "Before Upgrade"; 59 | $totals = "Before Upgrade"; 60 | } 61 | else 62 | { 63 | $est = "Missing Data"; 64 | $users = "Missing Data"; 65 | $totals = "Missing Data"; 66 | } 67 | 68 | } ELSE { 69 | //$est = number_format( $resdssa->balanceDelta, 8 ); 70 | $users = number_format( $resdssa->count ); 71 | //$totals = number_format( $resdssa->totalShares ); 72 | } 73 | 74 | echo ""; 75 | echo ""; 76 | echo ""; 77 | echo ""; 78 | //echo ""; 79 | //echo ""; 80 | //echo ""; 81 | } 82 | 83 | echo "
Blocks Found
BlockConfirmsFinderTimeEarningsSharesTotals Shares
" . number_format( $blockNo ) . "" . $confirms . "".$realUsername."".strftime("%B %d %Y %r",$resultrow->timestamp)."" . $est . "" . $users . "" . $totals . "
"; 84 | echo "You will not get paid till Confirms have hit 120"; 85 | echo "
"; 86 | echo "Stats"; 87 | 88 | include("includes/footer.php"); -------------------------------------------------------------------------------- /cronjobs/payout.php: -------------------------------------------------------------------------------- 1 | 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | 17 | // BTC Donations: 163Pv9cUDJTNUbadV4HMRQSSj3ipwLURRc 18 | 19 | 20 | $includeDirectory = "/var/www/includes/"; 21 | 22 | include($includeDirectory."requiredFunctions.php"); 23 | 24 | //Check that script is run locally 25 | ScriptIsRunLocally(); 26 | 27 | $txfee = 0; 28 | if ($settings->getsetting("sitetxfee") > 0) 29 | $txfee = $settings->getsetting("sitetxfee"); 30 | 31 | $sitepercent = $settings->getsetting("sitepercent"); 32 | /////////Pay users who have reached their threshold payout 33 | 34 | $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"); 35 | lock("money"); 36 | try { 37 | while ($resultR = mysql_fetch_object($resultQ)) { 38 | $currentBalance = $resultR->balance; 39 | $paid = $resultR->paid; 40 | $paymentAddress = $resultR->sendAddress; 41 | $userId = $resultR->userId; 42 | $donatepercent = $resultR->donate_percent; 43 | if ($paymentAddress != '') 44 | { 45 | $isValidAddress = $bitcoinController->validateaddress($paymentAddress); 46 | if($isValidAddress){ 47 | //Subtract TX fee, donation and site fees 48 | $currentBalance = ($currentBalance*(1-$sitepercent/100)*(1-$donatepercent/100)) - $txfee; 49 | $paid += $currentBalance; 50 | //Send money// 51 | mysql_query("BEGIN"); 52 | try { 53 | //Reduce balance amount to zero 54 | //echo "UPDATE accountBalance SET balance = '0', paid = '$paid' WHERE userId = $userId\n"; 55 | mysql_query("UPDATE accountBalance SET balance = '0', paid = '$paid' WHERE userId = $userId"); 56 | if($bitcoinController->sendtoaddress($paymentAddress, $currentBalance)) { 57 | mysql_query("INSERT INTO payoutHistory (userId, address, amount) VALUES ('".$resultR->userId."', '".$paymentAddress."', '".$currentBalance."')"); 58 | 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 "); 59 | mysql_query("COMMIT"); 60 | } else { 61 | mysql_query("ROLLBACK"); 62 | echo "Commodity $currentBalance failed to send to $paymentAddress for userid $userId\n"; 63 | } 64 | } catch (Exception $e) { 65 | mysql_query("ROLLBACK"); 66 | echo "Commodity $currentBalance failed to send to $paymentAddress for userid $userId\n"; 67 | } 68 | 69 | } 70 | } 71 | } 72 | } catch (Exception $ex) { 73 | echo $ex-getMessage(); 74 | } 75 | unlock("money"); 76 | -------------------------------------------------------------------------------- /includes/universalChecklogin.php: -------------------------------------------------------------------------------- 1 | 4 | // 5 | // This program is free software: you can redistribute it and/or modify 6 | // it under the terms of the GNU General Public License as published by 7 | // the Free Software Foundation, either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // This program is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU General Public License 16 | // along with this program. If not, see . 17 | 18 | // BTC Donations: 163Pv9cUDJTNUbadV4HMRQSSj3ipwLURRc 19 | 20 | */ 21 | 22 | $donatePercent = 0; 23 | 24 | //Check if the cookie is set, if so check if the cookie is valid 25 | if(isSet($_COOKIE[$cookieName])){ 26 | $cookieValid = false; 27 | $ip = $_SERVER['REMOTE_ADDR']; //Get Ip address for cookie validation 28 | $validateCookie = new checkLogin(); 29 | $cookieValid = $validateCookie->checkCookie(mysql_real_escape_string($_COOKIE[$cookieName]), $ip); 30 | $userId = $validateCookie->returnUserId($_COOKIE[$cookieName]); 31 | 32 | //ensure userId is numeric to prevent sql injection attack 33 | if (!is_numeric($userId)) { 34 | $userId = 0; 35 | exit; 36 | } 37 | 38 | //Get user information 39 | $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"); 40 | if ($userInfo = mysql_fetch_object($userInfoQ)) { 41 | $authPin = $userInfo->pin; 42 | $hashedPass = $userInfo->pass; 43 | $isAdmin = $userInfo->admin; 44 | $currentUserHashrate = $stats->userhashrate($userInfo->username); 45 | $userApiKey = $userInfo->api_key; 46 | $donatePercent = $userInfo->donate_percent; 47 | $userEmail = $userInfo->email; 48 | $userBtcLock = $userInfo->btc_lock; 49 | 50 | $totalUserShares = $stats->usersharecount($userId); 51 | 52 | //Get current round share information, estimated total earnings 53 | $totalOverallShares = $stats->currentshares(); 54 | 55 | //Calculate Estimate 56 | $userRoundEstimate = 0; 57 | if($totalUserShares > 0 && $totalOverallShares > 0) { 58 | //Get site percentage 59 | $sitePercent = 0; 60 | if (is_numeric($settings->getsetting("sitepercent"))) 61 | $sitePercent = $settings->getsetting("sitepercent")/100; 62 | 63 | if ($totalOverallShares > $bitcoinDifficulty) 64 | $estimatedTotalEarnings = $totalUserShares/$totalOverallShares; 65 | else 66 | $estimatedTotalEarnings = $totalUserShares/$bitcoinDifficulty; 67 | $estimatedTotalEarnings *= $bonusCoins*(1-$sitePercent); //The expected BTC to be givin out 68 | $userRoundEstimate = round($estimatedTotalEarnings, 8); 69 | } 70 | 71 | //Get Current balance 72 | $currentBalanceQ = mysql_query("SELECT balance, IFNULL(sendAddress,'') as sendAddress, threshold FROM accountBalance WHERE userId = '$userId' LIMIT 0,1"); 73 | if ($currentBalanceObj = mysql_fetch_object($currentBalanceQ)) { 74 | $currentBalance = $currentBalanceObj->balance; 75 | //Get payment address that is associated wit this user 76 | $paymentAddress = $currentBalanceObj->sendAddress; 77 | $payoutThreshold = $currentBalanceObj->threshold; 78 | } else { 79 | $currentBalance = 0; 80 | $paymentAddress = ""; 81 | $payoutThreshold = 0; 82 | } 83 | } 84 | 85 | } 86 | ?> -------------------------------------------------------------------------------- /users.php: -------------------------------------------------------------------------------- 1 | 18 |

Search for a user (% = Wildcard)

19 |
20 | By username:
21 | 22 |
23 | 25 |

Search for a user (% = Wildcard)

26 |
27 | By username:
28 | 29 |
30 | 31 | 35 |
38 |

Search for a user (% = Wildcard)

39 |
40 | By username:
41 | 42 |


43 | 48 |
49 |

Results for

50 |
51 | "); 55 | print("idUsernameEmailHashrateshare_countstale_share_countloggedIpDisable"); 56 | while($user = mysql_fetch_array($searchQ)){ 57 | print(""); 58 | print("$user[id]"); 59 | print("$user[username]"); 60 | print("$user[email]"); 61 | print("$stats->userhashrate($user[username])"); 62 | print("$user[share_count]"); 63 | print("$user[stale_share_count]"); 64 | print("$user[loggedIp]"); 65 | print("$user[accountLocked]"); 66 | 67 | 68 | //Make array of userId's to post 69 | if($userIdArray != ""){ 70 | $userIdArray .= ","; 71 | } 72 | $userIdArray .= $user["id"]; 73 | print(""); 74 | } 75 | print(""); 76 | 77 | ?> 78 | 79 | 85 |
86 | 87 | 88 | 89 | -------------------------------------------------------------------------------- /login.php: -------------------------------------------------------------------------------- 1 | id; 36 | 37 | if($checkPass->accountFailedAttempts >= 5){ 38 | echo "Account has been banned"; 39 | die(); 40 | } 41 | 42 | 43 | //Check if user exists before checking login data 44 | if($userExists > 0){ 45 | //Check to see if this user has an `accountLocked` 46 | if($checkPass->accountLocked < time()){ 47 | //Check to see if this user has attempted to login more then the maximum allowed failed attempts 48 | if($checkPass->accountFailedAttempts < 5){ 49 | $dbHash = $checkPass->pass; 50 | $inputHash = hash("sha256", $pass.$salt); 51 | //Do Check 52 | if($dbHash == $inputHash){ 53 | //Give out the secrect SHHH!! be quite too! 54 | //Get ip address so we can hash with the cookie so no one can steal the password 55 | $ip = $_SERVER['REMOTE_ADDR']; 56 | $timeoutStamp = time()+60*60*24*7; //1 week session 57 | //Update logged in ip address so no one can steal this cookie hash unless 58 | mysql_query("UPDATE `webUsers` SET `sessionTimeoutStamp` = ".$timeoutStamp.", `loggedIp` = '".$ip."' WHERE `id` = ".$userExists); 59 | 60 | //Set cookie in browser for session 61 | $hash = $checkPass->secret.$dbHash.$ip.$timeoutStamp; 62 | $cookieHash = hash("sha256", $hash.$salt); 63 | setcookie($cookieName, $checkPass->id."-".$cookieHash, $timeoutStamp, $cookiePath, $cookieDomain); 64 | $cookieValid = true; 65 | 66 | //Display output message 67 | $outputMessage = "Welcome back, we'll be returning to the main page shortly"; 68 | mysql_query("UPDATE webUsers SET accountFailedAttempts = 0 WHERE id = $userExists"); 69 | }else{ 70 | $outputMessage = "Wrong username or password."; 71 | $lock = $checkPass->accountFailedAttempts + 1; 72 | mysql_query("UPDATE webUsers SET accountFailedAttempts = $lock WHERE id = $userExists"); 73 | } 74 | } 75 | } 76 | }else{ 77 | $outputMessage = "User name dosent exist!"; 78 | } 79 | ?> 80 | 81 | 82 | <?php echo antiXss(outputPageTitle());?> 83 | 84 | 85 | 86 | 87 | 91 | 92 | 93 | 94 | -------------------------------------------------------------------------------- /jsonRPCClient.php: -------------------------------------------------------------------------------- 1 | 6 | 7 | This file is part of JSON-RPC PHP. 8 | 9 | JSON-RPC PHP is free software; you can redistribute it and/or modify 10 | it under the terms of the GNU General Public License as published by 11 | the Free Software Foundation; either version 2 of the License, or 12 | (at your option) any later version. 13 | 14 | JSON-RPC PHP is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with JSON-RPC PHP; if not, write to the Free Software 21 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 22 | */ 23 | 24 | /** 25 | * The object of this class are generic jsonRPC 1.0 clients 26 | * http://json-rpc.org/wiki/specification 27 | * 28 | * @author sergio 29 | */ 30 | class jsonRPCClient { 31 | 32 | /** 33 | * Debug state 34 | * 35 | * @var boolean 36 | */ 37 | private $debug; 38 | 39 | /** 40 | * The server URL 41 | * 42 | * @var string 43 | */ 44 | private $url; 45 | /** 46 | * The request id 47 | * 48 | * @var integer 49 | */ 50 | private $id; 51 | /** 52 | * If true, notifications are performed instead of requests 53 | * 54 | * @var boolean 55 | */ 56 | private $notification = false; 57 | 58 | /** 59 | * Takes the connection parameters 60 | * 61 | * @param string $url 62 | * @param boolean $debug 63 | */ 64 | public function __construct($url,$debug = false) { 65 | // server URL 66 | $this->url = $url; 67 | // proxy 68 | empty($proxy) ? $this->proxy = '' : $this->proxy = $proxy; 69 | // debug state 70 | empty($debug) ? $this->debug = false : $this->debug = true; 71 | // message id 72 | $this->id = 1; 73 | } 74 | 75 | /** 76 | * Sets the notification state of the object. In this state, notifications are performed, instead of requests. 77 | * 78 | * @param boolean $notification 79 | */ 80 | public function setRPCNotification($notification) { 81 | empty($notification) ? 82 | $this->notification = false 83 | : 84 | $this->notification = true; 85 | } 86 | 87 | /** 88 | * Performs a jsonRCP request and gets the results as an array 89 | * 90 | * @param string $method 91 | * @param array $params 92 | * @return array 93 | */ 94 | public function __call($method,$params) { 95 | 96 | // check 97 | if (!is_scalar($method)) { 98 | throw new Exception('Method name has no scalar value'); 99 | } 100 | 101 | // check 102 | if (is_array($params)) { 103 | // no keys 104 | $params = array_values($params); 105 | } else { 106 | throw new Exception('Params must be given as array'); 107 | } 108 | 109 | // sets notification or request task 110 | if ($this->notification) { 111 | $currentId = NULL; 112 | } else { 113 | $currentId = $this->id; 114 | } 115 | 116 | // prepares the request 117 | $request = array( 118 | 'method' => $method, 119 | 'params' => $params, 120 | 'id' => $currentId 121 | ); 122 | $request = json_encode($request); 123 | $this->debug && $this->debug.='***** Request *****'."\n".$request."\n".'***** End Of request *****'."\n\n"; 124 | 125 | // performs the HTTP POST 126 | $opts = array ('http' => array ( 127 | 'method' => 'POST', 128 | 'header' => 'Content-type: application/json', 129 | 'content' => $request 130 | )); 131 | $context = stream_context_create($opts); 132 | if ($fp = fopen($this->url, 'r', false, $context)) { 133 | $response = ''; 134 | while($row = fgets($fp)) { 135 | $response.= trim($row)."\n"; 136 | } 137 | $this->debug && $this->debug.='***** Server response *****'."\n".$response.'***** End of server response *****'."\n"; 138 | $response = json_decode($response,true); 139 | } else { 140 | throw new Exception('Unable to connect to '.$this->url); 141 | } 142 | 143 | // debug output 144 | if ($this->debug) { 145 | echo nl2br($debug); 146 | } 147 | 148 | // final checks and return 149 | if (!$this->notification) { 150 | // check 151 | if ($response['id'] != $currentId) { 152 | throw new Exception('Incorrect response id (request id: '.$currentId.', response id: '.$response['id'].')'); 153 | } 154 | if (!is_null($response['error'])) { 155 | throw new Exception('Request error: '.$response['error']); 156 | } 157 | 158 | return $response['result']; 159 | 160 | } else { 161 | return true; 162 | } 163 | } 164 | } 165 | ?> -------------------------------------------------------------------------------- /lostpassword.php: -------------------------------------------------------------------------------- 1 | 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | 17 | // BTC Donations: 163Pv9cUDJTNUbadV4HMRQSSj3ipwLURRc 18 | $pageTitle = "Password Recovery"; 19 | include ("includes/header.php"); 20 | 21 | $returnError = ""; 22 | $goodMessage = ""; 23 | 24 | if (isset($_POST["act"])) { 25 | $act = $_POST["act"]; 26 | //Send reset mail 27 | if ($act == "reset") { 28 | $resetUsername = mysql_real_escape_string($_POST["pwrUsername"]); 29 | $result = mysql_query("SELECT email, emailAuthPin FROM webUsers WHERE username='$resetUsername'"); 30 | if ($row = mysql_fetch_row($result)) { 31 | $email = $row[0]; 32 | 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 "); 33 | $goodMessage = "Your password reset information has been sent to ".$email; 34 | } else { 35 | $returnError = "We were unable to locate your records, please contact the site admin for further assistance."; 36 | } 37 | } else if ($act == "resetpass") { 38 | $validRegister = true; 39 | $resetUsername = mysql_real_escape_string($_POST["pwrUsername"]); 40 | $resetAuth = mysql_real_escape_string($_POST["auth"]); 41 | $pass = mysql_real_escape_string($_POST["pass"]); 42 | $rPass = mysql_real_escape_string($_POST["pass2"]); 43 | if($pass != $rPass) { 44 | if (strlen($pass) < 5) { 45 | $validRegister = false; 46 | $returnError .= " | Password is too short"; 47 | } else { 48 | $validRegister = false; 49 | $returnError .= " | Passwords do not match"; 50 | } 51 | } 52 | if ($validRegister = 1) { 53 | $result = mysql_query("UPDATE webUsers SET pass='".hash("sha256", $pass)."', accountFailedAttempts = 0 WHERE username='$resetUsername' AND emailAuthPin='$resetAuth' "); 54 | if ($result) { 55 | $goodMessage ="Password reset Successful. Please login using your new credentials."; 56 | } else { 57 | $returnError .= "We were unable to locate your records, please contact the site admin for further assistance."; 58 | } 59 | } 60 | 61 | 62 | } 63 | } 64 | 65 | //Handle incoming auth request 66 | $returningAuth = false; 67 | $resetUsername = ""; 68 | if (isset($_GET["auth"]) && isset($_GET["username"])) { 69 | $resetUsername = mysql_real_escape_string($_GET["username"]); 70 | $resetAuth = mysql_real_escape_string($_GET["auth"]); 71 | $result = mysql_query("SELECT id FROM webUsers WHERE username='$resetUsername' AND emailAuthPin='$resetAuth'"); 72 | if ($row = mysql_fetch_object($result) && mysql_numrows($result) > 0) { 73 | $returningAuth = true; 74 | } else { 75 | $returnError = "We were unable to locate your records, please contact the site admin for further assistance."; 76 | } 77 | } 78 | 79 | //Display Error and Good Messages(If Any) 80 | echo "".$goodMessage."
"; 81 | echo "".$returnError.""; 82 | 83 | if (!$returningAuth ) { 84 | ?> 85 | 86 |

Password Recovery


87 | 88 | 89 | Username:
90 | 91 | 92 | 93 | 94 |

Password Recovery


95 |
96 | 97 | "/> 98 | "/> 99 | New Password:
100 | Repeat Password:
101 | 102 | 103 |
104 | 105 | -------------------------------------------------------------------------------- /includes/header.php: -------------------------------------------------------------------------------- 1 | 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | 17 | // BTC Donations: 163Pv9cUDJTNUbadV4HMRQSSj3ipwLURRc 18 | 19 | //Set page starter variables// 20 | $cookieValid = false; 21 | $activeMiners = false; 22 | 23 | include("requiredFunctions.php"); 24 | 25 | include('includes/stats.php'); 26 | $stats = new Stats(); 27 | 28 | include("universalChecklogin.php"); 29 | 30 | if (!isset($pageTitle)) $pageTitle = outputPageTitle(); 31 | else $pageTitle = outputPageTitle(). " ". $pageTitle; 32 | 33 | ?> 34 | 35 | 36 | 37 | <?php echo $pageTitle;?> 38 | 39 | 40 | 41 | 42 | 56 | 57 | 61 | 62 | 65 | 66 | 67 | 81 |
82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 111 | 112 | 113 | 114 |
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: 106 | 107 | 108 | 109 | Lost Password 110 |
115 |
116 | 117 | 118 | 119 |
120 | -------------------------------------------------------------------------------- /adminPanel.php: -------------------------------------------------------------------------------- 1 | 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | 17 | // BTC Donations: 163Pv9cUDJTNUbadV4HMRQSSj3ipwLURRc 18 | 19 | $pageTitle = "- Admin Panel"; 20 | include ("includes/header.php"); 21 | 22 | $goodMessage = ""; 23 | $returnError = ""; 24 | //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 25 | 26 | if(!$cookieValid || $isAdmin != 1) { 27 | header('Location: /'); 28 | exit; 29 | } 30 | 31 | if (isset($_POST["act"]) && isset($_POST["authPin"])) 32 | { 33 | if (isset($_POST["authPin"])) { 34 | $inputAuthPin = hash("sha256", $_POST["authPin"].$salt); 35 | } else { 36 | $inputAuthPin = NULL; 37 | } 38 | 39 | //Make sure an authPin is set and valid when $act is active 40 | if(isset($_POST["act"]) && $authPin == $inputAuthPin) { 41 | $act = $_POST["act"]; 42 | //Update information if needed 43 | if($act == "UpdateMainPageSettings"){ 44 | try { 45 | $settings->setsetting("sitepayoutaddress", mysql_real_escape_string($_POST["paymentAddress"])); 46 | $settings->setsetting("sitepercent", mysql_real_escape_string($_POST["percentageFee"])); 47 | $settings->setsetting("websitename", mysql_real_escape_string($_POST["headerTitle"])); 48 | $settings->setsetting("pagetitle", mysql_real_escape_string($_POST["pageTitle"])); 49 | $settings->setsetting("slogan", mysql_real_escape_string($_POST["headerSlogan"])); 50 | $settings->setsetting("siterewardtype", mysql_real_escape_string($_POST["rewardType"])); 51 | $settings->setsetting("sitetxfee", mysql_real_escape_string($_POST["transactionFee"])); 52 | $settings->loadsettings(); //refresh settings 53 | $goodMessage = "Successfully updated general settings"; 54 | } catch (Exception $e) { 55 | $returnError = "Database Failed - General settings was not updated"; 56 | } 57 | } 58 | } else if($act && $authPin != $inputAuthPin){ 59 | $returnError = "Authorization Pin # - Invalid"; 60 | } 61 | } 62 | 63 | //Display Error and Good Messages(If Any) 64 | echo "".antiXss($goodMessage)."
"; 65 | echo "".antiXss($returnError).""; 66 | 67 | ?> 68 | 69 |
70 |

Welcome back admin


71 |

General Settings

72 |
73 | 74 |
75 | 76 | Page Title ">
77 | Header Title ">
78 | Header Slogan ">
79 | Percentage Fee ">%
80 | Transaction Fee " /> BTC
81 | Fee Address ">
82 | Default Reward Type 86 |

87 | Authorization Pin
88 | 89 |
90 |

91 |

Info

92 |
93 | 94 | 0")or sqlerr(__FILE__, __LINE__); 97 | $sitewalletq = mysql_fetch_row($sitewallet); 98 | $usersbalance = $sitewalletq[0]; 99 | $balance = $bitcoinController->query("getbalance"); 100 | $total = $balance - $usersbalance; 101 | 102 | echo "Block Number: ".$bitcoinController->getblocknumber()."
"; 103 | echo "Difficulty: ".$bitcoinDifficulty."
"; 104 | echo "Wallet Balance: ".$balance."
"; 105 | echo "UnPaid: ".$usersbalance."
"; 106 | echo "Total Left: $total
"; 107 | 108 | ?> 109 |

News Control

110 |
111 | Edit News 112 |

113 |

Users Control

114 |
115 | Show USers 116 |
117 | 118 | -------------------------------------------------------------------------------- /my_stats.php: -------------------------------------------------------------------------------- 1 | "; 16 | 17 | if( !$cookieValid ){ 18 | echo "

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

"; 19 | } 20 | else 21 | { 22 | // SHOW USER TOTAL PAID ************************************************************************************************************************* 23 | 24 | echo ""; 25 | echo "
Total BTC Earned
"; 26 | 27 | $result = mysql_query_cache("SELECT paid + balance as amount_earned FROM accountBalance WHERE userid = $userInfo->id"); 28 | if ($resultrow = $result[0]) { 29 | echo $resultrow->amount_earned; 30 | } 31 | 32 | echo "
"; 33 | 34 | // USER HASHRATE LAST HOUR/TIME GRAPH ************************************************************************************************************************* 35 | // http://www.filamentgroup.com/lab/update_to_jquery_visualize_accessible_charts_with_html5_from_designing_with/ 36 | // table is hidden, graph follows 37 | 38 | // echo ""; 39 | // echo ""; 40 | // echo ""; 41 | // 42 | // $query = "SELECT DISTINCT DATE_FORMAT(timestamp, '%h:%i') as time, hashrate FROM userHashrates WHERE timestamp > DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 1 HOUR) AND userId = $userInfo->id"; 43 | // $result = mysql_query($query); 44 | // 45 | // while($resultrow = mysql_fetch_object($result)) { 46 | // echo ""; 47 | // } 48 | // 49 | // echo ""; 50 | // 51 | // // re-iterate through results 52 | // if (mysql_num_rows($result) > 0) 53 | // mysql_data_seek($result, 0); 54 | // 55 | // while($resultrow = mysql_fetch_object($result)) { 56 | // echo ""; 57 | // } 58 | // 59 | // echo "
" . $userInfo->username . "'s Hashrate over the Last Hour
" . $resultrow->time . "
" . $userInfo->username . "'s Hashrate" . $resultrow->hashrate . "
"; 60 | 61 | //echo "
"; 62 | 63 | // USER HASHRATE LAST 24 HOURS/TIME GRAPH ************************************************************************************************************************* 64 | // http://www.filamentgroup.com/lab/update_to_jquery_visualize_accessible_charts_with_html5_from_designing_with/ 65 | // table is hidden, graph follows 66 | 67 | echo ""; 68 | echo ""; 69 | echo ""; 70 | 71 | $query = "SELECT DATE_FORMAT(timestamp, '%l:%i') as time, hashrate FROM userHashrates WHERE timestamp > DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 24 HOUR) AND userId = $userInfo->id"; 72 | $query .= " GROUP BY EXTRACT(DAY FROM timestamp), EXTRACT(HOUR FROM timestamp)"; 73 | 74 | $result = mysql_query_cache($query); 75 | 76 | foreach ($result as $resultrow) { 77 | echo ""; 78 | } 79 | 80 | echo ""; 81 | 82 | // re-iterate through results 83 | //if (mysql_num_rows($result) > 0) 84 | // mysql_data_seek($result, 0); 85 | 86 | foreach ($result as $resultrow) { 87 | echo ""; 88 | } 89 | 90 | echo "
" . $userInfo->username . "'s Hashrate over the Last 24 Hours
" . $resultrow->time . "
".$userInfo->username."'s Hashrate".$resultrow->hashrate."
"; 91 | 92 | //echo "
"; 93 | 94 | // USER HASHRATE OVER LAST MONTH GRAPH ************************************************************************************************************************* 95 | // http://www.filamentgroup.com/lab/update_to_jquery_visualize_accessible_charts_with_html5_from_designing_with/ 96 | // table is hidden, graph follows 97 | 98 | echo ""; 99 | echo ""; 100 | echo ""; 101 | 102 | $query = "SELECT DATE_FORMAT(timestamp, '%b %e') as day, hashrate FROM userHashrates WHERE timestamp > DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 1 MONTH) AND userId = " . $userInfo->id; 103 | $query .= " GROUP BY EXTRACT(MONTH FROM timestamp), EXTRACT(DAY FROM timestamp)"; 104 | 105 | $result = mysql_query_cache($query); 106 | 107 | foreach ($result as $resultrow) { 108 | echo ""; 109 | } 110 | 111 | echo ""; 112 | 113 | // re-iterate through results 114 | //if (mysql_num_rows($result) > 0) 115 | // mysql_data_seek($result, 0); 116 | 117 | foreach ($result as $resultrow) { 118 | echo ""; 119 | } 120 | 121 | echo "
" . $userInfo->username . "'s Hashrate over the Last Month
" . $resultrow->day . "
" . $userInfo->username . "'s Hashrate" . $resultrow->hashrate . "
"; 122 | 123 | //echo "
"; 124 | } 125 | 126 | echo "
"; 127 | 128 | include("includes/footer.php"); 129 | 130 | ?> -------------------------------------------------------------------------------- /register.php: -------------------------------------------------------------------------------- 1 | 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | 17 | // BTC Donations: 163Pv9cUDJTNUbadV4HMRQSSj3ipwLURRc 18 | 19 | $pageTitle = "- Register"; 20 | include ("includes/header.php"); 21 | 22 | /* 23 | Copyright (C) 41a240b48fb7c10c68ae4820ac54c0f32a214056bfcfe1c2e7ab4d3fb53187a0 Name Year (sha256) 24 | 25 | This program is free software; you can redistribute it and/or 26 | modify it under the terms of the GNU General Public License 27 | as published by the Free Software Foundation; either version 2 28 | of the License, or (at your option) any later version. 29 | 30 | This program is distributed in the hope that it will be useful, 31 | but WITHOUT ANY WARRANTY; without even the implied warranty of 32 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 33 | GNU General Public License for more details. 34 | 35 | You should have received a copy of the GNU General Public License 36 | along with this program; if not, write to the Free Software 37 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 38 | Website Reference:http://www.gnu.org/licenses/gpl-2.0.html 39 | 40 | Note From Author: Please donate at the following address: 1Fc2ScswXAHPUgj3qzmbRmwWJSLL2yv8Q 41 | */ 42 | 43 | //Test registration information 44 | $returnError = ""; 45 | $goodMessage = ""; 46 | if (isset($_POST["act"])) 47 | { 48 | $act = $_POST["act"]; 49 | if($act == "attemptRegister"){ 50 | //Valid date all fields 51 | $username = mysql_real_escape_string($_POST["user"]); 52 | $pass = mysql_real_escape_string($_POST["pass"]); 53 | $rPass = mysql_real_escape_string($_POST["pass2"]); 54 | $email = mysql_real_escape_string($_POST["email"]); 55 | $email2 = mysql_real_escape_string($_POST["email2"]); 56 | $authPin = mysql_real_escape_string($_POST["authPin"]); 57 | 58 | $validRegister = 1; 59 | //Validate username 60 | if (!preg_match('/^[a-z\d_]{4,20}$/i', $username)) { 61 | $validRegister = 0; 62 | $returnError .= "Wrong username format."; 63 | } 64 | 65 | //Validate passwords 66 | if($pass != $rPass){ 67 | if(strlen($pass) < 5){ 68 | $validRegister = 0; 69 | $returnError .= " | Password is too short"; 70 | }else{ 71 | $validRegister = 0; 72 | $returnError .= " | Passwords do not match"; 73 | } 74 | } 75 | 76 | //Email Validation 77 | if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { 78 | $validRegister = 0; 79 | $returnError .= " | Wrong email address format."; 80 | }else{ 81 | //Validate that emails match 82 | if($email != $email2){ 83 | $validRegister = 0; 84 | $returnError .= " | Emails didn't match!"; 85 | } 86 | } 87 | 88 | //validate authpin 89 | if(strlen($authPin) >= 4){ 90 | if(!is_numeric($authPin)){ 91 | $validRegister = 0; 92 | $returnError .= " | Not a valid authpin"; 93 | } 94 | }else{ 95 | $validRegister = 0; 96 | $returnError .= " | Authorization pin number is not valid"; 97 | } 98 | 99 | if($validRegister){ 100 | //Add user to webUsers 101 | $emailAuthPin = genRandomString(10); 102 | $secret = genRandomString(10); 103 | $apikey = hash("sha256",$username.$salt); 104 | //Check to see if user exists already 105 | $testUserQ = mysql_query("SELECT id FROM webUsers WHERE username = '".$username."' LIMIT 1"); 106 | //If not, create new user 107 | if (!$testUserQ || mysql_num_rows($testUserQ) == 0) { 108 | $result = mysql_query("INSERT INTO webUsers (admin, username, pass, email, emailAuthPin, secret, loggedIp, sessionTimeoutStamp, accountLocked, accountFailedAttempts, pin, api_key) 109 | VALUES (0, '$username', '".hash("sha256", $pass.$salt)."', '$email', '$emailAuthPin', '$secret', '0', '0', '0', '0', '".hash("sha256", $authPin.$salt)."','$apikey')"); 110 | $returnId = mysql_insert_id(); 111 | mysql_query("INSERT INTO accountBalance (userId, balance) VALUES ($returnId,'0')"); 112 | mysql_query("INSERT INTO pool_worker (associatedUserId, username, password) VALUES ($returnId,'".$username.".1','x')"); 113 | $goodMessage = "Your account has been successfully created. Please login to continue."; 114 | } else { 115 | $returnError = "Account already exists. Please choose a different username."; 116 | } 117 | } 118 | } 119 | } 120 | 121 | //Display Error and Good Messages(If Any) 122 | echo "".antiXss($goodMessage)."
"; 123 | echo "".antiXss($returnError).""; 124 | 125 | ?> 126 |
127 |

Join our pool

128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 |
Username:
Password:
Repeat Password:
Email:
Email Repeat:
PIN: (4 digit number "Remember this pin")
137 | 138 |
139 | 140 | -------------------------------------------------------------------------------- /includes/reward.php: -------------------------------------------------------------------------------- 1 | 119 ORDER BY id ASC"); 6 | if (mysql_num_rows($blocksQ) > 0) 7 | while ($blocksR = mysql_fetch_object($blocksQ)) { 8 | $overallreward = 0; 9 | $blockNumber = $blocksR->blockNumber; 10 | echo "Block: $blockNumber\n"; 11 | $unrewarededQ = mysql_query("SELECT userId, amount FROM unconfirmed_rewards WHERE blockNumber = $blockNumber AND rewarded = 'N'"); 12 | mysql("BEGIN"); 13 | try { 14 | while ($unrewardedR = mysql_fetch_object($unrewarededQ)) { 15 | $amount = $unrewardedR->amount; 16 | $userid = $unrewardedR->userId; 17 | $overallreward += $amount; 18 | echo "UPDATE accountBalance SET balance = balance + $amount WHERE userId = $userid\n"; 19 | mysql_query("UPDATE accountBalance SET balance = balance + $amount WHERE userId = $userid"); 20 | } 21 | mysql_query("DELETE FROM unconfirmed_rewards WHERE blockNumber = $blockNumber"); 22 | mysql_query("UPDATE winning_shares SET rewarded = 'Y' WHERE blockNumber = $blockNumber"); 23 | mysql_query("COMMIT"); 24 | echo "Total Reward: $overallreward\n"; 25 | } catch (Exception $e) { 26 | echo("Exception: " . $e->getMessage() . "\n"); 27 | mysql_query("ROLLBACK"); 28 | } 29 | } 30 | } 31 | 32 | function LastNShares($difficulty, $bonusCoins) { 33 | global $settings; 34 | $overallreward = 0; 35 | $blocksQ = mysql_query("SELECT share_id, blockNumber from winning_shares WHERE scored = 'N' ORDER BY id ASC"); 36 | while ($blocksR = mysql_fetch_object($blocksQ)) { 37 | echo "Last N shares scoring\n"; 38 | echo "difficulty is $difficulty \n"; 39 | $blockNumber = $blocksR->blockNumber; 40 | $shareId = $blocksR->share_id; 41 | $shareLimit = round($difficulty/2); 42 | 43 | //Make sure there are at least $shareLimit shares 44 | $limitQ = mysql_query("SELECT count(id) FROM shares WHERE id <= $shareId AND our_result='Y'"); 45 | if ($limitR = mysql_fetch_array($limitQ)) { 46 | if ($limitR[0] < $shareLimit) $shareLimit = round($limitR[0]); 47 | } 48 | echo "share limit is $shareLimit\n"; 49 | 50 | $sharesQ = mysql_query("SELECT u.id, count(s.id) as shares FROM webUsers u, pool_worker p, (SELECT id, username FROM shares WHERE id <= $shareId AND our_result='Y' ORDER BY id DESC LIMIT $shareLimit) s WHERE u.id = p.associatedUserId AND p.username = s.username GROUP BY u.id"); 51 | mysql_query("BEGIN"); 52 | try { 53 | while ($sharesR = mysql_fetch_object($sharesQ)) { 54 | $totalReward = $sharesR->shares/$shareLimit*$bonusCoins; 55 | $userid = $sharesR->id; 56 | $totalReward = $totalReward * 100000000; 57 | $totalReward = floor($totalReward); 58 | $totalReward = $totalReward/100000000; 59 | $overallreward += $totalReward; 60 | echo "$userid - $totalReward - $sharesR->shares\n"; 61 | if ($totalReward > 0.00000001) 62 | echo "INSERT INTO unconfirmed_rewards (userId, blockNumber, amount, shares) VALUES ($userid, $blockNumber, '$totalReward', $sharesR->shares)\n"; 63 | mysql_query("INSERT INTO unconfirmed_rewards (userId, blockNumber, amount, shares) VALUES ($userid, $blockNumber, '$totalReward', $sharesR->shares)"); 64 | //mysql_query("UPDATE accountBalance SET balance = balance + $totalReward WHERE userId = $userid"); 65 | } 66 | echo "UPDATE winning_shares SET scored = 'Y' WHERE share_id = $shareId\n"; 67 | mysql_query("UPDATE winning_shares SET scored = 'Y' WHERE share_id = $shareId"); 68 | mysql_query("COMMIT"); 69 | echo "Total Reward: $overallreward"; 70 | } catch (Exception $e) { 71 | echo("Exception: " . $e->getMessage() . "\n"); 72 | mysql_query("ROLLBACK"); 73 | } 74 | 75 | } 76 | } 77 | 78 | function ProportionalScoring($bonusCoins) { 79 | //Go through all of shares that are uncounted shares; Check if there are enough confirmed blocks to award user their BTC 80 | $overallReward = 0; 81 | $lastrewarded = 0; 82 | 83 | //Get last rewarded share id 84 | $rewardedblocksQ = mysql_query("SELECT share_id from winning_shares WHERE rewarded = 'Y' ORDER BY blockNumber DESC LIMIT 0,1") or die(mysql_error()); 85 | if ($rewardedblocksR = mysql_fetch_row($rewardedblocksQ)) { 86 | $lastrewarded = $rewardedblocksR[0]; 87 | } 88 | 89 | //Get unrewarded blocks 90 | $blocksQ = mysql_query("SELECT share_id, blockNumber from winning_shares WHERE scored = 'N' ORDER BY id ASC"); 91 | while ($blocksR = mysql_fetch_object($blocksQ)) { 92 | echo "Proportional Scoring \n"; 93 | $shareid = $blocksR->share_id; 94 | $blockNumber = $blocksR->blockNumber; 95 | //Get unrewarded shares 96 | $totalRoundSharesQ = mysql_query("SELECT count(id) as id FROM shares WHERE id <= $shareid AND id > $lastrewarded AND our_result='Y' "); 97 | if ($totalRoundSharesR = mysql_fetch_object($totalRoundSharesQ)) { 98 | $totalRoundShares = $totalRoundSharesR->id; 99 | $userListCountQ = mysql_query("SELECT DISTINCT username, count(id) as id FROM shares WHERE id <= $shareid AND id > $lastrewarded AND our_result='Y' GROUP BY username"); 100 | while ($userListCountR = mysql_fetch_object($userListCountQ)) { 101 | mysql_query("BEGIN"); 102 | try { 103 | $username = $userListCountR->username; 104 | $uncountedShares = $userListCountR->id; 105 | $shareRatio = $uncountedShares/$totalRoundShares; 106 | $predonateAmount = $bonusCoins*$shareRatio; 107 | 108 | //get owner userId and donation percent 109 | $ownerIdQ = mysql_query("SELECT p.associatedUserId, u.donate_percent FROM pool_worker p, webUsers u WHERE u.id = p.associatedUserId AND p.username = '$username' LIMIT 0,1"); 110 | $ownerIdObj = mysql_fetch_object($ownerIdQ); 111 | $userid = $ownerIdObj->associatedUserId; 112 | 113 | //Force decimal value (remove e values) 114 | $totalReward = rtrim(sprintf("%f",$predonateAmount ),"0"); 115 | 116 | if ($totalReward > 0.00000001) { 117 | //Round Down to 8 digits 118 | $totalReward = $totalReward * 100000000; 119 | $totalReward = floor($totalReward); 120 | $totalReward = $totalReward/100000000; 121 | 122 | //Update balance 123 | mysql_query("INSERT INTO unconfirmed_rewards (userId, blockNumber, amount, shares) VALUES ($userid, $blockNumber, '$totalReward', $uncountedShares)"); 124 | //$updateOk = mysql_query("UPDATE accountBalance SET balance = balance + $totalReward WHERE userId = $userid"); 125 | } 126 | mysql_query("UPDATE winning_shares SET scored = 'Y' WHERE share_id = $shareId"); 127 | mysql_query("COMMIT"); 128 | } catch (Exception $e) { 129 | echo("Exception: " . $e->getMessage() . "\n"); 130 | mysql_query("ROLLBACK"); 131 | } 132 | } 133 | } 134 | } 135 | } 136 | } 137 | ?> -------------------------------------------------------------------------------- /includes/block.php: -------------------------------------------------------------------------------- 1 | 0) 8 | return $row[0]; 9 | } 10 | return 0; 11 | } 12 | 13 | function InsertNetworkBlocks($lastBlockNumber,$lastwinningid) { 14 | //Check to see if last block number exists in the db. 15 | $inDatabaseQ = mysql_query("SELECT id FROM networkBlocks WHERE blockNumber = $lastBlockNumber LIMIT 0,1"); 16 | $inDatabase = mysql_num_rows($inDatabaseQ); 17 | if(!$inDatabase) { 18 | //If not, insert it. 19 | $currentTime = time(); 20 | mysql_query("INSERT INTO networkBlocks (blockNumber, timestamp) VALUES ($lastBlockNumber, $currentTime)"); 21 | 22 | //Save winning share (if there is one) 23 | $winningShareQ = mysql_query("SELECT id, username FROM shares where upstream_result = 'Y' AND id > $lastwinningid"); 24 | while ($winningShareR = mysql_fetch_object($winningShareQ)) { 25 | mysql_query("INSERT INTO winning_shares (blockNumber, username, share_id) VALUES ($lastBlockNumber,'$winningShareR->username',$winningShareR->id)"); 26 | removeCache("last_winning_share_id"); 27 | } 28 | } 29 | } 30 | 31 | function UpdateConfirms($bitcoinController) { 32 | $winningAccountQ = mysql_query("SELECT id, txid FROM winning_shares WHERE txid <> '' AND confirms < 120"); 33 | while ($winningAccountR = mysql_fetch_object($winningAccountQ)) { 34 | $txInfo = $bitcoinController->query("gettransaction", $winningAccountR->txid); 35 | if (count($txInfo["confirmations"]) > 0) { 36 | mysql_query("UPDATE winning_shares SET confirms = ".$txInfo["confirmations"]." WHERE id = $winningAccountR->id"); 37 | } 38 | } 39 | } 40 | 41 | function FindNewGenerations($bitcoinController) { 42 | //Get list of last 200 transactions 43 | $transactions = $bitcoinController->query("listtransactions", "*", "200"); 44 | 45 | //Go through all the transactions check if there is 50BTC inside 46 | $numAccounts = count($transactions); 47 | 48 | for($i = 0; $i < $numAccounts; $i++) { 49 | //Check for 50BTC inside only if they are in the generate category 50 | if($transactions[$i]["category"] == "generate" || $transactions[$i]["category"] == "immature") { 51 | //At this point we may or may not have found a block, 52 | //Check to see if this account addres is already added to `networkBlocks` 53 | $accountExistsQ = mysql_query("SELECT id FROM winning_shares WHERE txid = '".$transactions[$i]["txid"]."' ORDER BY blockNumber DESC LIMIT 0,1"); 54 | $accountExists = mysql_num_rows($accountExistsQ); 55 | //Insert txid into latest network block 56 | if (!$accountExists) { 57 | //Get last winning block 58 | $lastSuccessfullBlockQ = mysql_query("SELECT n.id, w.id as winningid FROM networkBlocks n, winning_shares w where n.blockNumber = w.blockNumber ORDER BY w.id DESC LIMIT 1"); 59 | $lastSuccessfullBlockR = mysql_fetch_object($lastSuccessfullBlockQ); 60 | $lastEmptyBlock = $lastSuccessfullBlockR->id; 61 | $winningid = $lastSuccessfullBlockR->winningid; 62 | mysql_query("UPDATE winning_shares SET amount = '".$transactions[$i]["amount"]."', txid = '".$transactions[$i]["txid"]."' WHERE id = $winningid")or die(mysql_error()); 63 | } 64 | } 65 | } 66 | } 67 | 68 | function CheckUnrewardedBlocks() { 69 | $result = mysql_query("SELECT id FROM winning_shares WHERE rewarded = 'N' AND confirms > 119 LIMIT 0,1") or die(mysql_error()); 70 | if ($row = mysql_fetch_object($result)) 71 | return true; 72 | return false; 73 | } 74 | 75 | function CheckUnscoredBlocks() { 76 | $result = mysql_query("SELECT id FROM winning_shares WHERE scored = 'N' LIMIT 0,1") or die(mysql_error()); 77 | if ($row = mysql_fetch_object($result)) 78 | return true; 79 | return false; 80 | } 81 | 82 | function NeedsArchiving($siterewardtype, $difficulty) { 83 | if ($siterewardtype == 0) { 84 | $sharesDesired = $difficulty/2; 85 | $result = mysql_query("SELECT share_id, rewarded FROM winning_shares ORDER BY id DESC"); 86 | while ($row = mysql_fetch_object($result)) { 87 | if ($row->rewarded == 'N') { 88 | $result2 = mysql_query("SELECT count(id) FROM shares WHERE id < $row->share_id and our_result='Y'"); 89 | if ($row2 = mysql_fetch_row($result2)) { 90 | if ($row2[0] < $sharesDesired) 91 | return false; 92 | } 93 | } else { 94 | $result2 = mysql_query("SELECT count(id) FROM shares WHERE id > $row->share_id and our_result='Y'"); 95 | if ($row2 = mysql_fetch_row($result2)) { 96 | if ($row2[0] > $sharesDesired) 97 | return true; 98 | } 99 | } 100 | } 101 | } else { 102 | $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"); 103 | $row = mysql_fetch_row($result); 104 | if ($row[0] > 0) 105 | return true; 106 | } 107 | return false; 108 | } 109 | 110 | function Archive($siterewardtype, $difficulty) { 111 | //echo "Archival requested\n"; 112 | $maxShareId = 0; 113 | $blockNumber = 0; 114 | //Get count since last winning share 115 | if ($siterewardtype == 0) { 116 | //Last N Shares 117 | $sharesDesired = round($difficulty/2); 118 | //echo "Desired Shares: $sharesDesired\n"; 119 | $result = mysql_query("SELECT share_id, blockNumber FROM winning_shares WHERE rewarded = 'Y' ORDER BY id DESC"); 120 | while ($row = mysql_fetch_object($result)) { 121 | $result2 = mysql_query("SELECT count(id) FROM shares WHERE id > $row->share_id and our_result='Y'"); 122 | if ($row2 = mysql_fetch_row($result2)) { 123 | if ($row2[0] > $sharesDesired) { 124 | $maxShareId = $row->share_id; 125 | $blockNumber = $row->blockNumber; 126 | break; 127 | } 128 | } 129 | } 130 | } else { 131 | $result = mysql_query("SELECT max(share_id), max(blockNumber) FROM winning_shares WHERE rewarded='Y'"); 132 | if ($row = mysql_fetch_row($result)) { 133 | $maxShareId = $row[0]; 134 | $blockNumber = $row[1]; 135 | } 136 | } 137 | if ($maxShareId > 0 && $blockNumber > 0) { 138 | //echo "Archiving\n"; 139 | //echo "Share Id: $maxShareId\n"; 140 | //echo "Block Number: $blockNumber\n"; 141 | //get counted shares by user id and move to shares_counted 142 | $sql = "SELECT p.associatedUserId, sum(s.valid) as valid, IFNULL(sum(si.invalid),0) as invalid FROM ". 143 | "(SELECT username, count(id) as valid FROM shares WHERE id <= $maxShareId AND our_result='Y' GROUP BY username) s LEFT JOIN ". 144 | "(SELECT username, count(id) as invalid FROM shares WHERE id <= $maxShareId AND our_result='N' GROUP BY username) si ON s.username=si.username ". 145 | "INNER JOIN pool_worker p ON p.username = s.username ". 146 | "GROUP BY associatedUserId"; 147 | $sharesQ = mysql_query($sql); 148 | $i = 0; 149 | $shareInputSql = ""; 150 | while ($sharesR = mysql_fetch_object($sharesQ)) { 151 | if ($i == 0) { 152 | $shareInputSql = "INSERT INTO shares_counted (blockNumber, userId, count, invalid) VALUES "; 153 | } 154 | if ($i > 0) { 155 | $shareInputSql .= ","; 156 | } 157 | $i++; 158 | $shareInputSql .= "($blockNumber,$sharesR->associatedUserId,$sharesR->valid,$sharesR->invalid)"; 159 | if ($i > 20) 160 | { 161 | echo "$shareInputSql\n"; 162 | mysql_query($shareInputSql); 163 | $shareInputSql = ""; 164 | $i = 0; 165 | } 166 | } 167 | if (strlen($shareInputSql) > 0) { 168 | echo "$shareInputSql\n"; 169 | mysql_query($shareInputSql); 170 | } 171 | 172 | //Remove counted shares from shares_history 173 | //echo "DELETE FROM shares WHERE id <= $maxShareId\n"; 174 | mysql_query("DELETE FROM shares WHERE id <= $maxShareId"); 175 | } 176 | } 177 | } 178 | ?> -------------------------------------------------------------------------------- /includes/mtgox.php: -------------------------------------------------------------------------------- 1 | 11 | * @copyright UKD1 Limited 2011 12 | * @license licence.txt ISC license 13 | * @see https://www.mtgox.com/support/tradeAPI 14 | * @see https://github.com/ukd1/Mt-Gox-Trade-API-PHP-Client 15 | */ 16 | 17 | 18 | /** 19 | * Order class for Mt Gox Orders 20 | * 21 | * @author Russell Smith 22 | * @copyright UKD1 Limited 2011 23 | * @license licence.txt ISC license 24 | * @see https://www.mtgox.com/support/tradeAPI 25 | * @see https://github.com/ukd1/Mt-Gox-Trade-API-PHP-Client 26 | */ 27 | class mtgox_order extends mtgox_base 28 | { 29 | private $data; 30 | 31 | /** 32 | * 33 | * 34 | * @param $user username for Mt Gox 35 | * @param $pass password for Mt Gox 36 | * @param null $data array of data about the order 37 | */ 38 | public function __construct ($user, $pass, $data = null) 39 | { 40 | $this->user = $user; 41 | $this->pass = $pass; 42 | $this->data = $data; 43 | } 44 | 45 | public function __get ($key) 46 | { 47 | return isset($this->data[$key]) ? $this->data[$key] : null; 48 | } 49 | 50 | /** 51 | * Is this a sell order? 52 | * @return bool 53 | */ 54 | public function is_sell_order () 55 | { 56 | return $this->data['type'] === self::SELL_ORDER; 57 | } 58 | 59 | /** 60 | * Is this a buy order? 61 | * @return bool 62 | */ 63 | public function is_buy_order () 64 | { 65 | return $this->data['type'] === self::BUY_ORDER; 66 | } 67 | 68 | /** 69 | * Cancel the order over the API 70 | * @return bool true on success 71 | */ 72 | public function cancel () 73 | { 74 | return is_array($this->_post('cancelOrder.php', array('oid' => $this->data['oid'], 'type' => $this->data['type']))); 75 | } 76 | } 77 | 78 | /** 79 | * Mt Gox Trade API implementation 80 | * 81 | * @author Russell Smith 82 | * @copyright UKD1 Limited 2011 83 | * @license licence.txt ISC license 84 | * @see https://www.mtgox.com/support/tradeAPI 85 | * @see https://github.com/ukd1/Mt-Gox-Trade-API-PHP-Client 86 | */ 87 | class mtgox extends mtgox_base 88 | { 89 | /** 90 | * @param string $user username 91 | * @param string $pass password 92 | */ 93 | public function __construct ($user, $pass) 94 | { 95 | $this->user = $user; 96 | $this->pass = $pass; 97 | } 98 | 99 | /** 100 | * Get your current balance 101 | * 102 | * @return array An array of your current USD / BTC balance 103 | */ 104 | public function balance () 105 | { 106 | return $this->_post('getFunds.php'); 107 | 108 | } 109 | 110 | /** 111 | * Request a transfer of BTC 112 | * 113 | * @param string $address BTC address to transfer to 114 | * @param float $amount amount of BTC to transfer 115 | * @return array|false 116 | */ 117 | public function widthdraw ($address, $amount) 118 | { 119 | return $this->_post('withdraw.php', array('bitcoin_address_to_send_to' => $address, 'amount' => $amount)); 120 | } 121 | 122 | /** 123 | * Return an array of your current orders 124 | * 125 | * @param int $oid optionally just return a single order 126 | * @return array 127 | */ 128 | public function orders () 129 | { 130 | $response = $this->_post('getOrders.php', array('amount' => '#', 'price' => '#')); 131 | 132 | $orders = array(); 133 | foreach ($response['orders'] as $_order) 134 | { 135 | $orders[] = new mtgox_order($this->user, $this->pass, $_order); 136 | } 137 | 138 | return $orders; 139 | } 140 | 141 | /** 142 | * Create a buy order for amount @ price 143 | * 144 | * @param int $amount amount of BTC to buy 145 | * @param float $price price to buy BTC at 146 | * @return array|bool 147 | */ 148 | public function buy ($amount, $price) 149 | { 150 | return $this->_post('buyBTC.php', array('amount' => $amount, 'price' => $price)); 151 | } 152 | 153 | /** 154 | * Create a sell order for amount @ price 155 | * 156 | * @param int $amount amount of BTC to sell 157 | * @param float $price price to sell BTC at 158 | * @return array|bool 159 | */ 160 | public function sell ($amount, $price) 161 | { 162 | return $this->_post('sellBTC.php', array('amount' => $amount, 'price' => $price)); 163 | } 164 | 165 | /** 166 | * Return an array of ticker data 167 | * 168 | * @return array 169 | */ 170 | public function ticker () 171 | { 172 | $ticker = $this->_get('data/ticker.php'); 173 | 174 | return $ticker['ticker']; 175 | } 176 | 177 | /** 178 | * Return an array of market depth data 179 | * @return array 180 | */ 181 | public function depth () 182 | { 183 | return $this->_get('data/getDepth.php'); 184 | } 185 | 186 | /** 187 | * Return an array of asks / bids 188 | * @return array 189 | */ 190 | public function trades () 191 | { 192 | return $this->_get('data/getTrades.php'); 193 | } 194 | 195 | } 196 | 197 | 198 | /** 199 | * Abstract class which the main / order class extend 200 | * 201 | * @author Russell Smith 202 | * @copyright UKD1 Limited 2011 203 | * @license licence.txt ISC license 204 | * @see https://www.mtgox.com/support/tradeAPI 205 | * @see https://github.com/ukd1/Mt-Gox-Trade-API-PHP-Client 206 | */ 207 | abstract class mtgox_base 208 | { 209 | /** 210 | * @var username to use for authentication against the API 211 | */ 212 | protected $user; 213 | 214 | /** 215 | * @var password to use for authentication against the API 216 | */ 217 | protected $pass; 218 | 219 | /** 220 | * Current Mt Gox fee in percent (unused) 221 | */ 222 | const MTGOX_FEE = 0.0065; 223 | 224 | /** 225 | * Mt Gox endpoint for the API 226 | */ 227 | const ENDPOINT = 'https://www.mtgox.com/code/'; 228 | 229 | /** 230 | * A timeout to control how long to wait for the API to respond in seconds 231 | */ 232 | const TIMEOUT = 3; 233 | 234 | /** 235 | * User agent string which is sent which all requests 236 | */ 237 | const USERAGENT = 'UKD1 MTGOX Client'; 238 | 239 | /** 240 | * Sell Order type 241 | */ 242 | const SELL_ORDER = 1; 243 | 244 | /** 245 | * Buy order type 246 | */ 247 | const BUY_ORDER = 2; 248 | 249 | /** 250 | * Order status ACTIVE 251 | */ 252 | const STATUS_ACTIVE = 1; 253 | 254 | /** 255 | * Order status INACTIVE (insufficent funds) 256 | */ 257 | const STATUS_INSUFFICENT_FUNDS = 2; 258 | 259 | /** 260 | * Do a HTTP POST to the specified URI 261 | * 262 | * @param string $uri uri to post to (appended to the endpoint) 263 | * @param array $data array of post fields to pass 264 | * @return bool|array 265 | */ 266 | protected function _post ($uri, $data = array()) 267 | { 268 | $data['name'] = $this->user; 269 | $data['pass'] = $this->pass; 270 | 271 | $r = $this->_http('POST', $uri, $data); 272 | 273 | if ($r['http_code'] === 200) 274 | { 275 | return json_decode($r['result'], true); 276 | } 277 | else 278 | { 279 | return false; 280 | } 281 | } 282 | 283 | /** 284 | * Perform an HTTP GET 285 | * 286 | * @param $uri URI to get, appended to the endpoint url 287 | * @param array $data get parameters 288 | * @return bool|array 289 | */ 290 | protected function _get ($uri, $data = array()) 291 | { 292 | $r = $this->_http('GET', $uri, $data); 293 | 294 | if ($r['http_code'] === 200) 295 | { 296 | return json_decode($r['result'], true); 297 | } 298 | else 299 | { 300 | return false; 301 | } 302 | } 303 | 304 | /** 305 | * perform a HTTP request 306 | * 307 | * @param string $method HTTP method to use, currently supports GET|POST 308 | * @param string $uri URI to append to the endppint 309 | * @param array $data single dimensional key / value pairs of data to pass 310 | * @return array 311 | */ 312 | protected function _http ($method, $uri, $data) 313 | { 314 | $url = self::ENDPOINT . $uri; 315 | 316 | $ch = curl_init(); 317 | curl_setopt($ch, CURLOPT_USERAGENT, self::USERAGENT); 318 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); 319 | curl_setopt($ch, CURLOPT_FOLLOWLOCATION, FALSE); 320 | curl_setopt($ch, CURLOPT_TIMEOUT, self::TIMEOUT); 321 | 322 | 323 | switch ($method) 324 | { 325 | case 'POST': 326 | $post_fields = array(); 327 | foreach ($data as $k=>$v) { 328 | array_push($post_fields, "$k=$v"); 329 | } 330 | $post_fields = implode('&', $post_fields); 331 | 332 | curl_setopt($ch, CURLOPT_URL, $url); 333 | curl_setopt($ch, CURLOPT_POST, TRUE); 334 | curl_setopt($ch, CURLOPT_POSTFIELDS, $post_fields); 335 | break; 336 | 337 | case 'GET': 338 | default: 339 | $get_fields = array(); 340 | foreach ($data as $k=>$v) { 341 | array_push($get_fields, "$k=$v"); 342 | } 343 | $url .= '?' . implode('&', $get_fields); 344 | 345 | curl_setopt($ch, CURLOPT_URL, $url); 346 | } 347 | 348 | $result = curl_exec ($ch); 349 | 350 | $tmp = curl_getinfo($ch); 351 | $tmp['result'] = $result; 352 | curl_close ($ch); 353 | 354 | return $tmp; 355 | } 356 | 357 | } 358 | -------------------------------------------------------------------------------- /includes/requiredFunctions.php: -------------------------------------------------------------------------------- 1 | addServer("localhost",11212); 59 | 60 | //Encrypt settings 61 | $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." 62 | 63 | /////////////////////////////////////////////////////////////////////NO NEED TO MESS WITH THE FOLLOWING | FOR DEVELOPERS ONLY/////////////////////////////////////////////////////////////////// 64 | 65 | $cookieValid = false; //Don't touch leave as: false 66 | 67 | //Connect to Main Db 68 | connectToDb(); 69 | 70 | //New PDO connection for readaccess (fallback to local if unavailable) 71 | try { 72 | $read_only_db = new PDO('mysql:dbname='.$readOnlyDbName.';host='.$readOnlyDbHost.';port='.$readOnlyDbPort, $readOnlyDbUsername, $readOnlyDbPassword); 73 | } catch (Exception $e) { 74 | $read_only_db = new PDO('mysql:dbname='.$dbDatabasename.';host='.$dbHost.';port='.$dbPort, $dbUsername, $dbPassword); 75 | } 76 | 77 | include('settings.php'); 78 | $settings = new Settings(); 79 | 80 | //Open a bitcoind connection 81 | $bitcoinController = new BitcoinClient($rpcType, $rpcUsername, $rpcPassword, $rpcHost, $rpcPort); 82 | 83 | //setup bitcoinDifficulty cache object 84 | $bitcoinDifficulty = GetCachedBitcoinDifficulty(); 85 | 86 | function connectToDb(){ 87 | //Set variables to global retireve outside of the scope 88 | global $dbHost, $dbUsername, $dbPassword, $dbDatabasename; 89 | 90 | //Connect to database 91 | mysql_connect($dbHost, $dbUsername, $dbPassword)or die(mysql_error()); 92 | mysql_select_db($dbDatabasename); 93 | } 94 | 95 | class checkLogin 96 | { 97 | function checkCookie($input, $ipaddress){ 98 | global $salt; 99 | connectToDb(); 100 | /*$input comes in the following format userId-passwordhash 101 | 102 | /*Validate that the cookie hash meets the following criteria: 103 | Cookie Ip: matches $ipaddres; 104 | Cookie Timeout: Is still greater then the current time(); 105 | Cookie Secret: matches the mysql database secret; 106 | */ 107 | 108 | //Split cookie into 2 mmmmm! 109 | $cookieInfo = explode("-", $input); 110 | 111 | $validCookie = false; 112 | 113 | //Get "secret" from MySql database 114 | $tempId = mysql_real_escape_string($cookieInfo[0]); 115 | if (!is_numeric($tempId)) { 116 | $tempId = 0; 117 | return false; 118 | } 119 | $getSecretQ = mysql_query("SELECT secret, pass, sessionTimeoutStamp FROM webUsers WHERE id = $tempId LIMIT 0,1"); 120 | if ($getSecret = mysql_fetch_object($getSecretQ)) { 121 | $password = $getSecret->pass; 122 | $secret = $getSecret->secret; 123 | $timeoutStamp = $getSecret->sessionTimeoutStamp; 124 | 125 | //Create a variable to test the cookie hash against 126 | $hashTest = hash("sha256", $secret.$password.$ipaddress.$timeoutStamp.$salt); 127 | 128 | //Test if $hashTest = $cookieInfo[1] hash value; return results 129 | if($hashTest == $cookieInfo[1]){ 130 | $validCookie = true; 131 | } 132 | } 133 | return $validCookie; 134 | } 135 | 136 | function returnUserId($input){ 137 | //Just split the cookie to get the userId 138 | $cookieInfo = explode("-", $input); 139 | 140 | return $cookieInfo[0]; 141 | } 142 | } 143 | 144 | function outputPageTitle(){ 145 | if (!isset($settings)) 146 | { 147 | connectToDb(); 148 | $settings = new Settings(); 149 | } 150 | //Get page title 151 | return $settings->getsetting("pagetitle");; 152 | } 153 | 154 | function outputHeaderTitle(){ 155 | if (!isset($settings)) 156 | { 157 | connectToDb(); 158 | $settings = new Settings(); 159 | } 160 | return $settings->getsetting("websitename"); 161 | } 162 | 163 | //Helpfull functions 164 | function genRandomString($length=10) { 165 | $characters = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; 166 | $string = ""; 167 | 168 | for ($p = 0; $p < $length; $p++) { 169 | $string .= $characters[mt_rand(0, strlen($characters) - 1)]; 170 | } 171 | 172 | return $string; 173 | } 174 | 175 | 176 | function antiXss($input) { 177 | //strip HTML tags from input data 178 | return htmlentities(strip_tags($input), ENT_QUOTES); 179 | } 180 | 181 | function sqlerr($file = '', $line = '') 182 | { 183 | print("" . 184 | "

SQL Error

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

in $file, line $line

" : "") . "
"); 186 | die; 187 | } 188 | 189 | $_current_lock = null; 190 | 191 | function islocked($name) { 192 | $result = mysql_query("SELECT locked FROM locks WHERE name ='$name' and locked=1 LIMIT 1"); 193 | if (!$result || mysql_numrows($result) == 0) 194 | return false; 195 | return true; 196 | } 197 | 198 | function unlock() { 199 | global $_current_lock; 200 | mysql_query("UNLOCK TABLES"); 201 | $sql = "UPDATE locks SET locked = 0 WHERE name = '" . mysql_real_escape_string($_current_lock) . "'"; 202 | mysql_query($sql); 203 | } 204 | 205 | function lock($name) { 206 | global $_current_lock; 207 | mysql_query("LOCK TABLES locks WRITE"); 208 | $q = mysql_query("SELECT locked FROM locks WHERE name = '" . mysql_real_escape_string($name) . "'"); 209 | 210 | $lock = mysql_fetch_object($q); 211 | if ($lock === false) { 212 | mysql_query("INSERT INTO locks (name, locked) VALUES ('".mysql_real_escape_string($name)."', 1)"); 213 | } elseif ($lock->locked) { 214 | echo("Lock already held, exiting. (".$name.")"); 215 | mysql_query("UNLOCK TABLES"); 216 | exit(); 217 | return; 218 | } else { 219 | mysql_query("UPDATE locks SET locked = 1 WHERE name = '" . mysql_real_escape_string($name) . "'"); 220 | } 221 | 222 | //mysql_query("UNLOCK TABLES"); 223 | $_current_lock = $name; 224 | register_shutdown_function('unlock'); 225 | } 226 | 227 | function ScriptIsRunLocally() { 228 | if (isset($_SERVER['REMOTE_ADDR']) && $_SERVER['REMOTE_ADDR'] != "127.0.0.1") { 229 | echo "This script can only be run locally."; 230 | exit; 231 | } 232 | } 233 | 234 | //Cache functions 235 | 236 | # Gets key / value pair into memcache ... called by mysql_query_cache() 237 | function getCache($key) { 238 | global $memcache; 239 | return ($memcache) ? $memcache->get($key) : false; 240 | } 241 | 242 | # Puts key / value pair into memcache ... called by mysql_query_cache() 243 | function setCache($key, $object, $timeout = 600) { 244 | global $memcache; 245 | return ($memcache) ? $memcache->set($key, $object, $timeout) : false; 246 | } 247 | 248 | function removeCache($key) { 249 | global $memcache; 250 | $memcache->delete($key); 251 | } 252 | 253 | function removeSqlCache($key) { 254 | global $memcache; 255 | $memcache->delete(md5("mysql_query".$key)); 256 | } 257 | 258 | # Caching version of mysql_query() 259 | function mysql_query_cache($sql, $timeout = 600) { 260 | if($objResultset = unserialize(getCache(md5("mysql_query".$sql)))) { 261 | return $objResultset; 262 | } 263 | $objResultSet = mysql_query($sql); 264 | $objarray = Array(); 265 | while ($row = mysql_fetch_object($objResultSet)) { 266 | $objarray[] = $row; 267 | } 268 | setCache(md5("mysql_query".$sql), serialize($objarray), $timeout); 269 | return $objarray; 270 | } 271 | 272 | function GetCachedBitcoinDifficulty() { 273 | global $bitcoinController; 274 | $difficulty = 0; 275 | if (!($difficulty = getCache("bitcoinDifficulty"))) { 276 | $difficulty = $bitcoinController->query("getdifficulty"); 277 | setCache("bitcoinDifficulty", $difficulty, 60); 278 | } 279 | return $difficulty; 280 | } 281 | 282 | ?> 283 | -------------------------------------------------------------------------------- /sql/simplecoin-v5.sql: -------------------------------------------------------------------------------- 1 | -- MySQL dump 10.13 Distrib 5.1.54, for debian-linux-gnu (x86_64) 2 | -- 3 | -- Host: localhost Database: simplecoin 4 | -- ------------------------------------------------------ 5 | -- Server version 5.1.54-1ubuntu4-log 6 | 7 | /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; 8 | /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; 9 | /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; 10 | /*!40101 SET NAMES utf8 */; 11 | /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; 12 | /*!40103 SET TIME_ZONE='+00:00' */; 13 | /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; 14 | /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; 15 | /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; 16 | /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; 17 | 18 | -- 19 | -- Table structure for table `accountBalance` 20 | -- 21 | 22 | DROP TABLE IF EXISTS `accountBalance`; 23 | /*!40101 SET @saved_cs_client = @@character_set_client */; 24 | /*!40101 SET character_set_client = utf8 */; 25 | CREATE TABLE `accountBalance` ( 26 | `id` int(255) NOT NULL AUTO_INCREMENT, 27 | `userId` int(255) NOT NULL, 28 | `balance` varchar(40) DEFAULT NULL, 29 | `sendAddress` varchar(255) DEFAULT '', 30 | `paid` varchar(40) DEFAULT '0', 31 | `threshold` tinyint(4) DEFAULT '0', 32 | PRIMARY KEY (`id`), 33 | UNIQUE KEY `userId` (`userId`), 34 | KEY `b_userId` (`userId`) 35 | ) ENGINE=MyISAM AUTO_INCREMENT=706 DEFAULT CHARSET=latin1; 36 | /*!40101 SET character_set_client = @saved_cs_client */; 37 | 38 | -- 39 | -- Dumping data for table `accountBalance` 40 | -- 41 | -- WHERE: 1=0 42 | 43 | LOCK TABLES `accountBalance` WRITE; 44 | /*!40000 ALTER TABLE `accountBalance` DISABLE KEYS */; 45 | /*!40000 ALTER TABLE `accountBalance` ENABLE KEYS */; 46 | UNLOCK TABLES; 47 | 48 | -- 49 | -- Table structure for table `locks` 50 | -- 51 | 52 | DROP TABLE IF EXISTS `locks`; 53 | /*!40101 SET @saved_cs_client = @@character_set_client */; 54 | /*!40101 SET character_set_client = utf8 */; 55 | CREATE TABLE `locks` ( 56 | `name` varchar(11) NOT NULL, 57 | `locked` tinyint(4) NOT NULL, 58 | PRIMARY KEY (`name`) 59 | ) ENGINE=MyISAM DEFAULT CHARSET=utf8; 60 | /*!40101 SET character_set_client = @saved_cs_client */; 61 | 62 | -- 63 | -- Dumping data for table `locks` 64 | -- 65 | -- WHERE: 1=0 66 | 67 | LOCK TABLES `locks` WRITE; 68 | /*!40000 ALTER TABLE `locks` DISABLE KEYS */; 69 | /*!40000 ALTER TABLE `locks` ENABLE KEYS */; 70 | UNLOCK TABLES; 71 | 72 | -- 73 | -- Table structure for table `networkBlocks` 74 | -- 75 | 76 | DROP TABLE IF EXISTS `networkBlocks`; 77 | /*!40101 SET @saved_cs_client = @@character_set_client */; 78 | /*!40101 SET character_set_client = utf8 */; 79 | CREATE TABLE `networkBlocks` ( 80 | `id` int(255) NOT NULL AUTO_INCREMENT, 81 | `blockNumber` int(255) NOT NULL, 82 | `timestamp` int(255) NOT NULL, 83 | PRIMARY KEY (`id`) 84 | ) ENGINE=MyISAM AUTO_INCREMENT=5876 DEFAULT CHARSET=latin1; 85 | /*!40101 SET character_set_client = @saved_cs_client */; 86 | 87 | -- 88 | -- Dumping data for table `networkBlocks` 89 | -- 90 | -- WHERE: 1=0 91 | 92 | LOCK TABLES `networkBlocks` WRITE; 93 | /*!40000 ALTER TABLE `networkBlocks` DISABLE KEYS */; 94 | /*!40000 ALTER TABLE `networkBlocks` ENABLE KEYS */; 95 | UNLOCK TABLES; 96 | 97 | -- 98 | -- Table structure for table `news` 99 | -- 100 | 101 | DROP TABLE IF EXISTS `news`; 102 | /*!40101 SET @saved_cs_client = @@character_set_client */; 103 | /*!40101 SET character_set_client = utf8 */; 104 | CREATE TABLE `news` ( 105 | `id` int(10) NOT NULL AUTO_INCREMENT, 106 | `message` varchar(255) NOT NULL, 107 | `timestap` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, 108 | `title` varchar(255) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL DEFAULT ' ', 109 | PRIMARY KEY (`id`) 110 | ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=latin1; 111 | /*!40101 SET character_set_client = @saved_cs_client */; 112 | 113 | -- 114 | -- Dumping data for table `news` 115 | -- 116 | -- WHERE: 1=0 117 | 118 | LOCK TABLES `news` WRITE; 119 | /*!40000 ALTER TABLE `news` DISABLE KEYS */; 120 | /*!40000 ALTER TABLE `news` ENABLE KEYS */; 121 | UNLOCK TABLES; 122 | 123 | -- 124 | -- Table structure for table `pool_worker` 125 | -- 126 | 127 | DROP TABLE IF EXISTS `pool_worker`; 128 | /*!40101 SET @saved_cs_client = @@character_set_client */; 129 | /*!40101 SET character_set_client = utf8 */; 130 | CREATE TABLE `pool_worker` ( 131 | `id` int(255) NOT NULL AUTO_INCREMENT, 132 | `associatedUserId` int(255) NOT NULL, 133 | `username` char(50) DEFAULT NULL, 134 | `password` char(255) DEFAULT NULL, 135 | `allowed_hosts` text, 136 | PRIMARY KEY (`id`), 137 | KEY `p_username` (`username`), 138 | KEY `pool_worker_associatedUserId` (`associatedUserId`), 139 | KEY `pool_worker_username` (`username`) 140 | ) ENGINE=MyISAM AUTO_INCREMENT=1398 DEFAULT CHARSET=latin1; 141 | /*!40101 SET character_set_client = @saved_cs_client */; 142 | 143 | -- 144 | -- Dumping data for table `pool_worker` 145 | -- 146 | -- WHERE: 1=0 147 | 148 | LOCK TABLES `pool_worker` WRITE; 149 | /*!40000 ALTER TABLE `pool_worker` DISABLE KEYS */; 150 | /*!40000 ALTER TABLE `pool_worker` ENABLE KEYS */; 151 | UNLOCK TABLES; 152 | 153 | -- 154 | -- Table structure for table `settings` 155 | -- 156 | 157 | DROP TABLE IF EXISTS `settings`; 158 | /*!40101 SET @saved_cs_client = @@character_set_client */; 159 | /*!40101 SET character_set_client = utf8 */; 160 | CREATE TABLE `settings` ( 161 | `setting` varchar(255) NOT NULL, 162 | `value` varchar(255) DEFAULT NULL, 163 | PRIMARY KEY (`setting`), 164 | KEY `set_setting` (`setting`) 165 | ) ENGINE=MyISAM DEFAULT CHARSET=latin1; 166 | /*!40101 SET character_set_client = @saved_cs_client */; 167 | 168 | -- 169 | -- Dumping data for table `settings` 170 | -- 171 | -- WHERE: 1=0 172 | 173 | LOCK TABLES `settings` WRITE; 174 | /*!40000 ALTER TABLE `settings` DISABLE KEYS */; 175 | /*!40000 ALTER TABLE `settings` ENABLE KEYS */; 176 | UNLOCK TABLES; 177 | 178 | -- 179 | -- Table structure for table `shares` 180 | -- 181 | 182 | DROP TABLE IF EXISTS `shares`; 183 | /*!40101 SET @saved_cs_client = @@character_set_client */; 184 | /*!40101 SET character_set_client = utf8 */; 185 | CREATE TABLE `shares` ( 186 | `id` bigint(30) NOT NULL AUTO_INCREMENT, 187 | `rem_host` varchar(255) NOT NULL, 188 | `username` varchar(120) NOT NULL, 189 | `our_result` enum('Y','N') NOT NULL, 190 | `upstream_result` enum('Y','N') DEFAULT NULL, 191 | `reason` varchar(50) DEFAULT NULL, 192 | `solution` varchar(257) NOT NULL, 193 | `time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, 194 | PRIMARY KEY (`id`), 195 | KEY `shares_username` (`username`), 196 | KEY `shares_time` (`time`), 197 | KEY `shares_our_result` (`our_result`) 198 | ) ENGINE=InnoDB AUTO_INCREMENT=17615344 DEFAULT CHARSET=latin1; 199 | /*!40101 SET character_set_client = @saved_cs_client */; 200 | 201 | -- 202 | -- Dumping data for table `shares` 203 | -- 204 | -- WHERE: 1=0 205 | 206 | LOCK TABLES `shares` WRITE; 207 | /*!40000 ALTER TABLE `shares` DISABLE KEYS */; 208 | /*!40000 ALTER TABLE `shares` ENABLE KEYS */; 209 | UNLOCK TABLES; 210 | 211 | -- 212 | -- Table structure for table `shares_counted` 213 | -- 214 | 215 | DROP TABLE IF EXISTS `shares_counted`; 216 | /*!40101 SET @saved_cs_client = @@character_set_client */; 217 | /*!40101 SET character_set_client = utf8 */; 218 | CREATE TABLE `shares_counted` ( 219 | `id` int(11) NOT NULL AUTO_INCREMENT, 220 | `blockNumber` int(11) NOT NULL, 221 | `userId` int(11) NOT NULL, 222 | `count` int(11) NOT NULL, 223 | `invalid` int(11) NOT NULL DEFAULT '0', 224 | PRIMARY KEY (`id`) 225 | ) ENGINE=MyISAM AUTO_INCREMENT=614 DEFAULT CHARSET=utf8; 226 | /*!40101 SET character_set_client = @saved_cs_client */; 227 | 228 | -- 229 | -- Dumping data for table `shares_counted` 230 | -- 231 | -- WHERE: 1=0 232 | 233 | LOCK TABLES `shares_counted` WRITE; 234 | /*!40000 ALTER TABLE `shares_counted` DISABLE KEYS */; 235 | /*!40000 ALTER TABLE `shares_counted` ENABLE KEYS */; 236 | UNLOCK TABLES; 237 | 238 | -- 239 | -- Table structure for table `unconfirmed_rewards` 240 | -- 241 | 242 | DROP TABLE IF EXISTS `unconfirmed_rewards`; 243 | /*!40101 SET @saved_cs_client = @@character_set_client */; 244 | /*!40101 SET character_set_client = utf8 */; 245 | CREATE TABLE `unconfirmed_rewards` ( 246 | `id` int(255) NOT NULL AUTO_INCREMENT, 247 | `userId` int(255) NOT NULL, 248 | `blockNumber` int(255) NOT NULL, 249 | `amount` varchar(40) NOT NULL, 250 | `rewarded` enum('N','Y') NOT NULL DEFAULT 'N', 251 | `shares` int(255) NOT NULL DEFAULT '0', 252 | PRIMARY KEY (`id`), 253 | KEY `unconfirmed_rewards_blockNumber` (`blockNumber`), 254 | KEY `unconfirmed_rewards_rewarded` (`rewarded`), 255 | KEY `unconfirmed_rewards_userId` (`userId`) 256 | ) ENGINE=InnoDB DEFAULT CHARSET=latin1; 257 | /*!40101 SET character_set_client = @saved_cs_client */; 258 | 259 | -- 260 | -- Dumping data for table `unconfirmed_rewards` 261 | -- 262 | -- WHERE: 1=0 263 | 264 | LOCK TABLES `unconfirmed_rewards` WRITE; 265 | /*!40000 ALTER TABLE `unconfirmed_rewards` DISABLE KEYS */; 266 | /*!40000 ALTER TABLE `unconfirmed_rewards` ENABLE KEYS */; 267 | UNLOCK TABLES; 268 | 269 | -- 270 | -- Table structure for table `userHashrates` 271 | -- 272 | 273 | DROP TABLE IF EXISTS `userHashrates`; 274 | /*!40101 SET @saved_cs_client = @@character_set_client */; 275 | /*!40101 SET character_set_client = utf8 */; 276 | CREATE TABLE `userHashrates` ( 277 | `id` int(10) unsigned NOT NULL AUTO_INCREMENT, 278 | `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, 279 | `userId` int(255) NOT NULL, 280 | `hashrate` int(11) NOT NULL DEFAULT '0', 281 | PRIMARY KEY (`id`), 282 | KEY `timestamp` (`timestamp`), 283 | KEY `userHashrates_id1` (`userId`), 284 | KEY `userId_timestamp` (`userId`,`timestamp`) 285 | ) ENGINE=InnoDB AUTO_INCREMENT=2253830 DEFAULT CHARSET=latin1; 286 | /*!40101 SET character_set_client = @saved_cs_client */; 287 | 288 | -- 289 | -- Dumping data for table `userHashrates` 290 | -- 291 | -- WHERE: 1=0 292 | 293 | LOCK TABLES `userHashrates` WRITE; 294 | /*!40000 ALTER TABLE `userHashrates` DISABLE KEYS */; 295 | /*!40000 ALTER TABLE `userHashrates` ENABLE KEYS */; 296 | UNLOCK TABLES; 297 | 298 | -- 299 | -- Table structure for table `webUsers` 300 | -- 301 | 302 | DROP TABLE IF EXISTS `webUsers`; 303 | /*!40101 SET @saved_cs_client = @@character_set_client */; 304 | /*!40101 SET character_set_client = utf8 */; 305 | CREATE TABLE `webUsers` ( 306 | `id` int(255) NOT NULL AUTO_INCREMENT, 307 | `admin` int(1) NOT NULL, 308 | `username` varchar(40) NOT NULL, 309 | `pass` varchar(255) NOT NULL, 310 | `email` varchar(255) NOT NULL COMMENT 'Assocaited email: used for validating users, and re-setting passwords', 311 | `emailAuthPin` varchar(10) NOT NULL COMMENT 'The pin required to authorize that email address', 312 | `secret` varchar(10) NOT NULL, 313 | `loggedIp` varchar(255) NOT NULL, 314 | `sessionTimeoutStamp` int(255) NOT NULL, 315 | `accountLocked` int(255) NOT NULL COMMENT 'This is the timestamp when the account will be unlocked(usually used to lock accounts that are trying to be bruteforced)', 316 | `accountFailedAttempts` int(2) NOT NULL COMMENT 'This counts the number of failed attempts for web login', 317 | `pin` varchar(255) NOT NULL COMMENT 'four digit pin to allow account changes', 318 | `share_count` int(11) NOT NULL DEFAULT '0', 319 | `stale_share_count` int(11) NOT NULL DEFAULT '0', 320 | `shares_this_round` int(11) NOT NULL DEFAULT '0', 321 | `api_key` varchar(255) CHARACTER SET latin1 COLLATE latin1_bin DEFAULT NULL, 322 | `activeEmail` int(1) DEFAULT NULL, 323 | `donate_percent` varchar(11) DEFAULT '1', 324 | `btc_lock` enum('0','1') NOT NULL DEFAULT '0', 325 | PRIMARY KEY (`id`), 326 | KEY `u_username` (`username`) 327 | ) ENGINE=MyISAM AUTO_INCREMENT=710 DEFAULT CHARSET=latin1; 328 | /*!40101 SET character_set_client = @saved_cs_client */; 329 | 330 | -- 331 | -- Dumping data for table `webUsers` 332 | -- 333 | -- WHERE: 1=0 334 | 335 | LOCK TABLES `webUsers` WRITE; 336 | /*!40000 ALTER TABLE `webUsers` DISABLE KEYS */; 337 | /*!40000 ALTER TABLE `webUsers` ENABLE KEYS */; 338 | UNLOCK TABLES; 339 | 340 | -- 341 | -- Table structure for table `winning_shares` 342 | -- 343 | 344 | DROP TABLE IF EXISTS `winning_shares`; 345 | /*!40101 SET @saved_cs_client = @@character_set_client */; 346 | /*!40101 SET character_set_client = utf8 */; 347 | CREATE TABLE `winning_shares` ( 348 | `id` int(11) NOT NULL AUTO_INCREMENT, 349 | `blockNumber` int(11) NOT NULL, 350 | `username` varchar(11) NOT NULL, 351 | `share_id` int(255) NOT NULL DEFAULT '0', 352 | `rewarded` enum('N','Y') NOT NULL DEFAULT 'N', 353 | `amount` varchar(40) NOT NULL DEFAULT '0', 354 | `confirms` smallint(6) NOT NULL DEFAULT '0', 355 | `txid` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL, 356 | `scored` enum('N','Y') NOT NULL DEFAULT 'N', 357 | PRIMARY KEY (`id`), 358 | KEY `winning_shares_scored` (`scored`) 359 | ) ENGINE=MyISAM AUTO_INCREMENT=14 DEFAULT CHARSET=utf8; 360 | /*!40101 SET character_set_client = @saved_cs_client */; 361 | 362 | -- 363 | -- Dumping data for table `winning_shares` 364 | -- 365 | -- WHERE: 1=0 366 | 367 | LOCK TABLES `winning_shares` WRITE; 368 | /*!40000 ALTER TABLE `winning_shares` DISABLE KEYS */; 369 | /*!40000 ALTER TABLE `winning_shares` ENABLE KEYS */; 370 | UNLOCK TABLES; 371 | 372 | -- 373 | -- Dumping routines for database 'simplecoin' 374 | -- 375 | /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; 376 | 377 | /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; 378 | /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; 379 | /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; 380 | /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; 381 | /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; 382 | /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; 383 | /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; 384 | 385 | -- Dump completed on 2011-08-26 18:28:36 386 | -------------------------------------------------------------------------------- /stats.php: -------------------------------------------------------------------------------- 1 | 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | 17 | // BTC Donations: 163Pv9cUDJTNUbadV4HMRQSSj3ipwLURRc 18 | // 19 | // Improved Stats written by Tom Lightspeed (tomlightspeed@gmail.com + http://facebook.com/tomlightspeed) 20 | // Developed Socially for http://ozco.in 21 | // If you liked my work, want changes/etc please contact me or donate 16p56JHwLna29dFhTRcTAurj4Zc2eScxTD. 22 | // Special thanks to Wayno, Graet & Ycros from #ozcoin on freenode.net for their help :-) 23 | // Additional thanks to Krany from #ozcoin on freenode.net. 24 | // May the force be with you. 25 | 26 | $pageTitle = "- Stats"; 27 | include ("includes/header.php"); 28 | 29 | 30 | $numberResults = 30; 31 | $last_no_blocks_found = 5; 32 | 33 | $onion_winners = 10; 34 | 35 | $difficulty = $bitcoinDifficulty; 36 | //time = difficulty * 2**32 / hashrate 37 | // hashrate is in Mhash/s 38 | function CalculateTimePerBlock($btc_difficulty, $_hashrate){ 39 | if ($btc_difficulty > 0 && $_hashrate > 0) { 40 | $find_time_hours = ((($btc_difficulty * bcpow(2,32)) / ($_hashrate * bcpow(10,6))) / 3600); 41 | } else { 42 | $find_time_hours = 0; 43 | } 44 | return $find_time_hours; 45 | } 46 | 47 | function CoinsPerDay ($time_per_block, $btc_block) { 48 | if($time_per_block > 0 && $btc_block > 0) { 49 | $coins_per_day = (24 / $time_per_block) * $btc_block; 50 | } else { 51 | $coins_per_day = 0; 52 | } 53 | return $coins_per_day; 54 | } 55 | ?> 56 | 57 |
58 |

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

"; 61 | } 62 | ?> 63 |
64 | 65 | 66 | 67 | userhashrates(); 72 | $rank = 1; 73 | $user_found = false; 74 | 75 | foreach ($result as $username => $user_hash_rate) { 76 | //$username = $resultrow->username; 77 | if ($cookieValid && $username == $userInfo->username) { 78 | echo ""; 79 | $user_found = true; 80 | } else { 81 | echo ""; 82 | } 83 | echo ""; 95 | if ($rank == 30) 96 | break; 97 | $rank++; 98 | } 99 | 100 | if ($cookieValid && $user_found == false) { 101 | $rank = $stats->userrankhash($userInfo->id); 102 | $user_hashrate = $stats->userhashrate($userInfo->username); 103 | echo ""; 107 | } 108 | ?> 109 |
Top Hashrates
RankUser NameMH/sBTC/Day
".$rank; 84 | 85 | if ($rank == 1) { 86 | echo " "; 87 | } 88 | 89 | //$user_hash_rate = $resultrow->hashrate; 90 | echo "".$username."".number_format($user_hash_rate)." "; 91 | $time_per_block = CalculateTimePerBlock($difficulty, $user_hash_rate); 92 | $coins_day = CoinsPerDay($time_per_block, $bonusCoins); 93 | echo number_format( $coins_day, 3 ); 94 | echo "
" . $rank . "" . $userInfo->username . "" . number_format( $user_hashrate ) . ""; 104 | $time_per_block = CalculateTimePerBlock($difficulty, $user_hashrate); 105 | $coins_day = CoinsPerDay($time_per_block, $bonusCoins); 106 | echo number_format($coins_day, 3) . "


110 | 111 | "; 115 | /*echo ""; 116 | echo ""; 117 | echo ""; 118 | 119 | $result = $stats->onionwinners($onion_winners); 120 | $rank = 1; 121 | $user_found = false; 122 | 123 | foreach ($result as $username => $stale_percent) { 124 | //$resdss = mysql_query("SELECT username FROM webUsers WHERE id=$resultrow->id"); 125 | //$resdss = mysql_fetch_object($resdss); 126 | //$username = $resdss->username; 127 | if ($cookieValid && $username == $userInfo->username) { 128 | echo ""; 129 | $user_found = true; 130 | } else { 131 | echo ""; 132 | } 133 | 134 | echo ""; 139 | $rank++; 140 | }*/ 141 | /* 142 | if( $cookieValid && $user_found == false ) 143 | { 144 | $query_init = "SET @rownum := 0"; 145 | 146 | $query_getrank = "SELECT rank, stale_percent FROM ( 147 | SELECT @rownum := @rownum + 1 AS rank, (stale_share_count / share_count)*100 AS stale_percent FROM webUsers WHERE shares_this_round > 0 ORDER BY stale_percent DESC) as result WHERE id=" . $userInfo->id; 148 | 149 | mysql_query( $query_init ); 150 | $result = mysql_query( $query_getrank ); 151 | $row = mysql_fetch_object( $result ); 152 | 153 | echo ""; 154 | } 155 | */ 156 | //echo "
Our " . $onion_winners . " Onion Winners (Active this Round)
RankUser Name% Of Stales
" . $rank; 135 | 136 | echo " "; 137 | 138 | echo "" . $username . "" . number_format($stale_percent, 2) . "%
" . $row->rank . "" . $userInfo->username . "" . $row->stale_percent . "%
"; 157 | echo ""; 158 | ?> 159 |
160 | 161 | 162 | 163 | userssharecount($numberResults); 168 | $rank = 1; 169 | $user_found = false; 170 | 171 | foreach ($result as $username => $shares) { 172 | if ($cookieValid && $username == $userInfo->username) { 173 | echo ""; 174 | $user_found = true; 175 | } else { 176 | echo ""; 177 | } 178 | 179 | echo ""; 185 | $rank++; 186 | } 187 | 188 | if ($cookieValid && $user_found == false) { 189 | $rank_shares = $stats->userrankshares($userInfo->id); 190 | if (count($rank_shares) > 0) 191 | echo ""; 192 | } 193 | ?> 194 |
Top Lifetime Shares
RankUser NameShares
" . $rank; 180 | 181 | if ($rank == 1) 182 | echo " "; 183 | 184 | echo "".$username."" . number_format($shares) . "
".$rank_shares[0]."" . $userInfo->username . "".number_format($rank_shares[1])."
195 |
196 |
197 | 198 | currenthashrate() / 1000,3); 202 | $current_block_no = $bitcoinController->getblocknumber(); 203 | $show_difficulty = round($difficulty, 2); 204 | 205 | echo ""; 206 | echo ""; 207 | echo ""; 208 | echo ""; 209 | 210 | $res = $stats->userhashrates(); 211 | $hashcount = 0; 212 | foreach ($res as $hash) 213 | if ($hash > 0) 214 | $hashcount++; 215 | 216 | echo ""; 217 | echo ""; 218 | echo ""; 220 | echo ""; 221 | 222 | $lastblocks = $stats->lastwinningblocks($last_no_blocks_found); 223 | 224 | $show_time_since_found = false; 225 | $time_last_found; 226 | 227 | if (count($lastblocks) > 0) { 228 | $found_block_no = $lastblocks[0][1]; 229 | $confirm_no = $lastblocks[0][2]; 230 | 231 | echo ""; 232 | 233 | $time_last_found = $lastblocks[0][3]; 234 | 235 | $show_time_since_found = true; 236 | } 237 | 238 | $time_to_find = CalculateTimePerBlock($difficulty, $stats->currenthashrate()); 239 | // change 25.75 hours to 25:45 hours 240 | $intpart = floor( $time_to_find ); 241 | $fraction = $time_to_find - $intpart; // results in 0.75 242 | $minutes = number_format(($fraction * 60 ),0); 243 | 244 | echo ""; 245 | 246 | $now = new DateTime( "now" ); 247 | if (isset($time_last_found)) 248 | $hours_diff = ($now->getTimestamp() - $time_last_found) / 3600; 249 | else 250 | $hours_diff = 0; 251 | 252 | if( $hours_diff < $time_to_find ) 253 | { 254 | $time_last_found_out = ""; 255 | } 256 | elseif( ( $hours_diff * 2 ) > $time_to_find ) 257 | { 258 | $time_last_found_out = ""; 259 | } 260 | else 261 | { 262 | $time_last_found_out = ""; 263 | } 264 | 265 | $time_last_found_out = $time_last_found_out . floor( $hours_diff ). " Hours " . $hours_diff*60%60 . " Minutes"; 266 | 267 | echo ""; 268 | 269 | echo "
Server Stats
Pool Hash Rate". number_format($show_hashrate, 3) . " Ghashes/s
Pool Efficiency". number_format($stats->poolefficiency(), 2) . "%
Current Users Mining" . number_format($hashcount) . "
Current Total Miners" . number_format($stats->currentworkers()) . "
Current Block"; 219 | echo number_format($current_block_no) . "
Current Difficulty" . number_format($show_difficulty) . "
Last Block Found" . number_format($found_block_no) . "
Est. Time To Find Block" . number_format($time_to_find,0) . " Hours " . $minutes . " Minutes
Time Since Last Block" . $time_last_found_out . "
"; 270 | 271 | // SHOW LAST (=$last_no_blocks_found) BLOCKS ************************************************************************************************************************* 272 | 273 | echo ""; 274 | echo ""; 275 | echo ""; 276 | 277 | foreach ($lastblocks as $resultrow) { 278 | echo ""; 279 | $splitUsername = explode(".", $resultrow[0]); 280 | $realUsername = $splitUsername[0]; 281 | 282 | 283 | $confirms = $resultrow[2]; 284 | 285 | if ($confirms > 119) { 286 | $confirms = "Done"; 287 | } 288 | 289 | $block_no = $resultrow[1]; 290 | 291 | echo ""; 292 | echo ""; 293 | echo ""; 294 | echo ""; 295 | echo ""; 296 | } 297 | 298 | echo "
Last $last_no_blocks_found Blocks Found - All Blocks Found
BlockConfirmsFinderTime
" . number_format($block_no) . "" . $confirms . "$realUsername".strftime("%F %r",$resultrow[3])."
"; 299 | 300 | // SERVER BLOCKS/TIME GRAPH ************************************************************************************************************************* 301 | // http://www.filamentgroup.com/lab/update_to_jquery_visualize_accessible_charts_with_html5_from_designing_with/ 302 | // table is hidden, graph follows 303 | 304 | echo ""; 305 | echo ""; 306 | echo ""; 307 | 308 | // get last 7 days of blocks, confirms over 0 309 | $query = "SELECT sum(no_blocks) as blocks_found, DATE_FORMAT(date, '%b %e') as date from 310 | (SELECT COUNT(n.blockNumber) as no_blocks, CAST(FROM_UNIXTIME(n.timestamp) as date) as date 311 | FROM networkBlocks n, winning_shares w 312 | WHERE n.blockNumber = w. blockNumber AND w.confirms > 0 313 | AND CAST(FROM_UNIXTIME(n.timestamp) as DATE) > DATE_SUB(now(), INTERVAL 6 DAY) 314 | GROUP BY DAY(FROM_UNIXTIME(n.timestamp)) 315 | UNION 316 | SELECT 0, CAST(FROM_UNIXTIME(timestamp) as DATE) as date 317 | FROM networkBlocks 318 | WHERE CAST(FROM_UNIXTIME(timestamp) as DATE) > DATE_SUB(CURDATE(), INTERVAL 6 DAY) 319 | GROUP BY DAY(FROM_UNIXTIME(timestamp)) 320 | ) as blah group by date order by blah.date ASC"; 321 | $result = mysql_query_cache($query); 322 | 323 | foreach ($result as $resultrow) { 324 | echo ""; 325 | } 326 | 327 | echo ""; 328 | 329 | // re-iterate through results 330 | //mysql_data_seek($result, 0); 331 | 332 | foreach ($result as $resultrow) { 333 | echo ""; 334 | } 335 | 336 | echo "
Blocks Found Over Last Week
" . $resultrow->date . "
Simplecoin.us Pool" . $resultrow->blocks_found . "
"; 337 | 338 | echo "
"; 339 | 340 | 341 | echo "
"; 342 | 343 | include("includes/footer.php"); 344 | 345 | ?> -------------------------------------------------------------------------------- /css/mainstyle.css: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) Copyright (C) 41a240b48fb7c10c68ae4820ac54c0f32a214056bfcfe1c2e7ab4d3fb53187a0 Name Year (sha256) 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License 6 | as published by the Free Software Foundation; either version 2 7 | of the License, or (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, write to the Free Software 16 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 | Website Reference:http://www.gnu.org/licenses/gpl-2.0.html 18 | 19 | */ 20 | *{ 21 | margin:0; 22 | padding:0; 23 | } 24 | 25 | body{ 26 | background-color:#FFF; 27 | color:#000; 28 | font-family: Arial; 29 | } 30 | 31 | a:link, a.visited { 32 | color: #0000FF; 33 | } 34 | 35 | a:hover { 36 | color: #FF0000; 37 | } 38 | a:active { 39 | color: #00FF00; 40 | } 41 | 42 | input{ 43 | border: 1px solid #000; 44 | } 45 | 46 | .hide 47 | { 48 | display:none; 49 | } 50 | 51 | /*-----End of Defaults------*/ 52 | 53 | a.menu:active,a.menu:link,a.menu:visited{ 54 | color:#FFF; 55 | font-weight:bold; 56 | font-size:1.5em; 57 | text-align:center; 58 | text-decoration: none; 59 | } 60 | 61 | a.menu:hover{ 62 | color:#000; 63 | font-weight:bold; 64 | font-size:1.5em; 65 | text-align:center; 66 | text-decoration: none; 67 | } 68 | 69 | 70 | #header{ 71 | width:100%; 72 | height:8em; 73 | background-color:#144e56; 74 | } 75 | #logo{ 76 | width:100%; 77 | height:8em; 78 | float:left; 79 | } 80 | 81 | #loginForm{ 82 | position:relative; 83 | top:.5em; 84 | left:.5em; 85 | } 86 | 87 | #lostPassForm{ 88 | position:relative; 89 | top:0; 90 | left: 1em; 91 | } 92 | 93 | #userInfo{ 94 | float: left; 95 | background-color:#DDD; 96 | width:15em; 97 | height: 100%; 98 | padding:.5em; 99 | } 100 | 101 | #bodyContent{ 102 | height:100%; 103 | background-color:#FFF; 104 | } 105 | 106 | #blogContainer{ 107 | margin-left:1em; 108 | padding-top:1em; 109 | padding-left:1em; 110 | } 111 | #footer{ 112 | text-align:center; 113 | clear: both; 114 | } 115 | 116 | /*-----Menu Buttons------*/ 117 | #menuBar{ 118 | background-color:#144e56; 119 | width: 100%; 120 | height:2em; 121 | white-space: nowrap; 122 | } 123 | 124 | div.menuBtn{ 125 | background-color:#000; 126 | float:left; 127 | margin-left:1em; 128 | height:2em; 129 | } 130 | 131 | div.menuBtnSelected{ 132 | background-color: #FFF; 133 | color: #000; 134 | float:left; 135 | margin-left:1em; 136 | height:2em; 137 | } 138 | 139 | div.menuBtn:Hover{ 140 | float:left; 141 | margin-left:1em; 142 | background-color:#CAE1FF; 143 | height:2em; 144 | } 145 | 146 | /*-----Text-----*/ 147 | h1.header{ 148 | font-size:3.5em; 149 | margin:0 auto; 150 | width:100%; 151 | text-align:center; 152 | color:#CAE1FF; 153 | } 154 | h3.slogan{ 155 | text-align:center; 156 | width:100%; 157 | color:#CAE1FF; 158 | } 159 | 160 | span.goodMessage{ 161 | color:#66FF33; 162 | font-weight:bold; 163 | } 164 | span.returnMessage{ 165 | color:#FF66FF; 166 | font-weight:bold; 167 | font-size:1.5em; 168 | } 169 | 170 | #leftsidebar { 171 | float: left; 172 | background-color:#DDD; 173 | width: 15em; 174 | padding:.5em; 175 | overflow: none; 176 | } 177 | 178 | #content { 179 | white-space: normal; 180 | padding: 1em; 181 | margin: .5em; 182 | margin-left: 1em; 183 | background-color: #FFF; 184 | } 185 | 186 | #currentRates { 187 | vertical-align: middle; 188 | padding-right: 1em; 189 | } 190 | 191 | #stats_wrap { 192 | width: 1024px; 193 | padding:0px; 194 | margin:0px; 195 | } 196 | 197 | #stats_wrap_2 198 | { 199 | width: 1024px; 200 | padding: 0px; 201 | margin-top: 10px; 202 | margin-bottom:10px; 203 | } 204 | 205 | .onion 206 | { 207 | width:18px; 208 | height:18px; 209 | } 210 | 211 | #new_user_message{ 212 | width: 1024px; 213 | } 214 | 215 | #new_user_message p 216 | { 217 | margin: 10px; 218 | margin-left:0px; 219 | padding: 0px; 220 | } 221 | 222 | #stats_members { 223 | float:left; 224 | } 225 | 226 | #stats_lifetime { 227 | padding-left:10px; 228 | float:left; 229 | } 230 | 231 | #stats_onions { 232 | float:left; 233 | } 234 | 235 | #stats_server { 236 | padding-left:10px; 237 | float:left; 238 | } 239 | 240 | .green{ 241 | color: #347235 !important; 242 | } 243 | 244 | .red{ 245 | color: #7E2217 !important; 246 | } 247 | 248 | .orange{ 249 | color: #F88017 !important; 250 | } 251 | 252 | .earned_coin 253 | { 254 | height: 40px; 255 | width: 40px; 256 | } 257 | 258 | .money_table 259 | { 260 | background-color: #FFCF4B !important; 261 | border: 1px solid #DD9222 !important; 262 | } 263 | 264 | .moneyheader 265 | { 266 | color: #DD9222 !important; 267 | background-color: #FFCF4B; 268 | border-right: 2px solid #DD9222 !important; 269 | border-bottom: 2px solid #DD9222; 270 | } 271 | 272 | .bitcoin_image 273 | { 274 | width: 1%; 275 | border-bottom: 2px solid #DD9222 !important; 276 | border-right:0px !important; 277 | } 278 | 279 | .bitcoins 280 | { 281 | border-left:0px; 282 | border-bottom: 2px solid #DD9222 !important; 283 | border-right: 2px solid #DD9222 !important; 284 | font-size: 22px !important; 285 | } 286 | 287 | .money_table th, .money_table td 288 | { 289 | background-color: #FFCF4B !important; 290 | color: #632a2a !important; 291 | } 292 | 293 | .money_table th[scope=col] 294 | { 295 | border-bottom: 2px solid #DD9222 !important; 296 | border-right: 2px solid #DD9222 !important; 297 | } 298 | 299 | .money_table th, .money_table td 300 | { 301 | padding: 5px; 302 | text-align: left; 303 | } 304 | 305 | .stats_table, .money_table 306 | { 307 | padding: 0; 308 | margin: 0; 309 | border-collapse: collapse; 310 | border: 1px solid #333; 311 | font-family: "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif; 312 | font-size: 0.9em; 313 | color: #000; 314 | background: #bcd0e4; 315 | } 316 | 317 | .stats_table caption, .money_table caption 318 | { 319 | caption-side: bottom; 320 | font-size: 0.9em; 321 | font-style: italic; 322 | text-align: right; 323 | padding: 0.5em 0; 324 | } 325 | 326 | .stats_table th, .stats_table td 327 | { 328 | border: 1px dotted #666; 329 | padding: 0.5em; 330 | text-align: left; 331 | color: #632a39; 332 | } 333 | 334 | .stats_table th[scope=col], .money_table th[scope=col] 335 | { 336 | color: #000; 337 | background-color: #8fadcc; 338 | font-size: 0.9em; 339 | border-bottom: 2px solid #333; 340 | border-right: 2px solid #333; 341 | } 342 | 343 | .stats_table th+th[scope=col] 344 | { 345 | color: #fff; 346 | background-color: #7d98b3; 347 | border-right: 1px dotted #666; 348 | } 349 | 350 | .leftheader 351 | { 352 | color: #fff !important; 353 | background-color: #7d98b3; 354 | border-right: 2px solid #333 !important; 355 | border-bottom: 2px solid #333; 356 | } 357 | 358 | .stats_table th[scope=row], .money_table th[scope=row] 359 | { 360 | background-color: #b8cfe5; 361 | border-right: 2px solid #333; 362 | } 363 | 364 | .stats_table tr.alt th, .stats_table tr.alt td, .money_table tr.alt th, .money_table tr.alt td 365 | { 366 | color: #2a4763; 367 | } 368 | 369 | .stats_table .user_position th[scope=row], .stats_table .user_position td 370 | { 371 | background-color: #632a2a; 372 | color: #fff; 373 | } 374 | 375 | .member_width 376 | { 377 | width: 275px; 378 | } 379 | 380 | .server_width 381 | { 382 | width: 400px; 383 | } 384 | 385 | .blocks_width 386 | { 387 | width:800px; 388 | } 389 | 390 | .top_spacing 391 | { 392 | margin-top: 10px; 393 | } 394 | 395 | .bottom_spacing 396 | { 397 | margin-bottom: 10px; 398 | } 399 | 400 | .left_spacing 401 | { 402 | margin-left: 10px; 403 | } 404 | 405 | .align_right 406 | { 407 | text-align: right !important; 408 | } 409 | 410 | .clear { 411 | clear:both; 412 | } 413 | 414 | a.fancy_button, button.fancy_button { 415 | background: #555; 416 | background: -webkit-gradient(linear, left top, left bottom, from(rgba(0,0,0,0.4)), to(rgba(77,77,77,0.4))); 417 | background: -moz-linear-gradient(top, rgba(0,0,0,0.4), rgba(77,77,77,0.4)); 418 | float: left; 419 | padding: 4px; 420 | text-decoration: none; 421 | outline: 0; 422 | border-width: 1px; 423 | border-style: solid; 424 | width: auto; 425 | overflow: visible; 426 | border-color: transparent transparent #666 transparent; 427 | border-color: transparent transparent rgba(202,202,202,0.27) transparent; 428 | -webkit-border-radius: 12px; -moz-border-radius: 12px; border-radius: 12px; 429 | -webkit-background-clip: padding-box; 430 | } 431 | 432 | a.fancy_button span, button.fancy_button span { 433 | display: block; 434 | float: left; 435 | letter-spacing: -1px; 436 | border-width: 1px; 437 | border-style: solid; 438 | border-color: #ccc #444 #111 #444; 439 | border-color: rgba(255,255,255,0.7) rgba(0,0,0,0.5) rgba(0,0,0,0.7) rgba(0,0,0,0.5); 440 | font: bold 16px/0.8em Arial; 441 | color: white; 442 | padding: 0.48em 2em; 443 | cursor: pointer; 444 | text-shadow: rgba(0,0,0,0.45) 0 -1px 0; 445 | -webkit-box-shadow: rgba(0,0,0,0.75) 0px 0px 3px; -moz-box-shadow: rgba(0,0,0,0.75) 0px 0px 3px; box-shadow: rgba(0,0,0,0.75) 0px 0px 3px; 446 | -webkit-border-radius: 7px; -moz-border-radius: 7px; border-radius: 7px; 447 | background: transparent -webkit-gradient(linear, left top, left bottom, from(rgba(255,255,255,0.6)), color-stop(0.5, rgba(255,255,255,0.15)), color-stop(0.5, rgba(255,255,255,0.01)), to(transparent)); 448 | background: transparent -moz-linear-gradient(top, rgba(255,255,255,0.6), rgba(255,255,255,0.15) 50%, rgba(255,255,255,0.01) 50%, transparent); 449 | filter: progid:DXImageTransform.Microsoft.Gradient(GradientType=0, StartColorstr='#80FFFFFF', EndColorstr='#00FFFFFF'); 450 | -webkit-background-clip: padding-box; 451 | } 452 | 453 | a.fancy_button:hover span, button.fancy_button:hover span { 454 | border-top-color: rgba(255,255,255,0.65); 455 | background: -webkit-gradient(linear, left top, left bottom, from(rgba(220,220,220,0.6)), color-stop(0.5, rgba(100,100,100,0.2)), color-stop(0.5, rgba(0,0,0,0.21)), to(rgba(0, 0, 0, 0.20))); 456 | background: -moz-linear-gradient(top, rgba(220,220,220,0.6), rgba(100,100,100,0.2) 50%, rgba(0,0,0,0.21) 50%, rgba(0, 0, 0, 0.20)); 457 | filter: progid:DXImageTransform.Microsoft.gradient(GradientType=0, StartColorStr='#99dcdcdc', EndColorStr='#33000000'); 458 | -webkit-background-clip: padding-box; 459 | } 460 | 461 | a.fancy_button:active span, button.fancy_button:active span { 462 | border-top-color: rgba(255,255,255,0.2); 463 | border-left-color: rgba(0,0,0,0.4); 464 | background: -webkit-gradient(linear, left top, left bottom, from(rgba(150,150,150,0.6)), color-stop(0.5, rgba(60,60,60,0.6)), color-stop(0.5, rgba(40,40,40,0.6)), to(rgba(20, 20, 20, 0.5))); 465 | background: -moz-linear-gradient(top, rgba(150,150,150,0.6), rgba(60,60,60,0.6) 50%, rgba(40,40,40,0.6) 50%, rgba(20, 20, 20, 0.5)); 466 | filter: progid:DXImageTransform.Microsoft.gradient(GradientType=0, StartColorStr='#80969696', EndColorStr='#59000000'); 467 | -webkit-box-shadow: inset 0 0 18px rgba(0,0,0,0.75), rgba(0,0,0,0.75) 0px 0px 3px; -moz-box-shadow: inset 0 0 18px rgba(0,0,0,0.75), rgba(0,0,0,0.75) 0px 0px 3px; box-shadow: inset 0 0 18px rgba(0,0,0,0.75), rgba(0,0,0,0.75) 0px 0px 3px; 468 | -webkit-background-clip: padding-box; 469 | } 470 | 471 | a.fancy_button span:active, button.fancy_button span:active { 472 | border-top-color: rgba(255,255,255,0.2); 473 | border-left-color: rgba(0,0,0,0.4); 474 | filter: progid:DXImageTransform.Microsoft.gradient(GradientType=0, StartColorStr='#80969696', EndColorStr='#59000000'); 475 | -webkit-background-clip: padding-box; 476 | } 477 | 478 | .round { 479 | border-radius: 3px; -webkit-border-radius: 3px; -moz-border-radius: 3px; 480 | } 481 | 482 | /* menu */ 483 | #menu{ margin:0px; padding:0px; list-style:none; color:#fff; line-height:45px; display:inline-block; float:left; z-index:1000; } 484 | #menu a { color:#fff; text-decoration:none; } 485 | #menu > li {background:#172322 none repeat scroll 0 0; cursor:pointer; float:left; position:relative;padding:0px 10px;} 486 | #menu > li a:hover {color:#B0D730;} 487 | #menu .logo {background:transparent none repeat scroll 0% 0%; padding:0px; background-color:Transparent;} 488 | /* sub-menus*/ 489 | /* #menu ul { padding:0px; margin:0px; display:block; display:inline;} 490 | #menu li ul { position:absolute; left:-10px; top:0px; margin-top:45px; width:150px; line-height:16px; background-color:#172322; color:#0395CC; /* for IE display:none; } 491 | #menu li:hover ul { display:block;} 492 | #menu li ul li{ display:block; margin:5px 20px; padding: 5px 0px; border-top: dotted 1px #606060; list-style-type:none; } 493 | #menu li ul li:first-child { border-top: none; } 494 | #menu li ul li a { display:block; color:#0395CC; } 495 | #menu li ul li a:hover { color:#7FCDFE; } */ 496 | 497 | /* header stats */ 498 | #headerstats{ margin:0px; padding:0px; list-style:none; color:#fff; line-height:30px; display:inline-block; width:100%; } 499 | #headerstats a { color:#fff; text-decoration:none; } 500 | #headerstats > li {background:#172322 none repeat scroll 0 0; cursor:pointer; float:left; position:relative;padding:0px 10px;} 501 | #headerstats > li a:hover {color:#B0D730;} 502 | /* main submenu */ 503 | /*#menu #main { left:0px; top:-20px; padding-top:20px; background-color:#7cb7e3; color:#fff; z-index:999;}*/ 504 | 505 | /* corners*/ 506 | /* #menu .corner_inset_left { position:absolute; top:0px; left:-12px;} 507 | #menu .corner_inset_right { position:absolute; top:0px; left:150px;} 508 | #menu .last { background:transparent none repeat scroll 0% 0%; margin:0px; padding:0px; border:none; position:relative; border:none; height:0px;} 509 | #menu .corner_left { position:absolute; left:0px; top:0px;} 510 | #menu .corner_right { position:absolute; left:132px; top:0px;} 511 | #menu .middle { position:absolute; left:18px; height: 20px; width: 115px; top:0px;}*/ 512 | -------------------------------------------------------------------------------- /accountdetails.php: -------------------------------------------------------------------------------- 1 | 3 | // 4 | // This program is free software: you can redistribute it and/or modify 5 | // it under the terms of the GNU General Public License as published by 6 | // the Free Software Foundation, either version 3 of the License, or 7 | // (at your option) any later version. 8 | // 9 | // This program is distributed in the hope that it will be useful, 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | // GNU General Public License for more details. 13 | // 14 | // You should have received a copy of the GNU General Public License 15 | // along with this program. If not, see . 16 | 17 | // BTC Donations: 163Pv9cUDJTNUbadV4HMRQSSj3ipwLURRc 18 | 19 | $pageTitle = "- Account Details"; 20 | include ("includes/header.php"); 21 | 22 | /* 23 | Copyright (C) 41a240b48fb7c10c68ae4820ac54c0f32a214056bfcfe1c2e7ab4d3fb53187a0 Name Year (sha256) 24 | 25 | This program is free software; you can redistribute it and/or 26 | modify it under the terms of the GNU General Public License 27 | as published by the Free Software Foundation; either version 2 28 | of the License, or (at your option) any later version. 29 | 30 | This program is distributed in the hope that it will be useful, 31 | but WITHOUT ANY WARRANTY; without even the implied warranty of 32 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 33 | GNU General Public License for more details. 34 | 35 | You should have received a copy of the GNU General Public License 36 | along with this program; if not, write to the Free Software 37 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 38 | Website Reference:http://www.gnu.org/licenses/gpl-2.0.html 39 | 40 | Note From Author: Keep the original donate address in the source files when transferring or redistrubuting this code. 41 | Please donate at the following address: 1Fc2ScswXAHPUgj3qzmbRmwWJSLL2yv8Q 42 | */ 43 | 44 | if(!$cookieValid) { 45 | header('Location: /'); 46 | exit; 47 | } 48 | //Execute the following based on what $_POST["act"] is set to 49 | $returnError = ""; 50 | $goodMessage = ""; 51 | if (isset($_POST["act"])) { 52 | $act = $_POST["act"]; 53 | 54 | if (isset($_POST["authPin"])) { 55 | $inputAuthPin = hash("sha256", $_POST["authPin"].$salt); 56 | } else { 57 | $inputAuthPin = NULL; 58 | } 59 | 60 | 61 | //Check if authorization pin has been inputted correctly 62 | if($inputAuthPin == $authPin && $act){ 63 | if($act == "cashOut"){ 64 | $txfee = 0; 65 | if ($settings->getsetting("sitetxfee") > 0) 66 | $txfee = $settings->getsetting("sitetxfee"); 67 | //Get user's balance and send it to set address; 68 | //Does user have any money in their balance 69 | if($currentBalance > $txfee) { 70 | //Send $currentBalance to $paymentAddress 71 | //Validate that a $paymentAddress has been set & is valid before sending 72 | $isValidAddress = $bitcoinController->validateaddress($paymentAddress); 73 | if($isValidAddress) { 74 | if (!islocked("money")) { 75 | //Subtract TX fee, site percentage and donation percentage. 76 | $sitepercent = $settings->getsetting("sitepercent"); 77 | $currentBalance = ($currentBalance*(1-$sitepercent/100)*(1-$donatePercent/100)) - $txfee; 78 | //Send money// 79 | try { 80 | $paid = 0; 81 | $result = mysql_query("SELECT IFNULL(paid,'0') as paid FROM accountBalance WHERE userId=".$userId); 82 | if ($resultrow = mysql_fetch_object($result)) $paid = $resultrow->paid + $currentBalance; 83 | 84 | lock("money"); 85 | mysql_query("BEGIN"); 86 | //Reduce balance amount to zero 87 | mysql_query("UPDATE accountBalance SET balance = '0', paid = '$paid' WHERE userId = $userId"); 88 | if ($bitcoinController->sendtoaddress($paymentAddress, $currentBalance)) { 89 | $goodMessage = "You have successfully sent ".$currentBalance." to the following address:".$paymentAddress; 90 | 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 "); 91 | //Set new variables so it appears on the page flawlessly 92 | $currentBalance = 0; 93 | mysql_query("COMMIT"); 94 | }else{ 95 | mysql_query("ROLLBACK"); 96 | $returnError = "Commodity failed to send."; 97 | } 98 | } catch (Exception $e) { 99 | mysql_query("ROLLBACK"); 100 | } 101 | unlock("money"); 102 | } 103 | else 104 | { 105 | $returnError = "Automatic payouts currently in progress, try again later."; 106 | } 107 | }else{ 108 | $returnError = "That isn't a valid Bitcoin address"; 109 | } 110 | }else{ 111 | $returnError = "You have no money in your account!"; 112 | } 113 | } 114 | 115 | 116 | if($act == "updateDetails"){ 117 | //Update user's details 118 | if (!$userBtcLock) 119 | $newSendAddress = mysql_real_escape_string($_POST["paymentAddress"]); 120 | else 121 | $newSendAddress = $paymentAddress; 122 | $newDonatePercent = mysql_real_escape_string($_POST["donatePercent"]); 123 | $newPayoutThreshold = mysql_real_escape_string($_POST["payoutThreshold"]); 124 | if ($newPayoutThreshold > 25) 125 | $newPayoutThreshold = 25; 126 | if ($newPayoutThreshold < 1) 127 | $newPayoutThreshold = 0; 128 | if ($newDonatePercent < 0) 129 | $newDonatePercent = 0; 130 | if ($newDonatePercent > 100) 131 | $newDonatePercent = 100; 132 | if (isset($_POST["cbxLock"]) && $_POST["cbxLock"] == "1") { 133 | mysql_query("UPDATE webUsers SET btc_lock = '1' WHERE id = $userId"); 134 | $userBtcLock = true; 135 | } 136 | $updateSuccess1 = mysql_query("UPDATE accountBalance SET sendAddress = '$newSendAddress', threshold = '$newPayoutThreshold' WHERE userId = $userId"); 137 | if (!is_nan($newDonatePercent)) 138 | $updateSuccess2 = mysql_query("UPDATE webUsers SET donate_percent='$newDonatePercent' WHERE id = $userId"); 139 | else 140 | $returnError = "Donation % must be numeric."; 141 | 142 | if($updateSuccess1 && $updateSuccess2){ 143 | $goodMessage = "Account details are now updated."; 144 | $paymentAddress = $newSendAddress; 145 | $donatePercent = $newDonatePercent; 146 | $payoutThreshold = $newPayoutThreshold; 147 | } 148 | } 149 | 150 | if($act == "updatePassword"){ 151 | //Update password 152 | $oldPass = hash("sha256", mysql_real_escape_string($_POST["currentPassword"])); 153 | $newPass = mysql_real_escape_string($_POST["newPassword"]); 154 | $newPassConfirm = mysql_real_escape_string($_POST["newPassword2"]); 155 | 156 | //If hash $oldPass is the same as the DB already hashed password continue you with the password change 157 | if($oldPass == $hashedPass){ 158 | //Check if new password is valid 159 | if($newPass != "" && strlen($newPass) > 6){ 160 | //Change the password only if $newPass == $newPassConfirm 161 | if($newPass == $newPassConfirm){ 162 | //Update hashed password 163 | $newHashedPass = hash("sha256", $newPass.$salt); 164 | $passchangeSuccess = mysql_query("UPDATE `webUsers` SET `pass` = '".$newHashedPass."' WHERE `id` = '".$userId."'"); 165 | if($passchangeSuccess){ 166 | $goodMessage = "Password successfully changed."; 167 | }else{ 168 | $returnError = "Database Failure - Unable to change password"; 169 | } 170 | }else if($newPass != $newPassConfirm){ 171 | $returnError = "The \"New Password\" and \"New Password Repeat\" fields must match"; 172 | } 173 | }else{ 174 | $returnError = "Your new password is not valid, Must be longer then 6 characters"; 175 | } 176 | 177 | }else if($oldPass != $hashedPass){ 178 | //Typed in password dosent match DB password 179 | $returnError = "You must type in the correct current password before you can set a new password."; 180 | } 181 | } 182 | 183 | 184 | } else if ($inputAuthPin != $authPin && $act) { 185 | $returnError = "Authorization Pin is Invalid!"; 186 | } 187 | 188 | if($act == "addWorker"){ 189 | //Add worker 190 | $prefixUsername = $userInfo->username; 191 | $inputUser = $prefixUsername.".".mysql_real_escape_string($_POST["username"]); 192 | $inputPass = mysql_real_escape_string($_POST["pass"]); 193 | 194 | //Check if username already exists 195 | $usernameExistsQ = mysql_query("SELECT id FROM pool_worker WHERE associatedUserId = $userId AND username = '$inputUser'"); 196 | $usernameExists = mysql_num_rows($usernameExistsQ); 197 | 198 | if($usernameExists == 0){ 199 | $addWorkerQ = mysql_query("INSERT INTO pool_worker (associatedUserId, username, password) VALUES('$userId', '$inputUser', '$inputPass')"); 200 | if($addWorkerQ){ 201 | $goodMessage = "Worker successfully added!"; 202 | }else if(!$addWorkerQ){ 203 | $returnError = "Database Error - Worker was not added :("; 204 | } 205 | }else if($usernameExists == 1){ 206 | $returnError = "Try using a different Worker Username"; 207 | } 208 | } 209 | 210 | 211 | if($act == "Update Worker"){ 212 | 213 | //Mysql Injection Protection 214 | $workerId = mysql_real_escape_string($_POST["workerId"]); 215 | $workernum = mysql_real_escape_string($_POST["workernum"]); 216 | $password = mysql_real_escape_string($_POST["password"]); 217 | 218 | $prefixUsername = $userInfo->username; 219 | $inputUser = $prefixUsername.".".mysql_real_escape_string($_POST["workernum"]); 220 | //update worker 221 | mysql_query("UPDATE pool_worker SET username = '$inputUser', password = '$password' WHERE id = '$workerId' AND associatedUserId = '$userId'"); 222 | } 223 | 224 | 225 | if($act == "Delete Worker"){ 226 | 227 | //Mysql Injection Protection 228 | $workerId = mysql_real_escape_string($_POST["workerId"]); 229 | 230 | //Delete worker OH NOES! 231 | mysql_query("DELETE FROM pool_worker WHERE id = '$workerId' AND associatedUserId = '$userId'"); 232 | } 233 | } 234 | 235 | //Display Error and Good Messages(If Any) 236 | echo "".$goodMessage."
"; 237 | echo "".$returnError.""; 238 | ?> 239 | Account Details
240 |
241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 |
Username: username);?>
User Id:
API Key:
Payment Address:
Permanently lock Bitcoin address to this account
Donation %:
Automatic Payout:
(1-25 BTC, 0 for manual)
Authorize Pin:
253 |
254 |
255 |
256 | Cash Out
257 | getsetting("sitetxfee") > 0) {?>(Please note: a getsetting("sitetxfee")?> btc transaction fee is required by the bitcoin client for processing)
258 |
259 | 260 | 261 | 262 | 263 | 264 |
Account Balance:
Payout to:
Authorize Pin:
265 |
266 |
267 |
268 | 269 | Change Password
270 |
271 | 272 | 273 | 274 | 275 | 276 |
Current Password:
New Password:
New Password Repeat:
Authorize Pin:
277 | (You will be redirected to the login screen upon success)
278 |
279 |
280 |
281 | 282 | Workers
283 | 284 | 285 | 290 | 291 | "> 292 | 297 | 298 | 299 | 300 | 301 | 303 | 304 | 305 | 306 | 307 | 310 |
Worker Name Worker PasswordActiveHashrate (Mhash/s)UpdateDelete
workerhashrate($worker["username"]) == 0) { ?>style="color: red">username); ?>." size="10">workerhashrate($worker["username"]) > 0) echo "Y"; else echo "N"; ?> 302 | workerhashrate($worker["username"]); ?>
311 |
314 | username);?>. ·
318 | 319 |
320 |
321 | 322 | 323 | -------------------------------------------------------------------------------- /js/visualize.jQuery.js: -------------------------------------------------------------------------------- 1 | /* 2 | * -------------------------------------------------------------------- 3 | * jQuery inputToButton plugin 4 | * Author: Scott Jehl, scott@filamentgroup.com 5 | * Copyright (c) 2009 Filament Group 6 | * licensed under MIT (filamentgroup.com/examples/mit-license.txt) 7 | * -------------------------------------------------------------------- 8 | */ 9 | (function($) { 10 | $.fn.visualize = function(options, container){ 11 | return $(this).each(function(){ 12 | //configuration 13 | var o = $.extend({ 14 | type: 'bar', //also available: area, pie, line 15 | width: $(this).width(), //height of canvas - defaults to table height 16 | height: $(this).height(), //height of canvas - defaults to table height 17 | appendTitle: true, //table caption text is added to chart 18 | title: null, //grabs from table caption if null 19 | appendKey: true, //color key is added to chart 20 | rowFilter: ' ', 21 | colFilter: ' ', 22 | colors: ['#be1e2d','#666699','#92d5ea','#ee8310','#8d10ee','#5a3b16','#26a4ed','#f45a90','#e9e744'], 23 | textColors: [], //corresponds with colors array. null/undefined items will fall back to CSS 24 | parseDirection: 'x', //which direction to parse the table data 25 | pieMargin: 20, //pie charts only - spacing around pie 26 | pieLabelsAsPercent: true, 27 | pieLabelPos: 'inside', 28 | lineWeight: 4, //for line and area - stroke weight 29 | barGroupMargin: 10, 30 | barMargin: 1, //space around bars in bar chart (added to both sides of bar) 31 | yLabelInterval: 30 //distance between y labels 32 | },options); 33 | 34 | //reset width, height to numbers 35 | o.width = parseFloat(o.width); 36 | o.height = parseFloat(o.height); 37 | 38 | 39 | var self = $(this); 40 | 41 | //function to scrape data from html table 42 | function scrapeTable(){ 43 | var colors = o.colors; 44 | var textColors = o.textColors; 45 | var tableData = { 46 | dataGroups: function(){ 47 | var dataGroups = []; 48 | if(o.parseDirection == 'x'){ 49 | self.find('tr:gt(0)').filter(o.rowFilter).each(function(i){ 50 | dataGroups[i] = {}; 51 | dataGroups[i].points = []; 52 | dataGroups[i].color = colors[i]; 53 | if(textColors[i]){ dataGroups[i].textColor = textColors[i]; } 54 | $(this).find('td').filter(o.colFilter).each(function(){ 55 | dataGroups[i].points.push( parseFloat($(this).text()) ); 56 | }); 57 | }); 58 | } 59 | else { 60 | var cols = self.find('tr:eq(1) td').filter(o.colFilter).size(); 61 | for(var i=0; itopValue) topValue = parseFloat(this); 93 | }); 94 | return topValue; 95 | }, 96 | bottomValue: function(){ 97 | var bottomValue = 0; 98 | var allData = this.allData().join(',').split(','); 99 | $(allData).each(function(){ 100 | if(thistopYtotal) topYtotal = parseFloat(this); 140 | }); 141 | return topYtotal; 142 | }, 143 | totalYRange: function(){ 144 | return this.topValue() - this.bottomValue(); 145 | }, 146 | xLabels: function(){ 147 | var xLabels = []; 148 | if(o.parseDirection == 'x'){ 149 | self.find('tr:eq(0) th').filter(o.colFilter).each(function(){ 150 | xLabels.push($(this).html()); 151 | }); 152 | } 153 | else { 154 | self.find('tr:gt(0) th').filter(o.rowFilter).each(function(){ 155 | xLabels.push($(this).html()); 156 | }); 157 | } 158 | return xLabels; 159 | }, 160 | yLabels: function(){ 161 | var yLabels = []; 162 | yLabels.push(bottomValue); 163 | var numLabels = Math.round(o.height / o.yLabelInterval); 164 | var loopInterval = Math.ceil(totalYRange / numLabels) || 1; 165 | while( yLabels[yLabels.length-1] < topValue - loopInterval){ 166 | yLabels.push(yLabels[yLabels.length-1] + loopInterval); 167 | } 168 | yLabels.push(topValue); 169 | return yLabels; 170 | } 171 | }; 172 | 173 | return tableData; 174 | }; 175 | 176 | 177 | //function to create a chart 178 | var createChart = { 179 | pie: function(){ 180 | 181 | canvasContain.addClass('visualize-pie'); 182 | 183 | if(o.pieLabelPos == 'outside'){ canvasContain.addClass('visualize-pie-outside'); } 184 | 185 | var centerx = Math.round(canvas.width()/2); 186 | var centery = Math.round(canvas.height()/2); 187 | var radius = centery - o.pieMargin; 188 | var counter = 0.0; 189 | var toRad = function(integer){ return (Math.PI/180)*integer; }; 190 | var labels = $('
    ') 191 | .insertAfter(canvas); 192 | 193 | //draw the pie pieces 194 | $.each(memberTotals, function(i){ 195 | var fraction = (this <= 0 || isNaN(this))? 0 : this / dataSum; 196 | ctx.beginPath(); 197 | ctx.moveTo(centerx, centery); 198 | ctx.arc(centerx, centery, radius, 199 | counter * Math.PI * 2 - Math.PI * 0.5, 200 | (counter + fraction) * Math.PI * 2 - Math.PI * 0.5, 201 | false); 202 | ctx.lineTo(centerx, centery); 203 | ctx.closePath(); 204 | ctx.fillStyle = dataGroups[i].color; 205 | ctx.fill(); 206 | // draw labels 207 | var sliceMiddle = (counter + fraction/2); 208 | var distance = o.pieLabelPos == 'inside' ? radius/1.5 : radius + radius / 5; 209 | var labelx = Math.round(centerx + Math.sin(sliceMiddle * Math.PI * 2) * (distance)); 210 | var labely = Math.round(centery - Math.cos(sliceMiddle * Math.PI * 2) * (distance)); 211 | var leftRight = (labelx > centerx) ? 'right' : 'left'; 212 | var topBottom = (labely > centery) ? 'bottom' : 'top'; 213 | var percentage = parseFloat((fraction*100).toFixed(2)); 214 | 215 | if(percentage){ 216 | var labelval = (o.pieLabelsAsPercent) ? percentage + '%' : this; 217 | var labeltext = $('' + labelval +'') 218 | .css(leftRight, 0) 219 | .css(topBottom, 0); 220 | if(labeltext) 221 | var label = $('
  • ') 222 | .appendTo(labels) 223 | .css({left: labelx, top: labely}) 224 | .append(labeltext); 225 | labeltext 226 | .css('font-size', radius / 8) 227 | .css('margin-'+leftRight, -labeltext.width()/2) 228 | .css('margin-'+topBottom, -labeltext.outerHeight()/2); 229 | 230 | if(dataGroups[i].textColor){ labeltext.css('color', dataGroups[i].textColor); } 231 | } 232 | counter+=fraction; 233 | }); 234 | }, 235 | 236 | line: function(area){ 237 | 238 | if(area){ canvasContain.addClass('visualize-area'); } 239 | else{ canvasContain.addClass('visualize-line'); } 240 | 241 | //write X labels 242 | var xInterval = canvas.width() / (xLabels.length -1); 243 | var xlabelsUL = $('
      ') 244 | .width(canvas.width()) 245 | .height(canvas.height()) 246 | .insertBefore(canvas); 247 | $.each(xLabels, function(i){ 248 | var thisLi = $('
    • '+this+'
    • ') 249 | .prepend('') 250 | .css('left', xInterval * i) 251 | .appendTo(xlabelsUL); 252 | var label = thisLi.find('span:not(.line)'); 253 | var leftOffset = label.width()/-2; 254 | if(i == 0){ leftOffset = 0; } 255 | else if(i== xLabels.length-1){ leftOffset = -label.width(); } 256 | label 257 | .css('margin-left', leftOffset) 258 | .addClass('label'); 259 | }); 260 | 261 | //write Y labels 262 | var yScale = canvas.height() / totalYRange; 263 | var liBottom = canvas.height() / (yLabels.length-1); 264 | var ylabelsUL = $('
        ') 265 | .width(canvas.width()) 266 | .height(canvas.height()) 267 | .insertBefore(canvas); 268 | 269 | $.each(yLabels, function(i){ 270 | var thisLi = $('
      • '+this+'
      • ') 271 | .prepend('') 272 | .css('bottom',liBottom*i) 273 | .prependTo(ylabelsUL); 274 | var label = thisLi.find('span:not(.line)'); 275 | var topOffset = label.height()/-2; 276 | if(i == 0){ topOffset = -label.height(); } 277 | else if(i== yLabels.length-1){ topOffset = 0; } 278 | label 279 | .css('margin-top', topOffset) 280 | .addClass('label'); 281 | }); 282 | 283 | //start from the bottom left 284 | ctx.translate(0,zeroLoc); 285 | //iterate and draw 286 | $.each(dataGroups,function(h){ 287 | ctx.beginPath(); 288 | ctx.lineWidth = o.lineWeight; 289 | ctx.lineJoin = 'round'; 290 | var points = this.points; 291 | var integer = 0; 292 | ctx.moveTo(0,-(points[0]*yScale)); 293 | $.each(points, function(){ 294 | ctx.lineTo(integer,-(this*yScale)); 295 | integer+=xInterval; 296 | }); 297 | ctx.strokeStyle = this.color; 298 | ctx.stroke(); 299 | if(area){ 300 | ctx.lineTo(integer,0); 301 | ctx.lineTo(0,0); 302 | ctx.closePath(); 303 | ctx.fillStyle = this.color; 304 | ctx.globalAlpha = .3; 305 | ctx.fill(); 306 | ctx.globalAlpha = 1.0; 307 | } 308 | else {ctx.closePath();} 309 | }); 310 | }, 311 | 312 | area: function(){ 313 | createChart.line(true); 314 | }, 315 | 316 | bar: function(){ 317 | 318 | canvasContain.addClass('visualize-bar'); 319 | 320 | //write X labels 321 | var xInterval = canvas.width() / (xLabels.length); 322 | var xlabelsUL = $('
          ') 323 | .width(canvas.width()) 324 | .height(canvas.height()) 325 | .insertBefore(canvas); 326 | $.each(xLabels, function(i){ 327 | var thisLi = $('
        • '+this+'
        • ') 328 | .prepend('') 329 | .css('left', xInterval * i) 330 | .width(xInterval) 331 | .appendTo(xlabelsUL); 332 | var label = thisLi.find('span.label'); 333 | label.addClass('label'); 334 | }); 335 | 336 | //write Y labels 337 | var yScale = canvas.height() / totalYRange; 338 | var liBottom = canvas.height() / (yLabels.length-1); 339 | var ylabelsUL = $('
            ') 340 | .width(canvas.width()) 341 | .height(canvas.height()) 342 | .insertBefore(canvas); 343 | $.each(yLabels, function(i){ 344 | var thisLi = $('
          • '+this+'
          • ') 345 | .prepend('') 346 | .css('bottom',liBottom*i) 347 | .prependTo(ylabelsUL); 348 | var label = thisLi.find('span:not(.line)'); 349 | var topOffset = label.height()/-2; 350 | if(i == 0){ topOffset = -label.height(); } 351 | else if(i== yLabels.length-1){ topOffset = 0; } 352 | label 353 | .css('margin-top', topOffset) 354 | .addClass('label'); 355 | }); 356 | 357 | //start from the bottom left 358 | ctx.translate(0,zeroLoc); 359 | //iterate and draw 360 | for(var h=0; h')) 393 | .height(o.height) 394 | .width(o.width) 395 | .append(canvas); 396 | 397 | //scrape table (this should be cleaned up into an obj) 398 | var tableData = scrapeTable(); 399 | var dataGroups = tableData.dataGroups(); 400 | var allData = tableData.allData(); 401 | var dataSum = tableData.dataSum(); 402 | var topValue = tableData.topValue(); 403 | var bottomValue = tableData.bottomValue(); 404 | var memberTotals = tableData.memberTotals(); 405 | var totalYRange = tableData.totalYRange(); 406 | var zeroLoc = o.height * (topValue/totalYRange); 407 | var xLabels = tableData.xLabels(); 408 | var yLabels = tableData.yLabels(); 409 | 410 | //title/key container 411 | if(o.appendTitle || o.appendKey){ 412 | var infoContain = $('
            ') 413 | .appendTo(canvasContain); 414 | } 415 | 416 | //append title 417 | if(o.appendTitle){ 418 | $('
            '+ title +'
            ').appendTo(infoContain); 419 | } 420 | 421 | 422 | //append key 423 | if(o.appendKey){ 424 | var newKey = $('
              '); 425 | var selector; 426 | if(o.parseDirection == 'x'){ 427 | selector = self.find('tr:gt(0) th').filter(o.rowFilter); 428 | } 429 | else{ 430 | selector = self.find('tr:eq(0) th').filter(o.colFilter); 431 | } 432 | 433 | selector.each(function(i){ 434 | $('
            • '+ $(this).text() +'
            • ') 435 | .appendTo(newKey); 436 | }); 437 | newKey.appendTo(infoContain); 438 | }; 439 | 440 | //append new canvas to page 441 | 442 | if(!container){canvasContain.insertAfter(this); } 443 | if( typeof(G_vmlCanvasManager) != 'undefined' ){ G_vmlCanvasManager.init(); G_vmlCanvasManager.initElement(canvas[0]); } 444 | 445 | //set up the drawing board 446 | var ctx = canvas[0].getContext('2d'); 447 | 448 | //create chart 449 | createChart[o.type](); 450 | 451 | //clean up some doubled lines that sit on top of canvas borders (done via JS due to IE) 452 | $('.visualize-line li:first-child span.line, .visualize-line li:last-child span.line, .visualize-area li:first-child span.line, .visualize-area li:last-child span.line, .visualize-bar li:first-child span.line,.visualize-bar .visualize-labels-y li:last-child span.line').css('border','none'); 453 | if(!container){ 454 | //add event for updating 455 | canvasContain.bind('visualizeRefresh', function(){ 456 | self.visualize(o, $(this).empty()); 457 | }); 458 | } 459 | }).next(); //returns canvas(es) 460 | }; 461 | })(jQuery); 462 | 463 | 464 | -------------------------------------------------------------------------------- /js/EnhanceJS/enhance.js: -------------------------------------------------------------------------------- 1 | /* 2 | * EnhanceJS version 1.1 - Test-Driven Progressive Enhancement 3 | * http://enhancejs.googlecode.com/ 4 | * Copyright (c) 2010 Filament Group, Inc, authors.txt 5 | * Licensed under MIT (license.txt) 6 | */ 7 | (function(win, doc, undefined) { 8 | var settings, body, fakeBody, windowLoaded, head, 9 | docElem = doc.documentElement, 10 | testPass = false, 11 | mediaCookieA, mediaCookieB, 12 | toggledMedia = []; 13 | 14 | if(doc.getElementsByTagName){ head = doc.getElementsByTagName('head')[0] || docElem; } 15 | else{ head = docElem; } 16 | 17 | win.enhance = function(options) { 18 | options = options || {}; 19 | settings = {}; 20 | // mixin settings 21 | for (var name in enhance.defaultSettings) { 22 | var option = options[name]; 23 | settings[name] = option !== undefined ? option : enhance.defaultSettings[name]; 24 | } 25 | // mixin additional tests 26 | for (var test in options.addTests) { 27 | settings.tests[test] = options.addTests[test]; 28 | } 29 | //add testName class immediately for FOUC prevention, remove later on fail 30 | if (docElem.className.indexOf(settings.testName) === -1) { 31 | docElem.className += ' ' + settings.testName; 32 | } 33 | //cookie names for toggled media types 34 | mediaCookieA = settings.testName + '-toggledmediaA'; 35 | mediaCookieB = settings.testName + '-toggledmediaB'; 36 | toggledMedia = [readCookie(mediaCookieA), readCookie(mediaCookieB)]; 37 | //fallback for removing testName class 38 | setTimeout(function(){ if(!testPass){ removeHTMLClass(); } }, 3000); 39 | 40 | runTests(); 41 | 42 | applyDocReadyHack(); 43 | 44 | windowLoad(function() { windowLoaded = true; }); 45 | }; 46 | 47 | enhance.defaultTests = { 48 | getById: function() { 49 | return !!doc.getElementById; 50 | }, 51 | getByTagName: function() { 52 | return !!doc.getElementsByTagName; 53 | }, 54 | createEl: function() { 55 | return !!doc.createElement; 56 | }, 57 | boxmodel: function() { 58 | var newDiv = doc.createElement('div'); 59 | newDiv.style.cssText = 'width: 1px; padding: 1px;'; 60 | body.appendChild(newDiv); 61 | var divWidth = newDiv.offsetWidth; 62 | body.removeChild(newDiv); 63 | return divWidth === 3; 64 | }, 65 | position: function() { 66 | var newDiv = doc.createElement('div'); 67 | newDiv.style.cssText = 'position: absolute; left: 10px;'; 68 | body.appendChild(newDiv); 69 | var divLeft = newDiv.offsetLeft; 70 | body.removeChild(newDiv); 71 | return divLeft === 10; 72 | }, 73 | floatClear: function() { 74 | var pass = false, 75 | newDiv = doc.createElement('div'), 76 | style = 'style="width: 5px; height: 5px; float: left;"'; 77 | newDiv.innerHTML = '
              '; 78 | body.appendChild(newDiv); 79 | var childNodes = newDiv.childNodes, 80 | topA = childNodes[0].offsetTop, 81 | divB = childNodes[1], 82 | topB = divB.offsetTop; 83 | if (topA === topB) { 84 | divB.style.clear = 'left'; 85 | topB = divB.offsetTop; 86 | if (topA !== topB) { 87 | pass = true; 88 | } 89 | } 90 | body.removeChild(newDiv); 91 | return pass; 92 | }, 93 | heightOverflow: function() { 94 | var newDiv = doc.createElement('div'); 95 | newDiv.innerHTML = '
              '; 96 | newDiv.style.cssText = 'overflow: hidden; height: 0;'; 97 | body.appendChild(newDiv); 98 | var divHeight = newDiv.offsetHeight; 99 | body.removeChild(newDiv); 100 | return divHeight === 0; 101 | }, 102 | ajax: function() { 103 | //factory test borrowed from quirksmode.org 104 | var xmlhttp = false, index = -1, factory, 105 | XMLHttpFactories = [ 106 | function() { return new XMLHttpRequest() }, 107 | function() { return new ActiveXObject("Msxml2.XMLHTTP") }, 108 | function() { return new ActiveXObject("Msxml3.XMLHTTP") }, 109 | function() { return new ActiveXObject("Microsoft.XMLHTTP") } 110 | ]; 111 | while ((factory = XMLHttpFactories[++index])) { 112 | try { xmlhttp = factory(); } 113 | catch (e) { continue; } 114 | break; 115 | } 116 | return !!xmlhttp; 117 | }, 118 | resize: function() { 119 | return win.onresize != false; 120 | }, 121 | print: function() { 122 | return !!win.print; 123 | } 124 | }; 125 | 126 | enhance.defaultSettings = { 127 | testName: 'enhanced', 128 | loadScripts: [], 129 | loadStyles: [], 130 | queueLoading: true, 131 | appendToggleLink: true, 132 | forcePassText: 'View high-bandwidth version', 133 | forceFailText: 'View low-bandwidth version', 134 | tests: enhance.defaultTests, 135 | addTests: {}, 136 | alertOnFailure: false, 137 | onPass: function(){}, 138 | onFail: function(){}, 139 | onLoadError: addIncompleteClass, 140 | onScriptsLoaded: function(){} 141 | }; 142 | 143 | function cookiesSupported(){ 144 | return !!doc.cookie; 145 | } 146 | enhance.cookiesSupported = cookiesSupported(); 147 | 148 | function forceFail() { 149 | createCookie(settings.testName, 'fail'); 150 | win.location.reload(); 151 | } 152 | if(enhance.cookiesSupported){ enhance.forceFail = forceFail; } 153 | 154 | function forcePass() { 155 | createCookie(settings.testName, 'pass'); 156 | win.location.reload(); 157 | } 158 | if(enhance.cookiesSupported){ enhance.forcePass = forcePass; } 159 | 160 | function reTest() { 161 | eraseCookie(settings.testName); 162 | win.location.reload(); 163 | } 164 | if(enhance.cookiesSupported){ enhance.reTest = reTest; } 165 | 166 | function addFakeBody(){ 167 | fakeBody = doc.createElement('body'); 168 | docElem.insertBefore(fakeBody, docElem.firstChild); 169 | body = fakeBody; 170 | } 171 | function removeFakeBody(){ 172 | docElem.removeChild(fakeBody); 173 | body = doc.body; 174 | } 175 | 176 | function runTests() { 177 | var result = readCookie(settings.testName); 178 | //check for cookies from a previous test 179 | if (result) { 180 | if (result === 'pass') { 181 | enhancePage(); 182 | settings.onPass(); 183 | } else { 184 | settings.onFail(); 185 | removeHTMLClass(); 186 | } 187 | 188 | // append toggle link 189 | if (settings.appendToggleLink) { 190 | windowLoad(function() { 191 | appendToggleLinks(result); 192 | }); 193 | } 194 | } 195 | //no cookies - run tests 196 | else { 197 | var pass = true; 198 | addFakeBody(); 199 | for (var name in settings.tests) { 200 | pass = settings.tests[name](); 201 | if (!pass) { 202 | if (settings.alertOnFailure) { 203 | alert(name + ' failed'); 204 | } 205 | break; 206 | } 207 | } 208 | removeFakeBody(); 209 | result = pass ? 'pass' : 'fail'; 210 | createCookie(settings.testName, result); 211 | if (pass) { 212 | enhancePage(); 213 | settings.onPass(); 214 | } 215 | else { 216 | settings.onFail(); 217 | removeHTMLClass(); 218 | } 219 | 220 | if (settings.appendToggleLink) { 221 | windowLoad(function() { 222 | appendToggleLinks(result); 223 | }); 224 | } 225 | } 226 | } 227 | 228 | function windowLoad(callback) { 229 | if (windowLoaded) { 230 | callback(); 231 | } else { 232 | var oldonload = win.onload 233 | win.onload = function() { 234 | if (oldonload) { oldonload(); } 235 | callback(); 236 | } 237 | } 238 | } 239 | 240 | function appendToggleLinks(result) { 241 | if (!settings.appendToggleLink || !enhance.cookiesSupported) { return; } 242 | if (result) { 243 | var a = doc.createElement('a'); 244 | a.href = "#"; 245 | a.className = settings.testName + '_toggleResult'; 246 | a.innerHTML = result === 'pass' ? settings.forceFailText : settings.forcePassText; 247 | a.onclick = result === 'pass' ? enhance.forceFail : enhance.forcePass; 248 | doc.getElementsByTagName('body')[0].appendChild(a); 249 | } 250 | } 251 | 252 | function removeHTMLClass(){ 253 | docElem.className = docElem.className.replace(settings.testName,''); 254 | } 255 | 256 | function enhancePage() { 257 | testPass = true; 258 | if (settings.loadStyles.length) { 259 | appendStyles(); 260 | } 261 | if (settings.loadScripts.length) { 262 | appendScripts(); 263 | } 264 | else{ 265 | settings.onScriptsLoaded(); 266 | } 267 | } 268 | 269 | //media toggling methods and storage 270 | function toggleMedia(mediaA,mediaB){ 271 | if(readCookie(mediaCookieA) && readCookie(mediaCookieB)){ 272 | eraseCookie(mediaCookieA); 273 | eraseCookie(mediaCookieB); 274 | } 275 | else{ 276 | createCookie(mediaCookieA, mediaA); 277 | createCookie(mediaCookieB, mediaB); 278 | } 279 | win.location.reload(); 280 | } 281 | enhance.toggleMedia = toggleMedia; 282 | 283 | //return a toggled media type/query 284 | function mediaSwitch(q){ 285 | if(toggledMedia.length == 2){ 286 | if(q == toggledMedia[0]){ q = toggledMedia[1]; } 287 | else if(q == toggledMedia[1]){ q = toggledMedia[0]; } 288 | } 289 | return q; 290 | } 291 | 292 | function addIncompleteClass (){ 293 | var errorClass = settings.testName + '-incomplete'; 294 | if (docElem.className.indexOf(errorClass) === -1) { 295 | docElem.className += ' ' + errorClass; 296 | } 297 | } 298 | 299 | function appendStyles() { 300 | var index = -1, 301 | item; 302 | while ((item = settings.loadStyles[++index])) { 303 | var link = doc.createElement('link'); 304 | link.type = 'text/css'; 305 | link.rel = 'stylesheet'; 306 | link.onerror = settings.onLoadError; 307 | 308 | if (typeof item === 'string') { 309 | link.href = item; 310 | head.appendChild(link); 311 | } 312 | else { 313 | if(item['media']){ item['media'] = mediaSwitch(item['media']); } 314 | if(item['excludemedia']){ item['excludemedia'] = mediaSwitch(item['excludemedia']); } 315 | 316 | for (var attr in item) { 317 | if (attr !== 'iecondition' && attr !== 'excludemedia') { 318 | link.setAttribute(attr, item[attr]); 319 | } 320 | } 321 | var applies = true; 322 | if(item['media'] && item['media'] !== 'print' && item['media'] !== 'projection' && item['media'] !== 'speech' && item['media'] !== 'aural' && item['media'] !== 'braille'){ 323 | applies = mediaquery(item['media']); 324 | } 325 | if(item['excludemedia']){ 326 | applies = !mediaquery(item['excludemedia']); 327 | } 328 | if (item['iecondition']) { 329 | applies = isIE(item['iecondition']); 330 | } 331 | if(applies){ 332 | head.appendChild(link); 333 | } 334 | } 335 | } 336 | } 337 | 338 | var isIE = (function() { 339 | var cache = {}, 340 | b; 341 | return function(condition) { 342 | if(/*@cc_on!@*/true){return false;} 343 | var cc = 'IE'; 344 | if(condition){ 345 | if(condition !== 'all'){ //deprecated support for 'all' keyword 346 | if( !isNaN(parseFloat(condition)) ){ 347 | cc += ' ' + condition; //deprecated support for straight version # 348 | } 349 | else { 350 | cc = condition; //recommended (conditional comment syntax) 351 | } 352 | } 353 | } 354 | if (cache[cc] === undefined) { 355 | b = b || doc.createElement('B'); 356 | b.innerHTML = ''; 357 | cache[cc] = !!b.getElementsByTagName('b').length; 358 | } 359 | return cache[cc]; 360 | } 361 | })(); 362 | 363 | //test whether a media query applies 364 | var mediaquery = (function(){ 365 | var cache = {}, 366 | testDiv = doc.createElement('div'); 367 | 368 | testDiv.setAttribute('id','ejs-qtest'); 369 | return function(q){ 370 | //check if any media types should be toggled 371 | if (cache[q] === undefined) { 372 | addFakeBody(); 373 | var styleBlock = doc.createElement('style'); 374 | styleBlock.type = "text/css"; 375 | head.appendChild(styleBlock); 376 | /*set inner css text. credit: http://www.phpied.com/dynamic-script-and-style-elements-in-ie/*/ 377 | var cssrule = '@media '+q+' { #ejs-qtest { position: absolute; width: 10px; } }'; 378 | if (styleBlock.styleSheet){ styleBlock.styleSheet.cssText = cssrule; } 379 | else { styleBlock.appendChild(doc.createTextNode(cssrule)); } 380 | body.appendChild(testDiv); 381 | var divWidth = testDiv.offsetWidth; 382 | body.removeChild(testDiv); 383 | head.removeChild(styleBlock); 384 | removeFakeBody(); 385 | cache[q] = (divWidth == 10); 386 | } 387 | return cache[q]; 388 | } 389 | })(); 390 | enhance.query = mediaquery; 391 | 392 | function appendScripts(){ 393 | settings.queueLoading ? appendScriptsSync() : appendScriptsAsync(); 394 | } 395 | 396 | function appendScriptsSync() { 397 | var queue = [].concat(settings.loadScripts); 398 | function next() { 399 | if (queue.length === 0) { 400 | return false; 401 | } 402 | var item = queue.shift(), 403 | script = createScriptTag(item), 404 | done = false; 405 | if(script){ 406 | script.onload = script.onreadystatechange = function() { 407 | if (!done && (!this.readyState || this.readyState == 'loaded' || this.readyState == 'complete')) { 408 | done = true; 409 | if(next() === false){ 410 | settings.onScriptsLoaded(); 411 | } 412 | this.onload = this.onreadystatechange = null; 413 | } 414 | } 415 | head.insertBefore(script, head.firstChild); 416 | } 417 | else{ 418 | return next(); 419 | } 420 | } 421 | next(); 422 | } 423 | 424 | function appendScriptsAsync() { 425 | var index = -1, 426 | item; 427 | while ((item = settings.loadScripts[++index])) { 428 | var script = createScriptTag(item); 429 | if(script){ 430 | head.insertBefore(script, head.firstChild); 431 | } 432 | } 433 | settings.onScriptsLoaded(); 434 | } 435 | 436 | function createScriptTag(item) { 437 | var script = doc.createElement('script'); 438 | script.type = 'text/javascript'; 439 | script.onerror = settings.onLoadError; 440 | if (typeof item === 'string') { 441 | script.src = item; 442 | return script; 443 | } 444 | else { 445 | if(item['media']){ item['media'] = mediaSwitch(item['media']); } 446 | if(item['excludemedia']){ item['excludemedia'] = mediaSwitch(item['excludemedia']); } 447 | 448 | for (var attr in item) { 449 | if (attr !== 'iecondition' && attr !== 'media' && attr !== 'excludemedia') { 450 | script.setAttribute(attr, item[attr]); 451 | } 452 | } 453 | var applies = true; 454 | if(item['media']){ 455 | applies = mediaquery(item['media']); 456 | } 457 | if(item['excludemedia']){ 458 | applies = !mediaquery(item['excludemedia']); 459 | } 460 | if (item['iecondition']) { 461 | applies = isIE(item['iecondition']); 462 | } 463 | return applies ? script : false; 464 | } 465 | } 466 | 467 | /* cookie functions from quirksmode.org (modified) */ 468 | function createCookie(name, value, days) { 469 | days = days || 90; 470 | var date = new Date(); 471 | date.setTime(date.getTime()+(days*24*60*60*1000)); 472 | var expires = "; expires="+date.toGMTString(); 473 | doc.cookie = name+"="+value+expires+"; path=/"; 474 | } 475 | 476 | function readCookie(name) { 477 | var nameEQ = name + "="; 478 | var ca = doc.cookie.split(';'); 479 | for (var i=0;i < ca.length;i++) { 480 | var c = ca[i]; 481 | while (c.charAt(0)==' ') c = c.substring(1,c.length); 482 | if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length); 483 | } 484 | return null; 485 | } 486 | 487 | function eraseCookie(name) { 488 | createCookie(name,"",-1); 489 | } 490 | 491 | function applyDocReadyHack() { 492 | // via http://webreflection.blogspot.com/2009/11/195-chars-to-help-lazy-loading.html 493 | // verify that document.readyState is undefined 494 | // verify that document.addEventListener is there 495 | // these two conditions are basically telling us 496 | // we are using Firefox < 3.6 497 | if (doc.readyState == null && doc.addEventListener){ 498 | // on DOMContentLoaded event, supported since ages 499 | doc.addEventListener("DOMContentLoaded", function DOMContentLoaded(){ 500 | // remove the listener itself 501 | doc.removeEventListener("DOMContentLoaded", DOMContentLoaded, false); 502 | // assign readyState as complete 503 | doc.readyState = "complete"; 504 | }, false); 505 | // set readyState = loading or interactive 506 | // it does not really matter for this purpose 507 | doc.readyState = "loading"; 508 | } 509 | } 510 | })(window, document); --------------------------------------------------------------------------------