root/dev/cron/cron_import.php @ 349

Revision 349, 2.7 KB (checked in by beans, 12 years ago)

Fixed the cron scripts

Line 
1#!/usr/bin/php
2<?php
3@error_reporting(E_ALL ^ E_NOTICE);
4//
5// Simple Cronjob script - set it to run this, no more than once an hour as you can only pull info once an hour anyway
6// by Captain Thunk! (ISK donations are all gratefully received)
7//
8
9@set_time_limit(0);
10
11// 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
12echo "Edit the \$KB_HOME and remove this line and the next\n";
13die();
14$KB_HOME = "/your/killboard/path";
15//chdir($KB_HOME);
16//chdir('/../../'); // finds Killboard root assuming that the we've started where we're supposed to start (<kb root>/mods/api_mod) - if this fails comment out and uncomment two lines above and edit path to correct path
17
18$path = ini_get("include_path");
19ini_set("include_path", $path . ":" . $KB_HOME);
20require_once( "kbconfig.php" );
21require_once( "common/includes/class.config.php" );
22require_once( "common/includes/class.event.php" );
23require_once( "common/includes/globals.php" );
24require_once( "common/includes/class.eveapi.php" );
25require_once( "common/includes/db.php" );
26
27$config = new Config(KB_SITE);
28if (((bool)config::get('cfg_memcache')) === true)
29{
30        require_once('common/includes/class.db_memcache.php');
31        $mc = new Memcache();
32        $mc->connect(config::get('cfg_memcache_server'), config::get('cfg_memcache_port'));
33}
34
35define('KB_TITLE', config::get('cfg_kbtitle'));
36
37// corporation OR alliance id
38if (config::get('cfg_corpid'))
39{
40    define('CORP_ID', config::get('cfg_corpid'));
41    define('ALLIANCE_ID', 0);
42} else {
43    define('CORP_ID', 0);
44    define('ALLIANCE_ID', config::get('cfg_allianceid'));
45}
46
47if (!$dir = config::get('cache_dir'))
48{
49    $dir = 'cache/data';
50}
51define('KB_CACHEDIR', $dir);
52
53$outhead = "Running API Mod ". APIVERSION . " on " . gmdate("M d Y H:i") . "\n\n";
54$out = '';
55
56$myEveAPI = new EveAPI();
57$myEveAPI->iscronjob_ = true;
58
59$keycount = config::get('API_Key_count');
60
61for ($i = 1; $i <= $keycount; $i++)
62{
63    $keyindex = $i;
64    $myEveAPI->Output_ = "Importing Mails for " . $config->get("API_Name_" . $i);
65        $myEveAPI->Output_ .= "\n";
66    $typestring = $config->get("API_Type_" . $i);
67    $keystring = 'userID=' . $config->get('API_UserID_' . $i) . '&apiKey=' . $config->get('API_Key_' . $i) . '&characterID=' . $config->get('API_CharID_' . $i);
68    $outtemp .= $myEveAPI->Import($keystring, $typestring, $keyindex);
69        config::set('API_CachedUntil_' . $keyindex, $myEveAPI->cachetext_);
70}
71$out = $outtemp;
72
73if ($out)
74{
75    $out = str_replace("<div class=block-header2>","",$out);
76    $out = str_replace("</div>","\n",$out);
77    $out = str_replace("<br>","\n",$out);
78
79    //print $outhead . strip_tags($out, '<a>');
80    print $outhead . strip_tags($out);
81}
82?>
Note: See TracBrowser for help on using the browser.