Changeset 162 for dev/common
- Timestamp:
- 12/23/06 02:31:43 (16 years ago)
- Location:
- dev/common
- Files:
-
- 8 modified
Legend:
- Unmodified
- Added
- Removed
-
dev/common/admin.php
r158 r162 23 23 check_tblstrct5(); 24 24 chk_kb3_items(); 25 chk_kb3_items2(); 25 26 check_tblstrct6(); 26 27 -
dev/common/admin_sync.php
r154 r162 1 1 <?php 2 require_once("db.php");3 2 require_once("class.page.php"); 4 3 require_once("class.contract.php"); … … 10 9 $page->setTitle("Administration - Synchronization"); 11 10 12 if ($_REQUEST['do'] == "sync")11 if ($_REQUEST['do'] == 'sync') 13 12 { 14 $do_sync = true; 15 } 13 $http = new http_request(KB_SYNCURL); 14 $fp = $http->connect(); 15 if (!$fp) 16 { 17 $html .= "Could not connect to Server:<br/>\n"; 18 $html .= $http-getError(); 16 19 17 if ($do_sync) 18 { 20 $page->addContext($menubox->generate()); 21 $page->setContent($html); 22 $page->generate(); 23 return; 24 } 25 26 $content_file = 'DATA_START'; 19 27 $qry = new DBQuery(); 20 28 $qry->execute("select plt_name, plt_externalid from kb3_pilots where plt_externalid != 0"); … … 24 32 } 25 33 26 $ http = new http_request(KB_SYNCURL);27 $ fp = $http->connect();28 if (!$fp)34 $content_file .= 'ITEMS_START'; 35 $qry->execute("select itm_name, itm_externalid, itm_value from kb3_items where itm_value != 0"); 36 while ($data = $qry->getRow()) 29 37 { 30 $ html .= "Could not connect to Server<br>\n";38 $content_file .= '§'.$data['itm_name'].'|'.$data['itm_externalid'].'|'.$data['itm_value'].'-'; 31 39 } 32 } 33 if ($do_sync && $fp) 34 { 40 35 41 $content_file = gzdeflate($content_file); 36 42 37 43 $http->set_postdata('data', $content_file); 38 44 $http->set_useragent("EVE-KB SYNC (VER ".KB_VERSION.")"); 45 $http->set_header('X-KBHost: '.base64_encode(KB_HOST)); 46 $http->setSockettimeout(30); 39 47 $file = $http->get_content(); 40 48 $header = $http->get_header(); … … 58 66 // get all names we'll find 59 67 preg_match_all("^!(.*?)\|(.*?)-^", $data, $matches); 60 unset($data);61 68 $results = count($matches[1]); 62 69 $update = new DBQuery(); … … 65 72 $update->execute("update kb3_pilots set plt_externalid='".addslashes($matches[2][$i])."' where plt_name='".addslashes($matches[1][$i])."' limit 1"); 66 73 } 67 $html .= "Synchronization complete, got $results new ids from server running version ".$version[0].'.'.$version[1].'.'.$version[2].'.<br>'; 74 $html .= "Synchronization complete, got $results new ids from server running version ".$version[0].'.'.$version[1].'.'.$version[2].'.<br/>'; 75 76 if (isset($_REQUEST['itm_update'])) 77 { 78 preg_match_all('^§(.*?)\|(.*?)\|(.*?)-^', $data, $matches); 79 unset($data); 80 $results = count($matches[1]); 81 for ($i = 0; $i<$results; $i++) 82 { 83 $update->execute("update kb3_items set itm_externalid='".addslashes($matches[2][$i])."', itm_value='".addslashes($matches[3][$i])."' where itm_name='".addslashes($matches[1][$i])."' limit 1"); 84 } 85 if ($results == 0) 86 { 87 $html .= 'No items fetched, itm_sync_module may be offline.<br/>'; 88 } 89 else 90 { 91 $html .= $results.' item prices have been fetched.<br/>'; 92 } 93 } 94 68 95 $html .= "Sent ".round($sended/1024, 2)." kB and received ".round($recv/1024, 2)." kB of data.<br>\n"; 69 96 $html .= '<a href="?a=admin_sync">Back</a>'; … … 74 101 if ($version[1] > $ownversion[1] && $version[1] % 2 == 1) 75 102 { 76 // test vor new minor updates below the dev-version103 // test for new minor updates below the dev-version 77 104 if ($version[1]-1 > $ownversion[1]) 78 105 { … … 87 114 if ($version[0] > $ownversion[0] || $upgrade) 88 115 { 89 $html .= "Looks like your Killboard version is pretty old, perhaps you want to upgrade it ?<br >\n";116 $html .= "Looks like your Killboard version is pretty old, perhaps you want to upgrade it ?<br/>\n"; 90 117 $html .= "Check the <a href='http://www.eve-dev.net/forums/viewforum.php?f=2'>EVE-Dev Forums</a> for new releases and additional information<br>\n"; 91 118 } … … 98 125 $html .= 'One synchronization every one or two weeks should be enough.<br>'; 99 126 $html .= 'Please don\'t abuse this free service!<br>'; 100 $html .= '<a href="?a=admin_sync&do=sync">Synchronize now</a>'; 127 $html .= '<form id="options" name="options" method="post" action="?a=admin_sync">'; 128 $html .= "<table class=kb-subtable>"; 129 $html .= "<tr><td width=120><b>Update item values</b></td><td><input type=checkbox name=itm_update id=itm_update"; 130 $html .= " checked=\"checked\"></td></tr>"; 131 $html .= '<input type="hidden" name="do" value="sync">'; 132 $html .= '<tr><td width=120></td><td><input type=submit name=submit value="Synchronize now"></td></tr></table></form>'; 101 133 } 102 134 $page->addContext($menubox->generate()); -
dev/common/autoupgrade.php
r158 r162 269 269 } 270 270 } 271 function chk_kb3_items2() 272 { 273 $qry = new DBQuery(); 274 $query = 'select itm_externalid from kb3_items where itm_name = \'Repair Drone\''; 275 $result = mysql_query($query); 276 $result = mysql_fetch_array($result); 277 if ($result['itm_externalid'] == '9871') 278 { 279 return; 280 } 281 $queries = " 282 update kb3_items set itm_externalid='10246' where itm_name='Mining Drone I'; 283 update kb3_items set itm_externalid='10248' where itm_name='Mining Drone - Improved UNUSED'; 284 update kb3_items set itm_externalid='10250' where itm_name='Mining Drone II'; 285 update kb3_items set itm_externalid='1187' where itm_name='Mining Drone - Elite'; 286 update kb3_items set itm_externalid='1201' where itm_name='Proximity Drone'; 287 update kb3_items set itm_externalid='1202' where itm_name='Wasp I'; 288 update kb3_items set itm_externalid='15508' where itm_name='Civilian Mining Drone'; 289 update kb3_items set itm_externalid='15510' where itm_name='Vespa I'; 290 update kb3_items set itm_externalid='16206' where itm_name='Valkyrie I'; 291 update kb3_items set itm_externalid='17565' where itm_name='Hellhound I'; 292 update kb3_items set itm_externalid='21050' where itm_name='Unanchoring Drone'; 293 update kb3_items set itm_externalid='21638' where itm_name='Survey Drone'; 294 update kb3_items set itm_externalid='21640' where itm_name='Vespa II'; 295 update kb3_items set itm_externalid='2173' where itm_name='Valkyrie II'; 296 update kb3_items set itm_externalid='2175' where itm_name='Infiltrator I'; 297 update kb3_items set itm_externalid='2183' where itm_name='Infiltrator II'; 298 update kb3_items set itm_externalid='2185' where itm_name='Hammerhead I'; 299 update kb3_items set itm_externalid='2193' where itm_name='Hammerhead II'; 300 update kb3_items set itm_externalid='2195' where itm_name='Praetor I'; 301 update kb3_items set itm_externalid='2203' where itm_name='Praetor II'; 302 update kb3_items set itm_externalid='2205' where itm_name='Acolyte I'; 303 update kb3_items set itm_externalid='2205' where itm_name='Acolyte II'; 304 update kb3_items set itm_externalid='22572' where itm_name='Praetor EV-900'; 305 update kb3_items set itm_externalid='22574' where itm_name='Warp Scrambling Drone'; 306 update kb3_items set itm_externalid='22713' where itm_name='10mn webscramblifying Drone'; 307 update kb3_items set itm_externalid='22765' where itm_name='Heavy Shield Maintenance Bot I'; 308 update kb3_items set itm_externalid='22780' where itm_name='Fighter Uno'; 309 update kb3_items set itm_externalid='23055' where itm_name='Templar'; 310 update kb3_items set itm_externalid='23057' where itm_name='Dragonfly'; 311 update kb3_items set itm_externalid='23059' where itm_name='Firbolg'; 312 update kb3_items set itm_externalid='23061' where itm_name='Einherji'; 313 update kb3_items set itm_externalid='23473' where itm_name='Wasp EC-900'; 314 update kb3_items set itm_externalid='23506' where itm_name='Ogre SD-900'; 315 update kb3_items set itm_externalid='23510' where itm_name='Praetor TD-900'; 316 update kb3_items set itm_externalid='23512' where itm_name='Berserker TP-900'; 317 update kb3_items set itm_externalid='23523' where itm_name='Heavy Armor Maintenance Bot I'; 318 update kb3_items set itm_externalid='23525' where itm_name='Curator I'; 319 update kb3_items set itm_externalid='23559' where itm_name='Berserker SW-900'; 320 update kb3_items set itm_externalid='23559' where itm_name='Warden I'; 321 update kb3_items set itm_externalid='23561' where itm_name='Garde I'; 322 update kb3_items set itm_externalid='23563' where itm_name='Bouncer I'; 323 update kb3_items set itm_externalid='23659' where itm_name='Acolyte EV-300'; 324 update kb3_items set itm_externalid='23702' where itm_name='Infiltrator EV-600'; 325 update kb3_items set itm_externalid='23705' where itm_name='Vespa EC-600'; 326 update kb3_items set itm_externalid='23707' where itm_name='Hornet EC-300'; 327 update kb3_items set itm_externalid='23709' where itm_name='Medium Armor Maintenance Bot I'; 328 update kb3_items set itm_externalid='23711' where itm_name='Light Armor Maintenance Bot I'; 329 update kb3_items set itm_externalid='23713' where itm_name='Hammerhead SD-600'; 330 update kb3_items set itm_externalid='23715' where itm_name='Hobgoblin SD-300'; 331 update kb3_items set itm_externalid='23717' where itm_name='Medium Shield Maintenance Bot I'; 332 update kb3_items set itm_externalid='23719' where itm_name='Light Shield Maintenance Bot I'; 333 update kb3_items set itm_externalid='23721' where itm_name='Valkyrie TP-600'; 334 update kb3_items set itm_externalid='23723' where itm_name='Warrior TP-300'; 335 update kb3_items set itm_externalid='23725' where itm_name='Infiltrator TD-600'; 336 update kb3_items set itm_externalid='23727' where itm_name='Acolyte TD-300'; 337 update kb3_items set itm_externalid='23729' where itm_name='Valkyrie SW-600'; 338 update kb3_items set itm_externalid='23731' where itm_name='Warrior SW-300'; 339 update kb3_items set itm_externalid='23759' where itm_name='FA-14 Templar'; 340 update kb3_items set itm_externalid='2436' where itm_name='Wasp II'; 341 update kb3_items set itm_externalid='2444' where itm_name='Ogre I'; 342 update kb3_items set itm_externalid='2446' where itm_name='Ogre II'; 343 update kb3_items set itm_externalid='2454' where itm_name='Hobgoblin I'; 344 update kb3_items set itm_externalid='2456' where itm_name='Hobgoblin II'; 345 update kb3_items set itm_externalid='24618' where itm_name='horrible tracking drone'; 346 update kb3_items set itm_externalid='2464' where itm_name='Hornet I'; 347 update kb3_items set itm_externalid='2466' where itm_name='Hornet II'; 348 update kb3_items set itm_externalid='2476' where itm_name='Berserker I'; 349 update kb3_items set itm_externalid='2478' where itm_name='Berserker II'; 350 update kb3_items set itm_externalid='2486' where itm_name='Warrior I'; 351 update kb3_items set itm_externalid='2488' where itm_name='Warrior II'; 352 update kb3_items set itm_externalid='3218' where itm_name='Harvester Mining Drone'; 353 update kb3_items set itm_externalid='3549' where itm_name='Tutorial Attack Drone'; 354 update kb3_items set itm_externalid='9871' where itm_name='Repair Drone'; 355 "; 356 $query = explode("\n", $queries); 357 foreach ($query as $querystring) 358 { 359 if ($string = trim(str_replace(');', ')', $querystring))) 360 { 361 $qry->execute($string); 362 } 363 } 364 } 271 365 function check_tblstrct6() 272 366 { -
dev/common/class.http.php
r159 r162 20 20 $this->postform = array(); 21 21 $this->postdata = array(); 22 $this->headers = array(); 23 $this->socket_timeout = 5; 24 } 25 26 // socket timeout is the amount of time in second which is waited 27 // for incoming data, set higher if you request stuff from heavy-loaded 28 // scripts or compressed data streams 29 function setSockettimeout($int) 30 { 31 $this->socket_timeout = $int; 22 32 } 23 33 … … 54 64 if (!$this->fp) 55 65 { 56 //echo "Error occured with fsockopen: $errstr ($errno)<br>\n"; 66 $this->_errno = $errno; 67 $this->_errstr = $errstr; 57 68 return false; 58 69 } 59 70 return true; 71 } 72 73 function getError() 74 { 75 return 'Error occured with fsockopen: '.$this->_errstr.' ('.$this->_errno.')<br/>'."\n"; 60 76 } 61 77 … … 82 98 .'Host: '.$this->url['host'].$lf 83 99 .'Connection: close'.$lf; 100 if (count($this->headers)) 101 { 102 $request_string .= join($lf, $this->headers).$lf; 103 } 84 104 if ($this->method == 'POST') 85 105 { … … 115 135 116 136 $header = 1; 117 socket_set_timeout($fp, 5);137 socket_set_timeout($fp, $this->socket_timeout); 118 138 while ($line = fgets($fp, 4096)) 119 139 { … … 161 181 $this->useragent = $string; 162 182 } 183 184 function set_header($headerstring) 185 { 186 if (!strpos($headerstring, ':')) 187 { 188 return; 189 } 190 $this->headers[$headerstring] = $headerstring; 191 } 163 192 } 164 193 ?> -
dev/common/class.killlist.php
r158 r162 59 59 if ($config->getConfig('ship_values')) 60 60 { 61 $this->sql_ .= ' left join kb3_ships_values ksv on (shp.shp_id = ksv.shp_id) ';61 $this->sql_ .= ' left join kb3_ships_values ksv on (shp.shp_id = ksv.shp_id) '; 62 62 } 63 63 … … 83 83 if ($this->inv_crp_) 84 84 $this->sql_ .= " inner join kb3_inv_crp inc 85 on ( inc.inc_crp_id in ( ".substr($this->inv_crp_, 0, strlen($this->inv_crp_) - 2)." ) and kll.kll_id = inc.inc_kll_id ) "; 85 on ( inc.inc_crp_id in ( ".substr($this->inv_crp_, 0, strlen($this->inv_crp_) - 2)." ) and kll.kll_id = inc.inc_kll_id 86 and inc.inc_crp_id != kll.kll_crp_id ) "; 86 87 if ($this->inv_all_) 87 88 $this->sql_ .= " inner join kb3_inv_all ina 88 on ( ina.ina_all_id in ( ".substr($this->inv_all_, 0, strlen($this->inv_all_) - 2)." ) and kll.kll_id = ina.ina_kll_id ) "; 89 on ( ina.ina_all_id in ( ".substr($this->inv_all_, 0, strlen($this->inv_all_) - 2)." ) and kll.kll_id = ina.ina_kll_id 90 and ina.ina_all_id != kll.kll_all_id ) "; 89 91 } 90 92 else -
dev/common/globals.php
r139 r162 6 6 // current version: major.minor.sub 7 7 // unpair numbers for minor = development version 8 define('KB_VERSION', '1.2. 1');8 define('KB_VERSION', '1.2.2'); 9 9 10 10 // set the running-server for id-syncs here -
dev/common/kill_related.php
r157 r162 56 56 { 57 57 $h = ($baseh-$i) % 24; 58 if ($h < 0) 59 { 60 $h += 24; 61 } 58 62 if (!isset($ts[$h])) 59 63 { -
dev/common/sync_server.php
r57 r162 18 18 if ($version[0] <= 1 && $version[1] < 1) 19 19 { 20 echo "Your Killboard is too old, please upgrade to 1.2. 0or newer<br>\n";20 echo "Your Killboard is too old, please upgrade to 1.2.2 or newer<br>\n"; 21 21 return; 22 } 23 24 if (!function_exists('apache_request_headers')) 25 { 26 function apache_request_headers() 27 { 28 return getallheaders(); 29 } 30 } 31 $header = apache_request_headers(); 32 foreach ($header as $key => $value) 33 { 34 if ($key == 'X-KBHost') 35 { 36 $host = base64_decode($value); 37 } 22 38 } 23 39 … … 36 52 // get all names we'll find 37 53 preg_match_all("^!(.*?)\|(.*?)-^", &$data, $matches); 38 unset($data);54 $data = strstr($data, 'ITEMS_START'); 39 55 $results = count($matches[1]); 40 56 if ($results == 0) … … 46 62 } 47 63 64 $s_data = array(); 48 65 // construct an array with name as key and id as value 49 66 for ($i = 0; $i<$results; $i++) … … 51 68 $s_data[$matches[1][$i]] = $matches[2][$i]; 52 69 } 70 unset($matches); 71 72 if ($host) 73 { 74 $qry = new DBQuery(); 75 $qry->execute("show tables like '%item_%'"); 76 while ($row = $qry->getRow()) 77 { 78 $tables .= array_pop($row); 79 } 80 if (!strstr($tables, 'kb3_item_stats')) 81 { 82 $qry->execute("CREATE TABLE `kb3_item_stats` (\n `itm_name` varchar(128) NOT NULL,\n `kb_host` int(11) NOT NULL,\n `itm_externalid` int(11) NOT NULL,\n `itm_value` bigint(4) NOT NULL,\n PRIMARY KEY (`itm_name`,`kb_host`)\n) TYPE=MyISAM"); 83 $qry->execute("CREATE TABLE `kb3_item_hosts` (\n `kb_host` int(11) NOT NULL,\n `kb_name` varchar(255) NOT NULL,\n `itm_update` timestamp NOT NULL default '0000-00-00 00:00:00',\n RPIMARY KEY (`kb_host`)\n) TYPE=MyISAM"); 84 } 85 preg_match_all('^§(.*?)\|(.*?)\|(.*?)-^', &$data, $matches); 86 87 $hostid = abs(crc32($host)); 88 $qry->execute('replace into kb3_item_hosts (kb_host, kb_name, itm_update) VALUES (\''.$hostid.'\',\''.addslashes($host).'\',\''.date('Y-m-d H:i:s').'\')'); 89 90 $results = count($matches[1]); 91 for ($i = 0; $i<$results; $i++) 92 { 93 $qry->execute("replace into kb3_item_stats (itm_name,kb_host,itm_externalid,itm_value) VALUES ('".addslashes($matches[1][$i])."','".$hostid."','".addslashes($matches[2][$i])."','".addslashes($matches[3][$i])."')"); 94 } 95 } 96 unset($data); 53 97 54 98 // now get our list from the database … … 84 128 } 85 129 130 $data_array = $data_values = array(); 131 $qry->execute('select itm_name, itm_externalid, itm_value from kb3_item_stats order by itm_name asc, itm_value asc'); 132 while ($data = $qry->getRow()) 133 { 134 $data_array[$data['itm_name']] = $data; 135 $data_values[$data['itm_name']][] = $data['itm_value']; 136 } 137 138 $content_file .= 'ITEMS_START'; 139 foreach ($data_array as $data) 140 { 141 // get the median value for every item 142 $val_cnt = count($data_values[$data['itm_name']]); 143 $val_cnt = min(ceil($val_cnt/2), $val_cnt)-1; 144 $value = $data_values[$data['itm_name']][$val_cnt]; 145 146 $content_file .= '§'.$data['itm_name'].'|'.$data['itm_externalid'].'|'.$value.'-'; 147 } 148 86 149 // return the compressed data back to the client 87 150 echo gzdeflate($content_file);