Dynamic payment added to surfbar
authorRoland Häder <roland@mxchange.org>
Wed, 17 Sep 2008 19:29:02 +0000 (19:29 +0000)
committerRoland Häder <roland@mxchange.org>
Wed, 17 Sep 2008 19:29:02 +0000 (19:29 +0000)
17 files changed:
.gitattributes
inc/databases.php
inc/functions.php
inc/language/surfbar_de.php
inc/libs/surfbar_functions.php
inc/modules/member/what-surfbar_start.php
templates/de/html/admin/admin_contct_user_form.tpl
templates/de/html/admin/admin_reset_pass_done.tpl
templates/de/html/doubler/doubler_index.tpl
templates/de/html/guest/guest_doubler.tpl
templates/de/html/guest/guest_sponsor_activate.tpl
templates/de/html/guest/guest_sponsor_login.tpl
templates/de/html/guest/guest_sponsor_lost.tpl
templates/de/html/member/member_doubler.tpl
templates/de/html/member/member_surfbar_link.tpl
templates/de/html/member/member_surfbar_start_dynamic.tpl [new file with mode: 0644]
templates/de/html/member/member_surfbar_start_static.tpl

index 9fb971a..5211aa3 100644 (file)
@@ -1299,6 +1299,7 @@ templates/de/html/member/member_support_form.tpl -text
 templates/de/html/member/member_surfbar_book_dynamic.tpl -text
 templates/de/html/member/member_surfbar_book_static.tpl -text
 templates/de/html/member/member_surfbar_link.tpl -text
+templates/de/html/member/member_surfbar_start_dynamic.tpl -text
 templates/de/html/member/member_surfbar_start_static.tpl -text
 templates/de/html/member/member_themes.tpl -text
 templates/de/html/member/member_transfer_list.tpl -text
index e4e9589..99964d8 100644 (file)
@@ -113,7 +113,7 @@ define('USAGE_BASE', "usage");
 define('SERVER_URL', "http://www.mxchange.org");
 
 // This current patch level
-define('CURR_SVN_REVISION', "352");
+define('CURR_SVN_REVISION', "353");
 
 // Take a prime number which is long (if you know a longer one please try it out!)
 define('_PRIME', 591623);
index 533e824..75a0e57 100644 (file)
@@ -1260,8 +1260,8 @@ function GENERATE_IMAGE($img_code, $header=true) {
 }
 // Create selection box or array of splitted timestamp
 function CREATE_TIME_SELECTIONS($timestamp, $prefix="", $display="", $align="center", $return_array=false) {
-       // Calculate 15-seconds timestamp (15-seconds-steps shall be fine ;) )
-       $stamp = round($timestamp / 15) * 15;
+       // Calculate 2-seconds timestamp
+       $stamp = round($timestamp / 2) * 2;
 
        // Do we have a leap year?
        $SWITCH = 0;
@@ -1290,7 +1290,7 @@ function CREATE_TIME_SELECTIONS($timestamp, $prefix="", $display="", $align="cen
        // Is seconds zero and time is < 60 seconds?
        if (($s == 0) && ($stamp < 60)) {
                // Fix seconds
-               $s = $timestamp;
+               $s = round($timestamp);
        } // END - if
 
        //
@@ -1537,8 +1537,14 @@ function CREATE_FANCY_TIME($stamp) {
                } // END - if
        } // END - foreach
 
-       // Remove leading commata and space
-       $ret = substr($ret, 2);
+       // Do we have something there?
+       if (strlen($ret) > 0) {
+               // Remove leading commata and space
+               $ret = substr($ret, 2);
+       } else {
+               // Zero seconds
+               $ret = "0 "._SECONDS;
+       }
 
        // Return fancy time string
        return $ret;
index 9ba208a..87c0608 100644 (file)
@@ -46,7 +46,7 @@ define('ADMIN_CONFIG_SURFBAR_STATIC_LOCK', "Statische Reload-Sperre (oberes Fram
 define('ADMIN_CONFIG_SURFBAR_PAYMENT_MODEL', "Verg&uuml;tungsmodel ausw&auml;hlen:");
 define('ADMIN_CONFIG_SURFBAR_PAYMENT_MODEL_STATIC', "Statische Werte verwenden.");
 define('ADMIN_CONFIG_SURFBAR_PAYMENT_MODEL_DYNAMIC', "Dynamische Werte errechnen.");
-define('ADMIN_CONFIG_SURFBAR_DYNAMIC_PERCENT', "Prozent auf dynamische Verg&uuml;tung:");
+define('ADMIN_CONFIG_SURFBAR_DYNAMIC_PERCENT', "Prozent auf dynamische Verg&uuml;tung/ Verweildauer/Reload-Sperre:");
 define('ADMIN_CONFIG_SURFBAR_MAX_ORDER', "Maximal durch Mitglied in Surfbar buchbare URLs:");
 define('ADMIN_CONFIG_SURFBAR_RESTART_TIME', "Ruhezeit der Surfbar, wenn alle URLs in Reload-Lock sind:&nbsp;(*)");
 define('ADMIN_CONFIG_SURFBAR_AUTOSTART', "Surfbar soll nach Ruhezeit automatisch starten?");
@@ -96,8 +96,8 @@ define('ADMIN_SURFBAR_NOTIFY_URL_REG_SUBJECT', "Mitglied hat URL in Surfbar gebu
 define('ADMIN_SURFBAR_NOTIFY_URL_CONFIRMED_SUBJECT', "URL in Surfbar freigegeben");
 
 // Auto-generated admin subject lines
-define('ADMIN_DEL_SURFBAR_URLS_SUBJECT', "[Surfbar:] URL entfernt");
-define('ADMIN_EDIT_SURFBAR_URLS_SUBJECT', "[Surfbar:] URL ge&auml;ndert");
+define('ADMIN_DEL_SURFBAR_URLS_SUBJECT', "[Surfbar:] URL entfernt");
+define('ADMIN_EDIT_SURFBAR_URLS_SUBJECT', "[Surfbar:] URL ge&auml;ndert");
 define('ADMIN_CONFIRMED_SURFBAR_URLS_SUBJECT', "[Surfbar:] Freigabe einer URL");
 define('ADMIN_LOCKED_SURFBAR_URLS_SUBJECT', "[Surfbar:] Sperrung einer URL");
 
index ec04562..f2b006c 100644 (file)
@@ -725,6 +725,81 @@ function SURFBAR_CHANGE_STATUS ($id, $prevStatus, $newStatus) {
        // All done!
        return true;
 }
+// Calculate minimum value for dynamic payment model
+function SURFBAR_CALCULATE_DYNAMIC_MIN_VALUE () {
+       global $_CONFIG;
+
+       // Addon is zero by default
+       $addon = 0;
+
+       // Percentage part
+       $percent = abs(log($_CONFIG['surfbar_dynamic_percent'] / 100 + 1));
+
+       // Get total users
+       $totalUsers = GET_TOTAL_DATA("CONFIRMED", "user_data", "userid", "status", true);
+
+       // Get online users
+       $onlineUsers = SURFBAR_DETERMINE_TOTAL_ONLINE();
+
+       // Calculate addon
+       $addon += abs(log($onlineUsers / $totalUsers + 1) * $percent * $totalUsers);
+
+       // Get total URLs
+       $totalUrls = SURFBAR_GET_TOTAL_URLS();
+
+       // Get user's total URLs
+       $userUrls = SURFBAR_GET_TOTAL_USER_URLS();
+
+       // Calculate addon
+       $addon += abs(log($userUrls / $totalUrls + 1) * $percent * $totalUrls);
+
+       // Return addon
+       return $addon;
+}
+// Calculate maximum value for dynamic payment model
+function SURFBAR_CALCULATE_DYNAMIC_MAX_VALUE () {
+       global $_CONFIG;
+
+       // Addon is zero by default
+       $addon = 0;
+
+       // Maximum value
+       $max = log(2);
+
+       // Percentage part
+       $percent = abs(log($_CONFIG['surfbar_dynamic_percent'] / 100 + 1));
+
+       // Get total users
+       $totalUsers = GET_TOTAL_DATA("CONFIRMED", "user_data", "userid", "status", true);
+
+       // Calculate addon
+       $addon += abs($max * $percent * $totalUsers);
+
+       // Get total URLs
+       $totalUrls = SURFBAR_GET_TOTAL_URLS();
+
+       // Calculate addon
+       $addon += abs($max * $percent * $totalUrls);
+
+       // Return addon
+       return $addon;
+}
+// Calculate dynamic lock
+function SURFBAR_CALCULATE_DYNAMIC_LOCK () {
+       global $_CONFIG;
+
+       // Default lock is 30 seconds
+       $addon = 30;
+
+       // Get online users
+       $onlineUsers = SURFBAR_DETERMINE_TOTAL_ONLINE();
+
+       // Calculate lock
+       $addon = abs(log($onlineUsers / $addon +1));
+
+       // Return value
+       return $addon;
+}
 // "Getter" for lock ids array
 function SURFBAR_GET_LOCK_IDS () {
        // Prepare some arrays
index 2308f2a..a5f8103 100644 (file)
@@ -49,12 +49,30 @@ ADD_DESCR("member", basename(__FILE__));
 
 // Prepare content for output
 $content = array(
-       'surfbar_static_reward'   => TRANSLATE_COMMA($_CONFIG['surfbar_static_reward']),
-       'surfbar_static_time'     => CREATE_FANCY_TIME($_CONFIG['surfbar_static_time']),
-       'surfbar_static_lock'     => CREATE_FANCY_TIME($_CONFIG['surfbar_static_lock']),
-       'surfbar_dynamic_percent' => TRANSLATE_COMMA($_CONFIG['surfbar_dynamic_percent'])
+       'surfbar_static_reward' => TRANSLATE_COMMA($_CONFIG['surfbar_static_reward']),
+       'surfbar_static_time'   => CREATE_FANCY_TIME($_CONFIG['surfbar_static_time']),
+       'surfbar_static_lock'   => CREATE_FANCY_TIME($_CONFIG['surfbar_static_lock']),
 );
 
+// In dynamic mode we need some more data
+if ($_CONFIG['surfbar_pay_model'] == "DYNAMIC") {
+       // Total URLs
+       $content = array(
+               'surfbar_dynamic_percent' => TRANSLATE_COMMA($_CONFIG['surfbar_dynamic_percent']),
+               'surfbar_total_urls'      => SURFBAR_GET_TOTAL_URLS("CONFIRMED", "0"),
+               'surfbar_user_urls'       => SURFBAR_GET_TOTAL_USER_URLS(),
+               'surfbar_total_online'    => SURFBAR_DETERMINE_TOTAL_ONLINE(),
+               'surfbar_total_users'     => TRANSLATE_COMMA(GET_TOTAL_DATA("CONFIRMED", "user_data", "userid", "status", true)),
+               'surfbar_min_reward'      => TRANSLATE_COMMA(SURFBAR_CALCULATE_DYNAMIC_MIN_VALUE()),
+               'surfbar_max_reward'      => TRANSLATE_COMMA(SURFBAR_CALCULATE_DYNAMIC_MAX_VALUE()),
+               'surfbar_min_time'        => CREATE_FANCY_TIME(SURFBAR_CALCULATE_DYNAMIC_MIN_VALUE()),
+               'surfbar_max_time'        => CREATE_FANCY_TIME(SURFBAR_CALCULATE_DYNAMIC_MAX_VALUE()),
+               'surfbar_dynamic_lock'    => CREATE_FANCY_TIME(SURFBAR_CALCULATE_DYNAMIC_LOCK()),
+               'surfbar_static_reward'   => TRANSLATE_COMMA($_CONFIG['surfbar_static_reward']),
+               'surfbar_static_time'     => CREATE_FANCY_TIME($_CONFIG['surfbar_static_time'])
+       );
+} // END - if
+
 // Load the template
 LOAD_TEMPLATE("member_surfbar_start_".strtolower($_CONFIG['surfbar_pay_model']), false, $content);
 
index 19d1a82..7767ab3 100644 (file)
@@ -1,12 +1,10 @@
-<FORM
-       action="{!URL!}/modules.php?module=admin&amp;what=user_contct&amp;u_id=$content[u_id]"
-       method="POST">
-<TABLE border="0" cellspacing="0" cellpadding="0" width="400"
-       class="admin_table dashed" align="center">
+<FORM action="{!URL!}/modules.php?module=admin&amp;what=user_contct&amp;u_id=$content[u_id]" method="POST">
+<TABLE border="0" cellspacing="0" cellpadding="0" width="400" class="admin_table dashed" align="center">
        <TR>
-               <TD align="center" class="admin_title bottom2" height="30"><STRONG>{--ADMIN_CONTACT_USER--}:<BR />
-               $content[surname] $content[family] &lt;<A
-                       href="mailto:$content[email]">$content[email]</A>&gt;</STRONG></TD>
+               <TD align="center" class="admin_title bottom2" height="30">
+                       <STRONG>{--ADMIN_CONTACT_USER--}:<BR />
+                       $content[surname] $content[family] &lt;<A href="mailto:$content[email]">$content[email]</A>&gt;</STRONG>
+               </TD>
        </TR>
        <TR>
                <TD align="center" class="bottom2" style="padding: 10px"><TEXTAREA
                </TD>
        </TR>
        <TR>
-               <TD class="admin_footer"><INPUT type="reset"
-                       class="admin_reset" value="{--CLEAR_FORM--}">&nbsp;* <INPUT
-                       type="submit" name="ok" class="admin_submit"
-                       value="{--CONTACT_USER--}"></TD>
+               <TD class="admin_footer">
+                       <INPUT type="reset" class="admin_reset" value="{--CLEAR_FORM--}" />&nbsp;*
+                       <INPUT type="submit" name="ok" class="admin_submit" value="{--CONTACT_USER--}" />
+               </TD>
        </TR>
 </TABLE>
 </FORM>
index ea48561..cb5264a 100644 (file)
@@ -12,7 +12,7 @@
 </TR>
 <TR>
        <TD class="admin_footer">
-               --&gt;&nbsp;<STRONG><A href="{!URL!}/modules.php?module=admin">{--ADMIN_CONTINUE_LOGIN--}</A></STRONG>
+               &raquo;&raquo;&nbsp;<STRONG><A href="{!URL!}/modules.php?module=admin">{--ADMIN_CONTINUE_LOGIN--}</A></STRONG>
        </TD>
 </TR>
 </TABLE>
index 4e4de9a..fabe8ea 100644 (file)
@@ -69,7 +69,7 @@
                {--DOUBLER_POINTS_1--} <STRONG>{!__CHARGE_VALUE!}%</STRONG>
                {--DOUBLER_POINTS_2--}<br />
                <br />
-               {--DOUBLER_EXAMPLE_1--} <STRONG>500 {!POINTS!}</STRONG> --&gt;
+               {--DOUBLER_EXAMPLE_1--} <STRONG>500 {!POINTS!}</STRONG> &raquo;&raquo;
                {--DOUBLER_EXAMPLE_2--} <STRONG>1000 {!POINTS!}</STRONG>{--DOUBLER_EXAMPLE_3--}<br />
                <br />
                <STRONG class="big">{--DOUBLER_FULL_PAYOUT--}</STRONG><br />
index 39ecaa6..961015c 100644 (file)
@@ -24,7 +24,7 @@
                        <LI>{--DOUBLER_POINTS_1--} <STRONG>{!__CHARGE_VALUE!}%</STRONG>
                        {--DOUBLER_POINTS_2--}</LI>
                        <LI>{--DOUBLER_EXAMPLE_1--} <STRONG>500 {!POINTS!}</STRONG>
-                       --&gt; {--DOUBLER_EXAMPLE_2--} <STRONG>1000 {!POINTS!}</STRONG>{--DOUBLER_EXAMPLE_3--}</LI>
+                       &raquo;&raquo; {--DOUBLER_EXAMPLE_2--} <STRONG>1000 {!POINTS!}</STRONG>{--DOUBLER_EXAMPLE_3--}</LI>
                        <LI>{--DOUBLER_REFERRAL_1--} <STRONG>{!__REF_VALUE!}%</STRONG>
                        {--DOUBLER_REFERRAL_2--} {--DOUBLER_REFERRAL_3--}
                        {--DOUBLER_REFERRAL_4--}
index 8747f22..74d6141 100644 (file)
@@ -35,7 +35,7 @@
 <TABLE border="0" cellspacing="0" cellpadding="0" class="guest_table" width="100%">
 <TR>
   <TD align="center" height="30">
-    --&gt;&nbsp;<A href="{!URL!}/modules.php?module=index&amp;what=sponsor_login">{--SPONSOR_BACK_TO_LOGIN--}</A><br />
+    &raquo;&raquo;&nbsp;<A href="{!URL!}/modules.php?module=index&amp;what=sponsor_login">{--SPONSOR_BACK_TO_LOGIN--}</A><br />
   </TD>
 </TR>
 </TABLE>
index 8dc8b09..e41adcb 100644 (file)
 <TABLE border="0" cellspacing="0" cellpadding="0" class="guest_table" width="100%">
 <TR>
   <TD align="center" height="30">
-    --&gt;&nbsp;<A href="{!URL!}/modules.php?module=index&amp;what=sponsor_login&amp;mode=lost_pass">{--SPONSOR_PASSWORD_LOST--}</A>
+    &raquo;&raquo;&nbsp;<A href="{!URL!}/modules.php?module=index&amp;what=sponsor_login&amp;mode=lost_pass">{--SPONSOR_PASSWORD_LOST--}</A>
   </TD>
 </TR>
 <TR>
   <TD align="center" height="30">
-    --&gt;&nbsp;<A href="{!URL!}/modules.php?module=index&amp;what=sponsor_login&amp;mode=activate">{--SPONSOR_ACTIVATION_LINK_LOST--}</A><br />
+    &raquo;&raquo;&nbsp;<A href="{!URL!}/modules.php?module=index&amp;what=sponsor_login&amp;mode=activate">{--SPONSOR_ACTIVATION_LINK_LOST--}</A><br />
   </TD>
 </TR>
 </TABLE>
index 43415dd..6d4f9d2 100644 (file)
@@ -43,7 +43,7 @@
 <TABLE border="0" cellspacing="0" cellpadding="0" class="guest_table" width="100%">
 <TR>
   <TD align="center" height="30">
-    --&gt;&nbsp;<A href="{!URL!}/modules.php?module=index&amp;what=sponsor_login">{--SPONSOR_BACK_TO_LOGIN--}</A><br />
+    &raquo;&raquo;&nbsp;<A href="{!URL!}/modules.php?module=index&amp;what=sponsor_login">{--SPONSOR_BACK_TO_LOGIN--}</A><br />
   </TD>
 </TR>
 </TABLE>
index fa17aff..15b88a4 100644 (file)
@@ -41,7 +41,7 @@
                        <LI>{--DOUBLER_POINTS_1--} <STRONG>{!__CHARGE_VALUE!}%</STRONG>
                        {--DOUBLER_POINTS_2--}</LI>
                        <LI>{--DOUBLER_EXAMPLE_1--} <STRONG>500 {!POINTS!}</STRONG>
-                       --&gt; {--DOUBLER_EXAMPLE_2--} <STRONG>1000 {!POINTS!}</STRONG>{--DOUBLER_EXAMPLE_3--}</LI>
+                       &raquo;&raquo; {--DOUBLER_EXAMPLE_2--} <STRONG>1000 {!POINTS!}</STRONG>{--DOUBLER_EXAMPLE_3--}</LI>
                        <LI>{--DOUBLER_REFERRAL_1--} <STRONG>{!__REF_VALUE!}%</STRONG>
                        {--DOUBLER_REFERRAL_2--} {--DOUBLER_REFERRAL_3--}
                        {--DOUBLER_REFERRAL_4--}
index c971391..72d4ea1 100644 (file)
@@ -1,3 +1,3 @@
 <div class="member_title2 dashed" style="width:600px;margin-top:10px">
-       &gt;&gt;&nbsp;<strong><a href="{!URL!}/surfbar.php">Jetzt die Surfbar starten!</a></strong>&nbsp;&lt;&lt;
+       &raquo;&raquo;&nbsp;<strong><a href="{!URL!}/surfbar.php">Jetzt die Surfbar starten!</a></strong>&nbsp;&laquo;&laquo;
 </div>
diff --git a/templates/de/html/member/member_surfbar_start_dynamic.tpl b/templates/de/html/member/member_surfbar_start_dynamic.tpl
new file mode 100644 (file)
index 0000000..f5b2171
--- /dev/null
@@ -0,0 +1,33 @@
+<div class="member_table dashed" style="width:600px">
+       <div class="member_title2 bottom2">
+               <strong>Dynamisch verg&uuml;tete Surfbar ist aktiv</strong>
+       </div>
+
+       <div style="padding:5px">
+               Bei der dynamischen Verg&uuml;tung werden Ihnen derzeit mindestens
+               <strong>$content[surfbar_min_reward]</strong> und maximal
+               <strong>$content[surfbar_max_reward] {!POINTS!}</strong> Aufschlag
+               zum Basispreis f&uuml;r jede besuchte Seite verg&uuml;tet. Diese
+               m&uuml;ssen Sie mindestens <strong>$content[surfbar_min_time]</strong>
+               und maximal <strong>$content[surfbar_max_time]</strong> zus&auml;tzlich
+               zur Basiszeit angesehen haben und k&ouml;nnen die selbe Seite erst nach
+               <strong>$content[surfbar_dynamic_lock]</strong> wieder aufrufen.
+       </div>
+
+       <div style="padding:5px">
+               Einige Hinweise zur Berechnung: Die derzeige Mitgliederanzahl von
+               <strong>$content[surfbar_total_users]</strong>, die derzeit die Surfbar
+               nutzenden <strong>$content[surfbar_total_online]</strong> Mitglieder,
+               die gesamt in der Surfbar gebuchten <strong>$content[surfbar_total_urls]</strong>
+               URLs (ohne von unseren Sponsoren), sowie Ihre gebuchten
+               <strong>$content[surfbar_user_urls]</strong> URLs werden als
+               Berechnungsgrundlage verwendet. Sie erhalten allerdings nur einen
+               reduzierten Anteil von <strong>$content[surfbar_dynamic_percent]%</strong>.
+       </div>
+
+       <div style="padding:5px">
+               Der Basispreis und die Basiszeit sind die Einstellungen aus dem
+               statischen Verg&uuml;tungsmodell: <strong>$content[surfbar_static_reward]
+               {!POINTS!}</strong> bzw. <strong>$content[surfbar_static_time]</strong>.
+       </div>
+</div>
index 8ed167f..e1bf76d 100644 (file)
@@ -4,9 +4,10 @@
        </div>
        <div style="padding:5px">
                Bei der statischen Verg&uuml;tung werden Ihnen derzeit
-               $content[surfbar_static_reward] {!POINTS!} f&uuml;r jede besuchte Seite
-               verg&uuml;tet. Diese m&uuml;ssen Sie $content[surfbar_static_time]
-               lang angesehen haben und k&ouml;nnen die selbe Seite erst nach
-               $content[surfbar_static_lock] wieder aufrufen.
+               <strong>$content[surfbar_static_reward] {!POINTS!}</strong> f&uuml;r
+               jede besuchte Seite verg&uuml;tet. Diese m&uuml;ssen Sie
+               <strong>$content[surfbar_static_time]</strong> lang angesehen haben
+               und k&ouml;nnen die selbe Seite erst nach
+               <strong>$content[surfbar_static_lock]</strong> wieder aufrufen.
        </div>
 </div>