Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
d75604d
Merge branch 'bootstrap' of https://github.com/MPOS/php-mpos into dev…
iAmShorty Mar 21, 2014
9a79363
Merge branch 'drop-baseline-shares' of https://github.com/MPOS/php-mp…
iAmShorty Mar 21, 2014
81fe0cf
Merge branch 'bootstrap' of https://github.com/MPOS/php-mpos into dev…
iAmShorty Mar 21, 2014
f76b2d5
Merge branch 'bootstrap' of https://github.com/MPOS/php-mpos into dev…
iAmShorty Mar 22, 2014
dd4beae
[UPDATE] style fixes
iAmShorty Mar 22, 2014
8ebecb7
Merge branch 'bootstrap' of https://github.com/MPOS/php-mpos into dev…
iAmShorty Mar 22, 2014
b9aa4aa
Merge branch 'development' of https://github.com/MPOS/php-mpos into d…
iAmShorty Mar 26, 2014
a555fa5
[FIX] Removed duplicate method implementation
MPOS123 Mar 26, 2014
6a79369
Merge pull request #2021 from MPOS/duplicate-method
TheSerapher Mar 26, 2014
3c6b645
[FIX] Admin News Delete Icon
nrpatten Mar 26, 2014
57c4e9c
Merge branch 'development' of https://github.com/MPOS/php-mpos into d…
iAmShorty Mar 26, 2014
2cc6943
[FIX] user invitations
iAmShorty Mar 26, 2014
26c0ee7
[FIX] user invitations style fix
iAmShorty Mar 26, 2014
2c81712
[FIX] stratum poke timeout error
iAmShorty Mar 26, 2014
222979e
[FIX] Login Form/Registration Form Look
nrpatten Mar 26, 2014
1d8fd33
[FIX] PPS 24 hour estimates
MPOS123 Mar 27, 2014
59d9a9a
[REPLACED] PHP mail() with Swiftmailer
MPOS123 Mar 27, 2014
623fc4c
[ADDED] Sendmail/SMTP configuration options
MPOS123 Mar 27, 2014
7a31e3c
Merge pull request #2035 from MPOS/swiftmailer
TheSerapher Mar 27, 2014
6159123
[CLEANUP] Admin Checks formatting and better exit message
MPOS123 Mar 27, 2014
79478ce
[FIX] stratum connect with timeout
iAmShorty Mar 27, 2014
3541d05
[FIX] socket timeout setting
iAmShorty Mar 27, 2014
256d438
[FIX] In case of SQL error function should return it
stambetto Mar 27, 2014
59f490d
[FIX] Wrong Memcache file path for Windows based systems
stambetto Mar 27, 2014
da40fd7
Merge branch 'development' of https://github.com/MPOS/php-mpos into d…
stambetto Mar 27, 2014
69ea8d9
Merge pull request #2038 from stambetto/development
TheSerapher Mar 27, 2014
8a272da
[FIX] table overflow ref issue #2022
nrpatten Mar 28, 2014
ab2a065
[FIX] Removed duplicate SQL upgrade
MPOS123 Mar 28, 2014
a9d7726
[FIX] Properly run all upgrades
MPOS123 Mar 28, 2014
5bb3727
[FIX] worker notification switch in user notifications
iAmShorty Mar 28, 2014
3089d07
Merge pull request #2042 from iAmShorty/notification-switch
TheSerapher Mar 28, 2014
f90f615
[UPDATE] style fixes, new designs
iAmShorty Mar 27, 2014
821d7ad
[FIX] isset host
iAmShorty Mar 28, 2014
4b13360
[UPDATE] more style fixes
iAmShorty Mar 28, 2014
9db6d7e
[FIX] admin news div fix
iAmShorty Mar 28, 2014
9fb6490
[UPDATE] more style fixes
iAmShorty Mar 28, 2014
ed517ed
[ADDED] Bonus to earnings page
MPOS123 Mar 28, 2014
a326cc3
Merge pull request #2044 from MPOS/add-bonus-earnings
TheSerapher Mar 28, 2014
bd8ae40
Merge pull request #2037 from iAmShorty/style-fixes
TheSerapher Mar 28, 2014
dbba22c
Fix bug in admin dashboard
lucasjones Mar 28, 2014
a70d6af
Merge pull request #2046 from LucasJones/development
TheSerapher Mar 28, 2014
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions public/include/admin_checks.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,18 @@

// poke stratum using gettingstarted details -> enotice
if (function_exists('socket_create')) {
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
if ($socket !== false) {
$address = @gethostbyname($config['gettingstarted']['stratumurl']);
$result = @socket_connect($socket, $address, $config['gettingstarted']['stratumport']);
if ($result !== true) {
$enotice[] = 'We tried to poke your Stratum server using your $config[\'gettingstarted\'] settings but it didn\'t respond';
}
$close = @socket_close($socket);
$host = @gethostbyname($config['gettingstarted']['stratumurl']);
$port = $config['gettingstarted']['stratumport'];

if (isset($host) and
isset($port) and
($socket=socket_create(AF_INET, SOCK_STREAM, SOL_TCP)) and
(socket_set_option($socket, SOL_SOCKET, SO_SNDTIMEO, array('sec' => 3, 'usec' => 0))) and
(@socket_connect($socket, $host, $port)))
{
socket_close($socket);
} else {
$enotice[] = 'We tried to poke your Stratum server using your $config[\'gettingstarted\'] settings but it didn\'t respond - ' . socket_strerror(socket_last_error());
}
} else {
// Connect via fsockopen as fallback
Expand Down
5 changes: 4 additions & 1 deletion public/include/autoloader.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
die('Unable to load your coins class definition for ' . $config['algorithm']);
}

// Swiftmailer
require_once(INCLUDE_DIR . '/lib/swiftmailer/swift_required.php');

// Detect device
if ( PHP_SAPI == 'cli') {
// Create a new compile folder just for crons
Expand Down Expand Up @@ -70,4 +73,4 @@
require_once(INCLUDE_DIR . '/lib/Michelf/Markdown.php');
require_once(INCLUDE_DIR . '/lib/scrypt.php');

?>
?>
42 changes: 33 additions & 9 deletions public/include/classes/mail.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,26 +46,50 @@ public function contactform($senderName, $senderEmail, $senderSubject, $senderMe
}

/**
* Send a mail with templating via Smarty
* Send a mail with templating via Smarty and Siftmailer
* @param template string Template name within the mail folder, no extension
* @param aData array Data array with some required fields
* SUBJECT : Mail Subject
* subject : Mail Subject
* email : Destination address
**/
public function sendMail($template, $aData) {
// Make sure we don't load a cached filed
// Prepare SMTP transport and mailer
$transport_type = $this->config['swiftmailer']['type'];
if ($transport_type == 'sendmail') {
$transport = Swift_SendmailTransport::newInstance($this->config['swiftmailer'][$transport_type]['path'] . ' ' . $this->config['swiftmailer'][$transport_type]['options']);
} else if ($this->config['swiftmailer']['type'] == 'smtp') {
$transport = Swift_SmtpTransport::newInstance($this->config['switfmailer']['smtp']['host'], $this->config['switfmailer']['smtp']['port'], $this->config['switfmailer']['smtp']['encryption']);
if (!empty($this->config['switfmailer']['smtp']['username']) && !empty($this->config['switfmailer']['smtp']['password'])) {
$transport->setUsername($this->config['switfmailer']['smtp']['username']);
$transport->setPassword($this->config['switfmailer']['smtp']['password']);
}
}
$mailer = Swift_Mailer::newInstance($transport);
// Prepare the smarty templates used
$this->smarty->clearCache(BASEPATH . 'templates/mail/' . $template . '.tpl');
$this->smarty->clearCache(BASEPATH . 'templates/mail/subject.tpl');
$this->smarty->assign('WEBSITENAME', $this->setting->getValue('website_name'));
$this->smarty->assign('SUBJECT', $aData['subject']);
$this->smarty->assign('DATA', $aData);
$headers = 'From: ' . $this->setting->getValue('website_name') . '<' . $this->setting->getValue('website_email') . ">\n";
$headers .= "MIME-Version: 1.0\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";

// Create new message for Swiftmailer
$message = Swift_Message::newInstance()
->setSubject($this->smarty->fetch(BASEPATH . 'templates/mail/subject.tpl'))
->setFrom(array( $this->setting->getValue('website_email') => $this->setting->getValue('website_name')))
->setTo($aData['email'])
->setSender($this->setting->getValue('website_email'))
->setReturnPath($this->setting->getValue('website_email'))
->setBody($this->smarty->fetch(BASEPATH . 'templates/mail/' . $template . '.tpl'), 'text/html');
if (strlen(@$aData['senderName']) > 0 && @strlen($aData['senderEmail']) > 0 )
$headers .= 'Reply-To: ' . $aData['senderName'] . ' <' . $aData['senderEmail'] . ">\n";
if (mail($aData['email'], $this->smarty->fetch(BASEPATH . 'templates/mail/subject.tpl'), $this->smarty->fetch(BASEPATH . 'templates/mail/' . $template . '.tpl'), $headers, '-f ' . $this->setting->getValue('website_email')))
return true;
$message->setReplyTo(array($aData['senderEmail'] => $aData['senderName']));

// Send message out with configured transport
try {
if ($mailer->send($message)) return true;
} catch (Exception $e) {
$this->setErrorMessage($e->getMessage());
return false;
}
$this->setErrorMessage($this->sqlError('E0031'));
return false;
}
Expand Down
3 changes: 1 addition & 2 deletions public/include/classes/monitoring.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,8 @@ public function getStatus($name) {
if ($query && $query->bind_param('s', $name) && $query->execute() && $result = $query->get_result()) {
return $result->fetch_assoc();
} else {
$this->sqlError();
return $this->sqlError();
}
return $value;
}

/**
Expand Down
9 changes: 9 additions & 0 deletions public/include/classes/setting.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@ public function createCache() {
return false;
}

/**
* Flush our local cache, may be required for upgrades
* or other places where we need live data
**/
public function flushCache() {
$this->cache = array();
return true;
}

/**
* Fetch a value from our table
* @param name string Setting name
Expand Down
10 changes: 0 additions & 10 deletions public/include/classes/share.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,16 +112,6 @@ public function getSharesForAccounts($previous_upstream=0, $current_upstream) {
return $this->sqlError();
}

/**
* Fetch the highest available share ID
**/
function getMaxShareId() {
$stmt = $this->mysqli->prepare("SELECT MAX(id) AS id FROM $this->table");
if ($this->checkStmt($stmt) && $stmt->execute() && $result = $stmt->get_result())
return $result->fetch_object()->id;
return $this->sqlError();
}

/**
* Fetch the highest available share ID from archive
**/
Expand Down
2 changes: 1 addition & 1 deletion public/include/classes/statistics.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ public function getAllUserShares() {
$data['data'][$row['id']]['is_anonymous'] = $row['is_anonymous'];
}
}
$data['share_id'] = $this->share->getMaxShareId();
$data['share_id'] = $this->share->getLastInsertedShareId();
return $this->memcache->setCache(STATISTICS_ALL_USER_SHARES, $data);
}
return $this->sqlError();
Expand Down
13 changes: 9 additions & 4 deletions public/include/classes/transaction.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,37 +109,42 @@ public function getTransactionSummary($account_id=NULL) {
public function getTransactionTypebyTime($account_id=NULL) {
$this->debug->append("STA " . __METHOD__, 4);
if ($data = $this->memcache->get(__FUNCTION__)) return $data;
$stmt = $this->mysqli->prepare("
SELECT
$stmt = $this->mysqli->prepare("
SELECT
IFNULL(SUM(IF(t.type = 'Credit' AND timestamp >= DATE_SUB(now(), INTERVAL 3600 SECOND), t.amount, 0)), 0) AS 1HourCredit,
IFNULL(SUM(IF(t.type = 'Bonus' AND timestamp >= DATE_SUB(now(), INTERVAL 3600 SECOND), t.amount, 0)), 0) AS 1HourBonus,
IFNULL(SUM(IF(t.type = 'Debit_MP' AND timestamp >= DATE_SUB(now(), INTERVAL 3600 SECOND), t.amount, 0)), 0) AS 1HourDebitMP,
IFNULL(SUM(IF(t.type = 'Debit_AP' AND timestamp >= DATE_SUB(now(), INTERVAL 3600 SECOND), t.amount, 0)), 0) AS 1HourDebitAP,
IFNULL(SUM(IF(t.type = 'TXFee' AND timestamp >= DATE_SUB(now(), INTERVAL 3600 SECOND), t.amount, 0)), 0) AS 1HourTXFee,
IFNULL(SUM(IF(t.type = 'Fee' AND timestamp >= DATE_SUB(now(), INTERVAL 3600 SECOND), t.amount, 0)), 0) AS 1HourFee,
IFNULL(SUM(IF(t.type = 'Donation' AND timestamp >= DATE_SUB(now(), INTERVAL 3600 SECOND), t.amount, 0)), 0) AS 1HourDonation,

IFNULL(SUM(IF(t.type = 'Credit' AND timestamp >= DATE_SUB(now(), INTERVAL 86400 SECOND), t.amount, 0)), 0) AS 24HourCredit,
IFNULL(SUM(IF(t.type = 'Bonus' AND timestamp >= DATE_SUB(now(), INTERVAL 86400 SECOND), t.amount, 0)), 0) AS 24HourBonus,
IFNULL(SUM(IF(t.type = 'Debit_MP' AND timestamp >= DATE_SUB(now(), INTERVAL 86400 SECOND), t.amount, 0)), 0) AS 24HourDebitMP,
IFNULL(SUM(IF(t.type = 'Debit_AP' AND timestamp >= DATE_SUB(now(), INTERVAL 86400 SECOND), t.amount, 0)), 0) AS 24HourDebitAP,
IFNULL(SUM(IF(t.type = 'TXFee' AND timestamp >= DATE_SUB(now(), INTERVAL 86400 SECOND), t.amount, 0)), 0) AS 24HourTXFee,
IFNULL(SUM(IF(t.type = 'Fee' AND timestamp >= DATE_SUB(now(), INTERVAL 86400 SECOND), t.amount, 0)), 0) AS 24HourFee,
IFNULL(SUM(IF(t.type = 'Donation' AND timestamp >= DATE_SUB(now(), INTERVAL 86400 SECOND), t.amount, 0)), 0) AS 24HourDonation,

IFNULL(SUM(IF(t.type = 'Credit' AND timestamp >= DATE_SUB(now(), INTERVAL 604800 SECOND), t.amount, 0)), 0) AS 1WeekCredit,
IFNULL(SUM(IF(t.type = 'Bonus' AND timestamp >= DATE_SUB(now(), INTERVAL 604800 SECOND), t.amount, 0)), 0) AS 1WeekBonus,
IFNULL(SUM(IF(t.type = 'Debit_MP' AND timestamp >= DATE_SUB(now(), INTERVAL 604800 SECOND), t.amount, 0)), 0) AS 1WeekDebitMP,
IFNULL(SUM(IF(t.type = 'Debit_AP' AND timestamp >= DATE_SUB(now(), INTERVAL 604800 SECOND), t.amount, 0)), 0) AS 1WeekDebitAP,
IFNULL(SUM(IF(t.type = 'TXFee' AND timestamp >= DATE_SUB(now(), INTERVAL 604800 SECOND), t.amount, 0)), 0) AS 1WeekTXFee,
IFNULL(SUM(IF(t.type = 'Fee' AND timestamp >= DATE_SUB(now(), INTERVAL 604800 SECOND), t.amount, 0)), 0) AS 1WeekFee,
IFNULL(SUM(IF(t.type = 'Donation' AND timestamp >= DATE_SUB(now(), INTERVAL 604800 SECOND), t.amount, 0)), 0) AS 1WeekDonation,

IFNULL(SUM(IF(t.type = 'Credit' AND timestamp >= DATE_SUB(now(), INTERVAL 2419200 SECOND), t.amount, 0)), 0) AS 1MonthCredit,
IFNULL(SUM(IF(t.type = 'Bonus' AND timestamp >= DATE_SUB(now(), INTERVAL 2419200 SECOND), t.amount, 0)), 0) AS 1MonthBonus,
IFNULL(SUM(IF(t.type = 'Debit_MP' AND timestamp >= DATE_SUB(now(), INTERVAL 2419200 SECOND), t.amount, 0)), 0) AS 1MonthDebitMP,
IFNULL(SUM(IF(t.type = 'Debit_AP' AND timestamp >= DATE_SUB(now(), INTERVAL 2419200 SECOND), t.amount, 0)), 0) AS 1MonthDebitAP,
IFNULL(SUM(IF(t.type = 'TXFee' AND timestamp >= DATE_SUB(now(), INTERVAL 2419200 SECOND), t.amount, 0)), 0) AS 1MonthTXFee,
IFNULL(SUM(IF(t.type = 'Fee' AND timestamp >= DATE_SUB(now(), INTERVAL 2419200 SECOND), t.amount, 0)), 0) AS 1MonthFee,
IFNULL(SUM(IF(t.type = 'Donation' AND timestamp >= DATE_SUB(now(), INTERVAL 2419200 SECOND), t.amount, 0)), 0) AS 1MonthDonation,

IFNULL(SUM(IF(t.type = 'Credit' AND timestamp >= DATE_SUB(now(), INTERVAL 31536000 SECOND), t.amount, 0)), 0) AS 1YearCredit,
IFNULL(SUM(IF(t.type = 'Bonus' AND timestamp >= DATE_SUB(now(), INTERVAL 31536000 SECOND), t.amount, 0)), 0) AS 1YearBonus,
IFNULL(SUM(IF(t.type = 'Debit_MP' AND timestamp >= DATE_SUB(now(), INTERVAL 31536000 SECOND), t.amount, 0)), 0) AS 1YearDebitMP,
IFNULL(SUM(IF(t.type = 'Debit_AP' AND timestamp >= DATE_SUB(now(), INTERVAL 31536000 SECOND), t.amount, 0)), 0) AS 1YearDebitAP,
IFNULL(SUM(IF(t.type = 'TXFee' AND timestamp >= DATE_SUB(now(), INTERVAL 31536000 SECOND), t.amount, 0)), 0) AS 1YearTXFee,
Expand Down
14 changes: 14 additions & 0 deletions public/include/config/global.inc.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,20 @@
$config['wallet']['username'] = 'testnet';
$config['wallet']['password'] = 'testnet';

/**
* Swiftmailer configuration
* Configure your way to send mails
* https://github.com/MPOS/php-mpos/wiki/Config-Setup#wiki-swiftmailer
**/
$config['swiftmailer']['type'] = 'sendmail';
$config['swiftmailer']['sendmail']['path'] = '/usr/sbin/sendmail';
$config['swiftmailer']['sendmail']['options'] = '-bs';
$config['switfmailer']['smtp']['host'] = 'your.mail-relay.com';
$config['switfmailer']['smtp']['port'] = '587';
$config['switfmailer']['smtp']['encryption'] = 'tls';
$config['switfmailer']['smtp']['username'] = '';
$config['switfmailer']['smtp']['password'] = '';

/**
* Getting Started Config
* Shown to users in the 'Getting Started' section
Expand Down
81 changes: 81 additions & 0 deletions public/include/lib/swiftmailer/classes/Swift.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<?php

/*
* This file is part of SwiftMailer.
* (c) 2004-2009 Chris Corbyn
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

/**
* General utility class in Swift Mailer, not to be instantiated.
*
* @package Swift
*
* @author Chris Corbyn
*/
abstract class Swift
{
public static $initialized = false;
public static $inits = array();

/** Swift Mailer Version number generated during dist release process */
const VERSION = '5.1.0';

/**
* Registers an initializer callable that will be called the first time
* a SwiftMailer class is autoloaded.
*
* This enables you to tweak the default configuration in a lazy way.
*
* @param mixed $callable A valid PHP callable that will be called when autoloading the first Swift class
*/
public static function init($callable)
{
self::$inits[] = $callable;
}

/**
* Internal autoloader for spl_autoload_register().
*
* @param string $class
*/
public static function autoload($class)
{
// Don't interfere with other autoloaders
if (0 !== strpos($class, 'Swift_')) {
return;
}

$path = dirname(__FILE__).'/'.str_replace('_', '/', $class).'.php';

if (!file_exists($path)) {
return;
}

require $path;

if (self::$inits && !self::$initialized) {
self::$initialized = true;
foreach (self::$inits as $init) {
call_user_func($init);
}
}
}

/**
* Configure autoloading using Swift Mailer.
*
* This is designed to play nicely with other autoloaders.
*
* @param mixed $callable A valid PHP callable that will be called when autoloading the first Swift class
*/
public static function registerAutoload($callable = null)
{
if (null !== $callable) {
self::$inits[] = $callable;
}
spl_autoload_register(array('Swift', 'autoload'));
}
}
73 changes: 73 additions & 0 deletions public/include/lib/swiftmailer/classes/Swift/Attachment.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<?php

/*
* This file is part of SwiftMailer.
* (c) 2004-2009 Chris Corbyn
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

/**
* Attachment class for attaching files to a {@link Swift_Mime_Message}.
*
* @package Swift
* @subpackage Mime
* @author Chris Corbyn
*/
class Swift_Attachment extends Swift_Mime_Attachment
{
/**
* Create a new Attachment.
*
* Details may be optionally provided to the constructor.
*
* @param string|Swift_OutputByteStream $data
* @param string $filename
* @param string $contentType
*/
public function __construct($data = null, $filename = null, $contentType = null)
{
call_user_func_array(
array($this, 'Swift_Mime_Attachment::__construct'),
Swift_DependencyContainer::getInstance()
->createDependenciesFor('mime.attachment')
);

$this->setBody($data);
$this->setFilename($filename);
if ($contentType) {
$this->setContentType($contentType);
}
}

/**
* Create a new Attachment.
*
* @param string|Swift_OutputByteStream $data
* @param string $filename
* @param string $contentType
*
* @return Swift_Mime_Attachment
*/
public static function newInstance($data = null, $filename = null, $contentType = null)
{
return new self($data, $filename, $contentType);
}

/**
* Create a new Attachment from a filesystem path.
*
* @param string $path
* @param string $contentType optional
*
* @return Swift_Mime_Attachment
*/
public static function fromPath($path, $contentType = null)
{
return self::newInstance()->setFile(
new Swift_ByteStream_FileByteStream($path),
$contentType
);
}
}
Loading