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}"); } }
$cacheid .= "_{$limit}"; if (!empty($_GET['expand']) || $USER->expand_about == 1) { $cacheid .= "E"; } if (isset($_GET['reject']) && empty($_GET['reject'])) { $cacheid .= "N"; } if (!$smarty->is_cached($template, $cacheid)) { if (isset($_GET['all']) || isset($_GET['more']) || isset($_GET['expand'])) { dieUnderHighLoad(); } require_once 'geograph/imagelist.class.php'; require_once 'geograph/gridimage.class.php'; require_once 'geograph/gridsquare.class.php'; 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) {
} //get token, we'll use it as a cache id $token = $mosaic->getToken(); //regenerate html? $cacheid = 'mapbrowse|' . $token; $smarty->cache_lifetime = 3600 * 24; //24hr cache if (isset($_GET['gridref_from']) && preg_match('/^[a-zA-Z]{1,3}\\d{4}$/', $_GET['gridref_from'])) { $smarty->assign('gridref_from', $_GET['gridref_from']); } //regenerate? if (!$smarty->is_cached($template, $cacheid)) { $overview->setPreset('overview'); //assign overview to smarty if ($mosaic->type_or_user > 0) { $profile = new GeographUser($mosaic->type_or_user); if (count($profile->stats) == 0) { $profile->getStats(); } //the map is only useful for people with images! if (!empty($profile->stats['images'])) { $smarty->assign('realname', $profile->realname); $smarty->assign('nickname', $profile->nickname); $smarty->assign('user_id', $mosaic->type_or_user); $overview->type_or_user = $mosaic->type_or_user; } else { $mosaic->type_or_user = 0; } } if ($mosaic->pixels_per_km == 40) { //largeoverview
function UploadPicture() { global $CONF; global $xml; global $USER; if (empty($_POST['userid']) || !intval($_POST['userid'])) { $xml['status'] = 'Not Logged In'; returnXML(); } else { $USER = new GeographUser(intval($_POST['userid'])); //TODO: check validation hash? if ($_POST['validation'] != md5($_POST['userid'] . '#' . $CONF['register_confirmation_secret'])) { $xml['status'] = 'User not verified'; returnXML(); } if (!$USER->user_id || !$USER->hasPerm('basic')) { $xml['status'] = 'Not authorised to post'; returnXML(); } } $um = new UploadManager(); $gs = new GridSquare(); // this is the check that we like the client and any image has // come in with the appropriate cc licence $ccl = $_POST['cclicence']; if ($ccl != "I grant you the permission to use this submission " . "under the terms of the Creative Commons by-sa-2.0 licence") { $xml['status'] = 'Bad client submission'; returnXML(); } // validate the grid square - we may be going back to the user // quickly here :-) $gs->setByFullGridRef($_POST['subject']); if ($gs->errormsg != "") { $xml['status'] = $gs->errormsg; returnXML(); } $takendate = strtotime_uk($_POST['date']); if ($takendate > time()) { $xml['status'] = "Date taken in future"; returnXML(); } // set up attributes from uploaded data $um->setSquare($gs); $um->setViewpoint($_POST['photographer']); $um->setDirection($_POST['direction']); $um->setTaken(date('Y-m-d', $takendate)); $um->setTitle($_POST['title']); $um->setComment($_POST['comments']); $um->setClass($_POST['feature']); $um->setUserStatus($_POST['supplemental']); $um->processUpload($_FILES['uploadfile']['tmp_name']); // where there any errors back from the image processing? // if so, JUppy needs to know... if ($um->error != "") { $xml['status'] = $um->error; } else { // so far so good... can we commit the submission? $rc = $um->commit(); if ($rc == "") { //clear user profile $ab = floor($USER->user_id / 10000); $smarty = new GeographPage(); $smarty->clear_cache(null, "user{$ab}|{$USER->user_id}"); $xml['status'] = "OK"; } else { $xml['status'] = $rc; } } returnXML(); }