Bravo List
Register
Go Back   > Bravo List > Source Code > Archived Trackers > TBDev > Mods & Themes
Reply
Thread Tools
  #1  
Old 19th July 2011, 16:44
Fynnon's Avatar
Fynnon Fynnon is offline
xxx
 
Join Date: Nov 2007
P2P
Posts: 984
Default Mass Seed Bonus
Can award seedbonus mass per user class
this is for http://www.bvlist.com/tbdev/4931-tbdev-2009-a.html

1. create a php file called massbonus.php and put in it this code:

PHP Code:
<?php
/*
+------------------------------------------------
|   $Date$ 030810
|   $Revision$ 2.0
|   $Author$ putyn,Bigjoos
|   $URL$
|   $Massbonus
|   
+------------------------------------------------
*/
if ( ! defined'IN_TBDEV_ADMIN' ) )
{
        
$HTMLOUT='';
        
$HTMLOUT .= "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"
                \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">
                <html xmlns='http://www.w3.org/1999/xhtml'>
                <head>
                <title>Error!</title>
                
<script type="
text/javascript">

window.google_analytics_uacct = "
UA-3186736-1";


</script>

<script type="
text/javascript">

window.google_analytics_uacct = "
UA-3186736-1";


</script>
</head>
                <body>
        <div style='font-size:33px;color:white;background-color:red;text-align:center;'>Incorrect access<br />You cannot access this file directly.</div>
        
<script type="
text/javascript"><!--
var gaJsHost = (("
https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" gaJsHost "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
//-->
</script>
<script type="text/javascript"><!--
try {
var pageTracker = _gat._getTracker("UA-3186736-1");
pageTracker._trackPageview();
} catch(err) {}
//-->
</script>

<script type="text/javascript"><!--
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
//-->
</script>
<script type="text/javascript"><!--
try {
var pageTracker = _gat._getTracker("UA-3186736-1");
pageTracker._trackPageview();
} catch(err) {}
//-->
</script>
</body></html>";
        print $HTMLOUT;
        exit();
}

require_once "include/user_functions.php";
require_once "include/html_functions.php";


$lang = array_merge( $lang );

$HTMLOUT="";
 
if ($CURUSER['class'] < UC_ADMINISTRATOR)
header( "Location: {$TBDEV['baseurl']}/index.php");

  //== Dont forget to edit this 
        $maxclass = UC_SYSOP;
        $firstclass = UC_USER;
        
        function mkpositive($n)
        {
                return strstr((string)$n,"-") ? 0 : $n ; // This will return 0 for negative numbers 
        }
        
        if ($_SERVER["REQUEST_METHOD"] == "POST")
        {
                $classes = isset($_POST["classes"])? $_POST["classes"] : "";
                $all = ($classes[0] == 255 ? true : false );
                if(empty($classes) && sizeof($classes) == 0 )
                stderr("Err","You need at least one class selected");
                $a_do = array("add","remove","remove_all");
                $do = isset($_POST["do"]) && in_array($_POST["do"],$a_do) ? $_POST["do"] : "";
                if(empty($do))
                        stderr("Err","wtf are you trying to do ");
                        
                $seedbonus = isset($_POST["seedbonus"]) ? 0+$_POST["seedbonus"] : 0;
                if($seedbonus == 0 && ($do == "add" || $do == "remove"))
                stderr("Err","You can't remove/add 0");
                        
                $sendpm = isset($_POST["pm"]) && $_POST["pm"] == "yes" ? true : false;
                
                $pms = array();
                $users = array();
                //== Select the users
                $q1 = mysql_query("SELECT id,seedbonus FROM users ".($all ? "" : "WHERE class in (".join(",",$classes).")" )." ORDER BY id desc ") or sqlerr(__FILE__, __LINE__);
                if(mysql_num_rows($q1) == 0)
                stderr("Sorry","There are no users in the class(es) you selected");
                        while($a = mysql_fetch_assoc($q1))
                        {
                                $users[] = "(".$a["id"].", ".($do == "remove_all" ? 0 : ($do == "add" ? $a["seedbonus"] + $seedbonus : mkpositive($a["seedbonus"] - $seedbonus))) .")";
                                if($sendpm)
                                {
                                        $subject = sqlesc($do == "remove_all" && $do == "remove" ?  "seedbonus adjusted" : "seedbonus adjusted");
                                        $body = sqlesc("Hey,\n we have decided to ". ($do == "remove_all" ?  "remove all seedbonus from your group class" : ($do == "add" ? "add $seedbonus Karma points".($seedbonus > 1 ? "s" : "")." to your group class" : "remove $seedbonus karma".($seedbonus > 1 ? "s" : "")."  from your group class")). " !\n ".$TBDEV['site_name'] ." staff");
                                        $pms[] = "(0,".$a["id"].",".sqlesc(time()).",$subject,$body)" ;
                                }
                        }
                        
                        if(sizeof($users) > 0)
                                $r = mysql_query("INSERT INTO users(id,seedbonus) VALUES ".join(",",$users)." ON DUPLICATE key UPDATE seedbonus=values(seedbonus) ") or sqlerr(__FILE__, __LINE__);
                        if(sizeof($pms) > 0)
                                $r1 = mysql_query("INSERT INTO messages (sender, receiver, added, subject, msg) VALUES ".join(",",$pms)." ") or sqlerr(__FILE__, __LINE__);
                                
                        if($r && ($sendpm ? $r1 : true))
                        {
                                header("Refresh: 2; url=admin.php?action=massbonus");
                                stderr("Success","Operation done!");
                        }
                        else
                                stderr("Error","Something was wrong");
        }

        $HTMLOUT .= begin_frame();
        
        $HTMLOUT .="<form  action='admin.php?action=massbonus' method='post'>
        <table width='500' cellpadding='5' cellspacing='0' border='1' align='center'>
          <tr>
                <td valign='top' align='right'>Classes</td>
                <td width='100%' align='left' colspan='3'>";
        
                                        $r= "<label for='all'><input type='checkbox' name='classes[]' value='255' id='all' />All classes</label><br />\n";
                                  for($i=$firstclass;$i<$maxclass+1; $i++ )
                                        $r .= "<label for='c$i'><input type='checkbox' name='classes[]' value='$i' id='c$i' />".get_user_class_name($i)." </label><br />\n";
                                  $HTMLOUT .= $r;
                
                $HTMLOUT .="</td>
          </tr>
          <tr>
                <td valign='top' align='center'>Options</td>
                <td valign='top'>Do
                  <select name='do' >
                        <option value='add'>Add seedbonus</option>
                        <option value='remove'>Remove seedbonus</option>
                        <option value='remove_all'>Remove all seedbonus</option>
                  </select></td>
                <td>seedbonus <input type='text' maxlength='8' name='seedbonus' size='5' />
                </td>
                <td>Send pm <select name='pm'><option value='no'>no</option><option value='yes'>yes</option></select></td></tr>
                <tr><td colspan='4' align='center'><input type='submit' value='Do!' /></td></tr>
        </table>
        </form>";

 $HTMLOUT .= end_frame();
print stdhead('Mass Bonus') . $HTMLOUT . stdfoot();
die;
?>
2. save the file massbonus.php to your admin folder
3. Add to admin.php

PHP Code:
'massbonus'   => 'massbonus'
4. Add to admin/index.php :

PHP Code:
<span class='btn'><a rel='nofollow' href='admin.php?action=massbonus'>Manage bonus</a></span
5. If using 09 Staffpanel simply add:

PHP Code:
admin.php?action=massbonus 
putyn@tbdev.net/topic/23579-09-mass-bonus
Reply With Quote
  #2  
Old 19th July 2011, 17:30
it53lv's Avatar
it53lv it53lv is offline
Senior Member
 
Join Date: Feb 2011
Latvia
Posts: 134
Default
finaly you're adding some stuff for tbdev here
Reply With Quote
  #3  
Old 5th November 2012, 01:55
GuldlocK GuldlocK is offline
Senior Member
 
Join Date: Feb 2010
P2P
Posts: 22
Default
this work for tbdev 2008 ?
Reply With Quote
Reply

Tags
bonus , mass , seed


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



All times are GMT +2. The time now is 19:32. vBulletin skin by ForumMonkeys. Powered by vBulletin® Version 3.8.11 Beta 3
Copyright ©2000 - 2024, vBulletin Solutions Inc.