function handleUser() { $_GET['key'] = $this->params[1]; if (preg_match('/nick:(.*)/', $this->params[0], $m)) { $profile = new GeographUser(); $profile->loadByNickname($m[1]); $user_id = htmlentities2($m[1]); } else { $user_id = intval($this->params[0]); $profile = new GeographUser($user_id); } if ($profile->registered) { $profile->getStats(); if (isset($profile->stats) && count($profile->stats)) { $this->beginResponse(); if ($this->output == 'json') { require_once '3rdparty/JSON.php'; $json = new Services_JSON(); $obj = new EmptyClass(); $obj->user_id = $profile->user_id; $obj->realname = $profile->realname; $obj->nickname = $profile->nickname; foreach ($profile->stats as $key => $value) { if (!is_numeric($key)) { $obj->stats[$key] = $value; } } print $json->encode($obj); } else { echo '<status state="ok"/>'; echo '<user_id>' . intval($profile->user_id) . '</user_id>'; echo '<realname>' . htmlentities2($profile->realname) . '</realname>'; echo '<nickname>' . htmlentities2($profile->nickname) . '</nickname>'; echo "<stats"; foreach ($profile->stats as $key => $value) { if (!is_numeric($key)) { echo " {$key}=\"{$value}\""; } } echo " />"; } $this->endResponse(); } else { $this->error("User {$user_id} unavailable (or they have not contributed anything)"); } } else { $this->error("Invalid user id {$user_id}"); } }
if (!$profile) { $profile = new GeographUser($uid); } if (!empty($_GET['a']) && $_GET['a'] == $profile->realname) { header("HTTP/1.0 301 Moved Permanently"); header("Status: 301 Moved Permanently"); header("Location: /profile/{$uid}"); exit; } if ($profile->user_id == 0) { header("HTTP/1.0 404 Not Found"); header("Status: 404 Not Found"); $smarty->display('static_404.tpl'); exit; } $profile->getStats(); if ($uid == $USER->user_id) { $profile->countTickets(); $USER->tickets = $profile->tickets; $USER->last_ticket_time = $profile->last_ticket_time; if (!empty($_SESSION['last_ticket_time']) && $profile->last_ticket_time <= $_SESSION['last_ticket_time']) { $profile->tickets = 0; } } $smarty->assign_by_ref('profile', $profile); $images = new ImageList(); if ($uid == $USER->user_id || $USER->hasPerm('moderator')) { if (isset($_GET['reject']) && empty($_GET['reject'])) { $statuses = array('pending', 'accepted', 'geograph'); } else { $statuses = '';