Skip to content

Commit acced2b

Browse files
committed
Merge pull request #1853 from MPOS/bootstrap
[ENHANCEMENT] Bootstrap implementation
2 parents dfd8985 + ff6b267 commit acced2b

File tree

323 files changed

+45765
-1699
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

323 files changed

+45765
-1699
lines changed

cronjobs/tickerupdate.php

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,26 @@
3333
$strLogMask = "| %-25.25s | %15.15s | %8.8s | %-6.6s | %-80.80s |";
3434
$log->logInfo(sprintf($strLogMask, 'Method', 'Value', 'Runtime', 'Status', 'Message'));
3535

36+
empty($config['price']['enabled']) ? $tickerupdate = false : $tickerupdate = $config['price']['enabled'];
37+
3638
// Fetch latest coin price via API call
3739
$start = microtime(true);
38-
$message = 'Updated latest ' . $config['currency'] . ' price from ' . $config['price']['url'] . ' API';
39-
$status = 'OK';
40-
if ($price = $tools->getPrice()) {
41-
if (!$setting->setValue('price', $price)) {
42-
$message = 'Unable to store new price value: ' . $setting->getCronError();
40+
if ($tickerupdate) {
41+
$message = 'Updated latest ' . $config['currency'] . ' price from ' . $config['price']['url'] . ' API';
42+
$status = 'OK';
43+
if ($price = $tools->getPrice()) {
44+
if (!$setting->setValue('price', $price)) {
45+
$message = 'Unable to store new price value: ' . $setting->getCronError();
46+
$status = 'ERROR';
47+
}
48+
} else {
49+
$message = 'Failed to fetch price from API: ' . $tools->getCronError();
4350
$status = 'ERROR';
4451
}
4552
} else {
46-
$message = 'Failed to fetch price from API: ' . $tools->getCronError();
47-
$status = 'ERROR';
53+
$message = 'Tickerupdate is disabled';
54+
$status = 'OK';
55+
$price = 0;
4856
}
4957
$log->logInfo(sprintf($strLogMask, 'Price Update', $price, number_format(microtime(true) - $start, 3), $status, $message));
5058

public/include/admin_checks.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,16 +127,16 @@
127127

128128
// display the errors
129129
foreach ($enotice as $en) {
130-
$_SESSION['POPUP'][] = array('CONTENT' => $en, 'TYPE' => 'info');
130+
$_SESSION['POPUP'][] = array('CONTENT' => $en, 'TYPE' => 'alert alert-info');
131131
}
132132
if (!count($notice) && !count($error)) {
133-
$_SESSION['POPUP'][] = array('CONTENT' => 'The config options we checked seem OK', 'TYPE' => 'success');
133+
$_SESSION['POPUP'][] = array('CONTENT' => 'The config options we checked seem OK', 'TYPE' => 'alert alert-success');
134134
} else {
135135
foreach ($notice as $n) {
136-
$_SESSION['POPUP'][] = array('CONTENT' => $n, 'TYPE' => 'warning');
136+
$_SESSION['POPUP'][] = array('CONTENT' => $n, 'TYPE' => 'alert alert-warning');
137137
}
138138
foreach ($error as $e) {
139-
$_SESSION['POPUP'][] = array('CONTENT' => $e, 'TYPE' => 'errormsg');
139+
$_SESSION['POPUP'][] = array('CONTENT' => $e, 'TYPE' => 'alert alert-danger');
140140
}
141141
}
142142
}

public/include/autoloader.inc.php

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,14 @@
2727
die('Unable to load your coins class definition for ' . $config['algorithm']);
2828
}
2929

30-
// We need this one in here to properly set our theme
31-
require_once(INCLUDE_DIR . '/lib/Mobile_Detect.php');
32-
3330
// Detect device
34-
if ($detect->isMobile() && $setting->getValue('website_mobile_theme')) {
35-
// Set to mobile theme
36-
$setting->getValue('website_mobile_theme') ? $theme = $setting->getValue('website_mobile_theme') : $theme = 'mobile';
37-
} else if ( PHP_SAPI == 'cli') {
31+
if ( PHP_SAPI == 'cli') {
3832
// Create a new compile folder just for crons
3933
// We call mail templates directly anyway
4034
$theme = 'cron';
4135
} else {
4236
// Use configured theme, fallback to default theme
43-
$setting->getValue('website_theme') ? $theme = $setting->getValue('website_theme') : $theme = 'mpos';
37+
$setting->getValue('website_theme') ? $theme = $setting->getValue('website_theme') : $theme = 'bootstrap';
4438
}
4539
define('THEME', $theme);
4640

@@ -76,4 +70,4 @@
7670
require_once(INCLUDE_DIR . '/lib/Michelf/Markdown.php');
7771
require_once(INCLUDE_DIR . '/lib/scrypt.php');
7872

79-
?>
73+
?>

public/include/bootstrap.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,4 @@
3636
// We include all needed files here, even though our templates could load them themself
3737
require_once(INCLUDE_DIR . '/autoloader.inc.php');
3838

39-
?>
39+
?>

public/include/classes/notification.class.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,10 @@ public function addNotification($account_id, $type, $data) {
5858
* @param id int Account ID
5959
* @return array Notification data
6060
**/
61-
public function getNotifications($account_id) {
61+
public function getNotifications($account_id,$limit=50) {
6262
$this->debug->append("STA " . __METHOD__, 4);
63-
$stmt = $this->mysqli->prepare("SELECT * FROM $this->table WHERE account_id = ? ORDER BY time DESC");
64-
if ($stmt && $stmt->bind_param('i', $account_id) && $stmt->execute() && $result = $stmt->get_result())
63+
$stmt = $this->mysqli->prepare("SELECT * FROM $this->table WHERE account_id = ? ORDER BY time DESC LIMIT ?");
64+
if ($stmt && $stmt->bind_param('ii', $account_id, $limit) && $stmt->execute() && $result = $stmt->get_result())
6565
return $result->fetch_all(MYSQLI_ASSOC);
6666
return $this->getError();
6767
}

public/include/classes/template.class.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,23 @@ public function getThemes() {
3131
return $aThemes;
3232
}
3333

34+
/**
35+
* Get all available designs
36+
* Read css files from css/design folder
37+
*
38+
* @return array - list of available designs
39+
*/
40+
public function getDesigns() {
41+
$this->debug->append("STA " . __METHOD__, 4);
42+
$aTmpDesigns = glob(BASEPATH . 'site_assets/' . THEME . '/css/design/*.css');
43+
$aDesigns = array();
44+
$aDesigns['default'] = 'default';
45+
foreach ($aTmpDesigns as $filename) {
46+
if (basename($filename) != '.' && basename($filename) != '..') $aDesigns[basename($filename, ".css")] = basename($filename, ".css");
47+
}
48+
return $aDesigns;
49+
}
50+
3451
/**
3552
* Cached getActiveTemplates method
3653
*

public/include/classes/transaction.class.php

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,60 @@ public function getTransactionSummary($account_id=NULL) {
100100
return $this->sqlError();
101101
}
102102

103+
104+
/**
105+
* Fetch a transaction summary by user with total amounts
106+
* @param account_id int Account ID, NULL for all
107+
* @return data array type and total
108+
**/
109+
public function getTransactionTypebyTime($account_id=NULL) {
110+
$this->debug->append("STA " . __METHOD__, 4);
111+
if ($data = $this->memcache->get(__FUNCTION__)) return $data;
112+
$stmt = $this->mysqli->prepare("
113+
SELECT
114+
IFNULL(SUM(IF(t.type = 'Credit' AND timestamp >= DATE_SUB(now(), INTERVAL 3600 SECOND), t.amount, 0)), 0) AS 1HourCredit,
115+
IFNULL(SUM(IF(t.type = 'Debit_MP' AND timestamp >= DATE_SUB(now(), INTERVAL 3600 SECOND), t.amount, 0)), 0) AS 1HourDebitMP,
116+
IFNULL(SUM(IF(t.type = 'Debit_AP' AND timestamp >= DATE_SUB(now(), INTERVAL 3600 SECOND), t.amount, 0)), 0) AS 1HourDebitAP,
117+
IFNULL(SUM(IF(t.type = 'TXFee' AND timestamp >= DATE_SUB(now(), INTERVAL 3600 SECOND), t.amount, 0)), 0) AS 1HourTXFee,
118+
IFNULL(SUM(IF(t.type = 'Fee' AND timestamp >= DATE_SUB(now(), INTERVAL 3600 SECOND), t.amount, 0)), 0) AS 1HourFee,
119+
IFNULL(SUM(IF(t.type = 'Donation' AND timestamp >= DATE_SUB(now(), INTERVAL 3600 SECOND), t.amount, 0)), 0) AS 1HourDonation,
120+
121+
IFNULL(SUM(IF(t.type = 'Credit' AND timestamp >= DATE_SUB(now(), INTERVAL 86400 SECOND), t.amount, 0)), 0) AS 24HourCredit,
122+
IFNULL(SUM(IF(t.type = 'Debit_MP' AND timestamp >= DATE_SUB(now(), INTERVAL 86400 SECOND), t.amount, 0)), 0) AS 24HourDebitMP,
123+
IFNULL(SUM(IF(t.type = 'Debit_AP' AND timestamp >= DATE_SUB(now(), INTERVAL 86400 SECOND), t.amount, 0)), 0) AS 24HourDebitAP,
124+
IFNULL(SUM(IF(t.type = 'TXFee' AND timestamp >= DATE_SUB(now(), INTERVAL 86400 SECOND), t.amount, 0)), 0) AS 24HourTXFee,
125+
IFNULL(SUM(IF(t.type = 'Fee' AND timestamp >= DATE_SUB(now(), INTERVAL 86400 SECOND), t.amount, 0)), 0) AS 24HourFee,
126+
IFNULL(SUM(IF(t.type = 'Donation' AND timestamp >= DATE_SUB(now(), INTERVAL 86400 SECOND), t.amount, 0)), 0) AS 24HourDonation,
127+
128+
IFNULL(SUM(IF(t.type = 'Credit' AND timestamp >= DATE_SUB(now(), INTERVAL 604800 SECOND), t.amount, 0)), 0) AS 1WeekCredit,
129+
IFNULL(SUM(IF(t.type = 'Debit_MP' AND timestamp >= DATE_SUB(now(), INTERVAL 604800 SECOND), t.amount, 0)), 0) AS 1WeekDebitMP,
130+
IFNULL(SUM(IF(t.type = 'Debit_AP' AND timestamp >= DATE_SUB(now(), INTERVAL 604800 SECOND), t.amount, 0)), 0) AS 1WeekDebitAP,
131+
IFNULL(SUM(IF(t.type = 'TXFee' AND timestamp >= DATE_SUB(now(), INTERVAL 604800 SECOND), t.amount, 0)), 0) AS 1WeekTXFee,
132+
IFNULL(SUM(IF(t.type = 'Fee' AND timestamp >= DATE_SUB(now(), INTERVAL 604800 SECOND), t.amount, 0)), 0) AS 1WeekFee,
133+
IFNULL(SUM(IF(t.type = 'Donation' AND timestamp >= DATE_SUB(now(), INTERVAL 604800 SECOND), t.amount, 0)), 0) AS 1WeekDonation,
134+
135+
IFNULL(SUM(IF(t.type = 'Credit' AND timestamp >= DATE_SUB(now(), INTERVAL 2419200 SECOND), t.amount, 0)), 0) AS 1MonthCredit,
136+
IFNULL(SUM(IF(t.type = 'Debit_MP' AND timestamp >= DATE_SUB(now(), INTERVAL 2419200 SECOND), t.amount, 0)), 0) AS 1MonthDebitMP,
137+
IFNULL(SUM(IF(t.type = 'Debit_AP' AND timestamp >= DATE_SUB(now(), INTERVAL 2419200 SECOND), t.amount, 0)), 0) AS 1MonthDebitAP,
138+
IFNULL(SUM(IF(t.type = 'TXFee' AND timestamp >= DATE_SUB(now(), INTERVAL 2419200 SECOND), t.amount, 0)), 0) AS 1MonthTXFee,
139+
IFNULL(SUM(IF(t.type = 'Fee' AND timestamp >= DATE_SUB(now(), INTERVAL 2419200 SECOND), t.amount, 0)), 0) AS 1MonthFee,
140+
IFNULL(SUM(IF(t.type = 'Donation' AND timestamp >= DATE_SUB(now(), INTERVAL 2419200 SECOND), t.amount, 0)), 0) AS 1MonthDonation,
141+
142+
IFNULL(SUM(IF(t.type = 'Credit' AND timestamp >= DATE_SUB(now(), INTERVAL 31536000 SECOND), t.amount, 0)), 0) AS 1YearCredit,
143+
IFNULL(SUM(IF(t.type = 'Debit_MP' AND timestamp >= DATE_SUB(now(), INTERVAL 31536000 SECOND), t.amount, 0)), 0) AS 1YearDebitMP,
144+
IFNULL(SUM(IF(t.type = 'Debit_AP' AND timestamp >= DATE_SUB(now(), INTERVAL 31536000 SECOND), t.amount, 0)), 0) AS 1YearDebitAP,
145+
IFNULL(SUM(IF(t.type = 'TXFee' AND timestamp >= DATE_SUB(now(), INTERVAL 31536000 SECOND), t.amount, 0)), 0) AS 1YearTXFee,
146+
IFNULL(SUM(IF(t.type = 'Fee' AND timestamp >= DATE_SUB(now(), INTERVAL 31536000 SECOND), t.amount, 0)), 0) AS 1YearFee,
147+
IFNULL(SUM(IF(t.type = 'Donation' AND timestamp >= DATE_SUB(now(), INTERVAL 31536000 SECOND), t.amount, 0)), 0) AS 1YearDonation
148+
FROM transactions AS t
149+
LEFT OUTER JOIN blocks AS b ON b.id = t.block_id
150+
WHERE
151+
t.account_id = ? AND (b.confirmations > 0 OR b.id IS NULL)");
152+
if ($this->checkStmt($stmt) && $stmt->bind_param("i", $account_id) && $stmt->execute() && $result = $stmt->get_result())
153+
return $this->memcache->setCache(__FUNCTION__ . $account_id, $result->fetch_assoc(), 60);
154+
return $this->sqlError();
155+
}
156+
103157
/**
104158
* Get all transactions from start for account_id
105159
* @param start int Starting point, id of transaction

public/include/config/admin_settings.inc.php

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
$defflip = (!cfip()) ? exit(header('HTTP/1.1 401 Unauthorized')) : 1;
33

44
$aThemes = $template->getThemes();
5+
$aDesigns = $template->getDesigns();
56

67
// Load the settings available in this system
78
$aSettings['website'][] = array(
@@ -49,16 +50,30 @@
4950
$aSettings['website'][] = array(
5051
'display' => 'Website theme', 'type' => 'select',
5152
'options' => $aThemes,
52-
'default' => 'mpos',
53+
'default' => 'bootstrap',
5354
'name' => 'website_theme', 'value' => $setting->getValue('website_theme'),
5455
'tooltip' => 'The default theme used on your pool.'
5556
);
5657
$aSettings['website'][] = array(
57-
'display' => 'Website mobile theme', 'type' => 'select',
58-
'options' => $aThemes,
59-
'default' => 'mobile',
60-
'name' => 'website_mobile_theme', 'value' => $setting->getValue('website_mobile_theme'),
61-
'tooltip' => 'The mobile theme used for your pool.'
58+
'display' => 'Website Design', 'type' => 'select',
59+
'options' => $aDesigns,
60+
'default' => 'default',
61+
'name' => 'website_design', 'value' => $setting->getValue('website_design'),
62+
'tooltip' => 'The default design used on your pool.'
63+
);
64+
$aSettings['website'][] = array(
65+
'display' => 'Website News Style', 'type' => 'select',
66+
'options' => array( 0 => 'Show all news in one Page', 1 => 'Show Responsive News Table' ),
67+
'default' => 0,
68+
'name' => 'website_news_style', 'value' => $setting->getValue('website_news_style'),
69+
'tooltip' => 'How News are displayed on Main Page.'
70+
);
71+
$aSettings['website'][] = array(
72+
'display' => 'Auto Hide Notifications', 'type' => 'select',
73+
'options' => array( 0 => 'Notifications always visible', 1 => 'Hide Notifications automatically' ),
74+
'default' => 0,
75+
'name' => 'website_notification_autohide', 'value' => $setting->getValue('website_notification_autohide'),
76+
'tooltip' => 'Hides Notifications after 5 seconds.'
6277
);
6378
$aSettings['blockchain'][] = array(
6479
'display' => 'Disable Blockexplorer', 'type' => 'select',
@@ -432,3 +447,18 @@
432447
'name' => 'notifications_disable_idle_worker', 'value' => $setting->getValue('notifications_disable_idle_worker'),
433448
'tooltip' => 'Enable/Disable IDLE worker notifications globally. Will remove the user option too.'
434449
);
450+
$aSettings['pools'][] = array(
451+
'display' => 'Enable Pool Navigation', 'type' => 'select',
452+
'options' => array( 0 => 'No', 1 => 'Yes' ),
453+
'default' => 0,
454+
'name' => 'poolnav_enabled', 'value' => $setting->getValue('poolnav_enabled'),
455+
'tooltip' => 'Enable or Disable Pool Navigation for multiple Pools in Header.'
456+
);
457+
$aSettings['pools'][] = array(
458+
'display' => 'Pools for Pool Navigation', 'type' => 'textarea',
459+
'size' => 20,
460+
'height' => 12,
461+
'default' => 'Pool Name|Pool URL',
462+
'name' => 'poolnav_pools', 'value' => $setting->getValue('poolnav_pools'),
463+
'tooltip' => '.'
464+
);

public/include/config/global.inc.dist.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
* Fetch exchange rates via an API
7373
* https://github.com/MPOS/php-mpos/wiki/Config-Setup#wiki-ticker-api
7474
**/
75+
$config['price']['enabled'] = false;
7576
$config['price']['url'] = 'https://btc-e.com';
7677
$config['price']['target'] = '/api/2/ltc_usd/ticker';
7778
$config['price']['currency'] = 'USD';

0 commit comments

Comments
 (0)