Changeset 370 for dev/cron

Show
Ignore:
Timestamp:
06/14/09 06:51:49 (12 years ago)
Author:
kovell
Message:

- SQL queries optimised for speed and error protection.
- feed syndication optimised
- front page includes optional clock and optional kill/loss display
- mysqli support added
- transaction protection of kills added where supported (mysqli and InnoDB)
- summary tables and contracts show total destroyed value instead of ship value
- html errors reduced
- related kill calculation improved
- query caching errors reduced
- minor bugfixes
- Smarty 2.6.25 added
- apoc fitting mod added and modded
- code optimisations
- code comments added (doxygen format)
- conflicting mods are now identified

Location:
dev/cron
Files:
1 added
2 modified

Legend:

Unmodified
Added
Removed
  • dev/cron/cron_fetcher.php

    r349 r370  
    33// //// 
    44// ////  ////// 
    5 // ////  liq's feed syndication mod v1.5 
     5// ////  liq's feed syndication mod v1.6 
    66// ////////// 
    77// ////////// 
     
    1212define(MASTER, 0); 
    1313 
    14 $version = "v1.5"; 
     14$version = "v1.6"; 
    1515@set_time_limit(0); 
    1616 
    1717// Has to be run from the KB main directory for nested includes to work 
    18 echo "Edit the \$KB_HOME and remove this line and the next\n"; 
    19 die(); 
    20 $KB_HOME = "/your/killboard/path"; 
     18//echo "Edit the \$KB_HOME and remove this line and the next\n"; 
     19//die(); 
     20$KB_HOME = ereg_replace('[/\\]cron$', '', getcwd()); 
    2121chdir($KB_HOME);  
    2222 
     
    2828require_once('common/includes/class.event.php'); 
    2929require_once('common/admin/feed_fetcher.php'); 
     30require_once('common/includes/db.php'); 
    3031 
    3132$config = new Config(KB_SITE); 
    32 if (((bool)config::get('cfg_memcache')) === true) 
    33 { 
    34         require_once('common/includes/class.db_memcache.php'); 
    35         $mc = new Memcache(); 
    36         $mc->connect(config::get('cfg_memcache_server'), config::get('cfg_memcache_port')); 
    37 } 
    3833 
    3934$validurl = "/^(http|https):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}((:[0-9]{1,5})?\/.*)?$/i"; 
     
    8176    $tmp = explode(':::', $str); 
    8277    $feed[$i] = $tmp[0]; 
    83     $time[$i] = $tmp[1]; 
     78    $feedlast[$i] = intval($tmp[1]); 
    8479    if ($tmp[2] == "on") 
    8580        $friend[$i] = $tmp[2]; 
    86  
    8781    $feedfetch = new Fetcher(); 
    8882    if (preg_match($validurl , $feed[$i])) 
    8983    { 
    9084        $str = ''; 
     85        if ($feedlast[$i]) 
     86        { 
     87            $str .= '&combined=1'; 
     88            $str .= '&lastkllid='.$feedlast[$i]; 
     89        } 
    9190        if ($friend[$i]) 
    9291            $str .= '&friend=1'; 
    9392        if (!config::get('fetch_compress')) 
    9493            $str .= "&gz=1"; 
    95         // Fetch for current and previous weeks, both kills and losses 
    96         for ($l = $week - 1; $l <= $week; $l++) 
     94        // If a last kill id is specified fetch all kills since then 
     95        if($feedlast[$i] > 0) 
    9796        { 
    98             $out .= preg_replace('/<div.+No kills added from feed.+<\/div>/','',$feedfetch->grab($feed[$i] . "&year=" . $year . "&week=" . $l, $myid . $str)). "\n"; 
    99             $out .= preg_replace('/<div.+No kills added from feed.+<\/div>/','',$feedfetch->grab($feed[$i] . "&year=" . $year . "&week=" . $l, $myid . $str . "&losses=1")) . "\n"; 
     97            $out .= preg_replace('/<div.+No kills added from feed.+<\/div>/','',$feedfetch->grab($feed[$i], $myid . $str, $friend[$i], "fetch_url_" . $i)). "\n"; 
     98            if(intval($feedfetch->lastkllid_)) $feedlast[$i] = intval($feedfetch->lastkllid_); 
     99            // Check if feed used combined list. get losses if not 
     100            if(!$feedfetch->combined_) 
     101            { 
     102                    $out .= preg_replace('/<div.+No kills added from feed.+<\/div>/','',$feedfetch->grab($feed[$i], $myid . $str . "&losses=1", $friend[$i], "fetch_url_" . $i)) . "\n"; 
     103                    if(intval($feedfetch->lastkllid_)) $feedlast[$i] = intval($feedfetch->lastkllid_); 
     104            } 
     105            // Store most recent kill id fetched 
     106            if($feedfetch->lastkllid_) 
     107            { 
     108                //Fetch final kill id of board from feed if possible and set as new last kill. 
     109                if(intval($feedfetch->finalkllid_)> $feedlast[$i])  
     110                    config::set("fetch_url_" . $i, $feed[$i] . ':::' . intval($feedfetch->finalkllid_) . ':::' . $friend[$i]); 
     111                else config::set("fetch_url_" . $i, $feed[$i] . ':::' . $feedlast[$i] . ':::' . $friend[$i]); 
     112            } 
     113        } 
     114        // If no last kill is specified then fetch by week 
     115        else 
     116        { 
     117                // Fetch for current and previous weeks, both kills and losses 
     118                for ($l = $week - 1; $l <= $week; $l++) 
     119                { 
     120                    $out .= preg_replace('/<div.+No kills added from feed.+<\/div>/','',$feedfetch->grab($feed[$i] . "&year=" . $year . "&week=" . $l, $myid . $str)). "\n"; 
     121                        if(intval($feedfetch->lastkllid_)) $feedlast[$i] = intval($feedfetch->lastkllid_); 
     122                    $out .= preg_replace('/<div.+No kills added from feed.+<\/div>/','',$feedfetch->grab($feed[$i] . "&year=" . $year . "&week=" . $l, $myid . $str . "&losses=1")) . "\n"; 
     123                        if(intval($feedfetch->lastkllid_ )) $feedlast[$i] = intval($feedfetch->lastkllid_); 
     124                } 
     125                // Store most recent kill id fetched 
     126                if($feedfetch->lastkllid_) config::set("fetch_url_" . $i, $feed[$i] . ':::' . $feedlast[$i] . ':::' . $friend[$i]); 
    100127        } 
    101128    } 
  • dev/cron/cron_import.php

    r365 r370  
    11#!/usr/bin/php  
    22<?php 
     3// check your php folder is correct as defined by the first line of this file 
     4 
    35@error_reporting(E_ALL ^ E_NOTICE); 
    46// 
     
    79// 
    810 
    9 @set_time_limit(0); 
     11if(function_exists("set_time_limit")) 
     12        set_time_limit(0); 
     13 
     14// current working directory minus last 5 letters of string ("/cron") 
     15//$KB_HOME = substr(getcwd(), 0, strlen(getcwd())-5); // current working directory minus last 5 letters of string ("/cron") 
     16$KB_HOME = ereg_replace('[/\\]cron$', '', getcwd()); 
     17 
     18chdir($KB_HOME);  
     19 
     20// If the above doesn't work - place your working directory path to killboard root below - comment out the above two lines and uncomment the two below 
    1021 
    1122// Edit the path below with your webspace directory to the killboard root folder - also check your php folder is correct as defined by the first line of this file 
    12  
    13 $KB_HOME = "/home/thunkage/public_html/kb"; 
    14 chdir($KB_HOME);  
    15 //chdir('/../'); // finds Killboard root assuming that the we've started where we're supposed to start (<kb root>/cron) - if this fails comment out and uncomment two lines above and edit path to correct path 
     23//$KB_HOME = "/home/yoursite/public_html/kb"; 
     24//chdir($KB_HOME);  
    1625 
    1726require_once( "kbconfig.php" ); 
    1827require_once( "common/includes/class.config.php" ); 
     28require_once( "common/includes/class.apicache.php" ); 
    1929require_once( "common/includes/class.event.php" ); 
    2030require_once( "common/includes/globals.php" ); 
     
    2333 
    2434$config = new Config(KB_SITE); 
    25 if (((bool)config::get('cfg_memcache')) === true) 
    26 { 
    27         require_once('common/includes/class.db_memcache.php'); 
    28         $mc = new Memcache(); 
    29         $mc->connect(config::get('cfg_memcache_server'), config::get('cfg_memcache_port')); 
    30 } 
     35$ApiCache = new ApiCache(KB_SITE); 
    3136 
    3237define('KB_TITLE', config::get('cfg_kbtitle')); 
     
    6368    $typestring = $config->get("API_Type_" . $i); 
    6469    $keystring = 'userID=' . $config->get('API_UserID_' . $i) . '&apiKey=' . $config->get('API_Key_' . $i) . '&characterID=' . $config->get('API_CharID_' . $i); 
     70        $myEveAPI->cachetext_ = ""; 
     71        $myEveAPI->cacheflag_ = false; 
    6572    $outtemp .= $myEveAPI->Import($keystring, $typestring, $keyindex); 
    66         config::set('API_CachedUntil_' . $keyindex, $myEveAPI->cachetext_); 
     73        //config::set('API_CachedUntil_' . $keyindex, $myEveAPI->cachetext_); 
    6774} 
    6875$out = $outtemp;