function processEvent(&$event) { //perform actions $topic_id = $event['event_param']; $db =& $this->_getDB(); require 'conf/' . $_SERVER['HTTP_HOST'] . '.conf.php'; $topic = $db->GetRow("select topic_title,forum_id,topic_time from geobb_topics where topic_id='{$topic_id}' and forum_id = {$CONF['forum_gridsquare']}"); //get title of topic $title = strtoupper(trim($topic['topic_title'])); //see if title matches a grid reference $gridsquare = new GridSquare(); if ($gridsquare->setGridRef($title)) { $gridsquare_id = $gridsquare->gridsquare_id; //set up mapping if ($gridsquare_id > 0) { $this->processor->trace("Mapping {$gridsquare_id} to topic {$topic_id} ({$title})"); $db->Execute("replace into gridsquare_topic(gridsquare_id,topic_id,forum_id,last_post) " . "values ({$gridsquare_id}, {$topic_id}, {$topic['forum_id']}, '{$topic['topic_time']}')"); //delete any smarty caches for this square $images = $db->getCol("select gridimage_id from gridimage where gridsquare_id = {$gridsquare_id}"); $smarty = new GeographPage(); foreach ($images as $gridimage_id) { //clear any caches involving this photo $ab = floor($gridimage_id / 10000); $smarty->clear_cache(null, "img{$ab}|{$gridimage_id}"); } } } //return true to signal completed processing //return false to have another attempt later return true; }
function processEvent(&$event) { $db =& $this->_getDB(); //very easy -trash any mappings to this topic $post_id = $event['event_param']; $post = $db->GetRow("select topic_id,post_time from geobb_posts where post_id='{$post_id}'"); if ($post) { //update timestamp of last post $db->Execute("update gridsquare_topic set last_post='{$post['post_time']}' where topic_id = '{$post['topic_id']}'"); //delete any smarty caches for this square $gridsquare_id = $db->getOne("select gridsquare_id from gridsquare_topic where topic_id = {$post['topic_id']}"); if ($gridsquare_id) { $images = $db->getCol("select gridimage_id from gridimage where gridsquare_id = {$gridsquare_id}"); $smarty = new GeographPage(); foreach ($images as $gridimage_id) { //clear any caches involving this photo $ab = floor($gridimage_id / 10000); $smarty->clear_cache(null, "img{$ab}|{$gridimage_id}"); } } } //return true to signal completed processing //return false to have another attempt later return true; }
function processEvent(&$event) { $db =& $this->_getDB(); list($gridimage_id, $updatemaps) = explode(',', $event['event_param']); $smarty = new GeographPage(); $ab = floor($gridimage_id / 10000); $smarty->clear_cache(null, "img{$ab}|{$gridimage_id}"); //return true to signal completed processing //return false to have another attempt later return true; }
function processEvent(&$event) { $db =& $this->_getDB(); $topic_id = $event['event_param']; //delete any smarty caches for this square $gridsquare_id = $db->getOne("select gridsquare_id from gridsquare_topic where topic_id = {$topic_id}"); if ($gridsquare_id) { $images = $db->getCol("select gridimage_id from gridimage where gridsquare_id = {$gridsquare_id}"); $smarty = new GeographPage(); foreach ($images as $gridimage_id) { //clear any caches involving this photo $ab = floor($gridimage_id / 10000); $smarty->clear_cache(null, "img{$ab}|{$gridimage_id}"); } // -trash any mappings to this topic $db->Execute("delete from gridsquare_topic where topic_id = {$topic_id}"); } //return true to signal completed processing //return false to have another attempt later return true; }
if ($_GET['action'] == 'view') { $v = $memcache->name_get($namespace, intval($_GET['image_id']) . ':' . $size); print "<pre>"; print htmlentities(print_r($v, true)); print "</pre>"; } elseif ($_GET['action'] == 'delete') { $ok = $memcache->name_delete($namespace, intval($_GET['image_id']) . ':' . $size); print "Delete return value: {$ok}"; } } elseif (isset($_GET['flushMemcache'])) { print "<h2>Flush Memcache</h2>"; print $memcache->flush(); print "<h3>done</h3>"; } elseif (isset($_GET['clearSmarty'])) { print "<h2>Clear Whole Smarty Cache</h2>"; $smarty->clear_cache(); print "<h3>done</h3>"; } elseif (isset($_GET['get'])) { $v = $memcache->get($_GET['get']); print "<pre>"; var_dump($v); print "</pre><pre>"; var_dump(unserialize($v)); exit; } elseif (isset($_GET['set'])) { $v = $memcache->set($_GET['set'], $_GET['v']); print "<pre>"; var_dump($v); print "</pre>"; } else { ?>
$errors[$key] = "missing required info"; } } if (!count($updates)) { $smarty->assign('error', "No Changes to Save"); $errors[1] = 1; } if ($_REQUEST['id'] == 'new') { $updates[] = "`user_id` = {$USER->user_id}"; $updates[] = "`created` = NOW()"; $sql = "INSERT INTO geoevent SET " . implode(',', $updates); } else { $sql = "UPDATE geoevent SET " . implode(',', $updates) . " WHERE geoevent_id = " . $db->Quote($_REQUEST['id']); } if (!count($errors) && count($updates)) { $db->Execute($sql); if ($_REQUEST['id'] == 'new') { $_REQUEST['id'] = $db->Insert_ID(); } $memcache->name_increment('ep', intval($_REQUEST['id']), 1, true); $smarty->clear_cache('events.tpl'); header("Location: /events/event.php?id=" . intval($_REQUEST['id'])); exit; } else { if ($errors[1] != 1) { $smarty->assign('error', "Please see messages below..."); } $smarty->assign_by_ref('errors', $errors); } } $smarty->display($template, $cacheid);
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ require_once 'geograph/global.inc.php'; require_once 'geograph/mapmosaic.class.php'; init_session(); $smarty = new GeographPage(); $template = 'statistics_not_geographed.tpl'; $cacheid = 'statistics|not_geographed'; if ($smarty->caching) { $smarty->caching = 2; // lifetime is per cache $smarty->cache_lifetime = 3600 * 24; //24hr cache } if (isset($_GET['refresh']) && $USER->hasPerm('admin')) { $smarty->clear_cache($template, $cacheid); } $smarty->assign_by_ref('references_real', $CONF['references']); if (!$smarty->is_cached($template, $cacheid)) { $db = NewADOConnection($GLOBALS['DSN']); if (!$db) { die('Database connection failed'); } #$db->debug = true; $mosaic = new GeographMapMosaic(); $mosaic->setScale(40); $mosaic->setMosaicFactor(2); $mostarray = array(); foreach ($CONF['references'] as $ri => $rname) { $letterlength = $CONF['gridpreflen'][$ri]; $most = $db->GetAll("select \n\t\tgrid_reference,x,y,\n\t\tconcat(substring(grid_reference,1," . ($letterlength + 1) . "),substring(grid_reference," . ($letterlength + 3) . ",1)) as tenk_square,\n\t\tsum(has_geographs) as geograph_count,\n\t\tsum(percent_land >0) as land_count\n\t\tfrom gridsquare \n\t\twhere reference_index = {$ri} \n\t\tgroup by tenk_square \n\t\thaving geograph_count = 0 and land_count > 0\n\t\torder by tenk_square");
if ($status == 'rejected') { $ticket = new GridImageTroubleTicket(); $ticket->setSuggester($USER->user_id); $ticket->setModerator($USER->user_id); $ticket->setPublic('everyone'); $ticket->setImage($gridimage_id); if (!empty($_GET['comment'])) { $ticket->setNotes("Auto-generated ticket, as a result of Moderation. Rejecting this image because: " . stripslashes($_GET['comment'])); } else { $ticket->setNotes("Auto-generated ticket, as a result of Moderation. Please leave a comment to explain the reason for rejecting this image."); } $status = $ticket->commit('open'); echo " <a href=\"/editimage.php?id={$gridimage_id}\"><B>View Ticket</b></a>"; } //clear caches involving the image $smarty->clear_cache('view.tpl', "{$gridimage_id}_0_0"); $smarty->clear_cache('view.tpl', "{$gridimage_id}_0_1"); $smarty->clear_cache('view.tpl', "{$gridimage_id}_1_0"); $smarty->clear_cache('view.tpl', "{$gridimage_id}_1_1"); //clear the users profile cache $smarty->clear_cache('profile.tpl', "{$image->user_id}_0"); $smarty->clear_cache('profile.tpl', "{$image->user_id}_1"); $memcache->name_delete('us', $image->user_id); } } else { echo "FAIL"; } } else { echo "NOT LOGGED IN"; } exit;
} if ($memcache->valid) { //the submit list $mkey = md5("{$square->gridsquare_id}:{$USER->user_id},,order by submitted desc limit 6"); $memcache->name_delete('gi', $mkey); //the browse page for the user (to show pending) $mkey = md5("{$square->gridsquare_id}:{$USER->user_id},,order by ftf desc,gridimage_id"); $memcache->name_delete('gi', $mkey); } } if (!empty($_POST['pattrib_default'])) { $USER->setCreditDefault($_POST['pattrib'] == 'other' ? stripslashes($_POST['pattrib_name']) : ''); } //clear user profile $ab = floor($USER->user_id / 10000); $smarty->clear_cache(null, "user{$ab}|{$USER->user_id}"); $token = new Token(); $token->setValueBinary("s", serialize($status)); $token->setValueBinary("f", serialize($filenames)); $t = $token->getToken($expiry); print "http://{$_SERVER['HTTP_HOST']}/puploader.php?success&t={$t}"; exit; } elseif (isset($_REQUEST['inner'])) { #print_r($_REQUEST); $template = 'puploader_inner.tpl'; $step = 1; $square = new GridSquare(); if (!empty($_REQUEST['photographer_gridref']) && empty($_REQUEST['grid_reference'])) { $_REQUEST['grid_reference'] = $_REQUEST['photographer_gridref']; } if (!empty($_REQUEST['grid_reference'])) {
$updates[] = "`create_time` = NOW()"; $sql = "INSERT INTO article SET " . implode(',', $updates); } else { $sql = "UPDATE article SET " . implode(',', $updates) . " WHERE article_id = " . $db->Quote($_REQUEST['article_id']); } if (!count($errors) && count($updates)) { $db->Execute($sql); if ($_REQUEST['page'] == 'new' || $_REQUEST['article_id'] == 'new') { $_REQUEST['article_id'] = $db->Insert_ID(); } require_once 'geograph/event.class.php'; new Event("article_updated", $_REQUEST['article_id']); //and back it up $sql = "INSERT INTO article_revisions SELECT *,NULL,{$USER->user_id} FROM article WHERE article_id = " . $db->Quote($_REQUEST['article_id']); $db->Execute($sql); $_SESSION[$_POST['url']] = $db->Insert_ID(); $smarty->clear_cache('article_article.tpl', $_POST['url']); $smarty->clear_cache('article.tpl'); $db->Execute("DELETE FROM article_lock WHERE user_id = {$USER->user_id} AND article_id = {$_REQUEST['article_id']}"); header("Location: /article/" . (empty($_POST['url']) ? $page['url'] : $_POST['url'])); exit; } else { if ($errors[1] != 1) { $smarty->assign('error', "Please see messages below..."); } $smarty->assign_by_ref('errors', $errors); } } $smarty->assign('licences', array('none' => '(Temporarily) Not Published', 'pd' => 'Public Domain', 'cc-by-sa/2.0' => 'Creative Commons BY-SA/2.0', 'copyright' => 'Copyright')); $smarty->assign('article_cat', array(0 => '') + $db->getAssoc("select article_cat_id,category_name from article_cat order by sort_order")); $smarty->display($template, $cacheid);
} else { header("Location: /photo/{$_REQUEST['id']}"); exit; } if (isset($_POST['pattrib'])) { if ($_POST['pattrib'] == 'other') { $image->setCredit(stripslashes($_POST['pattrib_name'])); } elseif ($_POST['pattrib'] == 'self') { $image->setCredit(''); } if (!empty($_POST['pattrib_default'])) { $USER->setCreditDefault($_POST['pattrib'] == 'other' ? stripslashes($_POST['pattrib_name']) : ''); } //clear any caches involving this photo $ab = floor($image->gridimage_id / 10000); $smarty->clear_cache(null, "img{$ab}|{$image->gridimage_id}"); //clear user specific stuff like profile page $smarty->clear_cache(null, "user{$image->user_id}"); header("Location: /photo/{$_REQUEST['id']}"); exit; } //do our thing! $smarty->assign('page_title', $image->grid_reference); $smarty->assign_by_ref('image', $image); $smarty->assign_by_ref('isowner', $isowner); $smarty->assign_by_ref('isadmin', $isadmin); } else { $smarty->assign('error', 'Invalid image id specified'); } } else { $smarty->assign('error', 'No image id specified');
/** * $Project: GeoGraph $ * $Id$ * * GeoGraph geographic photo archive project * This file copyright (C) 2005 Barry Hunter (geo@barryhunter.co.uk) * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ require_once 'geograph/global.inc.php'; init_session(); $USER->mustHavePerm("admin"); $smarty = new GeographPage(); if (!empty($_GET['template']) || !empty($_GET['cache_id'])) { $smarty->clear_cache($_GET['template'], $_GET['cache_id']); print "Done ->clear_cache({$_GET['template']},{$_GET['cache_id']})"; } else { print "Done Nothing!"; }
$mosaic->deleteAndInvalidateAll(); //redirect to prevent page refreshes of this url header("Location:http://{$_SERVER['HTTP_HOST']}/admin/recreatemaps.php"); exit; } if (isset($_GET['invalidateAll']) && $USER->hasPerm('admin')) { $mosaic = new GeographMapMosaic(); $mosaic->invalidateAll(); //redirect to prevent page refreshes of this url header("Location:http://{$_SERVER['HTTP_HOST']}/admin/recreatemaps.php"); exit; } if (isset($_GET['expireAll']) && $USER->hasPerm('admin')) { $mosaic = new GeographMapMosaic(); $mosaic->expireAll($_GET['expireAll'] ? true : false); $smarty->clear_cache(null, 'mapbrowse'); //redirect to prevent page refreshes of this url header("Location:http://{$_SERVER['HTTP_HOST']}/admin/recreatemaps.php"); exit; } $db = NewADOConnection($GLOBALS['DSN']); if (isset($_GET['coast_GB_40'])) { //invalidate coast'ish' GB squares at thumbnail level! $prefixes = $db->GetAll("select * \n\tfrom gridprefix \n\twhere reference_index = 1 \n\tand landcount < 9500 \n\tand landcount > 0"); foreach ($prefixes as $idx => $prefix) { $minx = $prefix['origin_x']; $maxx = $prefix['origin_x'] + $prefix['width'] - 1; $miny = $prefix['origin_y']; $maxy = $prefix['origin_y'] + $prefix['height'] - 1; if ($_GET['do']) { $db->Execute("update mapcache set age=age+1 where " . "map_x between {$minx} and {$maxx} and " . "map_y between {$miny} and {$maxy} and " . "pixels_per_km >= 40");
print "<a href=\"" . htmlentities($url) . "\">Continue to Search</a>"; exit; //should never return! } $template = 'explore_places_adm1.tpl'; $cacheid = 'places|' . $_GET['ri'] . '.' . $_GET['adm1']; } else { $template = 'explore_places_ri.tpl'; $cacheid = 'places|' . $_GET['ri']; } } else { $template = 'explore_places.tpl'; $cacheid = 'places'; } if (isset($_GET['refresh']) && $USER->hasPerm('admin')) { $smarty->clear_cache($template, 'places'); } //regenerate? if (!$smarty->is_cached($template, $cacheid)) { require_once 'geograph/gridimage.class.php'; require_once 'geograph/gridsquare.class.php'; require_once 'geograph/imagelist.class.php'; $db = NewADOConnection($GLOBALS['DSN']); if (!empty($_GET['ri'])) { $smarty->assign('ri', $_GET['ri']); if (!empty($_GET['adm1'])) { $smarty->assign('adm1', $_GET['adm1']); if (!empty($_GET['pid'])) { //todo: error message? } if ($_GET['ri'] == 2) {
require_once "3rdparty/S3.php"; $s3 = new S3($CONF['awsAccessKey'], $CONF['awsSecretKey']); $ok = $s3->putObjectFile($_SERVER['DOCUMENT_ROOT'] . $image->originalUrl, $CONF['awsS3Bucket'], preg_replace("/^\\//", '', $image->originalUrl), S3::ACL_PRIVATE); } if ($image->previewUrl != "/photos/error.jpg") { if (!empty($_POST['confirm'])) { //delete the preview - we dont need it unlink($_SERVER['DOCUMENT_ROOT'] . $image->previewUrl); } else { //store the preview as an alterantive fullsize $image->storeImage($_SERVER['DOCUMENT_ROOT'] . $image->previewUrl, true, '_640x640'); } } //clear caches involving the image $ab = floor($gridimage_id / 10000); $smarty->clear_cache('', "img{$ab}|{$gridimage_id}|"); $mkey = "{$gridimage_id}:F"; $memcache->name_delete('is', $mkey); $db->Execute("DELETE FROM gridimage_size WHERE gridimage_id = {$gridimage_id}"); if (!empty($_POST['confirm'])) { $db->Execute("UPDATE gridimage_pending gp SET status = 'confirmed' WHERE gridimage_id = {$gridimage_id} "); } else { $db->Execute("UPDATE gridimage_pending gp SET status = 'accepted' WHERE gridimage_id = {$gridimage_id} "); } } else { $smarty->assign('message', 'Verification failed - please let us know!'); } } else { $db->Execute("UPDATE gridimage_pending gp SET status = 'rejected' WHERE gridimage_id = {$gridimage_id} "); } $smarty->assign("last_id", $gridimage_id);
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(); }