diff --git a/contrib/shimmie_api/main.php b/contrib/shimmie_api/main.php index e7ddc59e..da65a2d6 100644 --- a/contrib/shimmie_api/main.php +++ b/contrib/shimmie_api/main.php @@ -97,29 +97,50 @@ class ShimmieApi extends Extension { if($event->page_matches("api/shimmie/get_user")) { $query = $user->id; + $type = "id"; if($event->count_args() == 1) { $query = $event->get_arg(0); } - if(isset($_GET['name'])) { - $query = $_GET['name']; - } - if(isset($_GET['id'])) { + elseif(isset($_GET['id'])) { $query = $_GET['id']; } + elseif(isset($_GET['name'])) { + $query = $_GET['name']; + $type = "name"; + } $all = $database->get_row( - "SELECT id,name,joindate,class FROM users WHERE name=? OR id=?", - array($_GET['name'], int_escape($_GET['id']))); + "SELECT id,name,joindate,class FROM users WHERE ".$type."=?", + array($query)); - //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, ...); - for($i=0; $i<4; $i++) unset($all[$i]); - $all['uploadcount'] = Image::count_images(array("user_id=".$all['id'])); - $all['uploadperday'] = sprintf("%.1f", ($all['uploadcount'] / (((time() - strtotime($all['joindate'])) / 86400) + 1))); - $all['commentcount'] = $database->get_one( - "SELECT COUNT(*) AS count FROM comments WHERE owner_id=:owner_id", - array("owner_id"=>$all['id'])); - $all['commentperday'] = sprintf("%.1f", ($all['commentcount'] / (((time() - strtotime($all['joindate'])) / 86400) + 1))); + if(!empty($all)){ + //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, ...); + for($i=0; $i<4; $i++) unset($all[$i]); + $all['uploadcount'] = Image::count_images(array("user_id=".$all['id'])); + $all['commentcount'] = $database->get_one( + "SELECT COUNT(*) AS count FROM comments WHERE owner_id=:owner_id", + array("owner_id"=>$all['id'])); + + if(isset($_GET['recent'])){ + $recent = $database->get_all( + "SELECT * FROM images WHERE owner_id=? ORDER BY id DESC LIMIT 0, 5", + array($all['id'])); + + $i = 0; + foreach($recent as $all['recentposts'][$i]){ + unset($all['recentposts'][$i]['owner_id']); //We already know the owners id.. + unset($all['recentposts'][$i]['owner_ip']); + + for($x=0; $x<14; $x++) unset($all['recentposts'][$i][$x]); + if(empty($all['recentposts'][$i]['author'])) unset($all['recentposts'][$i]['author']); + if($all['recentposts'][$i]['notes'] > 0) $all['recentposts'][$i]['has_notes'] = "Y"; + else $all['recentposts'][$i]['has_notes'] = "N"; + unset($all['recentposts'][$i]['notes']); + $i += 1; + } + } + } $page->set_data(json_encode($all)); } } diff --git a/contrib/tag_history/theme.php b/contrib/tag_history/theme.php index e88a2b81..eaa8761e 100644 --- a/contrib/tag_history/theme.php +++ b/contrib/tag_history/theme.php @@ -27,6 +27,14 @@ class Tag_HistoryTheme extends Themelet { $setter = "".html_escape($name)."$h_ip"; $selected = ($n == 2) ? " checked" : ""; + + $current_tags = explode(" ", $current_tags); + $taglinks = array(); + foreach($current_tags as $tag){ + $taglinks[] = "".$tag.""; + } + $current_tags = implode(" ", $taglinks); + $history_list .= "