Bravo List

Bravo List (http://www.bvlist.com/index.php)
-   TBDev (http://www.bvlist.com/forumdisplay.php?f=20)
-   -   [TBDev] User Promotions Log (http://www.bvlist.com/showthread.php?t=2022)

KustomizeR 15th February 2009 19:36

[TBDev] User Promotions Log
 
Hello, has anyone the script that allows you to view the User Promotions in the log.php file of TBDev source?

It looks like this:

Code:

if (strpos($arr['txt'],'was promoted/demoted to XXX  by')) $color = "green";

thanks

wMan 16th February 2009 17:38

PHP Code:

// promote power users
    
$maxdt sqlesc(get_date_time(gmtime() - $ap_time));
    
$res mysql_query("SELECT id FROM users WHERE class = ".UC_USER." AND uploaded >= $ap_limit AND uploaded / downloaded >= $ap_ratio AND added < $maxdt") or sqlerr(__FILE____LINE__);
    if (
mysql_num_rows($res) > 0)
    {
        
$dt sqlesc(get_date_time());
        
$msg sqlesc("Congratulations, you have been auto-promoted to [b]Power User[/b]. :)\n");
        while (
$arr mysql_fetch_assoc($res))
        {
            
mysql_query("UPDATE users SET class = ".UC_POWER_USER." WHERE id = $arr[id]") or sqlerr(__FILE____LINE__);
            
mysql_query("INSERT INTO messages (sender, receiver, added, msg, poster) VALUES(0, $arr[id]$dt$msg, 0)") or sqlerr(__FILE____LINE__);
        }
    }

    
// demote power users
    
$res mysql_query("SELECT id FROM users WHERE class = ".UC_POWER_USER." AND uploaded / downloaded < $ad_ratio") or sqlerr(__FILE____LINE__);
    if (
mysql_num_rows($res) > 0)
    {
        
$dt sqlesc(get_date_time());
        
$msg sqlesc("You have been auto-demoted from [b]Power User[/b] to [b]User[/b] because your share ratio has dropped below $ad_ratio.\n");
        while (
$arr mysql_fetch_assoc($res))
        {
            
mysql_query("UPDATE users SET class = ".UC_USER." WHERE id = $arr[id]") or sqlerr(__FILE____LINE__);
            
mysql_query("INSERT INTO messages (sender, receiver, added, msg, poster) VALUES(0, $arr[id]$dt$msg, 0)") or sqlerr(__FILE____LINE__);
        }
    } 


KustomizeR 16th February 2009 19:59

That is not correct! That is from cleanup.php and it`s the script that makes the rules about auto-promotions and it`s not showing anything in the log file

wMan 16th February 2009 22:21

then get log.php otherwise sorry cant help you

KustomizeR 21st March 2009 18:01

The script should look like this:

http://chat2pals.co.uk/bitbucket/Min...iff_log426.png

Undefined 21st March 2009 20:52

that pic is from tbdev installer and the code is from musicmania originally:coffee:

PHP Code:

CREATE TABLE `sitelog` (
  `
idint(10unsigned NOT NULL auto_increment,
  `
typenum('torrentupload','torrentedit','torrentdelete','promotion','demotion','addwarn','remwarn','accenabled','accdisabled','accdeleted','waitgrant','waitreject','passkeyreset','torrentgranted','autoclean','autowarn','autodewarn','autoban'collate utf8_bin NOT NULL default 'torrentupload',
  `
addeddatetime default NULL,
  `
txttext,
  
PRIMARY KEY  (`id`),
  
KEY `added` (`added`)
ENGINE=MyISAM 

PHP Code:

function write_log($typ$text)
{
   
$typ sqlesc($typ);
   
$text sqlesc($text);
   
$added sqlesc(get_date_time());
   
sql_query("INSERT INTO `sitelog` (`typ`, `added`, `txt`) VALUES($typ$added$text)") or sqlerr(__FILE____LINE__);


PHP Code:

<?php
require ("include/bittorrent.php");
require_once(
"include/user_functions.php");
require_once(
"include/bbcode_functions.php");
dbconn(false);
maxcoder();
if(!
logged_in())
{
header("HTTP/1.0 404 Not Found");
// moddifed logginorreturn by retro//Remember to change the following line to match your server
print("<html><h1>Not Found</h1><p>The requested URL /{$_SERVER['PHP_SELF']} was not found on this server.</p><hr /><address>Apache/1.1.11 (xxxxx) Server at ".$_SERVER['SERVER_NAME']." Port 80</address></body></html>\n");
die();
}

function 
puke($text "w00t")
{
    
stderr("w00t"$text);
}

if (
get_user_class() < UC_MODERATOR)
stderr("Error""Permission denied!");

function 
get_typ_name($typ)
{
    switch (
$typ) {
        case 
"torrentupload": return "Torrent uploaded";
        case 
"torrentedit": return "Torrent Edited";
        case 
"torrentdelete": return "Torrent Delete";
        case 
"autowarn": return "System Warnings";
        case 
"autodewarn": return "System Warnings Removed";
        case 
"autoban": return "System Ban  - Because of Bad Ratio";
        case 
"promotion": return "Promotion";
        case 
"demotion": return "Demotion";
        case 
"addwarn": return "Warning issued";
        case 
"remwarn": return "Warning removed";
        case 
"accenabled": return "Account Enabled";
        case 
"accdisabled": return "Account Disabled";
        case 
"accdeleted": return "Account deleted";
        case 
"passkeyreset": return "Passkey resets";
        case 
"autoclean": return "Auto cleanups";
        case 
"happyhour": return "Happy hours";
    }
}

$timerange = array(3600 => "1 Hour",
    
3600 => "3 Hours",
    
3600 => "6 Hours",
    
3600 => "9 Hours",
    
12 3600 => "12 Hours",
    
18 3600 => "18 Hours",
    
24 3600 => "1 Day",
    
24 3600 => "2 Days",
    
24 3600 => "3 Days",
    
24 3600 => "4 Days",
    
24 3600 => "5 Days",
    
24 3600 => "6 Days",
    
24 3600 => "1 Week",
    
14 24 3600 => "2 Weeks"
    
);

$types = array('torrentupload''torrentedit''torrentdelete''promotion''demotion''addwarn''remwarn''accenabled''accdisabled''accdeleted''passkeyreset''autoclean''happyhour''autowarn''autodewarn''autoban');
// Delete log items older than two weeks
$secs 14 24 3600;
stdhead("Site log");
sql_query("DELETE FROM sitelog2 WHERE " time() . " - UNIX_TIMESTAMP(added) > $secs") or sqlerr(__FILE____LINE__);
$where "WHERE ";
$typelist = Array();

if (isset(
$_GET["types"])) {
    foreach (
$_GET["types"] as $type) {
        
$typelist[] = sqlesc($type);
    }
    
$where .= "typ IN (" implode(","$typelist) . ") AND ";
}

if (isset(
$_GET["timerange"]))
    
$where .= time() . "-UNIX_TIMESTAMP(added)<" intval($_GET["timerange"]);
else {
    
$where .= time() . " - UNIX_TIMESTAMP(added) < 432000";
    
$_GET["timerange"] = 432000;
}

echo(
"<form action=\"log2.php\" method=\"get\"><a name=\"log\"></a><center>");
begin_table();
echo(
"<tr>\n");
$I 0;

foreach (
$types as $type) {
if (
$I == 4) {
    
$I 0;
        echo(
"</tr><tr>\n");
}
echo(
"<td class=\"tablea\"><input type=\"checkbox\" name=\"types[]\" value=\"$type\"");
if (
in_array(sqlesc($type), $typelist))
    echo(
" checked=checked");

    echo(
"> <a href=\"log2.php?timerange=" intval($_GET["timerange"]) . "&types[]=$type&filter=1#log\">" get_typ_name($type) . "</a></td>\n");
    
$I++;
}

if (
$I 4)
    echo 
"<td colspan=\"" . ($I) . "\"  class=\"tablea\">&nbsp;</td>\n";
    echo(
"</tr><tr><td class=\"tablea\" align=\"center\"><a href=\"log2.php?timerange=" intval($_GET["timerange"]) . "&filter=1#log\">Show all</a></td><td class=\"tablea\" colspan=\"2\" align=\"center\">Time: <select name=\"timerange\" size=\"1\">\n");
foreach (
$timerange as $range => $desc) {
    echo 
"<option value=\"$range\"";
if (
intval($_GET["timerange"]) == $range)
    echo 
" selected=\"selected\"";
    echo 
">$desc</option>\n";
}

echo(
"</select></td><td class=\"tablea\" align=\"center\"><input type=\"submit\" name=\"filter\" value=\"Filters\"></td></tr></table></form>");

if (isset(
$_GET["filter"])) {
    
$res sql_query("SELECT typ, added, txt FROM sitelog2 $where ORDER BY added DESC") or sqlerr(__FILE____LINE__);

    if (
mysql_num_rows($res) == 0)
        echo(
"<b>There are no events with the desired types.</b>\n");
    else {
        echo(
"<b>There were " mysql_num_rows($res) . " Events with the desired types.</b>\n");
        
begin_table(true);
        echo(
"<tr><td class=tablecat align=left>Date</td><td class=tablecat align=left>Time</td><td class=tablecat align=left>Type</td><td class=tablecat align=left>Event</td></tr>\n");
        while (
$arr mysql_fetch_assoc($res)) {
            
$typ get_typ_name($arr["typ"]);
            
$date substr($arr['added'], 0strpos($arr['added'], " "));
            
$time substr($arr['added'], strpos($arr['added'], " ") + 1);
            echo(
"<tr><td class=tableb>$date</td><td class=tablea>$time</td><td class=tableb align=left nowrap=nowrap>$typ</td><td class=tablea align=left>$arr[txt]</td></tr>\n");
        }
        echo(
"</table>");
    }
    echo(
"<p>All times are local.</p>\n");
}
end_frame();
stdfoot();

?>

found this - change all log2 to log and ALL your write log entrys to match this :nosepick:
I hope i didn't forget anything...

Big job mate but ask here if u need help !

Oh yeah and change example if u have this in takeupload
write_log("Torrent $id ($torrent) was uploaded by $CURUSER[username]");
change it to like this
write_log("torrentupload", "Torrent $id ($torrent) was uploaded by $CURUSER[username]");

ext. I hope u get the idea...


All times are GMT +2. The time now is 02:49.

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