flush(); $count++; $recordSet->MoveNext(); } $recordSet->Close(); print "<h2>All Done</h2>"; print "Squares done = {$count}<br/>"; print "Tiles deleted = {$tiles}"; flush(); exit; } elseif (isset($_GET['gridref'])) { $square = new GridSquare(); $ok = $square->validGridRef($_GET['gridref']); if ($ok) { $gridref = $_GET['gridref']; $smarty->assign_by_ref('gridref', $gridref); $smarty->assign('showinfo', 1); //can we find a square? $sq = $db->GetRow("select * from gridsquare where grid_reference='{$gridref}'"); if (count($sq)) { $smarty->assign('percent_land', $sq['percent_land']); } //update? if (isset($_GET['save'])) { $percent = intval($_GET['percent_land']); if (count($sq)) { //update existing square $db->Execute("update gridsquare set percent_land='{$percent}' where gridsquare_id='{$sq['gridsquare_id']}'"); $smarty->assign('status', "Existing gridsquare {$gridref} updated with new land percentage of {$percent} %"); $db->Execute("REPLACE INTO mapfix_log SET user_id = {$USER->user_id}, gridsquare_id = {$sq['gridsquare_id']}, new_percent_land='{$percent}', old_percent_land='{$sq['percent_land']}',created=now(),comment=" . $db->Quote($_GET['comment'])); require_once 'geograph/mapmosaic.class.php';
* 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->caching = 0; //dont cache! $cacheid = 0; $template = 'gallery.tpl'; $db = NewADOConnection($GLOBALS['DSN']); $data = $db->getRow("show table status like 'content'"); //we use content as it should only update when galleries update //when this table was modified $mtime = strtotime($data['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); if (!$smarty->is_cached($template, $cacheid)) { $prev_fetch_mode = $ADODB_FETCH_MODE; $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC; $list = $db->getAll("\r\n\tselect topic_id,topic_title,topic_poster,topic_poster_name,topic_time,topic_views,posts_count,count(*) as images_count\r\n\tfrom geobb_topics\r\n\tleft join gridimage_post using (topic_id)\r\n\twhere forum_id = {$CONF['forum_gallery']}\r\n\tgroup by topic_id\r\n\torder by topic_last_post_id desc"); foreach ($list as $i => $row) { $list[$i]['url'] = trim(strtolower(preg_replace('/[^\\w]+/', '_', html_entity_decode(preg_replace('/&#\\d+;?/', '_', $row['topic_title'])))), '_') . '_' . $row['topic_id']; } $smarty->assign_by_ref('list', $list); } $smarty->display($template, $cacheid);
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)) { $where_sql = " AND " . join(' AND ', $where); }
#$geographs = 0; $pending = 0; #$points = 0; foreach ($topusers as $user_id => $entry) { if ($lastgeographs == $entry['geographs']) { $topusers[$user_id]['ordinal'] = '" '; } else { $topusers[$user_id]['ordinal'] = smarty_function_ordinal($i); $lastgeographs = $entry['geographs']; } $i++; #$geographs += $entry['geographs']; $pending += $entry['pending']; #$points += $entry['points']; if (empty($entry['points'])) { $topusers[$user_id]['points'] = ''; } } $geographs = $sum['geographs']; $points = $sum['points']; $smarty->assign('geographs', $geographs); $smarty->assign('pending', $pending); $smarty->assign('points', $points); $smarty->assign_by_ref('topusers', $topusers); $smarty->assign('cutoff_time', time() - 86400 * 7); $smarty->assign('types', array('points', 'geosquares', 'images', 'depth')); $smarty->assign('typenames', $MESSAGES['moversboard']['type_names']); //lets find some recent photos new RecentImageList($smarty); } $smarty->display($template, $cacheid);
$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);
$smarty = new GeographPage(); $len = isset($_GET['len']) && is_numeric($_GET['len']) ? max(0, min(3, intval($_GET['len']))) : 2; $words = isset($_GET['words']) && preg_match('/^[\\w ]+$/', $_GET['words']) ? $_GET['words'] : ''; $u = isset($_GET['u']) && is_numeric($_GET['u']) ? intval($_GET['u']) : 0; //bare minimum for the dynamic section if ($u) { if ($u == -1) { if ($USER->registered) { $u = $USER->user_id; } else { $u = 0; } } if ($u) { $profile = new GeographUser($u); $smarty->assign_by_ref('profile', $profile); $smarty->assign_by_ref('u', $u); } } 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)) {
$_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"); customGZipHandlerStart(); //always turn off debugging, it will break the js $smarty->debugging = false; $smarty->display($template, $cacheid);
} $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);
} elseif (datetimeToTimestamp($smarty->get_template_vars('imagetaken')) > datetimeToTimestamp(date("Y-m-d"))) { $ok = false; $error['imagetaken'] = "Time machines are not allowed on Planet Geograph"; } if (($_POST['imageclass'] == 'Other' || empty($_POST['imageclass'])) && !empty($_POST['imageclassother'])) { $imageclass = stripslashes($_POST['imageclassother']); } else { if ($_POST['imageclass'] != 'Other') { $imageclass = stripslashes($_POST['imageclass']); } } if (strlen($imageclass) == 0) { $ok = false; $error['imageclass'] = "Please choose a geographical feature"; } else { $smarty->assign_by_ref('imageclass', $imageclass); } $title = trim(stripslashes($_POST['title'])); $title = strip_tags($title); $title2 = trim(stripslashes($_POST['title2'])); $title2 = strip_tags($title2); if (strlen($title) == 0 && strlen($title2) == 0) { $ok = false; $error['title'] = "Please specify an image title"; } //preserve title and comment $smarty->assign('title', $title); $smarty->assign('comment', trim(stripslashes($_POST['comment']))); $smarty->assign('title2', $title2); $smarty->assign('comment2', trim(stripslashes($_POST['comment2']))); $smarty->assign('user_status', stripslashes($_POST['user_status']));
} //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']); $cacheid .= '.' . $_GET['gridref_from']; } //regenerate? if (!$smarty->is_cached($template, $cacheid)) { dieUnderHighLoad(); if ($map->type_or_user > 0) { $profile = new GeographUser($map->type_or_user); $smarty->assign('realname', $profile->realname); $smarty->assign('user_id', $map->type_or_user); } //assign main map to smarty $smarty->assign_by_ref('map', $map); $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC; $grid =& $map->getGridArray(); $smarty->assign_by_ref('grid', $grid); $first = current($grid); $second = current($first); $ri = $second['reference_index']; $letterlength = $CONF['gridpreflen'][$ri]; $smarty->assign('ofe', $letterlength + 1); $smarty->assign('ofn', $letterlength + 3); //assign all the other useful stuff $gr = $map->getGridRef(-1, -1); $smarty->assign('gridref', $gr); if ($map->pixels_per_km == 4) { $starte = substr($gr, $letterlength, 2); $starte = intval($starte) - 50;
* 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'; require_once 'geograph/gridimage.class.php'; require_once 'geograph/gridsquare.class.php'; require_once 'geograph/token.class.php'; require_once 'geograph/gazetteer.class.php'; init_session(); $smarty = new GeographPage(); $template = 'map_frame.tpl'; $cacheid = ''; $square = new GridSquare(); $token = new Token(); if ($token->parse($_GET['t'])) { $s = false; $rastermap = new RasterMap($s); foreach ($token->data as $key => $value) { $rastermap->{$key} = $value; } $rastermap->inline = true; $smarty->assign_by_ref('rastermap', $rastermap); } else { die("invalid"); } $smarty->display($template, $cacheid);
$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'] !== ''); $profile->getStats(); $profile->md5_email = md5(strtolower($profile->email)); $smarty->assign_by_ref('profile', $profile); } #elseif (isset($_REQUEST['notifications'])) #FIXME #{ # //must be logged in to proceed with an edit # $USER->login(); # # $template='profile_notifications.tpl'; # # //save changes? # if (isset($_POST['savechanges'])) # { # # } # else # {
} $column = $date == 'taken' ? 'imagetaken' : 'submitted'; $title1 = $date == 'taken' ? 'Taken' : 'Submitted'; $where = array(); if ($date == 'taken') { $where[] = "{$column} not like '%-00%'"; } if (!empty($ri)) { $where[] = "reference_index=" . $ri; $smarty->assign('ri', $ri); } 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; } if (count($where)) { $where_sql = " WHERE " . join(' AND ', $where); } $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC; $graphs = array(); //================= if ($date != 'taken') { $graph = array(); $title = "Breakdown of Images by {$title1} Hour"; $table = $db->GetAll("SELECT \n\t\tHOUR({$column}) AS `title`, \n\t\tcount( * ) AS `value`\n\t\tFROM `gridimage` {$where_sql}\n\t\tGROUP BY HOUR({$column})"); $graph['table'] = $table; $graph['title'] = $title; $max = 0;
* * 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'; require_once 'geograph/searchcriteria.class.php'; require_once 'geograph/searchengine.class.php'; require_once 'geograph/searchenginebuilder.class.php'; init_session(); $smarty = new GeographPage(); $i = !empty($_GET['i']) ? intval($_GET['i']) : ''; $sortorders = array('' => '', 'dist_sqd' => 'Distance', 'gridimage_id' => 'Date Submitted', 'imagetaken' => 'Date Taken', 'imageclass' => 'Image Category', 'realname' => 'Contributor Name', 'grid_reference' => 'Grid Reference', 'title' => 'Image Title', 'x' => 'West->East', 'y' => 'South->North', 'seq_id' => '** Import Order **'); $breakdowns = array('' => '', 'imagetaken' => 'Day Taken', 'imagetaken_month' => 'Month Taken', 'imagetaken_year' => 'Year Taken', 'imagetaken_decade' => 'Decade Taken', 'imageclass' => 'Image Category', 'realname' => 'Contributor Name', 'grid_reference' => 'Grid Reference', 'submitted' => 'Day Submitted', 'submitted_month' => 'Month Submitted', 'submitted_year' => 'Year Submitted'); $displayclasses = array('full' => 'full listing', 'more' => 'full listing + links', 'thumbs' => 'thumbnails only', 'thumbsmore' => 'thumbnails + links', 'gmap' => 'on a map', 'slide' => 'slideshow - fullsize', 'reveal' => 'slideshow - map imagine', 'cooliris' => 'cooliris 3d wall', 'mooflow' => 'cover flow', 'text' => 'text list only', 'spelling' => 'spelling utility'); $smarty->assign_by_ref('displayclasses', $displayclasses); $smarty->assign('pagesizes', array(5, 10, 15, 20, 30, 50)); $smarty->assign_by_ref('imagestatuses', $imagestatuses); $smarty->assign_by_ref('sortorders', $sortorders); $smarty->assign_by_ref('breakdowns', $breakdowns); $pg = !empty($_GET['page']) ? intval(str_replace('/', '', $_GET['page'])) : 0; if (empty($pg) || $pg < 1) { $pg = 1; } $engine = new SearchEngine($i); if ($engine->criteria && $engine->criteria->searchclass == "Special" && ($USER->user_id == $engine->criteria->user_id || $USER->hasPerm('moderator'))) { //you can pass! } else { $smarty->display('no_permission.tpl'); exit; }
* * 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'; include_messages('usermsg'); init_session(); $smarty = new GeographPage(); $template = 'usermsg.tpl'; //gather what we need $recipient = new GeographUser($_REQUEST['to']); $from_name = isset($_POST['from_name']) ? stripslashes($_POST['from_name']) : $USER->realname; $from_email = isset($_POST['from_email']) ? stripslashes($_POST['from_email']) : $USER->email; $sendcopy = isset($_POST['sendcopy']) ? stripslashes($_POST['sendcopy']) : false; $smarty->assign_by_ref('recipient', $recipient); $smarty->assign_by_ref('from_name', $from_name); $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;
$step = intval($_REQUEST['step']); } if (empty($_REQUEST['grid_reference']) && $step == 2) { $step = 1; } if ($step == 2) { require_once 'geograph/rastermap.class.php'; $rastermap = new RasterMap($square, true); if (isset($_POST['photographer_gridref'])) { $square2 = new GridSquare(); $ok = $square2->setByFullGridRef($_POST['photographer_gridref'], false, false, true); $rastermap->addViewpoint($square2->reference_index, $square2->nateastings, $square2->natnorthings, $square2->natgrlen, $_POST['view_direction']); } elseif (isset($_POST['view_direction']) && strlen($_POST['view_direction']) && $_POST['view_direction'] != -1) { $rastermap->addViewDirection($_POST['view_direction']); } $smarty->assign_by_ref('rastermap', $rastermap); $smarty->assign_by_ref('square', $square); $smarty->assign('reference_index', $square->reference_index); 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); $rastermap->addLatLong($lat, $long); $dirs = array(-1 => ''); $jump = 360 / 16; $jump2 = 360 / 32; for ($q = 0; $q < 360; $q += $jump) { $s = $q % 90 == 0 ? strtoupper(heading_string($q)) : ucwords(heading_string($q)); $dirs[$q] = sprintf('%s : %03d deg (%03d > %03d)', str_pad($s, 16, '�'), $q, $q == 0 ? $q + 360 - $jump2 : $q - $jump2, $q + $jump2); }
if (!$db) { $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'); }
$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 = ''; if (count($where)) { $where_sql = " WHERE " . join(' AND ', $where);
} $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);
$result = mysql_query($sql) or die("Couldn't select query : {$sql} " . mysql_error() . "\n"); if (mysql_num_rows($result) > 0) { require_once 'geograph/gridimage.class.php'; $rows = array(); while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $rows[$row['gridimage_id']] = $row; } $images = array(); foreach ($ids as $c => $id) { if ($row = $rows[$id]) { $gridimage = new GridImage(); $gridimage->fastInit($rows[$id]); $images[] = $gridimage; } } $smarty->assign_by_ref("images", $images); $smarty->assign("query_info", $query_info); } else { $images = array(); $smarty->assign_by_ref("images", $images); $smarty->assign("query_info", "no results"); } } else { $images = array(); $smarty->assign_by_ref("images", $images); $smarty->assign("query_info", "no results"); } $smarty->assign("searchq", $qo); } $smarty->display($template, $cacheid); function didYouMean($q, $cl)
$ids = $sphinx->returnIds($pg, 'gaz'); } 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); }
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);
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"); $i = 1; $lastgeographs = -1;
* 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(); $smarty = new GeographPage(); $template = 'admin_team.tpl'; $cacheid = ''; if (!$smarty->is_cached($template, $cacheid)) { $db = NewADOConnection($GLOBALS['DSN']); if (!$db) { die('Database connection failed'); } $team = $db->GetAssoc("\r\n\tselect \r\n\t\tuser.user_id,user.realname,user.nickname,user.rights,role\r\n\tfrom user\r\n\twhere length(rights) > 0 AND (rights LIKE '%admin%' OR rights LIKE '%moderator%' OR role != '')\r\n\tgroup by user.user_id\r\n\torder by user.user_id"); $smarty->assign_by_ref('team', $team); } $smarty->display($template, $cacheid);
} $hectads = $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\t{$columns}\r\n\t\tsum(percent_land >0) as land_count,min(x) as x,min(y) as y\r\n\t\tfrom gridsquare \r\n\t\tgroup by tenk_square \r\n\t\thaving land_count > 0\r\n\t\torder by null"); $lookup = $grid = array(); $x1 = 9999999; $x2 = 0; foreach ($hectads as $i => $h) { $x = intval($h['x'] / 10) + 10; $y = intval($h['y'] / 10); $grid[$y][$x] = $h; $lookup[$h['tenk_square']] = array($y, $x); $x1 = min($x, $x1); $x2 = max($x, $x2); } 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";
* 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'; include_messages('ecard'); init_session(); $smarty = new GeographPage(); $template = 'ecard.tpl'; //you must be logged in to send e-cards $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 (!isValidRealName($from_name)) { $ok = false; $errors['from_name'] = 'Only letters A-Z, a-z, hyphens and apostrophes allowed'; } 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";
//24hr cache if (!$smarty->is_cached($template, $cacheid)) { dieUnderHighLoad(); $db = NewADOConnection($GLOBALS['DSN']); if (!$db) { die('Database connection failed'); } $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC; $tables = array(); ################### $table = array(); $table['title'] = "Great Britain"; $table['table'] = $db->GetAll("\r\n\t\tselect \r\n\t\t\tloc_country.name as Country,\r\n\t\t\tcount(*) as `Grid Squares`,\r\n\t\t\tsum(has_geographs) as `Geographed`,\r\n\t\t\tsum(has_geographs)/count(*)*100 as Percentage,\r\n\t\t\tsum(imagecount) as 'Total Photos'\r\n\t\tfrom gridsquare gs\r\n\t\t\tinner join os_gaz on (placename_id-1000000 = os_gaz.seq)\r\n\t\t\tinner join os_gaz_county on (os_gaz.co_code = os_gaz_county.co_code)\r\n\t\t\tinner join loc_country on (country = loc_country.code)\r\n\t\twhere gs.reference_index = 1 and percent_land > 0\r\n\t\tgroup by country with rollup\r\n\t\t"); foreach ($table['table'] as $id => $row) { } $table['total'] = count($table['table']); $table['table'][$table['total'] - 1]['Country'] = '-Total-'; $tables[] = $table; ################### $table = array(); $table['title'] = "Ireland"; $table['table'] = $db->GetAll("\r\n\t\tselect \r\n\t\t\tloc_country.name as Country,\r\n\t\t\tcount(*) as `Grid Squares`,\r\n\t\t\tsum(has_geographs) as `Geographed`,\r\n\t\t\tsum(has_geographs)/count(*)*100 as Percentage,\r\n\t\t\tsum(imagecount) as 'Total Photos'\r\n\t\tfrom gridsquare gs\r\n\t\t\tinner join loc_placenames on (placename_id = id)\r\n\t\t\tinner join loc_country on (country = loc_country.code)\r\n\t\twhere gs.reference_index = 2 and percent_land > 0\r\n\t\tgroup by country with rollup\r\n\t\t"); $table['total'] = count($table['table']); $table['table'][$table['total'] - 1]['Country'] = '-Total-'; $tables[] = $table; ################### $smarty->assign_by_ref('tables', $tables); $smarty->assign("headnote", "See also <a href=\"/statistics/coverage_by_county.php\">Coverage by County</a>."); $smarty->assign("h2title", 'Coverage by Country'); } $smarty->display($template, $cacheid);
} ################# # put it all together... $smarty->assign('title', $title); $info = $db->getAssoc("select moderator_id>0,count(*) as c from gridimage_ticket where status in ('pending','open') and deferred < NOW() group by moderator_id=0"); $types['pending'] .= " [~ {$info['0']}]"; $types['open'] .= " [~ {$info['1']}]"; $smarty->assign('type', $type); $smarty->assign('modifer', $modifer); $smarty->assign('theme', $theme); $smarty->assign('variation', $variation); $smarty->assign('minor', $minor); $smarty->assign('major', $major); $smarty->assign('defer', $defer); $smarty->assign('locked', $locked); $smarty->assign_by_ref('types', $types); $smarty->assign_by_ref('modifers', $modifers); $smarty->assign_by_ref('themes', $themes); $smarty->assign_by_ref('variations', $variations); $smarty->assign('query_string', $_SERVER['QUERY_STRING']); ################# # put it all together... $available = "(l.gridimage_id is null OR \n\t\t\t\t(l.user_id = {$USER->user_id} AND lock_type = 'modding') OR\n\t\t\t\t(l.user_id != {$USER->user_id} AND lock_type = 'cantmod')\n\t\t)"; if (empty($_GET['locked'])) { $db->Execute("LOCK TABLES " . implode(',', $locks)); $sql_where .= " and {$available}"; $columns .= ", 1 as available"; } else { $columns .= ", {$available} as available"; } # i.title,i.title2, DATEDIFF(NOW(),t.updated) as days,
$smarty->assign("page_title", "Ireland County Capital Towns"); $smarty->assign("extra_info", "* at the moment we dont actully store which county each capital is in, this information is furthermore only available for Ireland so far."); $counties = $db->GetAll("SELECT * FROM `loc_towns` WHERE `s` = '2' AND `reference_index` = 2 ORDER BY n"); } if ($counties) { foreach ($counties as $i => $row) { list($x, $y) = $conv->national_to_internal($row['e'], $row['n'], $row['reference_index']); $sql = "select * from gridimage_search where x={$x} and y={$y} order by moderation_status+0 desc,seq_no limit 1"; $rec = $db->GetRow($sql); if (count($rec)) { $gridimage = new GridImage(); $gridimage->fastInit($rec); $gridimage->county = $row['name']; $results[] = $gridimage; } else { $sql = "select grid_reference from gridsquare where x={$x} and y={$y} limit 1"; $rec = $db->GetRow($sql); if (count($rec)) { $rec['county'] = $row['name']; $unfilled[] = $rec; } else { $nonland[] = array('county' => $row['name']); } } } } $smarty->assign_by_ref("results", $results); $smarty->assign_by_ref("unfilled", $unfilled); $smarty->assign_by_ref("nonland", $nonland); } $smarty->display($template, $cacheid);