root/dev/common/portrait.php @ 44

Revision 44, 1.9 KB (checked in by exi, 14 years ago)

Changed Synchronization to use http-request class
Changed portrait generation to use http class and fixed some issues there aswell
Ordered Killist on alliance losses / explicit cast to int from URI
Added date support to comments (autoupgrading, just save your settings once again)
Added a combined view to campaigns so you can filter kills and losses for each shipclass on one page
Cast corpid to int from URI
Changed DB, define DB_HALTONERROR in your config to stop page generation on error.
Set minor version to svn revision
Adding base alliance logos as stated on  http://www.eve-dev.net/forums/viewtopic.php?t=35 Thanks to DarkXeRoX for those.

Line 
1<?php
2require_once("db.php");
3
4$id = intval($_GET['id']);
5$size = intval($_GET['size']);
6
7$portrait = "cache/portraits/".$id."_".$size.".jpg";
8if (file_exists($portrait))
9{
10    header("Content-Type: image/jpeg");
11    readfile($portrait);
12    exit;
13}
14
15// check for a valid, known external id
16$qry = new DBQuery();
17$qry->execute("select plt_externalid from kb3_pilots where plt_externalid = ".$id." limit 1");
18$row = $qry->getRow();
19if (!$id = $row['plt_externalid'])
20{
21    $portrait = "cache/portraits/0_".$size.".jpg";
22    if (file_exists($portrait))
23    {
24        header("Content-Type: image/jpeg");
25        readfile($portrait);
26        exit;
27    }
28}
29
30if (file_exists("cache/portraits/".$id."_512.jpg"))
31{
32    $img = imagecreatefromjpeg("cache/portraits/".$id."_512.jpg");
33}
34else
35{
36    $file = @file_get_contents("http://img.eve.is/serv.asp?s=512&c=".$id);
37    if ($img = imagecreatefromstring($file))
38    {
39        $fp = fopen("cache/portraits/".$id."_512.jpg", "w");
40        fwrite($fp, $file);
41        fclose($fp);
42    }
43    else
44    {
45        // try alternative access via fsockopen
46        // happens if allow_url_fopen wrapper is false
47        require_once("class.http.php");
48
49        $url = "http://img.eve.is/serv.asp?s=512&c=".$id;
50        $http = new http_request($url);
51        $file = $http->get_content();
52
53        if ($img = imagecreatefromstring($file))
54        {
55            $fp = fopen("cache/portraits/".$id."_512.jpg", "w");
56            fwrite($fp, $file);
57        }
58    }
59}
60
61if ($img)
62{
63    $newimg = imagecreatetruecolor($size, $size);
64    imagecopyresampled($newimg, $img, 0, 0, 0, 0, $size, $size, 512, 512);
65    imagejpeg($newimg, $portrait);
66    header("Content-Type: image/jpeg");
67    readfile($portrait);
68    exit;
69}
70
71// last try, we could not get a valid picture from the server
72// so output a '!'
73$portrait = "cache/portraits/0_".$size.".jpg";
74if (file_exists($portrait))
75{
76    header("Content-Type: image/jpeg");
77    readfile($portrait);
78    exit;
79}
80?>
Note: See TracBrowser for help on using the browser.