die("Missing Token"); } if ($map->pixels_per_km != 40 && $map->pixels_per_km != 4) { die("Invalid Parameter"); } if (isset($_GET['mine']) && $USER->hasPerm("basic")) { $map->type_or_user = $USER->user_id; } elseif (isset($_GET['u'])) { if (!empty($_GET['u'])) { $map->type_or_user = max(0, intval($_GET['u'])); } else { $map->type_or_user = 0; } } elseif (isset($_GET['depth'])) { if ($_GET['depth']) { $smarty->assign('depth', 1); $map->type_or_user = -1; } else { $map->type_or_user = 0; } } $template = $map->pixels_per_km == 4 ? $map->type_or_user == -1 ? 'mapsheet100kdepth.tpl' : 'mapsheet100k.tpl' : 'mapsheet.tpl'; //get token, we'll use it as a cache id $token = $map->getToken(); //regenerate html? $cacheid = 'mapsheet|' . $token; if ($map->pixels_per_km == 4) { $smarty->cache_lifetime = 3600 * 24; } //24hr cache if (isset($_GET['gridref_from']) && preg_match('/^[a-zA-Z]{1,3}\\d{4}$/', $_GET['gridref_from'])) {
} if (strlen($msg) == 0) { $ok = false; $errors['msg'] = "Please enter a message to send"; } if (isSpam($msg)) { $ok = false; $errors['msg'] = "Sorry, this looks like spam"; } if (!$ok) { die("ERROR: " . implode('. ', $errors)); } $smarty->assign_by_ref('msg', $msg); $smarty->assign_by_ref('contactmail', $CONF['abuse_email']); $enc_from_name = mb_encode_mimeheader($from_name, $CONF['mail_charset'], $CONF['mail_transferencoding']); $smarty->assign('http_host', "{$_SERVER['HTTP_HOST']} on behalf of {$domain}"); $body = $smarty->fetch('email_usermsg.tpl'); $subject = "{$from_name} contacting you via {$domain}"; $encsubject = mb_encode_mimeheader($CONF['mail_subjectprefix'] . $subject, $CONF['mail_charset'], $CONF['mail_transferencoding']); $ip = getRemoteIP(); $hostname = trim(`hostname -f`); $received = "Received: from [{$ip}]" . " by {$hostname} " . "with HTTP;" . strftime("%d %b %Y %H:%M:%S -0000", time()) . "\n"; if (!empty($_REQUEST['client_ip']) && preg_match("/^[\\w\\.]+\$/", $_REQUEST['client_ip'])) { $received .= "Received: from [{$_REQUEST['client_ip']}]" . " by [{$id}] " . "with HTTP;" . strftime("%d %b %Y %H:%M:%S -0000", empty($_REQUEST['timestamp']) ? time() : intval($_REQUEST['timestamp'])) . "\n"; } $mime = "MIME-Version: 1.0\n" . "Content-Type: text/plain; charset={$CONF['mail_charset']}\n" . "Content-Disposition: inline\n" . "Content-Transfer-Encoding: 8bit"; $from = "From: {$enc_from_name} <{$from_email}>\n"; $geofrom = "From: Geograph <{$CONF['mail_from']}>\n"; $envfrom = is_null($CONF['mail_envelopefrom']) ? null : "-f {$CONF['mail_envelopefrom']}"; if (preg_match('/(DORMANT|geograph\\.org\\.uk|geograph\\.co\\.uk|dev\\.null|deleted|localhost|127\\.0\\.0\\.1)/', $recipient->email)) { $email = $CONF['contact_email'];
} if (!isset($_GET['dontcount']) && @strpos($_SERVER['HTTP_REFERER'], $page['url']) === FALSE) { $db->Execute("UPDATE LOW_PRIORITY article_stat SET views=views+1 WHERE article_id = " . $page['article_id']); } //when this page was modified $mtime = strtotime($page['update_time']); //can't use IF_MODIFIED_SINCE for logged in users as has no concept as uniqueness customCacheControl($mtime, $cacheid, $USER->user_id == 0); } else { $template = 'static_404.tpl'; } if (!$smarty->is_cached($template, $cacheid)) { if (count($page)) { $CONF['global_thumb_limit'] *= 2; $CONF['post_thumb_limit'] *= 2; $smarty->assign($page); if (!empty($page['extract'])) { $smarty->assign('meta_description', "User contributed article about, " . $page['extract']); } if (!empty($page['gridsquare_id'])) { $square = new GridSquare(); $square->loadFromId($page['gridsquare_id']); $smarty->assign('grid_reference', $square->grid_reference); require_once 'geograph/conversions.class.php'; $conv = new Conversions(); list($lat, $long) = $conv->gridsquare_to_wgs84($square); $smarty->assign('lat', $lat); $smarty->assign('long', $long); } if (preg_match('/\\bgeograph\\b/i', $page['category_name'])) { $db->Execute("set @last=0");
require_once 'geograph/gridsquare.class.php'; require_once 'geograph/imagelist.class.php'; $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC; $db = NewADOConnection($GLOBALS['DSN']); if (!$db) { die('Database connection failed'); } $sql_qtable = array('squares' => array('column' => ''), 'geosquares' => array('column' => ''), 'geographs' => array('column' => "sum(i.moderation_status='geograph')"), 'additional' => array('column' => "sum(i.moderation_status='geograph' and ftf = 0)"), 'supps' => array('column' => "sum(i.moderation_status='accepted')"), 'images' => array('orderby' => ",points desc", 'column' => "sum(i.ftf=1 and i.moderation_status='geograph') as points, sum(i.moderation_status in ('geograph','accepted'))"), 'test_points' => array('column' => "sum((i.moderation_status = 'geograph') + ftf + 1)", 'table' => " gridimage_search i "), 'depth' => array('column' => "count(*)/count(distinct grid_reference)", 'table' => " gridimage_search i ", 'isfloat' => true), 'myriads' => array('column' => "count(distinct substring(grid_reference,1,length(grid_reference)-4))", 'table' => " gridimage_search i "), 'hectads' => array('column' => "count(distinct concat(substring(grid_reference,1,length(grid_reference)-3),substring(grid_reference,length(grid_reference)-1,1)) )", 'table' => " gridimage_search i "), 'days' => array('column' => "count(distinct imagetaken)", 'table' => " gridimage_search i "), 'antispread' => array('column' => "count(*)/count(distinct concat(substring(grid_reference,1,length(grid_reference)-3),substring(grid_reference,length(grid_reference)-1,1)) )", 'table' => " gridimage_search i ", 'isfloat' => true), 'spread' => array('column' => "count(distinct concat(substring(grid_reference,1,length(grid_reference)-3),substring(grid_reference,length(grid_reference)-1,1)) )/count(*)", 'table' => " gridimage_search i ", 'isfloat' => true), 'classes' => array('column' => "count(distinct imageclass)", 'table' => " gridimage_search i "), 'clen' => array('column' => "avg(length(comment))", 'table' => " gridimage_search i ", 'isfloat' => true), 'tlen' => array('column' => "avg(length(title))", 'table' => " gridimage_search i ", 'isfloat' => true), 'category_depth' => array('column' => "count(*)/count(distinct imageclass)", 'table' => " gridimage_search i ", 'isfloat' => true), 'centi' => array('column' => "COUNT(DISTINCT nateastings div 100, natnorthings div 100)", 'where' => "and i.moderation_status='geograph' and nateastings div 1000 > 0"), 'points' => array('column' => "sum(i.ftf=1 and i.moderation_status='geograph')")); if (!isset($sql_qtable[$type])) { $type = 'points'; } $isfloat = false; if (isset($sql_qtable[$type]['isfloat'])) { $isfloat = $sql_qtable[$type]['isfloat']; } $smarty->assign('heading', $MESSAGES['moversboard']['headings'][$type]); $smarty->assign('desc', $MESSAGES['moversboard']['descriptions'][$type]); $smarty->assign('type', $type); $smarty->assign('isfloat', $isfloat); $sql_column = ''; $sql_orderby = ''; $sql_table = " gridimage as i "; $sql_where = ''; if ($sql_qtable[$type]['column'] === '') { if ($type == 'geosquares') { $sql_where = " and i.moderation_status='geograph'"; } // else { // $type == 'squares' //} //squares has to use a count(distinct ...) meaning cant have pending in same query... possibly could do with a funky subquery but probably would lower performance... $sql = "select i.user_id,u.realname,\n\t\tcount(distinct grid_reference) as geographs\n\t\tfrom gridimage_search as i \n\t\tinner join user as u using(user_id) \n\t\twhere i.submitted > date_sub(now(), interval 7 day) {$sql_where}\n\t\tgroup by i.user_id \n\t\torder by geographs desc";
* * 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(); $smarty = new GeographPage(); $USER->mustHavePerm("basic"); $template = 'mapper_captcha.tpl'; $cacheid = 'mapper'; $ok = true; $verification = md5($CONF['register_confirmation_secret'] . $USER->user_id); if (!isset($_POST['verify']) || empty($_POST['verification']) || $_POST['verification'] != $verification || empty($_SESSION['verification']) || $_SESSION['verification'] != $verification) { $ok = false; $smarty->assign('verification', $verification); } else { define('CHECK_CAPTCHA', true); require "../stuff/captcha.jpg.php"; $ok = $ok && CAPTCHA_RESULT; if ($ok) { $_SESSION['verCount'] = isset($_SESSION['verCount']) ? $_SESSION['verCount'] - 2 : -2; } else { if (isset($_SESSION['verCount']) && $_SESSION['verCount'] > 3) { $smarty->assign('error', "Too many failures please try again later"); } else { $smarty->assign('verification', $verification); $smarty->assign('error', "Please Try again"); } $ok = false; $_SESSION['verCount'] = isset($_SESSION['verCount']) ? $_SESSION['verCount'] + 1 : 1;
} if (!empty($_GET['t'])) { $template = 'explore_wordnet_simple.tpl'; $cacheid = "explore|wordnet_simple{$u}." . $len . "." . str_replace(' ', '.', $words); } else { $template = 'explore_wordnet.tpl'; $cacheid = "explore|wordnet{$u}." . $len . "." . str_replace(' ', '.', $words); } $smarty->caching = 2; // lifetime is per cache $smarty->cache_lifetime = 3600 * 24; //24hr cache if (!$smarty->is_cached($template, $cacheid)) { //lets hobble this! header("HTTP/1.1 503 Service Unavailable"); $smarty->assign('searchq', stripslashes($_GET['q'])); $smarty->display('function_disabled.tpl'); exit; $db = NewADOConnection($GLOBALS['DSN']); if (empty($db)) { die('Database connection failed'); } $sql_crit = ''; $extra_link = '&len=' . $len; if (!empty($words)) { $ids = $db->cachegetAssoc(3600, "SELECT gid,title FROM `wordnet{$len}` WHERE title > 0 AND words = " . $db->Quote(trim($words))); if (count($ids)) { $sql_crit = " AND gid IN(" . implode(',', array_keys($ids)) . ")"; $smarty->assign('words', trim($_GET['words'])); } }
$_GET['days'] = $_SESSION['days'] = min(max(intval($_GET['days']), 1), 30); } elseif (isset($_SESSION['days'])) { $_GET['days'] = min(max(intval($_SESSION['days']), 1), 30); } else { $_GET['days'] = 10; } if (!$smarty->is_cached($template, $cacheid)) { $db = NewADOConnection($GLOBALS['DSN']); if (empty($db)) { die('Database connection failed'); } if ($u) { $where = "where submitted > date_sub(now(),interval {$_GET['days']} day) and user_id = {$u}"; $having = isset($_GET['full']) ? '' : 'having cnt>5'; $table = 'gridimage'; $smarty->assign('varname', 'catListUser'); $arr = $db->getCol("select imageclass,count(*) as cnt from {$table} {$where} group by imageclass {$having}"); } else { $where = isset($_GET['full']) ? '' : 'where c>5'; $table = 'category_stat'; $smarty->assign('varname', 'catList'); $arr = $db->getCol("select imageclass,c as cnt from {$table} {$where}"); } $smarty->assign_by_ref('classes', $arr); } if ($u) { customExpiresHeader(300, false); } else { customExpiresHeader(3600 * 3, true); } header("Content-type: text/javascript");
$ri = isset($_GET['ri']) && is_numeric($_GET['ri']) ? intval($_GET['ri']) : 0; $u = isset($_GET['u']) && is_numeric($_GET['u']) ? intval($_GET['u']) : 0; $cacheid = 'statistics|forum_image_breakdown' . $ri . '.' . $u; 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 (!$db) { die('Database connection failed'); } $title = "Breakdown of Images"; $where = array(); if (!empty($u)) { $where[] = "user_id=" . $u; $smarty->assign('u', $u); $profile = new GeographUser($u); $smarty->assign_by_ref('profile', $profile); $title .= " by " . $profile->realname; $having_sql = ''; $columns_sql = ''; } else { $having_sql = "HAVING `Seperate Images` > 4"; $columns_sql = ', count( DISTINCT user_id ) AS `Photographers`'; } if ($ri) { $where[] = "reference_index = {$ri}"; $smarty->assign('ri', $ri); $title .= " in " . $CONF['references_all'][$ri]; } $where_sql = '';
$enc_from_name = mb_encode_mimeheader($from_name, $CONF['mail_charset'], $CONF['mail_transferencoding']); $from = "From: {$enc_from_name} <{$from_email}>\n"; $mime = "MIME-Version: 1.0\n" . "Content-Type: text/plain; charset={$CONF['mail_charset']}\n" . "Content-Disposition: inline\n" . "Content-Transfer-Encoding: 8bit"; $mods = $db->GetCol("select email from user where FIND_IN_SET('admin',rights)>0;"); $url = 'http://' . $_SERVER['HTTP_HOST'] . '/admin/moderator_admin.php?stats=' . $USER->user_id; mail(implode(',', $mods), "[Geograph] Moderator Application ({$USER->user_id})", "Dear Admin, \n\nI have just completed verification,\nclick the following link to review the application:\t\n\n{$url}\n\nRegards, \n\n{$USER->realname}" . ($USER->nickname ? " (aka {$USER->nickname})" : ''), $from . $mime, $envfrom); header("Location: /profile.php"); exit; } $count = $db->getRow("select count(*) as total,sum(created > date_sub(now(),interval 60 day)) as recent from moderation_log WHERE user_id = {$USER->user_id} AND type = 'dummy'"); if ($count['total'] > 0) { $limit = 10; } //make sure they only do verifications $_GET['remoderate'] = 1; $smarty->assign('apply', 1); } elseif (isset($_GET['moderator'])) { $USER->mustHavePerm('admin'); } else { $USER->mustHavePerm('moderator'); } ############################# //lock the table so nothing can happen in between! (leave others as READ so they dont get totally locked) $db->Execute("LOCK TABLES \ngridsquare_moderation_lock WRITE, \ngridsquare_moderation_lock l WRITE,\nmoderation_log WRITE,\ngridsquare READ,\ngridsquare gs READ,\ngridimage gi READ,\nuser READ,\ngridprefix READ,\nuser v READ,\nuser m READ"); ############################# # find the list of squares with self pending images, and exclude them... $sql = "select distinct gridsquare_id \nfrom \n\tgridimage as gi\nwhere\n\t(moderation_status = 2) and\n\tgi.user_id = {$USER->user_id}\norder by null"; $recordSet =& $db->Execute($sql); while (!$recordSet->EOF) { $db->Execute("REPLACE INTO gridsquare_moderation_lock SET user_id = {$USER->user_id}, gridsquare_id = {$recordSet->fields['gridsquare_id']},lock_type = 'cantmod'"); $recordSet->MoveNext();
* 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 **/ require_once 'geograph/global.inc.php'; init_session(); require_once "3rdparty/xmlHandler.class.php"; $smarty = new GeographPage(); //you must be logged in to request changes $USER->mustHavePerm("basic"); $template = 'puploader.tpl'; $cacheid = ''; if (isset($_REQUEST['submit2'])) { $cacheid .= 'submit2'; $smarty->assign('submit2', 1); if (isset($_REQUEST['upload_id'])) { $smarty->assign('upload_id', $_REQUEST['upload_id']); } } if (isset($_GET['success'])) { $token = new Token(); if ($token->parse($_GET['t'])) { $template = 'puploader_success.tpl'; $smarty->assign('status', unserialize($token->getValueBinary("s"))); $smarty->assign('filenames', unserialize($token->getValueBinary("f"))); } } elseif (isset($_POST['selected'])) { //we dont get the button :( $status = array(); $filenames = array();
//do some processing? if (isset($_POST['go'])) { //this takes a long time, so we output a header first of all $smarty->display('_std_begin.tpl'); echo "<h3><a href=\"hashchanger.php\"><<</a> Changing image hashes...</h3>"; flush(); set_time_limit(3600 * 24); $recordSet =& $db->Execute("select * from gridimage"); while (!$recordSet->EOF) { $image = new GridImage(); $image->loadFromRecordset($recordSet); $CONF['photo_hashing_secret'] = $from; $oldfile = $image->_getFullpath(); if ($oldfile != '/photos/error.jpg' && file_exists($_SERVER['DOCUMENT_ROOT'] . $oldfile)) { $CONF['photo_hashing_secret'] = $to; $image->storeImage($_SERVER['DOCUMENT_ROOT'] . $oldfile, true); $newfile = $image->_getFullpath(); echo "<li>renamed {$oldfile}<br>to {$newfile}</li>"; flush(); } else { echo "<li>skipping {$oldfile} (not found)</li>"; } $recordSet->MoveNext(); } $recordSet->Close(); $smarty->display('_std_end.tpl'); exit; } $smarty->assign('from', $from); $smarty->assign('to', $to); $smarty->display('hashchanger.tpl');
if (!$USER->hasPerm("basic")) { $smarty->display('static_submit_intro.tpl'); exit; } if (isset($_SESSION['tab'])) { $selectedtab = $_SESSION['tab']; } else { $selectedtab = 1; } $step = isset($_POST['step']) ? intval($_POST['step']) : 1; if (!empty($_FILES['jpeg_exif']) && $_FILES['jpeg_exif']['error'] != UPLOAD_ERR_NO_FILE) { //Submit Step 1a.. switch ($_FILES['jpeg_exif']['error']) { case 0: if (!filesize($_FILES['jpeg_exif']['tmp_name'])) { $smarty->assign('error', 'Sorry, no file was received - please try again'); } elseif ($uploadmanager->processUpload($_FILES['jpeg_exif']['tmp_name'])) { $smarty->assign('upload_id', $uploadmanager->upload_id); $smarty->assign('transfer_id', $uploadmanager->upload_id); $smarty->assign('preview_url', "/submit.php?preview=" . $uploadmanager->upload_id); $smarty->assign('preview_width', $uploadmanager->upload_width); $smarty->assign('preview_height', $uploadmanager->upload_height); $exif = $uploadmanager->rawExifData; if (!empty($exif['GPS'])) { $conv = new Conversions(); if (is_array($exif['GPS']['GPSLatitude'])) { $deg = FractionToDecimal($exif['GPS']['GPSLatitude'][0]); $min = FractionToDecimal($exif['GPS']['GPSLatitude'][1]); $sec = FractionToDecimal($exif['GPS']['GPSLatitude'][2]); $lat = ExifConvertDegMinSecToDD($deg, $min, $sec); } else {
} $jump = 360 / 16; $jump2 = 360 / 32; $q = round($angle / $jump) * $jump; $s = $q % 90 == 0 ? strtoupper(heading_string($q)) : ucwords(heading_string($q)); $direction = sprintf('%s : %03d deg (%03d > %03d)', str_pad($s, 16, '�'), $q, $q == 0 ? $q + 360 - $jump2 : $q - $jump2, $q + $jump2); $angle = sprintf('%.1f', $angle); if (!$dist) { $line['Direction'] = "<small style=\"color:gray\">Same Location</small>"; $q = '-'; } elseif ($dist >= 1000) { $line['Direction'] = "<b>{$s}</b> <nobr>[{$angle}]</nobr>"; #"Wide:".$angle."<br>". $q = floor($q); } elseif ($promore4 && $submore4) { $line['Direction'] = "<b>{$s}</b> <nobr>[{$angle}]</nobr>"; #"Detailed:".$angle."<br>". $q = floor($q); } else { $line['Direction'] = "<small style=\"color:gray\">" . ($submore4 ? 'Photographer' : 'Subject') . ' Location Not Accurate Enough</small>'; $q = '-'; } $line['Result'] = $q; $line['Manually Specified'] = $image->view_direction > -1 ? $image->view_direction : '-'; $table[] = $line; } $smarty->assign_by_ref('table', $table); $smarty->assign("h2title", 'Listing images with Photographer position specified (and different to Subject)'); $smarty->assign("total", count($table)); } $smarty->display($template, $cacheid);
$smarty->display('_std_begin.tpl'); echo "<h3><a href=\"recreatemaps.php\"><<</a> Comparing tables...</h3>"; flush(); $sql = "SELECT mapcache2.* FROM mapcache2 NATURAL LEFT JOIN mapcache WHERE mapcache.map_x IS NULL"; $recordSet =& $db->Execute("{$sql}"); while (!$recordSet->EOF) { $values = array(); foreach ($recordSet->fields as $name => $value) { if (!is_numeric($name)) { $values[] = $value; } } $values[6] = 17; //we always want to invalidate this tile! Overkill but probably need to update this tile anyway... $sql = "INSERT DELAYED IGNORE INTO mapcache VALUES(" . join(',', $values) . ")"; $db->Execute($sql); $recordSet->MoveNext(); } $recordSet->Close(); #$db->Execute("TRUNCATE mapcache2"); print "<h3>Done</h3>"; $smarty->display('_std_end.tpl'); exit; } elseif (isset($_GET['setup'])) { $db->Execute("CREATE TABLE `mapcache2` (\n\t\t\t `map_x` smallint(6) NOT NULL default '0',\n\t\t\t `map_y` smallint(6) NOT NULL default '0',\n\t\t\t `image_w` smallint(6) unsigned NOT NULL default '0',\n\t\t\t `image_h` smallint(6) unsigned NOT NULL default '0',\n\t\t\t `pixels_per_km` float NOT NULL default '0',\n\t\t\t `type_or_user` smallint(6) NOT NULL default '0',\n\t\t\t `age` smallint(5) unsigned NOT NULL default '0',\n\t\t\t PRIMARY KEY (`map_x`,`map_y`,`image_w`,`image_h`,`pixels_per_km`,`type_or_user`)\n\t\t\t ) TYPE=MyISAM "); } elseif (isset($_GET['remove'])) { $db->Execute("DROP TABLE `mapcache2`"); } else { $smarty->assign('invalid_maps', $db->GetOne("select count(*) from mapcache where age > 0")); } $smarty->display('admin_recreatemaps.tpl');
$db = NewADOConnection($GLOBALS['DSN']); if (!$db) { die('Database connection failed'); } } $andwhere = ''; if ($when) { if (strlen($when) == 7) { $andwhere = " and submitted < DATE_ADD('{$when}-01',interval 1 month)"; } elseif (strlen($when) == 4) { $andwhere = " and submitted < DATE_ADD('{$when}-01-01',interval 1 year)"; } else { $andwhere = " and submitted < '{$when}'"; } $smarty->assign_by_ref('when', $when); $smarty->assign('whenname', getFormattedDate($when)); } if ($where) { $andwhere .= " and grid_reference like '{$where}%'"; $smarty->assign_by_ref('where', $where); } $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC; if (isset($_GET['cloud'])) { if ($andwhere) { $users = $db->CacheGetAssoc(3600 * 6, "select\r\n\t\t\t\tnickname,user.user_id,user.realname,user.user_id,count(*) as images\r\n\t\t\t\tfrom user\r\n\t\t\t\t\tinner join gridimage_search gi using (user_id)\r\n\t\t\t\twhere nickname != '' and rights IS NOT NULL {$andwhere}\r\n\t\t\t\tgroup by gi.user_id\r\n\t\t\t\torder by images desc"); $smarty->assign('what', 'Contributors'); } else { $users = $db->CacheGetAssoc(3600 * 6, "select\r\n\t\t\t\tnickname,user.user_id,user.realname,user.user_id,`us`.images\r\n\t\t\t\tfrom user\r\n\t\t\t\t\tinner join user_stat `us` using (user_id)\r\n\t\t\t\twhere nickname != '' and rights IS NOT NULL \r\n\t\t\t\torder by images desc"); $smarty->assign('what', 'Contributors'); } $size = $startsize = 30;
} elseif (preg_match('/[~\\|\\(\\)@"\\/-]/', $q)) { $mode = SPH_MATCH_EXTENDED; } $index = "gi_stemmed,gi_delta_stemmed"; if (strpos($q, '*') !== FALSE) { $index = 'gi_star'; } $cl = new SphinxClient(); $cl->SetServer($CONF['sphinx_host'], $CONF['sphinx_port']); $cl->SetWeights(array(100, 1)); $cl->SetSortMode(SPH_SORT_EXTENDED2, "@relevance DESC, @id DESC"); $cl->SetMatchMode($mode); $cl->SetLimits($offset, 25); $res = $cl->Query($q, $index); if (strlen($q) < 64 && $mode != SPH_MATCH_EXTENDED) { $smarty->assign("suggestions", didYouMean($q, $cl)); } // -------------- if ($res === false) { print "\tQuery failed: -- please try again later.\n"; exit; } else { if ($cl->GetLastWarning()) { print "\nWARNING: " . $cl->GetLastWarning() . "\n\n"; } $query_info = "Query '{$qo}' retrieved " . count($res['matches']) . " of {$res['total_found']} matches in {$res['time']} sec.\n"; } if (is_array($res["matches"])) { $ids = array_keys($res["matches"]); if (!empty($_GET['id'])) { header("Location: http://www.geograph.org.uk/search.php?marked=1&markedImages=" . join(",", $ids));
* 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(); $smarty = new GeographPage(); $smarty->assign('google_maps_api_key', $CONF['google_maps_api_key']); if (isset($_REQUEST['inner'])) { $cacheid = 'iframe'; $smarty->assign('inner', 1); } else { $cacheid = ''; } if (isset($_REQUEST['picasa'])) { $cacheid .= 'picasa'; $smarty->assign('picasa', 1); } elseif (isset($_REQUEST['submit2'])) { $cacheid .= 'submit2'; $smarty->assign('submit2', 1); } if (!empty($_REQUEST['grid_reference'])) { $square = new GridSquare();
require_once 'geograph/gridimage.class.php'; require_once 'geograph/map.class.php'; require_once 'geograph/mapmosaic.class.php'; require_once 'geograph/image.inc.php'; init_session(); $smarty = new GeographPage(); $map = new GeographMap(); $map->setOrigin(0, -10); $map->setImageSize(1200, 1700); $map->setScale(1.3); $map->type_or_user = -60; $target = $_SERVER['DOCUMENT_ROOT'] . $map->getImageFilename(); $template = 'stuff_thumbnail.tpl'; $cacheid = $map->type_or_user * -1; $smarty->caching = 2; // lifetime is per cache $smarty->cache_lifetime = 3600 * 7 * 24; //7 day cache (as search can be cached - and we manually refreshed anyway if (!empty($_GET['refresh']) && $USER->hasPerm("admin")) { unlink($target); $map->_renderMap(); $smarty->clear_cache($template, $cacheid); } //regenerate? if (!$smarty->is_cached($template, $cacheid)) { $imagemap = file_get_contents($target . ".html"); $smarty->assign_by_ref("imagemap", $imagemap); $smarty->assign_by_ref("map", $map); $smarty->assign("imageupdate", filemtime($target)); } $smarty->display($template, $cacheid);
} $column = 'created'; if (isset($_GET['week'])) { $from_date = "date(min({$column}))"; $group_date = "yearweek({$column},1)"; } else { $length = isset($_GET['month']) ? 10 : 7; //month=0 means daily ;-0 $from_date = "substring( {$column}, 1, {$length} )"; $group_date = "substring( {$column}, 1, {$length} )"; } $title = "Breakdown of Logins over Time"; $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC; $table = $db->GetAll("\r\n\tselect \r\n\t{$from_date} as `Date` ,\r\n\tcount(*) as `Logins`,\r\n\tcount(distinct user_id) as `Users`\t\r\n\tfrom autologin \r\n\tgroup by {$group_date}\r\n\t"); if (!isset($_GET['output']) || $_GET['output'] != 'csv') { foreach ($table as $idx => $entry) { $table[$idx]['Date'] = getFormattedDate($table[$idx]['Date']); } } $smarty->assign_by_ref('table', $table); $smarty->assign("h2title", $title); $smarty->assign("total", count($table)); $extra = array(); foreach (array('month') as $key) { if (isset($_GET[$key])) { $extra[$key] = $_GET[$key]; } } $smarty->assign_by_ref('extra', $extra); } $smarty->display($template, $cacheid);
if ($USER->user_id && count($page)) { $prev_fetch_mode = $ADODB_FETCH_MODE; $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC; $list = $db->getAll("\r\n\t\tselect post_id,poster_id,poster_name,post_text,post_time\r\n\t\tfrom geobb_posts\r\n\t\twhere topic_id = {$topic_id}\r\n\t\torder by post_id\r\n\t\tlimit {$pagelimit},{$pgsize}"); $last = count($list) - 1; $postID = $list[$last]['post_id']; $db->Execute($sql = "insert into geobb_lastviewed set topic_id={$topic_id},user_id={$USER->user_id},last_post_id = {$postID} on duplicate key update last_post_id = if(last_post_id < {$postID},{$postID},last_post_id)"); } } else { $template = 'static_404.tpl'; } if (!$smarty->is_cached($template, $cacheid)) { if (count($page)) { $CONF['global_thumb_limit'] *= 2; $CONF['post_thumb_limit'] *= 2; $smarty->assign($page); if (empty($list)) { $prev_fetch_mode = $ADODB_FETCH_MODE; $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC; $list = $db->getAll("\r\n\t\t\tselect post_id,poster_id,poster_name,post_text,post_time\r\n\t\t\tfrom geobb_posts\r\n\t\t\twhere topic_id = {$topic_id}\r\n\t\t\torder by post_id\r\n\t\t\tlimit {$pagelimit},{$pgsize}"); } $smarty->assign_by_ref('list', $list); if ($page['posts_count'] > $pgsize) { $numberOfPages = ceil($page['posts_count'] / $pgsize); $smarty->assign('pagesString', pagesString($pg, $numberOfPages, "/gallery/{$page['url']}/")); } } } else { $smarty->assign('topic_id', $topic_id); } $smarty->display($template, $cacheid);
} if (!empty($ids) && count($ids)) { $where = "id IN(" . join(",", $ids) . ")"; $db = NewADOConnection($GLOBALS['DSN2']); $limit = 25; $prev_fetch_mode = $ADODB_FETCH_MODE; $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC; $rows = $db->getAssoc("\r\n\t\t\t\tselect id,name,name_2,gr,localities,localities_2,score\r\n\t\t\t\tfrom placename_index \r\n\t\t\t\twhere {$where}\r\n\t\t\t\tlimit {$limit}"); $results = array(); foreach ($ids as $c => $id) { $row = $rows[$id]; $row['id'] = $id; $results[] = $row; } $smarty->assign_by_ref('results', $results); $smarty->assign("query_info", $sphinx->query_info); if ($sphinx->numberOfPages > 1) { $smarty->assign('pagesString', pagesString($pg, $sphinx->numberOfPages, $_SERVER['PHP_SELF'] . "?q=" . urlencode($q) . ($fuzzy ? "&f=on" : '') . "&page=")); $smarty->assign("offset", $offset); } $ADODB_FETCH_MODE = $prev_fetch_mode; } } else { $smarty->assign("query_info", "Search will only return 1000 results - please refine your search"); $smarty->assign('pagesString', pagesString($pg, 1, $_SERVER['PHP_SELF'] . "?q=" . urlencode($q) . "&page=")); } } $smarty->assign("q", $sphinx->qclean); $smarty->assign("fuzzy", $fuzzy); } $smarty->display($template, $cacheid);
$date = isset($_GET['date']) && preg_match('/^\\d{4}(-\\d{2}|)(-\\d{2}|)$/', $_GET['date']) ? $_GET['date'] : '2005-12'; $cacheid = 'statistics|distances' . $date . '.' . $ri . '.' . $u; if (!$smarty->is_cached($template, $cacheid)) { dieUnderHighLoad(); require_once 'geograph/gridimage.class.php'; require_once 'geograph/gridsquare.class.php'; require_once 'geograph/imagelist.class.php'; $db = NewADOConnection($GLOBALS['DSN']); if (!$db) { die('Database connection failed'); } $title = "Distances Travelled in a Day"; $where = array(); if (!empty($u)) { $where[] = 'user_id=' . $u; $smarty->assign('u', $u); $profile = new GeographUser($u); $smarty->assign_by_ref('profile', $profile); $title .= ' for ' . $profile->realname; } else { $columns_sql = "CONCAT('<a href=\"/profile/',user_id,'\">',realname,'</a>') as User,"; } if ($ri) { $where[] = "reference_index = {$ri}"; $where2 = "and reference_index = {$ri}"; $smarty->assign('ri', $ri); $title .= " in " . $CONF['references_all'][$ri]; } else { $where2 = ""; } if (!empty($date)) {
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ require_once 'geograph/global.inc.php'; init_session(); $smarty = new GeographPage(); $USER->mustHavePerm('basic'); $isadmin = $USER->hasPerm('moderator') ? 1 : 0; if (empty($_REQUEST['id'])) { $smarty->display('static_404.tpl'); exit; } $template = 'events_edit.tpl'; $cacheid = ''; $db = NewADOConnection($GLOBALS['DSN']); if ($_REQUEST['id'] == 'new') { $smarty->assign('id', "new"); $smarty->assign('title', "New Event"); $smarty->assign('realname', $USER->realname); $smarty->assign('user_id', $USER->user_id); $page = array(); } else { $sql_where = " geoevent_id = " . $db->Quote($_REQUEST['id']); $prev_fetch_mode = $ADODB_FETCH_MODE; $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC; $page = $db->getRow($sql = "\r\n\t\tselect geoevent.*,realname,gs.grid_reference\r\n\t\tfrom geoevent \r\n\t\t\tleft join user using (user_id)\r\n\t\t\tleft join gridsquare gs on (geoevent.gridsquare_id = gs.gridsquare_id)\r\n\t\twhere {$sql_where}\r\n\t\tlimit 1"); $ADODB_FETCH_MODE = $prev_fetch_mode; if (count($page) && ($page['user_id'] == $USER->user_id || $USER->hasPerm('moderator'))) { $smarty->assign($page); $smarty->assign('id', $page['geoevent_id']); } else { $template = 'static_404.tpl';
$USER->mustHavePerm("basic"); //gather what we need $from_name = isset($_POST['from_name']) ? stripslashes($_POST['from_name']) : $USER->realname; $from_email = isset($_POST['from_email']) ? stripslashes($_POST['from_email']) : $USER->email; $to_name = isset($_POST['to_name']) ? stripslashes($_POST['to_name']) : ''; $to_email = isset($_POST['to_email']) ? stripslashes($_POST['to_email']) : ''; $smarty->assign_by_ref('from_name', $from_name); $smarty->assign_by_ref('from_email', $from_email); $smarty->assign_by_ref('to_name', $to_name); $smarty->assign_by_ref('to_email', $to_email); $db = NewADOConnection($GLOBALS['DSN']); if (empty($db)) { die('Database connection failed'); } if ($db->getOne("select count(*) from throttle where used > date_sub(now(), interval 1 hour) and user_id={$USER->user_id} AND feature = 'ecard'") > 8) { $smarty->assign('throttle', 1); $throttle = 1; } elseif ($db->getOne("select count(*) from throttle where used > date_sub(now(), interval 24 hour) and user_id={$USER->user_id} AND feature = 'ecard'") > 30) { $smarty->assign('throttle', 1); $throttle = 1; } else { $throttle = 0; } if (rand(1, 10) > 5) { $db->query("delete from throttle where used < date_sub(now(), interval 48 hour)"); } if (isset($_REQUEST['image'])) { //initialise message require_once 'geograph/gridsquare.class.php'; require_once 'geograph/gridimage.class.php'; $image = new GridImage();
} if ($u) { $profile = new GeographUser($u); $smarty->assign_by_ref('profile', $profile); $title = " for " . $profile->realname; $hectads2 = $db->CacheGetAll(3600 * 24, "select \r\n\t\tconcat(substring(grid_reference,1,length(grid_reference)-3),substring(grid_reference,length(grid_reference)-1,1)) as tenk_square,\r\n\t\tcount(distinct x,y) as geograph_count\r\n\t\tfrom gridimage_search gs\r\n\t\twhere user_id = {$u} and moderation_status = 'geograph'\r\n\t\tgroup by tenk_square \r\n\t\torder by null"); foreach ($hectads2 as $i => $h) { list($y, $x) = $lookup[$h['tenk_square']]; $grid[$y][$x]['geograph_count'] = $h['geograph_count']; $grid[$y][$x]['percentage'] = round($h['geograph_count'] / $grid[$y][$x]['land_count'] * 100, 1); } } $ys = array_keys($grid); $y1 = min($ys); $y2 = max($ys); $smarty->assign('which', $w); switch ($w) { case '3': $w = "land_count"; break; case '2': $w = "percentage"; break; default: $w = "geograph_count"; break; } $smarty->assign('column', $w); $smarty->assign_by_ref('grid', $grid); $smarty->assign('x1', $x1); $smarty->assign('x2', $x2);
* * 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(); $smarty = new GeographPage(); if (isset($_GET['output']) && $_GET['output'] == 'csv') { $table = isset($_GET['table']) && is_numeric($_GET['table']) ? intval($_GET['table']) : 0; $smarty->assign('whichtable', $table); $template = 'statistics_tables_csv.tpl'; # let the browser know what's coming header("Content-type: application/octet-stream"); header("Content-Disposition: attachment; filename=\"" . basename($_SERVER['SCRIPT_NAME'], '.php') . ".{$table}.csv\""); $cacheid = 'statistics|coverage_by_country.' . $table; } else { $template = 'statistics_tables.tpl'; $cacheid = 'statistics|coverage_by_country'; } $smarty->caching = 2; // lifetime is per cache $smarty->cache_lifetime = 3600 * 24; //24hr cache if (!$smarty->is_cached($template, $cacheid)) { dieUnderHighLoad();
$u = isset($_GET['u']) && is_numeric($_GET['u']) ? intval($_GET['u']) : 0; $cacheid = 'statistics|busyday_forum' . isset($_GET['users']) . $u . '.' . isset($_GET['threads']); 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 (!$db) { die('Database connection failed'); } $column = 'post_time'; $title = "Busiest Day for Forum Posts"; $where = array(); if (!empty($u)) { $where[] = "poster_id=" . $u; $smarty->assign('u', $u); $profile = new GeographUser($u); $smarty->assign_by_ref('profile', $profile); $title .= " for " . $profile->realname; } elseif (isset($_GET['users'])) { $group_sql = 'poster_id,'; $column_sql = "CONCAT('<a href=\"/profile/',poster_id,'\">',poster_name,'</a>') as User,"; $title .= " by user"; } if (isset($_GET['threads'])) { $join_sql .= ' inner join geobb_topics using(topic_id)'; $group_sql .= 'geobb_posts.topic_id,'; $column_sql .= "CONCAT('<a href=\"/discuss/?action=vthread&topic=',geobb_posts.topic_id,'\">',topic_title,'</a>') as Topic,"; $title .= " by topic"; } if (count($where)) {
$smarty->assign_by_ref('from_email', $from_email); $smarty->assign_by_ref('sendcopy', $sendcopy); $db = NewADOConnection($GLOBALS['DSN']); if (empty($db)) { die('Database connection failed'); } $ip = getRemoteIP(); $user_id = "inet_aton('{$ip}')"; $throttlenumber = 5; if ($USER->hasPerm("ticketmod") || $USER->hasPerm("moderator")) { $throttlenumber = 30; } if (empty($CONF['usermsg_spam_trap'])) { $throttle = 0; } elseif ($db->getOne("select count(*) from throttle " . "where used > date_sub(now(), interval 1 hour) and " . "user_id={$user_id} AND feature = 'usermsg'") > $throttlenumber) { $smarty->assign('throttle', 1); $throttle = 1; } elseif ($db->getOne("select count(*) from throttle " . "where used > date_sub(now(), interval 24 hour) and " . "user_id={$user_id} AND feature = 'usermsg'") > $throttlenumber * 6) { $smarty->assign('throttle', 1); $throttle = 1; } else { $throttle = 0; } if (rand(1, 10) > 5) { $db->query("delete from throttle where used < date_sub(now(), interval 48 hour)"); } //try and send? if (isset($_POST['msg'])) { $ok = true; $msg = trim(stripslashes($_POST['msg'])); $errors = array();
$locks = array(); $locks[] = "gridimage_moderation_lock WRITE"; $locks[] = "gridimage_moderation_lock l WRITE"; $locks[] = "gridimage_ticket_comment as c WRITE"; $locks[] = "gridimage_ticket t READ"; $locks[] = "user suggester READ"; $locks[] = "gridimage i READ"; $locks[] = "user as submitter READ"; $columns = ''; $tables = ''; $sql_where = ''; ################# # setup type if (isset($_GET['moderator']) && ($mid = intval($_GET['moderator']))) { $sql_where .= " and t.moderator_id={$mid}"; $smarty->assign('moderator', 1); } elseif (isset($_GET['image_moderator']) && ($mid = intval($_GET['image_moderator']))) { $sql_where .= " and i.moderator_id={$mid}"; $smarty->assign('moderator', 1); } elseif (isset($_GET['user_id']) && ($mid = intval($_GET['user_id']))) { $sql_where .= " and i.user_id={$mid}"; } elseif (isset($_GET['suggestor']) && ($mid = intval($_GET['suggestor']))) { $sql_where .= " and t.user_id={$mid}"; } if (!empty($_GET['q'])) { if (isset($_GET['legacy']) || empty($CONF['sphinx_host'])) { if (strpos($_GET['q'], '!') === 0) { $q = $db->Quote("%" . preg_replace('/^!/', '', $_GET['q']) . "%"); #$sql_where .= " and not (t.notes like $q or i.title like $q)"; $sql_where .= " and not (t.notes like {$q} or i.title like {$q} or i.title2 like {$q})"; } else {
$USER->login(); $template = 'profile_edit.tpl'; //save changes? if (isset($_POST['savechanges'])) { $errors = array(); $ok = $USER->updateProfile($_POST, $errors); if ($ok) { //show the user their new profile $template = 'profile.tpl'; $ab = floor($USER->user_id / 10000); //clear anything with a cache id userxyz| $smarty->clear_cache(null, "user{$ab}|{$USER->user_id}"); $profile =& $USER; } else { $profile = new GeographUser($USER->user_id); $smarty->assign('errors', $errors); //ensure we keep submission intact foreach ($_POST as $name => $value) { $profile->{$name} = strip_tags(stripslashes($value)); } } } else { $profile = new GeographUser($USER->user_id); } $smarty->assign('pagesizes', array(5, 10, 15, 20, 30, 50)); $smarty->assign('delays', array(2, 3, 4, 5, 6, 10, 12)); $smarty->assign('stdsize', $CONF['img_max_size']); $smarty->assign('sizes', $CONF['img_sizes']); $smarty->assign('showorig', $CONF['img_size_unlimited']); $smarty->assign('largeimages', $CONF['img_size_unlimited'] || count($CONF['img_sizes']) != 0); $smarty->assign('canclearexif', $CONF['exiftooldir'] !== '');