less errors

This commit is contained in:
Daku 2012-03-12 08:10:36 +00:00
parent 60666f9300
commit 45365f7eb5

View file

@ -97,20 +97,23 @@ class ShimmieApi extends Extension {
if($event->page_matches("api/shimmie/get_user")) { if($event->page_matches("api/shimmie/get_user")) {
$query = $user->id; $query = $user->id;
$type = "id";
if($event->count_args() == 1) { if($event->count_args() == 1) {
$query = $event->get_arg(0); $query = $event->get_arg(0);
} }
if(isset($_GET['name'])) { elseif(isset($_GET['id'])) {
$query = $_GET['name'];
}
if(isset($_GET['id'])) {
$query = $_GET['id']; $query = $_GET['id'];
} }
elseif(isset($_GET['name'])) {
$query = $_GET['name'];
$type = "name";
}
$all = $database->get_row( $all = $database->get_row(
"SELECT id,name,joindate,class FROM users WHERE name=? OR id=?", "SELECT id,name,joindate,class FROM users WHERE ".$type."=?",
array($_GET['name'], int_escape($_GET['id']))); array($query));
if(!empty($all)){
//FIXME?: For some weird reason, get_all seems to return twice. Unsetting second value to make things look nice.. //FIXME?: For some weird reason, get_all seems to return twice. Unsetting second value to make things look nice..
// - it returns data as eg array(0=>1234, 'id'=>1234, 1=>'bob', 'name'=>bob, ...); // - it returns data as eg array(0=>1234, 'id'=>1234, 1=>'bob', 'name'=>bob, ...);
for($i=0; $i<4; $i++) unset($all[$i]); for($i=0; $i<4; $i++) unset($all[$i]);
@ -139,6 +142,7 @@ class ShimmieApi extends Extension {
$i += 1; $i += 1;
} }
} }
}
$page->set_data(json_encode($all)); $page->set_data(json_encode($all));
} }
} }