function run_upgrade() { global $db_prefix; $info['name'] = 'tea_api'; $info['esam'] = 'esam_api'; $cs['GLOBAL_REQUIRED_API'] = array('tea_regreq', 1); $cs['DISPLAY_EVE_NAME'] = array('tea_usecharname', 1); $cs['ADD_CORP_TICKER'] = array('tea_custom_name', 1); $cs['DISPLAY_EVE_PORTRAIT'] = array('tea_avatar_enabled', 1); //$cs['DISPLAY_CORP_TITLES'] = array('tea_regreq', 1); $check = esamup_check_table($db_prefix . $info['name']); $esam = esamup_check_table($db_prefix . $info['esam']); if ($check && $esam) { // settings $settings = esamup_select("SELECT NAME, VALUE FROM " . $db_prefix . "esam_settings"); if (!empty($settings)) { foreach ($settings as $s) { if (isset($cs[$s[0]]) && $s[1] == 'true') { esamup_query("\n\t\t\t\t\t\tREPLACE INTO " . $db_prefix . "settings\n\t\t\t\t\t\t\t(variable, value)\n\t\t\t\t\t\tVALUES \n\t\t\t\t\t\t('" . $cs[$s[0]][0] . "', '" . $cs[$s[0]][1] . "')"); } } } // api's $apis = esamup_select("SELECT ID_MEMBER, USER_ID, API_KEY FROM " . $db_prefix . "esam_api"); if (!empty($apis)) { foreach ($apis as $api) { esamup_query("\n\t\t\t\t\tREPLACE INTO " . $db_prefix . "tea_api\n\t\t\t\t\t\t(ID_MEMBER, userid, api)\n\t\t\t\t\tVALUES \n\t\t\t\t\t('" . $api[0] . "', '" . $api[1] . "', '" . $api[2] . "')"); } } // rules $rules = esamup_select("SELECT ID_RULE, TYPE, ROLE, ROLE_ID, GROUP_ID, TITLE, SKILL_ID, SKILL_LVL FROM " . $db_prefix . "esam_rules"); if (!empty($rules)) { global $sourcedir; require_once $sourcedir . '/TEA_SkillDump.php'; $skills = getSkillArray(); foreach ($rules as $rule) { $type = NULL; $value = NULL; $extra = NULL; $id = esamup_select("SELECT ruleid FROM " . $db_prefix . "tea_rules ORDER BY ruleid DESC LIMIT 1"); if (!empty($id)) { $id = $id[0][0] + 1; } else { $id = 1; } // elseif(is_numeric($_POST['id'])) // { // $id = $_POST['id']; // $exists = TRUE; // } // else // die("error id"); $andor = 'AND'; //if($andor != "AND" && $andor != "OR") // die("andor must be AND or OR"); $name = 'ESAM RULE ' . $rule[0]; // if($_POST['main'] == "main") // $main = 1; // else $main = 0; switch (strtoupper($rule[1])) { case 'P': // pilot rule, ignore entire rule continue 2; case 'C': $type = "corp"; $value = $rule[3]; break; case 'A': $type = "alliance"; $value = $rule[3]; break; case 'F': $type = "militia"; switch ($rule[3]) { case 500001: $value = 'Caldari State'; break; case 500002: $value = 'Minmatar Republic'; break; case 500003: $value = 'Amarr Empire'; break; case 500004: $value = 'Gallente Federation'; break; } break; default: continue 2; } // if(isset($types[$_POST['type']])) // $type = $_POST['type']; // else // die("Unknown Type"); // if($type == "corp" || $type == "alliance" || $type == "skill" || $type == "role" || $type == "title" || $type == "militia") // $value = mysql_real_escape_string($_POST['value']); // if($type == "skill") $extra = ''; // if(isset($groups[$_POST['group']])) $group = $rule[4]; // elseif(!$exists) // die("Invalid Group"); //if(!$exists) esamup_query("INSERT INTO " . $db_prefix . "tea_rules (ruleid, name, main, `group`, andor) VALUES ({$id}, '{$name}', {$main}, {$group}, '{$andor}')"); esamup_query("INSERT INTO " . $db_prefix . "tea_conditions (ruleid, type, value, extra) VALUES ({$id}, '{$type}', '{$value}', '{$extra}')"); //if(!isset($types[$_POST['type']])) // error //elseif(!is_numeric($_POST['id']) && $_POST['id'] != "new") // error //elseif(!is_numeric($_POST['group'])) // error if ($rule[2] == 'roleDirector') { $type = 'role'; $value = 'Director'; $extra = ''; esamup_query("INSERT INTO " . $db_prefix . "tea_conditions (ruleid, type, value, extra) VALUES ({$id}, '{$type}', '{$value}', '{$extra}')"); } if ($rule[5] != 'null' && !empty($rule[5])) { $type = 'title'; $value = $rule[5]; $extra = ''; esamup_query("INSERT INTO " . $db_prefix . "tea_conditions (ruleid, type, value, extra) VALUES ({$id}, '{$type}', '{$value}', '{$extra}')"); } if (!empty($rule[6])) { $type = 'skill'; $value = $skills[$rule[6]]; $extra = $rule[7]; esamup_query("INSERT INTO " . $db_prefix . "tea_conditions (ruleid, type, value, extra) VALUES ({$id}, '{$type}', '{$value}', '{$extra}')"); } } } } }
function skills($id, $api, $charid) { $skills = NULL; $skilllist = getSkillArray(); $post = array('userID' => $id, 'apiKey' => $api, 'characterID' => $charid); $xml = $this->get_xml('charsheet', $post); $xml = new SimpleXMLElement($xml); if (!empty($xml->result->rowset[0])) { foreach ($xml->result->rowset[0] as $skill) { //echo "<pre>";var_dump($skill["typeID"]); echo '<hr>'; $skills[strtolower($skilllist[(string) $skill["typeID"]])] = (string) $skill["level"]; } } return $skills; }