Advertisement
Guest User

Untitled

a guest
Aug 13th, 2011
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.63 KB | None | 0 0
  1. <?php
  2. if(!defined('VG')){ die; }
  3. class Generic {
  4.     function connectPerp() {
  5.         global $config;
  6.         if(!mysql_connect($config['serverDB']['host'], $config['serverDB']['username'], $config['serverDB']['password'])){
  7.             return false;
  8.         }else{
  9.             mysql_select_db($config['serverDB']['database']);
  10.             return true;
  11.         }
  12.     }
  13.    
  14.     function connectForum() {
  15.         global $config;
  16.         if(!mysql_connect($config['siteDB']['host'], $config['siteDB']['username'], $config['siteDB']['password'])){
  17.             return false;
  18.         }else{
  19.             mysql_select_db($config['siteDB']['database']);
  20.             return true;
  21.         }
  22.     }
  23.    
  24.     function setempty($str) {
  25.         if(isset($str) && !empty($str)){ return true; }else{ return false; }
  26.     }
  27.    
  28.     function red($url){
  29.         header('Location: '.$url);
  30.         ob_end_flush();
  31.     }
  32.    
  33.     function date($time, $format = 'm/d/Y h:i A') {
  34.         return date($format, $time);
  35.     }
  36.    
  37.     function initCaching($cachefile, $cachereset, $location = 'top'){
  38.         if($location == 'top'){
  39.             if(file_exists($cachefile) && ((time() - $cachereset) < filemtime($cachefile))){
  40.                 include($cachefile);
  41.                 exit;
  42.             }
  43.         }else{
  44.             $fp = fopen($cachefile, 'w');
  45.             fwrite($fp, "<? if(!defined('VG')){ die; } ?>".ob_get_contents());
  46.             fclose($fp);
  47.             ob_end_flush();
  48.         }
  49.     }
  50.    
  51.     function banPointCron() {
  52.         $this->connectPerp();
  53.         $q = mysql_query("SELECT `steamid`, `id` FROM `server_bans_points` WHERE `time` < '".time()."'");
  54.         while($a = mysql_fetch_array($q)){
  55.             mysql_query("UPDATE `ip_intel` SET `strikes` = strikes - 1 WHERE `steamid` = '".mysql_escape_string($a['steamid'])."'");
  56.             mysql_query("DELETE FROM `server_bans_points` WHERE `id` = '".$a['id']."'");
  57.         }
  58.     }
  59. }
  60. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement