Hoşgeldin Misafir

[MOD] Server Load Mod / Sayfa Yüklenme Süresi

MiRaT

13 Kas 2017
2,077 Mesaj

Aktiflik

Seviye

Deneyim

TIM / GÖREV:
Kod:
 ############################################################## 
## MOD Title: Server Load Mod 
## MOD Author: IDB < [email protected] > (Ian Brooks) http://www.team-allegiance.com
## MOD Description: Mod to show the number of pages served on your web server from your forums
## within a user-defined period (default is 5 mins).
## MOD Version: 0.1.0 
## 
## Installation Level: Moderate
## Installation Time: 10 Minutes 
## Files To Edit: functions.php, page_tail.php, overall_footer.php
## Included Files: n/a
############################################################## 
############################################################## 
## Author Notes: 
##
## 1. This mod requires 1 new table to be added to your database.  
##    Run the SQL statement shown below to do this.
##    Change the table prefix if you use other than phpbb.
##
##    CREATE TABLE phpbb_serverload (time int(14) NOT NULL default '0') TYPE=MyISAM;
##               
## 2. Change the overall_footer.tpl file for all your Templates
##
############################################################## 
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD 
############################################################## 

# 
#-----[ OPEN]------------------------------------------ 
# 

includes/functions.php

# 
#-----[ FIND ]------------------------------------------ 
# 

?>

# 
#-----[ ADD BEFORE ]------------------------------------------ 
# 

function serverload() {   
   
   //Ian D. Brooks
   
   global $db;
   $tablename = "phpbb_serverload";  //Change the table prefix if you use one other than phpbb
   
   $duration = "300";    // How many seconds load will represent.
                       // Change the time representation in overall_footer.tpl to match this

   // Delete old page counts
   $sql = "DELETE FROM $tablename WHERE time < " . (time()-$duration);
   if( !($result = $db->sql_query($sql)) )
   {
      message_die(GENERAL_ERROR, 'Could not delete Server Load entries', '', __LINE__, __FILE__, $sql);
   }
       
   // Insert the current page count
   
   $sql = "INSERT INTO $tablename (time) VALUES (" . time() . ") ";
   
        if( !($result = $db->sql_query($sql)) )
   {
      message_die(GENERAL_ERROR, 'Could not uppdate Server Load entries', '', __LINE__, __FILE__, $sql);
   }

   // Get page count (number of rows in the table)
   
   $sql = "SELECT time FROM $tablename";
   
        if( !($result = $db->sql_query($sql)) )
   {
      message_die(GENERAL_ERROR, 'Could not obtain Server Load entries', '', __LINE__, __FILE__, $sql);
   }
   
        return $db->sql_numrows($result);

} // END FUNCTION serverload

# 
#-----[ SAVE ]------------------------------------------ 
# 

includes/functions.php

# 
#-----[ OPEN]------------------------------------------ 
# 

includes/page_tail.php

# 
#-----[ FIND ]------------------------------------------ 
# 

$admin_link = ( $userdata['user_level'] == ADMIN ) ? '<a href="' . append_sid("admin/index.$phpEx") . '">' . $lang['Admin_panel'] . '</a><br /><br />' : '';

# 
#-----[ ADD BEFORE ]------------------------------------------ 
# 

//Serverload Mod

   $server_load = serverload();
   $out_server = '<center><span class="copyright">Server Load: ';
   $out_server .= $server_load;
   $out_server .=  " page(s) served in previous 5 minutes.";

//

# 
#-----[ FIND ]------------------------------------------ 
# 

$template->pparse('overall_footer');

# 
#-----[ ADD BEFORE ]------------------------------------------ 
# 

$template->assign_vars(array(
      "SERVER_LOAD" => $out_server)
   );

# 
#-----[ SAVE ]------------------------------------------ 
# 

includes/page_tail.php

# 
#-----[ OPEN]------------------------------------------ 
# 

templates/subSilver/overall_footer.php

# 
#-----[ FIND ]------------------------------------------ 
# 

</div>

# 
#-----[ ADD AFTER ]------------------------------------------ 
# 

<br />{SERVER_LOAD}

# 
#-----[ SAVE ]------------------------------------------ 
# 

templates/subSilver/overall_footer.php


# 
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------ 
# 
# EoM