root/dev/cron/cron_import.php @ 343

Revision 343, 2.5 KB (checked in by beans, 12 years ago)

A lot of updates done by Karbowiak (LaMaH).
See them here:  http://eve-id.net/forum/viewtopic.php?f=503&t=13204&p=15284#p15284

Highlights:
* Integrated feed fetcher & API Mod into the core
* memcached support in core

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
12$KB_HOME = "location/of/your/kb/main/dir";
13//chdir($KB_HOME);
14chdir('/../../'); // 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
15
16$path = ini_get("include_path");
17ini_set("include_path", $path . ":" . $KB_HOME);
18require_once( "kbconfig.php" );
19require_once( "common/includes/class.config.php" );
20require_once( "common/includes/class.event.php" );
21require_once( "common/includes/globals.php" );
22require_once( "common/includes/class.eveapi.php" );
23require_once( "common/includes/db.php" );
24require_once( "common/includes/class.db_memcache.php" );
25
26$mc = new Memcache();
27$mc->connect("127.0.0.1", 11211);
28
29$config = new Config(KB_SITE);
30define('KB_TITLE', config::get('cfg_kbtitle'));
31
32// corporation OR alliance id
33if (config::get('cfg_corpid'))
34{
35    define('CORP_ID', config::get('cfg_corpid'));
36    define('ALLIANCE_ID', 0);
37} else {
38    define('CORP_ID', 0);
39    define('ALLIANCE_ID', config::get('cfg_allianceid'));
40}
41
42if (!$dir = config::get('cache_dir'))
43{
44    $dir = 'cache/data';
45}
46define('KB_CACHEDIR', $dir);
47
48$outhead = "Running API Mod ". APIVERSION . " on " . gmdate("M d Y H:i") . "\n\n";
49$out = '';
50
51$myEveAPI = new EveAPI();
52$myEveAPI->iscronjob_ = true;
53
54$keycount = config::get('API_Key_count');
55
56for ($i = 1; $i <= $keycount; $i++)
57{
58    $keyindex = $i;
59    $myEveAPI->Output_ = "Importing Mails for " . $config->get("API_Name_" . $i);
60        $myEveAPI->Output_ .= "\n";
61    $typestring = $config->get("API_Type_" . $i);
62    $keystring = 'userID=' . $config->get('API_UserID_' . $i) . '&apiKey=' . $config->get('API_Key_' . $i) . '&characterID=' . $config->get('API_CharID_' . $i);
63    $outtemp .= $myEveAPI->Import($keystring, $typestring, $keyindex);
64        config::set('API_CachedUntil_' . $keyindex, $myEveAPI->cachetext_);
65}
66$out = $outtemp;
67
68if ($out)
69{
70    $out = str_replace("<div class=block-header2>","",$out);
71    $out = str_replace("</div>","\n",$out);
72    $out = str_replace("<br>","\n",$out);
73
74    //print $outhead . strip_tags($out, '<a>');
75    print $outhead . strip_tags($out);
76}
77?>
Note: See TracBrowser for help on using the browser.