Bravo List

Bravo List (http://www.bvlist.com/index.php)
-   Mods & Themes (http://www.bvlist.com/forumdisplay.php?f=97)
-   -   Optimization mod (http://www.bvlist.com/showthread.php?t=3456)

kp380lv 23rd September 2009 19:14

Optimization mod
 
Go to details.php and search for this:

Drop in your database: DROP TABLE `readtorrents`;
And add your database this: ALTER TABLE `users` ADD `last_checked` datetime NOT NULL default '0000-00-00 00:00:00';

PHP Code:

sql_query("INSERT INTO readtorrents (userid, torrentid) VALUES (".sqlesc($CURUSER["id"]).", ".sqlesc($id).")")/* or sqlerr(__FILE__,__LINE__)*/

After you find that simply comment it out...

like this:
PHP Code:

//sql_query("INSERT INTO readtorrents (userid, torrentid) VALUES (".sqlesc($CURUSER["id"]).", ".sqlesc($id).")")/* or sqlerr(__FILE__,__LINE__)*/; 

After this line add this;

PHP Code:

if(checkNewTorrent($id$row["added"])) 

  
$coo_ch $_COOKIE['torrents_vis']; 
  
setcookie("torrents_vis", ($coo_ch $coo_ch"A" .$id $id)); 
  
sql_query("UPDATE torrents SET views = views + 1 WHERE id = $id"); 


Then open functions.php and search for function userlogin

After this:

PHP Code:


$sec 
hash_pad($row["secret"]); 
    if (
$_COOKIE["pass"] !== $row["passhash"]) { 
        if (
$use_lang
            include_once(
'languages/lang_' $default_language '/lang_main.php'); 
        
user_session(); 
        return; 
    } 

Add this:

PHP Code:

$minutes 20
    
$seconds $minutes*60;
    
$dt get_date_time(gmtime() - $seconds);

    if(
$row['last_access'] < $dt)
    {
        
$set_checked ", last_checked = '" .$row['last_access']. "'";
        
setcookie("torrents_vis""");
    } 

Find this:

PHP Code:

sql_query("UPDATE users SET last_access = ".sqlesc(get_date_time()).", ip = ".sqlesc($ip)." WHERE id=" $row["id"]);// or die(mysql_error()); 

and replace it with this:

PHP Code:

sql_query("UPDATE users SET last_access = ".sqlesc(get_date_time()).", ip = ".sqlesc($ip).$set_checked ." WHERE id=" $row["id"]);// or die(mysql_error()); 

After that paste this code UNTIL function torrenttable

PHP Code:

 function checkNewTorrent($id$added
  { 
    global 
$CURUSER

      
$coo_new $_COOKIE["torrents_vis"]; 

      
$diff_add preg_replace("/[^0-9]/"""$added); 
      
$diff_lch preg_replace("/[^0-9]/"""$CURUSER["last_checked"]); 

      if(
$diff_add $diff_lch
      { 
         if(
$coo_new
         { 
        if(
explode("A"$coo_new)) 
        { 
           if(!
in_array($idexplode("A"$coo_new))) 
           
$new_t true
        } 
        else 
        { 
           if(
$coo_new != $id
           
$new_t true
        } 
         } 
         else 
        
$new_t true
      } 
      else 
     
$new_t false

     return 
$new_t
   } 

After that find and replace this:

PHP Code:

if ($row["readtorrent"] == && $variant == "index"
                   print (
"<b><font color=\"red\" size=\"1\">[NEW]</font></b>"); 

With this:

PHP Code:

 if (checkNewTorrent($row["id"], $row["added"]) && $is_user && $variant == "index"
       print (
"<b><font color=\"red\" size=\"1\">[NEW]</font></b>"$diff); 

Then open takesignup.php and replace this:

PHP Code:

$ret sql_query("INSERT INTO users (username, passhash, secret, editsecret, gender, country, icq, msn, aim, yahoo, skype, mirc, website, email, status, ". (!$users?"class, ":"") ."added, birthday, invitedby, invitedroot) VALUES (" .
        
implode(","array_map("sqlesc", array($wantusername$wantpasshash$secret$editsecret$gender$country$icq$msn$aim$yahoo$skype$mirc$website$email$status))).
        
", ". (!$users?UC_SYSOP.", ":""). "'"get_date_time() ."', '$birthday', '$inviter', '$invitedroot')");// or sqlerr(__FILE__, __LINE__); 

With this:

PHP Code:

 $ret sql_query("INSERT INTO users (username, passhash, secret, editsecret, gender, country, icq, msn, aim, yahoo, skype, mirc, website, email, status, ". (!$users?"class, ":"") ."added, birthday, language, invitedby, invitedroot, last_checked) VALUES (" .
        
implode(","array_map("sqlesc", array($wantusername$wantpasshash$secret$editsecret$gender$country$icq$msn$aim$yahoo$skype$mirc$website$email$status))).
        
", ". (!$users?UC_SYSOP.", ":""). "'"get_date_time() ."', '$birthday', '$default_language', '$inviter', '$invitedroot', '"get_date_time() ."')");// or sqlerr(__FILE__, __LINE__); 

Now open markread.php and replace it with this code:

PHP Code:


<?
require "include/bittorrent.php";
dbconn(false);
loggedinorreturn();
ob_start();

stdhead();


if (
sql_query("UPDATE users SET last_checked = " .sqlesc(get_date_time()). " WHERE id = " .sqlesc($CURUSER["id"])) && setcookie("torrents_vis"""))
   
stdmsg("Successfully""Latest torrents marked as read.");
else
   
stdmsg("Error""Evaluation of new torrents occurred with error: ".mysql_error());


stdfoot();

header("Refresh: 5; url=browse.php");
?>

Now delete unneeded things..

cleanup.php

PHP Code:

sql_query("DELETE FROM readtorrents WHERE userid = ".sqlesc($arr["id"])) or sqlerr(__FILE__,__LINE__);
sql_query("DELETE FROM readtorrents WHERE userid = ".sqlesc($arr["id"])) or sqlerr(__FILE__,__LINE__

details.php

PHP Code:

sql_query("INSERT INTO readtorrents (userid, torrentid) VALUES (".sqlesc($CURUSER["id"]).", ".sqlesc($id).")")/* or sqlerr(__FILE__,__LINE__)*/

browse.php

PHP Code:

".($CURUSER ? "EXISTS(SELECT FROM readtorrents WHERE readtorrents.userid ".sqlesc($CURUSER["id"])." AND readtorrents.torrentid torrents.id) AS readtorrent" : "AS readtorrent")." 

delacct.php

PHP Code:

sql_query("DELETE FROM readtorrents WHERE userid = $id") or sqlerr(__FILE__,__LINE__); 

delaccadmin.php

PHP Code:

sql_query("DELETE FROM readtorrents WHERE userid = $id") or sqlerr(__FILE__,__LINE__); 

deltorrent.php

PHP Code:

sql_query("DELETE FROM readtorrents WHERE torrentid IN (" implode(", "array_map("sqlesc"$_POST["delete"])) . ")") or sqlerr(__FILE__,__LINE__); 

modtask.php

PHP Code:

sql_query("DELETE FROM readtorrents WHERE userid = $userid") or sqlerr(__FILE__,__LINE__); 


That's all.

benjaminbih 5th October 2009 23:04

nice work, thank you for providing it

DOPE 24th July 2011 00:55

What does this do exactly?


All times are GMT +2. The time now is 15:14.

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