Bravo List

Bravo List (http://www.bvlist.com/index.php)
-   Mods & Themes (http://www.bvlist.com/forumdisplay.php?f=109)
-   -   Mass Seed Bonus (http://www.bvlist.com/showthread.php?t=6764)

Fynnon 19th July 2011 16:44

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 accessYou 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>\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>\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

it53lv 19th July 2011 17:30

finaly you're adding some stuff for tbdev here

GuldlocK 5th November 2012 01:55

this work for tbdev 2008 ? :sos:


All times are GMT +2. The time now is 22:08.

Powered by vBulletin® Version 3.8.11 Beta 3
Copyright ©2000 - 2024, vBulletin Solutions Inc.