Browse Source

Initial import

master
Chris Smith 13 years ago
commit
5b8d443228
6 changed files with 104 additions and 0 deletions
  1. 3
    0
      .gitignore
  2. 3
    0
      .gitmodules
  3. 10
    0
      api/common.php
  4. 57
    0
      db/evedb.class.php
  5. 1
    0
      modules/pheal
  6. 30
    0
      www/test.php

+ 3
- 0
.gitignore View File

@@ -0,0 +1,3 @@
1
+/db/*.db
2
+/cache
3
+/logs

+ 3
- 0
.gitmodules View File

@@ -0,0 +1,3 @@
1
+[submodule "modules/pheal"]
2
+	path = modules/pheal
3
+	url = git://github.com/ppetermann/pheal.git

+ 10
- 0
api/common.php View File

@@ -0,0 +1,10 @@
1
+<?PHP
2
+
3
+ require_once(dirname(dirname(__FILE__)) . '/modules/pheal/Pheal.php');
4
+
5
+ spl_autoload_register("Pheal::classload");
6
+ PhealConfig::getInstance()->api_base = 'https://api.eveonline.com/';
7
+ PhealConfig::getInstance()->cache = new PhealFileCache(dirname(dirname(__FILE__)) . '/cache/');
8
+ PhealConfig::getInstance()->log = new PhealFileLog(dirname(dirname(__FILE__)) . '/logs/');
9
+
10
+?>

+ 57
- 0
db/evedb.class.php View File

@@ -0,0 +1,57 @@
1
+<?PHP
2
+
3
+class EveDB {
4
+
5
+ private $pdo;
6
+
7
+ private $handlers;
8
+
9
+ public function __construct($connection = null) {
10
+  $this->pdo = new PDO($connection == null ? 'sqlite:' . dirname(__FILE__) . '/inc110-sqlite3-v1.db' : $connection);
11
+
12
+  $this->handlers = array(
13
+   'items' => new ItemsTableHandler($this->pdo),
14
+  );
15
+ }
16
+
17
+ public function __get($type) {
18
+  return isset($this->handlers[$type]) ? $this->handlers[$type] : null;
19
+ }
20
+
21
+}
22
+
23
+abstract class BaseHandler {
24
+
25
+ protected $pdo;
26
+
27
+ public function __construct($pdo) {
28
+  $this->pdo = $pdo;
29
+  $this->initStatements();
30
+ }
31
+
32
+ protected abstract function initStatements();
33
+
34
+}
35
+
36
+class ItemsTableHandler extends BaseHandler {
37
+
38
+ private $getByIdSmt;
39
+
40
+ protected function initStatements() {
41
+  $columns = 'categoryName, typeID, typeName, invTypes.description';
42
+  $joins = 'JOIN invGroups ON (invGroups.groupID = invTypes.groupID) JOIN invCategories ON (invGroups.categoryID = invCategories.categoryID)';
43
+  $skeleton = 'SELECT ' . $columns . ' FROM invTypes ' . $joins . ' WHERE';
44
+
45
+  $this->getByIdSmt = $this->pdo->prepare($skeleton . ' typeID = :id');
46
+ }
47
+
48
+ public function getById($id) {
49
+  $this->getByIdSmt->execute(array(':id' => $id));
50
+  return $this->getByIdSmt->fetch(PDO::FETCH_CLASS | PDO::FETCH_CLASSTYPE);
51
+ }
52
+
53
+}
54
+
55
+class Ship {}
56
+
57
+?>

+ 1
- 0
modules/pheal

@@ -0,0 +1 @@
1
+Subproject commit d924c834f37911a2b72a6a40f1f5aafecbb2038b

+ 30
- 0
www/test.php View File

@@ -0,0 +1,30 @@
1
+<?PHP
2
+
3
+ require('../api/common.php');
4
+ require('../db/evedb.class.php');
5
+
6
+ header('Content-type: text/plain');
7
+
8
+ $api = new Pheal($_GET['user'], $_GET['key']);
9
+ $db = new EveDB();
10
+
11
+ function getAsset($asset) {
12
+  global $db;
13
+
14
+  $res = $db->items->getById($asset->typeID);
15
+  
16
+  if (isset($asset->contents)) {
17
+   $res->contents = array();
18
+
19
+   foreach($asset->contents as $content) {
20
+    $res->contents[] = getAsset($content);
21
+   }
22
+  }
23
+
24
+  return $res;
25
+ }
26
+
27
+ foreach ($api->charScope->AssetList(array('characterID' => $_GET['char']))->assets as $asset) {
28
+  var_dump(getAsset($asset));
29
+ }
30
+?>

Loading…
Cancel
Save