From b2ae8efbd0928e02669bce42c04df3f07cec8aa1 Mon Sep 17 00:00:00 2001 From: nrpatten Date: Thu, 12 Sep 2013 19:20:54 +1000 Subject: [PATCH 01/19] Create default.tpl --- public/templates/test/about/default.tpl | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 public/templates/test/about/default.tpl diff --git a/public/templates/test/about/default.tpl b/public/templates/test/about/default.tpl new file mode 100644 index 00000000..f1369c6a --- /dev/null +++ b/public/templates/test/about/default.tpl @@ -0,0 +1,25 @@ +
+

About PPLNS Payout system, Facts and myths

+
+ + +

First of all if talking about PPLNS it is important to understand how it works. PPLNS is short for .Pay Per Last N Shares.. The current proportional reward system is round based. One round is the time between the first share after the last found block and the share which solves a block. PPLNS however means that we no longer consider valid shares of one round but we consider a number N of shares. No matter if they are part of the round or not. The number N is currently for each blockchain twice the difficulty (actually rounded down to an easy to calculate integer value).

+

Let me illustrate PPLNS using the image below. One round has an arbitrary number of shares which is solely based on sheer luck. On proportional reward system only shares of one round are considered for calculating rewards. However with PPLNS a quite constant number N of shares is considered for calculating rewards. This number N changes only with the difficulty. Please have a look at the image below:

+

PPLNS share per round

+

As you know the number of shares needed to solve a block within a round is different. Round one and three needed (difficulty * 2) shares to be solved. Round two and four are quite short rounds. There were less than (difficulty * 2) shares nessecary to solve them. Round five however is a very long round which means the pool needed more than (difficulty * 2) shares to solve the block. From this follows that:

+
    +
  • Rounds one and three are like proportional rounds. All of your shares from the given round are considered for reward calculations.
  • +
  • For rounds two and four shares from the previous rounds are considered for calculations as well (marked green). In other words: regardless of round boundaries we always consider the last (difficulty * 2) shares. Your portion of the amount of shares is used to calculate your reward.
  • +
  • Round five however is very long. In this round your lowermost shares (within the marked red part) are silently dropped if they are not within the last (difficulty * 2) shares.
  • +
+

Why do we need to switch the reward system at all?

+

PPLNS favors constant and/or occasional loyal pool members over pool hoppers. As you might have seen each time we find a LTC block the pools hashrate peaks instantly. This is due to pool hoppers starting to mine. They are betting for a .quick win. (like round two above) with low shares per round. If the round exceeds a certain amount of shares they .hop. to another proportional pool which started a new round more recently trying their luck on the other pool. This assures better rewards for pool hoppers over occasional or constant miners which are loyal to their pool. Pool hopping however implies that pool hoppers need to know when a round is started and how much shares are considered for reward. This is very easy with propotional reward system. Using PPLNS this is no longer true. On long rounds (like round five above) the pool hoppers shares won.t be considered for reward calculations in favor of loyal miners. This is due to the fact that pool hoppers only mine on the beginning of rounds. On short and normal rounds pool hoppers won.t loose their shares. But due to the fact that shares from previous rounds from loyal miners are considered twice (or even more often on extremely short rounds) the pool hopper won.t get the same reward as from proportional reward system.

+

I.m only an occasional miner. Will I loose shares if playing/being offline?

+

It depends. Even if you are a constant miner you.ll loose shares on very long rounds. On the other hand if you for example stop mining shortly before the end of round three from the image above you.ll be rewarded for round three. If you then start mining on the mid of round five you.ll be rewarded a bit for round four (despite the fact you haven.t submitted any shares as some of your shares from round three are considered for round four as well) and you.ll be fully rewarded for round five (you won.t loose any shares as you .skipped. the .red part. of shares which have been cut off due to the length of the round). The point however is no one (and thus the pool hopper as well) knows when a round ends in advance. Thus you deliberately can.t avoid cut offs. Sometimes you are lucky sometimes your are not. This however levels out over the time for non-hoppers. The important point is, that you as loyal pool member have an advantage over pool hoppers. Even if you are mining only occasionally in order to enjoy the silence within your mining room.

+

Isn.t it that you as pool operator earn more from PPLNS?

+

Short answer: No. As a pool operator I. In fact for a pool operator it doesn.t matter at all which reward system is used. I expect rounds to become a bit longer after PPLNS is activated as the pool hoppers will start to avoid the Pool. Thus revenues for me will be lower. But there were some loyal pool members who clearly stated that they want to get rid of the pool hoppers and I respect their wish. Furthermore I.m too an occasional miner on the Pool as I don.t want the miners to be running at night and from time to time I need them to test new Pool versions on development systems. Thus being a miner like you I like PPLNS better than proportional. But speaking as pool operator there is no difference between the reward systems.

+

Thanks to g2x3k/Poolx-eu for PPLNS description

+ +
+
+
From 18e977e12da4e575303e7b201f9d264a1b56c9d7 Mon Sep 17 00:00:00 2001 From: nrpatten Date: Thu, 12 Sep 2013 19:21:57 +1000 Subject: [PATCH 02/19] Create default.tpl --- public/templates/test/about/api/default.tpl | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 public/templates/test/about/api/default.tpl diff --git a/public/templates/test/about/api/default.tpl b/public/templates/test/about/api/default.tpl new file mode 100644 index 00000000..888d3a24 --- /dev/null +++ b/public/templates/test/about/api/default.tpl @@ -0,0 +1,10 @@ +
+

API Reference

+
+
+ +

Please head over to the official documentation to learn about the API featured in mmcfe-ng.

+
+
+
+
From acecc5ea1dd2287f36ced1193d09460fb3585c58 Mon Sep 17 00:00:00 2001 From: nrpatten Date: Thu, 12 Sep 2013 19:22:56 +1000 Subject: [PATCH 03/19] Create default.tpl --- public/templates/test/about/pool/default.tpl | 32 ++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 public/templates/test/about/pool/default.tpl diff --git a/public/templates/test/about/pool/default.tpl b/public/templates/test/about/pool/default.tpl new file mode 100644 index 00000000..ec0fbbcf --- /dev/null +++ b/public/templates/test/about/pool/default.tpl @@ -0,0 +1,32 @@ +
+

ThePool Collective

+
+ + +

After mining in other pools I have decided to setup my own pool, mostly for educational reason. I was curious how pools work, what is needed to get them started and what tools can be used to run them.

+

Lots of digging finally revealed that the following tools were required to run a Litecoin pool:

+ +
    +
  • Litecoin
  • +
  • 1. Provides litecoind, used to synchronize blocks and offer the API the pool connects to
  • +
  • Pushpool 0.5.1-tenebrix, a modified version of Pushpool supporting changed target difficulties (2^22 in this pool)
  • +
  • 2. Provides the API each worker (client miner) authenticates and connects to
  • +
  • mmcFE modified by Greedi & g2x3k with adjustments for this pool (proper hashrate for 2^22 difficulty)
  • +
  • 3. The Webinterface merging SQL and API information into a cohesive interface for user and worker management
  • +
+ +

+The hardest part was finding all the information needed and applying it to a new setup. +Many tools exist and even those three took a while to get them to work. +Especially the difficulty adjustment would not have been possible (for me) if it wasn't +for the pushpool tenebrix branch allowing a custom target bit and reducing difficulty per share. +More adjustments in the PHP code were necessary to reflect those changes and, at least +close enough, properly display hashrates on the pool site. It is running well right now but +please keen in mind that neither the code nor functionaliy are supported. +I am not responsible for lost coins due to a pool crash or other malfunctions which +could be caused by by code or the tools used in this implementation. +

+ +
+
+
From 25ec8f3ec6f81a606259c76b9f235d7da3b6a79f Mon Sep 17 00:00:00 2001 From: nrpatten Date: Thu, 12 Sep 2013 19:23:54 +1000 Subject: [PATCH 04/19] Create default.tpl --- public/templates/test/about/pplns/default.tpl | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 public/templates/test/about/pplns/default.tpl diff --git a/public/templates/test/about/pplns/default.tpl b/public/templates/test/about/pplns/default.tpl new file mode 100644 index 00000000..f1369c6a --- /dev/null +++ b/public/templates/test/about/pplns/default.tpl @@ -0,0 +1,25 @@ +
+

About PPLNS Payout system, Facts and myths

+
+ + +

First of all if talking about PPLNS it is important to understand how it works. PPLNS is short for .Pay Per Last N Shares.. The current proportional reward system is round based. One round is the time between the first share after the last found block and the share which solves a block. PPLNS however means that we no longer consider valid shares of one round but we consider a number N of shares. No matter if they are part of the round or not. The number N is currently for each blockchain twice the difficulty (actually rounded down to an easy to calculate integer value).

+

Let me illustrate PPLNS using the image below. One round has an arbitrary number of shares which is solely based on sheer luck. On proportional reward system only shares of one round are considered for calculating rewards. However with PPLNS a quite constant number N of shares is considered for calculating rewards. This number N changes only with the difficulty. Please have a look at the image below:

+

PPLNS share per round

+

As you know the number of shares needed to solve a block within a round is different. Round one and three needed (difficulty * 2) shares to be solved. Round two and four are quite short rounds. There were less than (difficulty * 2) shares nessecary to solve them. Round five however is a very long round which means the pool needed more than (difficulty * 2) shares to solve the block. From this follows that:

+
    +
  • Rounds one and three are like proportional rounds. All of your shares from the given round are considered for reward calculations.
  • +
  • For rounds two and four shares from the previous rounds are considered for calculations as well (marked green). In other words: regardless of round boundaries we always consider the last (difficulty * 2) shares. Your portion of the amount of shares is used to calculate your reward.
  • +
  • Round five however is very long. In this round your lowermost shares (within the marked red part) are silently dropped if they are not within the last (difficulty * 2) shares.
  • +
+

Why do we need to switch the reward system at all?

+

PPLNS favors constant and/or occasional loyal pool members over pool hoppers. As you might have seen each time we find a LTC block the pools hashrate peaks instantly. This is due to pool hoppers starting to mine. They are betting for a .quick win. (like round two above) with low shares per round. If the round exceeds a certain amount of shares they .hop. to another proportional pool which started a new round more recently trying their luck on the other pool. This assures better rewards for pool hoppers over occasional or constant miners which are loyal to their pool. Pool hopping however implies that pool hoppers need to know when a round is started and how much shares are considered for reward. This is very easy with propotional reward system. Using PPLNS this is no longer true. On long rounds (like round five above) the pool hoppers shares won.t be considered for reward calculations in favor of loyal miners. This is due to the fact that pool hoppers only mine on the beginning of rounds. On short and normal rounds pool hoppers won.t loose their shares. But due to the fact that shares from previous rounds from loyal miners are considered twice (or even more often on extremely short rounds) the pool hopper won.t get the same reward as from proportional reward system.

+

I.m only an occasional miner. Will I loose shares if playing/being offline?

+

It depends. Even if you are a constant miner you.ll loose shares on very long rounds. On the other hand if you for example stop mining shortly before the end of round three from the image above you.ll be rewarded for round three. If you then start mining on the mid of round five you.ll be rewarded a bit for round four (despite the fact you haven.t submitted any shares as some of your shares from round three are considered for round four as well) and you.ll be fully rewarded for round five (you won.t loose any shares as you .skipped. the .red part. of shares which have been cut off due to the length of the round). The point however is no one (and thus the pool hopper as well) knows when a round ends in advance. Thus you deliberately can.t avoid cut offs. Sometimes you are lucky sometimes your are not. This however levels out over the time for non-hoppers. The important point is, that you as loyal pool member have an advantage over pool hoppers. Even if you are mining only occasionally in order to enjoy the silence within your mining room.

+

Isn.t it that you as pool operator earn more from PPLNS?

+

Short answer: No. As a pool operator I. In fact for a pool operator it doesn.t matter at all which reward system is used. I expect rounds to become a bit longer after PPLNS is activated as the pool hoppers will start to avoid the Pool. Thus revenues for me will be lower. But there were some loyal pool members who clearly stated that they want to get rid of the pool hoppers and I respect their wish. Furthermore I.m too an occasional miner on the Pool as I don.t want the miners to be running at night and from time to time I need them to test new Pool versions on development systems. Thus being a miner like you I like PPLNS better than proportional. But speaking as pool operator there is no difference between the reward systems.

+

Thanks to g2x3k/Poolx-eu for PPLNS description

+ +
+
+
From 2e7187faba42e7aa88c9b354aaf4cd27589cd08a Mon Sep 17 00:00:00 2001 From: nrpatten Date: Thu, 12 Sep 2013 19:26:38 +1000 Subject: [PATCH 05/19] Create default.tpl --- .../templates/test/about/donors/default.tpl | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 public/templates/test/about/donors/default.tpl diff --git a/public/templates/test/about/donors/default.tpl b/public/templates/test/about/donors/default.tpl new file mode 100644 index 00000000..bcbb65f5 --- /dev/null +++ b/public/templates/test/about/donors/default.tpl @@ -0,0 +1,31 @@ +
+

Pool Donors

+
+
+{include file="global/pagination.tpl"} + + + + + + + + +
+ +{section name=donor loop=$DONORS} + + + + + +{sectionelse} + + + +{/section} + +
Name%{$GLOBAL.config.currency} Total
{if $DONORS[donor].is_anonymous|default:"0" == 1}anonymous{else}{$DONORS[donor].username}{/if}{$DONORS[donor].donate_percent}{$DONORS[donor].donation|number_format:"2"}
No confirmed donations yet, please be patient!
+
+
+
From 72e3a75a1e630daaee5189e53e803911df4e9795 Mon Sep 17 00:00:00 2001 From: nrpatten Date: Thu, 12 Sep 2013 19:29:06 +1000 Subject: [PATCH 06/19] Create default.tpl --- .../templates/test/gettingstarted/default.tpl | 80 +++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 public/templates/test/gettingstarted/default.tpl diff --git a/public/templates/test/gettingstarted/default.tpl b/public/templates/test/gettingstarted/default.tpl new file mode 100644 index 00000000..ac0ddfae --- /dev/null +++ b/public/templates/test/gettingstarted/default.tpl @@ -0,0 +1,80 @@ +
+

GettingStarted

+
+ + +

+

+
  • 1. Create account. +
    +
      +
    • Register here, or login if you already have account
    • +
    • Create a worker that will be used by the miner to login
    • +
    + +
  • 2. Download a miner. + +
  • +
  • 3. Configure your miner. +

    +Settings for Stratum (recommended): +
  • + +
    + + + + + + + +
    STRATUM:stratum+tcp://yourdomain.com
    PORT:3333
    Username:Weblogin.Worker
    Password:Worker Password
    + + +
    + If you use a command-line miner, type: +
    	./cgminer --scrypt -o stratum+tcp://yourdomain.com:3333 -u Weblogin.Worker -p Worker password
    +
    + If you want, you can create additional workers with usernames and passwords of your choice Here

    + +
  • 4. Create a Litecoin address to recieve payments. +
      +
    • Downloading the client & block chain: Download the Litecoin client from the here.
      + Generate a new address and input it on your account page to receive payments. +
    • + +
  • +
    + + +
  • 5. Advanced cgminer settings / FAQ +
      +
    • + Scrypt readme +
    • +
    • + Don't set intensity too high, I=11 is standard and safest. Higher intensity takes more GPU RAM. Check for hardware errors in cgminer (HW). HW=0 is good, otherwise lower intensity :) +
    • +
    • + Set shaders according to the readme (or look at your graphic cards specifications). Cgminer uses this value at first run to calculate thread-concurrency. + Easiest way to get this optimized is to use same settings as others have used here: here. +
    • +
    • + There's also an interesting project which gives you a GUI for cgminer. Windows only it seems. +
    • +
    • + Here's a great guide how to get up and running with Xubuntu. +
    • +
    +
  • + +
    +
    +
    From 4e36a25c8184818feb8348c8a4887a3aa37e1e51 Mon Sep 17 00:00:00 2001 From: nrpatten Date: Thu, 12 Sep 2013 19:30:17 +1000 Subject: [PATCH 07/19] Create default.tpl --- public/templates/test/support/default.tpl | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 public/templates/test/support/default.tpl diff --git a/public/templates/test/support/default.tpl b/public/templates/test/support/default.tpl new file mode 100644 index 00000000..d56872ce --- /dev/null +++ b/public/templates/test/support/default.tpl @@ -0,0 +1,10 @@ +
    +

    Contact & Support

    +
    +
    + +

    This product comes 'as-is' without any warranty. Please check the Apache License, Version 2.0, for details.

    +
    +
    +
    +
    From 2c1a560e82cbf2efd61e806141c2d2d7273de850 Mon Sep 17 00:00:00 2001 From: nrpatten Date: Thu, 12 Sep 2013 19:43:59 +1000 Subject: [PATCH 08/19] Update navigation.tpl --- public/templates/test/global/navigation.tpl | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/public/templates/test/global/navigation.tpl b/public/templates/test/global/navigation.tpl index cde6d5e6..fe15aa7f 100644 --- a/public/templates/test/global/navigation.tpl +++ b/public/templates/test/global/navigation.tpl @@ -31,12 +31,25 @@
  • Graphs
  • Round
  • +

    Help

    +

    Other

      {if $smarty.session.AUTHENTICATED|default:"0" == 1} + {if !$GLOBAL.config.disable_contactform} +
    • Support
    • + {/if}
    • Logout
    • {else} +
    • Sign Up
    • +
    • Support
    • {/if}
    From 84173e225c2a9a8ea05f98d1d23d05761f6d8eca Mon Sep 17 00:00:00 2001 From: nrpatten Date: Thu, 12 Sep 2013 19:46:37 +1000 Subject: [PATCH 09/19] Create disabled.tpl --- public/templates/test/contactform/disabled.tpl | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 public/templates/test/contactform/disabled.tpl diff --git a/public/templates/test/contactform/disabled.tpl b/public/templates/test/contactform/disabled.tpl new file mode 100644 index 00000000..d56872ce --- /dev/null +++ b/public/templates/test/contactform/disabled.tpl @@ -0,0 +1,10 @@ +
    +

    Contact & Support

    +
    +
    + +

    This product comes 'as-is' without any warranty. Please check the Apache License, Version 2.0, for details.

    +
    +
    +
    +
    From ae7e19c5f683b9f4b6c71b5f3081b0c173fb5f53 Mon Sep 17 00:00:00 2001 From: nrpatten Date: Thu, 12 Sep 2013 19:51:36 +1000 Subject: [PATCH 10/19] Create default.tpl --- public/templates/test/contactform/default.tpl | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 public/templates/test/contactform/default.tpl diff --git a/public/templates/test/contactform/default.tpl b/public/templates/test/contactform/default.tpl new file mode 100644 index 00000000..3734ec84 --- /dev/null +++ b/public/templates/test/contactform/default.tpl @@ -0,0 +1,29 @@ +
    +

    Contact Us

    +
    +
    + + +
    + + +
    +
    + + +
    +
    + + +
    +
    + + +
    +
    {nocache}{$RECAPTCHA|default:""}{/nocache}
    + +
    +
    +
    +
    +
    From 233cc96ea258deffaedc00a59ecca59b3aafafd1 Mon Sep 17 00:00:00 2001 From: nrpatten Date: Thu, 12 Sep 2013 19:52:10 +1000 Subject: [PATCH 11/19] Create default.tpl --- public/templates/test/contactform/contactform/default.tpl | 1 + 1 file changed, 1 insertion(+) create mode 100644 public/templates/test/contactform/contactform/default.tpl diff --git a/public/templates/test/contactform/contactform/default.tpl b/public/templates/test/contactform/contactform/default.tpl new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/public/templates/test/contactform/contactform/default.tpl @@ -0,0 +1 @@ + From 493dfcd85cbebfeeb399a7f9efeedd92495ae757 Mon Sep 17 00:00:00 2001 From: nrpatten Date: Thu, 12 Sep 2013 19:55:59 +1000 Subject: [PATCH 12/19] Update mail.class.php --- public/include/classes/mail.class.php | 43 +++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/public/include/classes/mail.class.php b/public/include/classes/mail.class.php index ca1342aa..9160320c 100644 --- a/public/include/classes/mail.class.php +++ b/public/include/classes/mail.class.php @@ -15,6 +15,49 @@ class Mail extends Base { return true; } + /** + * Mail form contact site admin + * @param senderName string senderName + * @param senderEmail string senderEmail + * @param senderSubject string senderSubject + * @param senderMessage string senderMessage + * @param email string config Email address + * @param subject string header subject + * @return bool + **/ + public function contactform($senderName, $senderEmail, $senderSubject, $senderMessage) { + $this->debug->append("STA " . __METHOD__, 4); + if (preg_match('/[^a-z_\.\!\?\-0-9\\s ]/i', $senderName)) { + $this->setErrorMessage('Username may only contain alphanumeric characters'); + return false; + } + if (empty($senderEmail) || !filter_var($senderEmail, FILTER_VALIDATE_EMAIL)) { + $this->setErrorMessage( 'Invalid e-mail address' ); + return false; + } + if (preg_match('/[^a-z_\.\!\?\-0-9\\s ]/i', $senderSubject)) { + $this->setErrorMessage('Subject may only contain alphanumeric characters'); + return false; + } + if (strlen(strip_tags($senderMessage)) < strlen($senderMessage)) { + $this->setErrorMessage('Your message may only contain alphanumeric characters'); + return false; + } + $aData['senderName'] = $senderName; + $aData['senderEmail'] = $senderEmail; + $aData['senderSubject'] = $senderSubject; + $aData['senderMessage'] = $senderMessage; + $aData['email'] = $this->setting->getValue('website_email'); + $aData['subject'] = 'Contact From'; + if ($this->sendMail('contactform/body', $aData)) { + return true; + } else { + $this->setErrorMessage( 'Unable to send email' ); + return false; + } + return false; + } + public function sendMail($template, $aData) { $this->smarty->assign('WEBSITENAME', $this->setting->getValue('website_name')); $this->smarty->assign('SUBJECT', $aData['subject']); From 34bc88533fb53e5e907d5d0e4ac8a2ea42a8b9b5 Mon Sep 17 00:00:00 2001 From: nrpatten Date: Thu, 12 Sep 2013 19:57:30 +1000 Subject: [PATCH 13/19] Update mail.class.php --- public/include/classes/mail.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/include/classes/mail.class.php b/public/include/classes/mail.class.php index 9160320c..ea00cef6 100644 --- a/public/include/classes/mail.class.php +++ b/public/include/classes/mail.class.php @@ -25,7 +25,7 @@ class Mail extends Base { * @param subject string header subject * @return bool **/ - public function contactform($senderName, $senderEmail, $senderSubject, $senderMessage) { + public function contactform($senderName, $senderEmail, $senderSubject, $senderMessage) { $this->debug->append("STA " . __METHOD__, 4); if (preg_match('/[^a-z_\.\!\?\-0-9\\s ]/i', $senderName)) { $this->setErrorMessage('Username may only contain alphanumeric characters'); From c9c507c93ed3c11e173f263d984379a32362501e Mon Sep 17 00:00:00 2001 From: nrpatten Date: Thu, 12 Sep 2013 19:59:38 +1000 Subject: [PATCH 14/19] Update admin_settings.inc.php --- public/include/config/admin_settings.inc.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/public/include/config/admin_settings.inc.php b/public/include/config/admin_settings.inc.php index 69b55e75..305f6c11 100644 --- a/public/include/config/admin_settings.inc.php +++ b/public/include/config/admin_settings.inc.php @@ -172,6 +172,13 @@ $aSettings['system'][] = array( 'name' => 'disable_api', 'value' => $setting->getValue('disable_api'), 'tooltip' => 'Enable or Disable the pool wide API functions. See API reference on Github for details.' ); +$aSettings['system'][] = array( + 'display' => 'Disable Contactform', 'type' => 'select', + 'options' => array( 0 => 'No', 1 => 'Yes' ), + 'default' => 0, + 'name' => 'disable_contactform', 'value' => $setting->getValue('disable_contactform'), + 'tooltip' => 'Enable or Disable Contactform. Users will not be able to use the contact form.' +); $aSettings['recaptcha'][] = array( 'display' => 'Enable re-Captcha', 'type' => 'select', 'options' => array( 0 => 'No', 1 => 'Yes' ), From ff6bd18749d1f8e60931f397ac83de3fe5aafa21 Mon Sep 17 00:00:00 2001 From: nrpatten Date: Thu, 12 Sep 2013 20:01:28 +1000 Subject: [PATCH 15/19] Create contactform.inc.php --- public/include/pages/contactform.inc.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 public/include/pages/contactform.inc.php diff --git a/public/include/pages/contactform.inc.php b/public/include/pages/contactform.inc.php new file mode 100644 index 00000000..e4f947c4 --- /dev/null +++ b/public/include/pages/contactform.inc.php @@ -0,0 +1,18 @@ +getValue('disable_contactform')) { + $_SESSION['POPUP'][] = array('CONTENT' => 'Contactform is currently disabled. Please try again later.', 'TYPE' => 'errormsg'); + $smarty->assign("CONTENT", "disabled.tpl"); +} else { + if ($setting->getValue('recaptcha_enabled')) { + require_once(INCLUDE_DIR . '/lib/recaptchalib.php'); + $smarty->assign("RECAPTCHA", recaptcha_get_html($setting->getValue('recaptcha_public_key'))); + } + + // Tempalte specifics + $smarty->assign("CONTENT", "default.tpl"); +} +?> From 61f6f5b94b887f8c4b0e056163ba233b135bf0a8 Mon Sep 17 00:00:00 2001 From: nrpatten Date: Thu, 12 Sep 2013 20:03:58 +1000 Subject: [PATCH 16/19] Create contactform.inc.php --- .../pages/contactform/contactform.inc.php | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 public/include/pages/contactform/contactform.inc.php diff --git a/public/include/pages/contactform/contactform.inc.php b/public/include/pages/contactform/contactform.inc.php new file mode 100644 index 00000000..6ff2d84e --- /dev/null +++ b/public/include/pages/contactform/contactform.inc.php @@ -0,0 +1,51 @@ +getValue('recaptcha_enabled')) { + // Load re-captcha specific data + require_once(INCLUDE_DIR . '/lib/recaptchalib.php'); + $rsp = recaptcha_check_answer ( + $setting->getValue('recaptcha_private_key'), + $_SERVER["REMOTE_ADDR"], + $_POST["recaptcha_challenge_field"], + $_POST["recaptcha_response_field"] + ); +} + +if ($setting->getValue('disable_contactform')) { + $_SESSION['POPUP'][] = array('CONTENT' => 'Contactform is currently disabled. Please try again later.', 'TYPE' => 'errormsg'); +} else { + // Check if recaptcha is enabled, process form data if valid + if($setting->getValue('recaptcha_enabled') && $_POST["recaptcha_response_field"] && $_POST["recaptcha_response_field"]!=''){ + if ($rsp->is_valid) { + $smarty->assign("RECAPTCHA", recaptcha_get_html($setting->getValue('recaptcha_public_key'))); + if ($user->contactform($_POST['senderName'], $_POST['senderEmail'], $_POST['senderSubject'], $_POST['senderMesage'])) { + $_SESSION['POPUP'][] = array('CONTENT' => 'Thanks for sending your message! We will get back to you shortly'); + } else { + $_SESSION['POPUP'][] = array('CONTENT' => 'There was a problem sending your message. Please try again.' . $user->getError(), 'TYPE' => 'errormsg'); + } + } else { + $smarty->assign("RECAPTCHA", recaptcha_get_html($setting->getValue('recaptcha_public_key'), $rsp->error)); + $_SESSION['POPUP'][] = array('CONTENT' => 'Invalid Captcha, please try again. (' . $rsp->error . ')', 'TYPE' => 'errormsg'); + } + // Empty captcha + } else if ($setting->getValue('recaptcha_enabled')) { + $smarty->assign("RECAPTCHA", recaptcha_get_html($setting->getValue('recaptcha_public_key'), $rsp->error)); + $_SESSION['POPUP'][] = array('CONTENT' => 'Empty Captcha, please try again.', 'TYPE' => 'errormsg'); + // Captcha disabled + } else { + if ($mail->contactform($_POST['senderName'], $_POST['senderEmail'], $_POST['senderSubject'], $_POST['senderMessage'])) { + $_SESSION['POPUP'][] = array('CONTENT' => 'Thanks for sending your message! We will get back to you shortly'); + } else { + $_SESSION['POPUP'][] = array('CONTENT' => 'There was a problem sending your message. Please try again. ' . $user->getError(), 'TYPE' => 'errormsg'); + } + } +} + +// Tempalte specifics +$smarty->assign("CONTENT", "default.tpl"); + +?> From 3176363b24708a1a9fe4b26aa841c39493bdbba6 Mon Sep 17 00:00:00 2001 From: nrpatten Date: Thu, 12 Sep 2013 20:06:16 +1000 Subject: [PATCH 17/19] Create body.tpl --- public/templates/mail/contactform/body.tpl | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 public/templates/mail/contactform/body.tpl diff --git a/public/templates/mail/contactform/body.tpl b/public/templates/mail/contactform/body.tpl new file mode 100644 index 00000000..5f0d1b9f --- /dev/null +++ b/public/templates/mail/contactform/body.tpl @@ -0,0 +1,10 @@ + + +

    {$WEBSITENAME} Message,

    +

    {$DATA.senderName} Sent you a message

    +

    Senders Email: {$DATA.senderEmail}

    +

    Subject: {$DATA.senderSubject}

    +

    Personal message:

    {$DATA.senderMessage}

    +

    + + From 962079b97cae56f10526457c8758f557bcfbb7f3 Mon Sep 17 00:00:00 2001 From: nrpatten Date: Thu, 12 Sep 2013 20:12:40 +1000 Subject: [PATCH 18/19] Update navigation.tpl --- public/templates/test/global/navigation.tpl | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/public/templates/test/global/navigation.tpl b/public/templates/test/global/navigation.tpl index fe15aa7f..ef7417a8 100644 --- a/public/templates/test/global/navigation.tpl +++ b/public/templates/test/global/navigation.tpl @@ -31,6 +31,22 @@
  • Graphs
  • Round
  • + {else} +

    Statistics

    +
      + {if $GLOBAL.acl.pool.statistics} +
    • Pool
    • + {else} +
    • Statistics + {/if} + {if $GLOBAL.acl.block.statistics} +
    • Blocks
    • + {/if} + {if $GLOBAL.acl.round.statistics} +
    • Round
    • + {/if} +
    + {/if}

    Help

    • GettingStarted
    • From 32e789b8e62b1aa7f5fc499b159e9d4a58778551 Mon Sep 17 00:00:00 2001 From: nrpatten Date: Thu, 12 Sep 2013 20:19:49 +1000 Subject: [PATCH 19/19] Update navigation.tpl --- public/templates/test/global/navigation.tpl | 1 + 1 file changed, 1 insertion(+) diff --git a/public/templates/test/global/navigation.tpl b/public/templates/test/global/navigation.tpl index ef7417a8..402ad7bb 100644 --- a/public/templates/test/global/navigation.tpl +++ b/public/templates/test/global/navigation.tpl @@ -24,6 +24,7 @@
    • News
    {/if} + {if $smarty.session.AUTHENTICATED|default}

    Statistics