function processEvent(&$event)
 {
     list($gridimage_id, $user_id) = explode(',', $event['event_param']);
     $image = new GridImage();
     $image->gridimage_id = $gridimage_id;
     $image->user_id = $user_id;
     //beware image is not a full image object.
     //this wont be a full normal valid thumbnail, html, but it will have at least created the thumbnail.jpg which is the object of this exercise.
     $image->getThumbnail(213, 160);
     //return true to signal completed processing
     //return false to have another attempt later
     return true;
 }
Exemplo n.º 2
0
non-owner gets basic info

owner gets basic info, opportunity to add a new note (email sent to mods)
*/
require_once 'geograph/global.inc.php';
require_once 'geograph/gridimage.class.php';
require_once 'geograph/gridsquare.class.php';
require_once 'geograph/gridimagetroubleticket.class.php';
init_session();
$smarty = new GeographPage();
//you must be logged in to request changes
$USER->mustHavePerm("basic");
$template = 'editimage.tpl';
$cacheid = '';
$image = new GridImage();
//should we display a thumb
$thumb = false;
if (isset($_GET['thumb'])) {
    $thumb = (bool) $_GET['thumb'];
    $_SESSION['thumb'] = $thumb;
    //ToDo - if logged in user, save this in profile
} elseif (false) {
    //get setting from profile
} elseif (isset($_SESSION['thumb'])) {
    $thumb = $_SESSION['thumb'];
}
$smarty->assign('thumb', $thumb);
if (isset($_REQUEST['id'])) {
    $image->loadFromId($_REQUEST['id']);
    $isowner = $image->user_id == $USER->user_id ? 1 : 0;
Exemplo n.º 3
0
$smarty = new GeographPage();
$db = NewADOConnection($GLOBALS['DSN']);
if (empty($_REQUEST['key']) || preg_match("/[^\\w\\.]/", $_REQUEST['key'])) {
    die("ERROR: no api key");
}
$sql = "SELECT * FROM `apikeys` WHERE `apikey` = " . $db->Quote($_REQUEST['key']) . " AND (`ip` = INET_ATON('{$_SERVER['REMOTE_ADDR']}') OR `ip` = 0) AND `enabled` = 'Y'";
$profile = $db->GetRow($sql);
if (empty($profile['apikey'])) {
    die("ERROR: invalid api key. please contact us");
}
if (empty($_REQUEST['to'])) {
    if (!empty($_REQUEST['image'])) {
        //initialise message
        require_once 'geograph/gridsquare.class.php';
        require_once 'geograph/gridimage.class.php';
        $image = new GridImage();
        $image->loadFromId($_REQUEST['image']);
        $msg = "Re: image for {$image->grid_reference} ({$image->title})\r\nhttp://{$_SERVER['HTTP_HOST']}/photo/{$image->gridimage_id}\r\n";
        $_REQUEST['to'] = $image->user_id;
    } else {
        die("ERROR: no image/user specified");
    }
} else {
    $msg = '';
}
$recipient = new GeographUser($_REQUEST['to']);
$from_name = !empty($_REQUEST['from_name']) ? stripslashes($_REQUEST['from_name']) : die('ERROR: no name');
$from_email = !empty($_REQUEST['from_email']) ? stripslashes($_REQUEST['from_email']) : die('ERROR: no email');
$domain = !empty($_REQUEST['domain']) && preg_match('/^[\\w.]+$/', $_REQUEST['domain']) ? stripslashes($_REQUEST['domain']) : die('ERROR: no domain');
$msg = !empty($_REQUEST['message']) ? $msg . stripslashes($_REQUEST['message']) : die('ERROR: no message');
#$msg = preg_replace("/[^\r]\n/","\r\n",$msg);
Exemplo n.º 4
0
         $r = "\t--none--";
     }
 }
 if ($sql) {
     $db = NewADOConnection($GLOBALS['DSN']);
     $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");
Exemplo n.º 5
0
init_session();
$USER->mustHavePerm("admin");
$smarty = new GeographPage();
$db = NewADOConnection($GLOBALS['DSN']);
$from = isset($_POST['from']) ? $_POST['from'] : $CONF['photo_hashing_secret'];
$to = isset($_POST['to']) ? $_POST['to'] : $CONF['photo_hashing_secret'];
//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\">&lt;&lt;</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();
init_session();
$smarty = new GeographPage();
$template = 'statistics_table.tpl';
$u = isset($_GET['u']) && is_numeric($_GET['u']) ? intval($_GET['u']) : $USER->user_id;
$cacheid = 'viewdirection.' . $u;
$smarty->caching = 2;
if (isset($_GET['refresh']) && $USER->hasPerm('admin')) {
    $smarty->clear_cache($template, $cacheid);
}
if (!$smarty->is_cached($template, $cacheid)) {
    $db = NewADOConnection($GLOBALS['DSN']);
    $table = array();
    $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
    $images = $db->getAll("\n\tSELECT\n\t\tgridimage_id\n\tFROM\n\t\tgridimage \n\tWHERE\n\t\tuser_id = {$u}\n\tAND \n\t\tmoderation_status in ('geograph','accepted')\n\tAND\n\t\tviewpoint_eastings > 0 AND viewpoint_northings > 0\n\tAND\n\t\tviewpoint_eastings != nateastings AND viewpoint_northings != natnorthings\n\tLIMIT\n\t\t100\n\t");
    foreach ($images as $i => $row) {
        $image = new GridImage();
        $image->LoadFromId($row['gridimage_id']);
        $image->compact();
        $line = array();
        $line['Square'] = $image->grid_reference;
        $line['Title'] = "<a href=\"/photo/{$row['gridimage_id']}\">{$image->title}</a>";
        $submore4 = $image->grid_square->nateastings > 0;
        $line['Photographer'] = $image->getPhotographerGridref();
        $line['Subject'] = $image->getSubjectGridref();
        $promore4 = $image->photographer_gridref_precision < 1000;
        //mimic the behaviour doen by getNatEastings to place the location in the center of the 1km square
        if (!$promore4) {
            $image->viewpoint_eastings += 500;
            $image->viewpoint_northings += 500;
        }
        $dist = sqrt(pow($image->grid_square->nateastings - $image->viewpoint_eastings, 2) + pow($image->grid_square->natnorthings - $image->viewpoint_northings, 2));
Exemplo n.º 7
0
 require $pathToFiles . 'bb_func_txt.php';
 $logged_admin = $user_id == 1 ? 1 : 0;
 $disbbcode = (isset($_POST['disbbcode']) and $_POST['disbbcode'] == 1 ? 1 : 0);
 $topicTitle2 = stripslashes(textFilter($_POST['topicTitle'], $topic_max_length, $post_word_maxlength, 0, 1, 0, 0));
 $postText2 = stripslashes(textFilter($_POST['postText'], $post_text_maxlength, $post_word_maxlength, 1, $disbbcode, 1, $logged_admin));
 if (empty($CONF['disable_discuss_thumbs']) && preg_match_all('/\\[\\[(\\[?)(\\w{0,3} ?\\d+ ?\\d*)(\\]?)\\]\\]/', $postText2, $g_matches)) {
     $thumb_count = 0;
     foreach ($g_matches[2] as $i => $g_id) {
         if (is_numeric($g_id)) {
             if ($global_thumb_count > $CONF['global_thumb_limit'] || $thumb_count > $CONF['post_thumb_limit']) {
                 $posterText = preg_replace("/\\[?\\[\\[{$g_id}\\]\\]\\]?/", "[[<a href=\"http://{$_SERVER['HTTP_HOST']}/photo/{$g_id}\">{$g_id}</a>]]", $posterText);
             } else {
                 if (!isset($g_image)) {
                     require_once 'geograph/gridimage.class.php';
                     require_once 'geograph/gridsquare.class.php';
                     $g_image = new GridImage();
                 }
                 $ok = $g_image->loadFromId($g_id);
                 if ($ok && $g_image->moderation_status == 'rejected' && (!isset($userRanks[$cc]) || $userRanks[$cc] == 'Member')) {
                     $ok = false;
                 }
                 if ($ok) {
                     if ($g_matches[1][$i]) {
                         $g_img = $g_image->getThumbnail(120, 120, false, true);
                         #$g_img = preg_replace('/alt="(.*?)"/','alt="'.$g_image->grid_reference.' : \1 by '.$g_image->realname.'"',$g_img);
                         $g_title = $g_image->grid_reference . ' : ' . htmlentities($g_image->title) . ' by ' . $g_image->realname;
                         $postText2 = str_replace("[[[{$g_id}]]]", "<a href=\"http://{$_SERVER['HTTP_HOST']}/photo/{$g_id}\" target=\"_blank\" title=\"{$g_title}\">{$g_img}</a>", $postText2);
                     } else {
                         $postText2 = preg_replace("/(?<!\\[)\\[\\[{$g_id}\\]\\]/", "{<a href=\"http://{$_SERVER['HTTP_HOST']}/photo/{$g_id}\" target=\"_blank\">{$g_image->grid_reference} : {$g_image->title}</a>}", $postText2);
                     }
                 }
Exemplo n.º 8
0
     foreach ($breakdowns as &$bdrow) {
         $bdrow['name'] = $MESSAGES['browse']['breakdowns'][$bdrow['type']];
     }
     unset($bdrow);
     $smarty->assign_by_ref('breakdowns', $breakdowns);
     if (rand(1, 10) > 7) {
         $order = "(moderation_status = 'geograph') desc,rand()";
     } else {
         $order = "moderation_status+0 desc,seq_no";
     }
     //find the first geograph
     $sql = "select gi.*,gi.realname as credit_realname,if(gi.realname!='',gi.realname,user.realname) as realname from gridimage as gi inner join user using(user_id) where gridsquare_id={$square->gridsquare_id} \n\t\t\tand moderation_status in ('accepted','geograph') order by {$order} limit 1";
     $rec = $db->GetRow($sql);
     if (count($rec)) {
         $rec['grid_reference'] = $square->grid_reference;
         $image = new GridImage();
         $image->fastInit($rec);
         $smarty->assign_by_ref('image', $image);
     }
 } elseif (!empty($_GET['by'])) {
     $square->totalimagecount = $square->imagecount;
     if (!$db) {
         $db = NewADOConnection($GLOBALS['DSN']);
     }
     $breakdown = array();
     $i = 0;
     if ($_GET['by'] == 'class') {
         $breakdown_title = $MESSAGES['browse']['bdtitle_class'];
         $title = $MESSAGES['browse']['title_class'];
         $all = $db->cacheGetAll($cacheseconds, "SELECT imageclass,count(*) as count,\n\t\t\t\tgridimage_id,title,user_id,gi.realname as credit_realname,if(gi.realname!='',gi.realname,user.realname) as realname,user.realname as user_realname\n\t\t\t\tFROM gridimage gi inner join user using(user_id)\n\t\t\t\tWHERE gridsquare_id = '{$square->gridsquare_id}'\n\t\t\t\tAND {$user_crit} {$custom_where}\n\t\t\t\tGROUP BY imageclass");
         $start = rand(0, max(0, count($all) - 20));
Exemplo n.º 9
0
        $smarty->assign($page);
        if (!empty($page['extract'])) {
            $smarty->assign('meta_description', $page['description']);
        }
        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 (!empty($page['gridimage_id'])) {
            $image = new GridImage();
            $image->loadFromId($page['gridimage_id']);
            if ($image->moderation_status == 'rejected' || $image->moderation_status == 'pending') {
                //clear the image
                $image = false;
            }
            $smarty->assign_by_ref('image', $image);
        }
    } else {
        $template = 'static_404.tpl';
    }
} else {
    $smarty->assign('user_id', $page['user_id']);
    $smarty->assign('url', $page['url']);
}
$types = array('attend' => 'will attend', 'maybe' => 'probably attend', 'not' => 'unable to attend');
<input type="text" name="images" id="images" />
<br />
<input type="submit" name="listsubmit" id="listsubmit" value="Start" />
</p>
</form>
<?php 
set_time_limit(3600 * 24);
if (isset($_POST['listsubmit']) && isset($_POST['images']) && preg_match('/^(\\s*[1-9][0-9]*\\s*,)*\\s*[1-9][0-9]*\\s*$/', $_POST['images'])) {
    require_once 'geograph/gridimage.class.php';
    echo "<h3>Rebuilding gridimage_search from gridimage for the given images</h3>";
    flush();
    $images = explode(',', $_POST['images']);
    foreach ($images as $image) {
        $gridimage_id = intval($image);
        echo "<p>Image {$gridimage_id}: ";
        $gridimage = new GridImage($gridimage_id);
        if ($gridimage->isValid()) {
            $gridimage->updateCachedTables();
            echo "done";
        } else {
            echo "<b>not found</b>";
        }
        echo "</p>";
        flush();
    }
}
if (isset($_POST['recreate'])) {
    die("THIS IS TOO DANGEROUS - exiting for your own safety");
    echo "<h3>Rebuilding gridimage_search from gridimage</h3>";
    flush();
    if ($_POST['use_new']) {
Exemplo n.º 11
0
 * 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 = 'reuse.tpl';
if (isset($_REQUEST['id'])) {
    //initialise message
    require_once 'geograph/gridsquare.class.php';
    require_once 'geograph/gridimage.class.php';
    $image = new GridImage();
    $ok = $image->loadFromId($_REQUEST['id']);
    if (!$ok || $image->moderation_status == 'rejected') {
        //clear the image
        $image = new GridImage();
        header("HTTP/1.0 410 Gone");
        header("Status: 410 Gone");
        $template = "static_404.tpl";
    } else {
        if (isset($_REQUEST['download']) && $_REQUEST['download'] == $image->_getAntiLeechHash()) {
            if (stripos($_SERVER['HTTP_REFERER'], 'seadragon.com') !== FALSE) {
                header("HTTP/1.0 307 Temporary Redirect");
                header("Status: 307 Temporary Redirect");
                header("Location: /photo/" . intval($_REQUEST['id']));
                print "<a href=\"http://{$_SERVER['HTTP_HOST']}/photo/" . intval($_REQUEST['id']) . "\">View image page</a>";
                exit;
            }
            if (in_array(intval($_REQUEST['size']), $CONF['show_sizes'])) {
                $filepath = $image->getImageFromOriginal(intval($_REQUEST['size']), intval($_REQUEST['size']), true);
            } elseif ($_REQUEST['size'] == 'original') {
Exemplo n.º 12
0
 * 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/searchcriteria.class.php';
require_once 'geograph/searchengine.class.php';
require_once 'geograph/gridsquare.class.php';
require_once 'geograph/kmlfile.class.php';
require_once 'geograph/kmlfile2.class.php';
if (isset($_GET['id'])) {
    require_once 'geograph/gridimage.class.php';
    require_once 'geograph/gridsquare.class.php';
    $image = new GridImage();
    $ok = $image->loadFromId($_GET['id']);
    if ($ok && $image->moderation_status == 'rejected') {
        header("HTTP/1.0 410 Gone");
        header("Status: 410 Gone");
    } elseif ($ok) {
        if (strpos($_SERVER["REQUEST_URI"], '/photo/') === FALSE && isset($_GET['id']) || strlen($_GET['id']) !== strlen(intval($_GET['id']))) {
            //keep urls nice and clean - esp. for search engines!
            header("HTTP/1.0 301 Moved Permanently");
            header("Status: 301 Moved Permanently");
            header("Location: /photo/" . intval($_GET['id']) . ".kml");
            print "<a href=\"http://{$_SERVER['HTTP_HOST']}/photo/" . intval($_GET['id']) . ".kml\">View file</a>";
            exit;
        }
        $version42plus = false;
        if ($_GET['new']) {
 /**
  * commit the upload process
  */
 function commit($method = '', $skip_cleanup = false)
 {
     global $USER, $CONF, $memcache;
     if ($this->validUploadId($this->upload_id)) {
         $uploadfile = $this->_pendingJPEG($this->upload_id);
         if (!file_exists($uploadfile)) {
             return "Upload image not found";
         }
     } else {
         return "Must assign upload id";
     }
     if (!is_object($this->square)) {
         return "Must assign square";
     }
     $viewpoint = new GridSquare();
     if ($this->viewpoint_gridreference) {
         $ok = $viewpoint->setByFullGridRef($this->viewpoint_gridreference, true, true, true);
     }
     //get sequence number
     $mkey = $this->square->gridsquare_id;
     $seq_no =& $memcache->name_get('sid', $mkey);
     if (empty($seq_no) && !empty($CONF['use_insertionqueue'])) {
         $seq_no = $this->db->GetOne("select max(seq_no) from gridimage_queue where gridsquare_id={$this->square->gridsquare_id}");
     }
     if (empty($seq_no)) {
         $seq_no = $this->db->GetOne("select max(seq_no) from gridimage where gridsquare_id={$this->square->gridsquare_id}");
     }
     $seq_no = max($seq_no + 1, 0);
     $memcache->name_set('sid', $mkey, $seq_no, false, $memcache->period_long);
     //ftf is zero under image is moderated
     $ftf = 0;
     //get the exif data and set orientation
     $this->reReadExifFile();
     if (!empty($CONF['use_insertionqueue'])) {
         $table = "gridimage_queue";
     } else {
         $table = "gridimage";
     }
     //create record
     // nateasting/natnorthings will only have values if getNatEastings has been called (in this case because setByFullGridRef has been called IF an exact location is specifed)
     $sql = sprintf("insert into {$table} (" . "gridsquare_id, seq_no, user_id, ftf," . "moderation_status,title,comment,title2,comment2,nateastings,natnorthings,natgrlen,imageclass,imagetaken," . "submitted,viewpoint_eastings,viewpoint_northings,viewpoint_grlen,view_direction,use6fig,user_status,realname,reference_index,viewpoint_refindex) values " . "(%d,%d,%d,%d," . "'pending',%s,%s,%s,%s,%d,%d,'%d',%s,%s," . "now(),%d,%d,'%d',%d,%d,%s,%s,'%d','%d')", $this->square->gridsquare_id, $seq_no, $USER->user_id, $ftf, $this->db->Quote($this->title), $this->db->Quote($this->comment), $this->db->Quote($this->title2), $this->db->Quote($this->comment2), $this->square->nateastings, $this->square->natnorthings, $this->square->natgrlen, $this->db->Quote($this->imageclass), $this->db->Quote($this->imagetaken), $viewpoint->nateastings, $viewpoint->natnorthings, $viewpoint->natgrlen, $this->view_direction, $this->use6fig, $this->db->Quote($this->user_status), $this->db->Quote($this->realname), $this->square->reference_index, $viewpoint->reference_index);
     $this->db->Query($sql);
     //get the id
     $gridimage_id = $this->db->Insert_ID();
     //save the exif
     $sql = sprintf("insert into gridimage_exif (" . "gridimage_id,exif) values " . "(%d,%s)", $gridimage_id, $this->db->Quote($exif));
     $this->db->Query($sql);
     //copy image to correct area
     $src = $this->_pendingJPEG($this->upload_id);
     $image = new GridImage();
     $image->gridimage_id = $gridimage_id;
     $image->user_id = $USER->user_id;
     if ($this->clearexif && $CONF['exiftooldir'] !== '') {
         $cmd = sprintf("\"%sexiftool\" -overwrite_original -all= \"%s\" > /dev/null 2>&1", $CONF['exiftooldir'], $src);
         passthru($cmd);
     }
     $storedoriginal = false;
     if ($ok = $image->storeImage($src)) {
         $orginalfile = $this->_originalJPEG($this->upload_id);
         if (file_exists($orginalfile) && $this->largestsize && $this->largestsize > $CONF['img_max_size']) {
             if ($this->switchxy) {
                 list($oheight, $owidth, $otype, $oattr) = getimagesize($orginalfile);
             } else {
                 list($owidth, $oheight, $otype, $oattr) = getimagesize($orginalfile);
             }
             list($destwidth, $destheight, $destdim, $changedim) = $this->_new_size($owidth, $oheight, $this->largestsize);
             $this->_downsizeFile($orginalfile, $destdim);
             if ($this->clearexif && $CONF['exiftooldir'] !== '') {
                 $cmd = sprintf("\"%sexiftool\" -overwrite_original -all= \"%s\" > /dev/null 2>&1", $CONF['exiftooldir'], $orginalfile);
                 passthru($cmd);
             }
             $storedoriginal = $image->storeOriginal($orginalfile);
         }
         if (!$skip_cleanup) {
             $this->cleanUp();
         }
     }
     //fire an event
     require_once 'geograph/event.class.php';
     new Event(EVENT_NEWPHOTO, $gridimage_id . ',' . $USER->user_id . ',' . $storedoriginal);
     #//assign the snippets now we know the real id.
     #$gid = crc32($this->upload_id)+4294967296;
     #$gid += $USER->user_id * 4294967296;
     #
     #$this->db->Execute($sql = "UPDATE gridimage_snippet SET gridimage_id = $gridimage_id WHERE gridimage_id = ".$gid);
     $this->gridimage_id = $gridimage_id;
     #if (!empty($method)) {
     #	if (!empty($GLOBALS['STARTTIME'])) {
     #
     #		list($usec, $sec) = explode(' ',microtime());
     #		$endtime = ((float)$usec + (float)$sec);
     #		$timetaken = $endtime - $GLOBALS['STARTTIME'];
     #
     #		$this->db->Execute("INSERT INTO submission_method SET gridimage_id = $gridimage_id,method='$method',timetaken=$timetaken");
     #	} else {
     #		$this->db->Execute("INSERT INTO submission_method SET gridimage_id = $gridimage_id,method='$method'");
     #	}
     #}
 }
Exemplo n.º 14
0
 * 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/mapmosaic.class.php';
require_once 'geograph/rastermap.class.php';
init_session();
customGZipHandlerStart();
$smarty = new GeographPage();
$template = 'view.tpl';
$cacheid = 0;
$smarty->caching = 0;
//do we have a valid image?
if (!empty($_POST)) {
    $image = new GridImage();
    $image->gridimage_id = 0;
    $image->moderation_status = 'pending';
    $image->submitted = time();
    $image->user_id = $USER->user_id;
    $image->realname = $USER->realname;
    $image->profile_link = "/profile/{$image->user_id}";
    $image->title1 = strip_tags(trim(stripslashes($_POST['title'])));
    $image->comment1 = strip_tags(trim(stripslashes($_POST['comment'])));
    $image->title2 = strip_tags(trim(stripslashes($_POST['title2'])));
    $image->comment2 = strip_tags(trim(stripslashes($_POST['comment2'])));
    $image->title = combineTexts($image->title1, $image->title2);
    $image->comment = combineTexts($image->comment1, $image->comment2);
    $image->imageclass = strip_tags(trim(stripslashes($_POST['imageclass'])));
    if ($image->imageclass == "Other") {
        $image->imageclass = strip_tags(trim(stripslashes($_POST['imageclassother'])));
Exemplo n.º 15
0
    require_once 'geograph/gridimagetroubleticket.class.php';
}
require_once 'geograph/uploadmanager.class.php';
init_session();
$uploadmanager = new UploadManager();
//display preview image?
if (isset($_GET['preview'])) {
    $uploadmanager->outputPreviewImage($_GET['preview']);
    exit;
}
$smarty = new GeographPage();
//you must be logged in to request changes
$USER->mustHavePerm("basic");
$template = 'resubmit.tpl';
$cacheid = '';
$image = new GridImage();
if (isset($_REQUEST['id'])) {
    $image->loadFromId($_REQUEST['id']);
    $isowner = $image->user_id == $USER->user_id ? 1 : 0;
    $isadmin = $USER->hasPerm('ticketmod') ? 1 : 0;
    if ($image->isValid()) {
        if ($isowner || $isadmin) {
            //ok, we'll let it lie...
        } else {
            header("Location: /photo/{$_REQUEST['id']}");
            exit;
        }
        $smarty->assign_by_ref('image', $image);
        if (isset($_POST['finalise'])) {
            if ($uploadmanager->setUploadId($_POST['upload_id'])) {
                $uploadmanager->setLargestSize($_POST['largestsize']);
Exemplo n.º 16
0
    //3hour cache
}
$image = new GridImage();
if (isset($_GET['id'])) {
    $image->loadFromId(intval($_GET['id']));
    $isowner = $image->user_id == $USER->user_id ? 1 : 0;
    $ismoderator = $USER->hasPerm('moderator') ? 1 : 0;
    $ab = floor($_GET['id'] / 10000);
    $cacheid = "img{$ab}|{$_GET['id']}|{$isowner}_{$ismoderator}";
    //is the image rejected? - only the owner and administrator should see it
    if ($image->moderation_status == 'rejected') {
        if ($isowner || $ismoderator) {
            //ok, we'll let it lie...
        } else {
            //clear the image
            $image = new GridImage();
            $cacheid = 0;
            $rejected = true;
        }
    }
}
//do we have a valid image?
if ($image->isValid()) {
    //what style should we use?
    $style = $USER->getStyle();
    $cacheid .= $style;
    //when this image was modified
    $mtime = strtotime($image->upd_timestamp);
    //page is unqiue per user (the profile and links)
    $hash = $cacheid . '.' . $USER->user_id;
    //can't use IF_MODIFIED_SINCE for logged in users as has no concept as uniqueness
Exemplo n.º 17
0
$photos = $db->GetAll($sql = "select \r\n\tgridimage_id,title,title2,gi.realname as credit_realname,if(gi.realname!='',gi.realname,user.realname) as realname,user.user_id,comment,nateastings,natnorthings,natgrlen,view_direction\r\n\tfrom gridimage gi\r\n\t\t inner join user using(user_id)\r\n\twhere {$sql_where}\r\n\torder by null");
foreach ($photos as $id => $entry) {
    $title = combineTexts($entry['title'], $entry['title2']);
    if ($entry['nateastings']) {
        if ($entry['natgrlen'] == 6) {
            $entry['nateastings'] += 50;
            $entry['natnorthings'] += 50;
        }
        list($wgs84_lat, $wgs84_long) = $conv->national_to_wgs84($entry['nateastings'], $entry['natnorthings'], $square->reference_index);
    } else {
        list($wgs84_lat, $wgs84_long) = $conv->internal_to_wgs84($square->x, $square->y, $square->reference_index);
    }
    $point = new kmlPoint($wgs84_lat, $wgs84_long);
    $placemark = new kmlPlacemark_Photo($entry['gridimage_id'], $square->grid_reference . ' :: ' . $title, $point);
    $placemark->useHoverStyle();
    $image = new GridImage();
    $image->fastInit($entry);
    $placemark->useCredit($image->realname, "http://{$_SERVER['HTTP_HOST']}/photo/" . $image->gridimage_id);
    $html .= getHtmlLinkP($placemark->link, $square->grid_reference . ' :: ' . $title . ' by ' . $image->realname);
    $linkTag = "<a href=\"" . $placemark->link . "\">";
    $details = $image->getThumbnail(120, 120, 2);
    $thumb = $details['server'] . $details['url'];
    $thumbTag = $details['html'];
    $description = $linkTag . $thumbTag . "</a><br/>" . GeographLinks($image->comment) . " (" . $linkTag . "view full size</a>)" . "<br/><br/> &copy; Copyright <a title=\"view user profile\" href=\"http://" . $_SERVER['HTTP_HOST'] . $image->profile_link . "\">" . $image->realname . "</a> and licensed for reuse under this <a rel=\"license\" href=\"http://creativecommons.org/licenses/by-sa/2.0/\">Creative Commons Licence</a><br/><br/>";
    $placemark->setItemCDATA('description', $description);
    //yes that is uppercase S!
    $placemark->setItemCDATA('Snippet', strip_tags($description));
    $placemark->useImageAsIcon($thumb);
    if (strlen($entry['view_direction']) && $entry['view_direction'] != -1) {
        $placemark->addViewDirection($entry['view_direction']);
    }
Exemplo n.º 18
0
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=\"recreatethumbs.php\">&lt;&lt;</a> Creating Thumbnails...</h3>";
    flush();
    set_time_limit(3600 * 24);
    $datefrom = makeTimeStamp('datefrom');
    $dateto = makeTimeStamp('dateto');
    $funct = $_GET['function'];
    print "<PRE>";
    print_r($_POST);
    print "</PRE>";
    print "{$datefrom} - {$dateto}<BR>";
    $recordSet =& $db->Execute("select * from gridimage");
    while (!$recordSet->EOF) {
        $image = new GridImage();
        $image->loadFromRecordset($recordSet);
        $oldfile = $image->_getFullpath();
        if (file_exists($_SERVER['DOCUMENT_ROOT'] . $oldfile)) {
            $filedate = filemtime($_SERVER['DOCUMENT_ROOT'] . $oldfile);
            printf("%c = %d %d %d<BR>", $oldfile, $filedate, $filedate - $datefrom, $dateto - $filedate);
            if ($filedate > $datefrom && $filedate <= $dateto) {
                ##			$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>";
Exemplo n.º 19
0
     $smarty->assign("page_title", "Modern Administrative County Centre Points");
     $smarty->assign("start_info", "These are approximate centres for modern administrative counties.");
     $smarty->assign("extra_info", "<div class=\"copyright\">Great Britain locations based upon Ordnance Survey&reg 1:50 000 Scale Gazetteer with the permission of Ordnance Survey on behalf of The Controller of Her Majesty's Stationery Office, &copy; Crown copyright. Educational licence 100045616.</div>");
     $counties = $db->GetAll("select * from os_gaz_county where n > 0 and name not like 'XX%' order by reference_index,n");
 } elseif ($type == 'capital') {
     $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']);
             }
         }
     }
 }
Exemplo n.º 20
0
 if (preg_match('/\\bgs\\b/', $_POST['crit'])) {
     $join .= " inner join gridsquare gs using (gridsquare_id)";
 }
 if (preg_match('/\\bgi\\b/', $_POST['crit'])) {
     $join .= " inner join gridimage gi using (gridsquare_id)";
 }
 if (preg_match('/\\bu\\b/', $_POST['crit'])) {
     $join .= " inner join user u using (user_id)";
 }
 $recordSet =& $db->Execute("select * from {$table} {$join} where {$_POST['crit']} {$limit}");
 if (!empty($_POST['file'])) {
     $handle = fopen($_SERVER['DOCUMENT_ROOT'] . "/rss/placename_updates.sql", 'a') or die("unable to open file");
 }
 while (!$recordSet->EOF) {
     if ($table == 'gridimage') {
         $image = new GridImage();
         $gid = $recordSet->fields['gridimage_id'];
         $image->_initFromArray($recordSet->fields);
         $square = $image->grid_square;
         $extra = ",upd_timestamp = '{$recordSet->fields['upd_timestamp']}'";
         if (!isset($square->nateastings)) {
             $square->getNatEastings();
         }
         //to optimise the query, we scan a square centred on the
         //the required point
         $radius = 30000;
         $places = $square->findNearestPlace($radius);
         $pid = $places['pid'];
     } else {
         $gid = $recordSet->fields['gridsquare_id'];
         #$from_stratch = 1;
$db = NewADOConnection($GLOBALS['DSN']);
if (isset($_GET['check2'])) {
    set_time_limit(3600 * 24);
    //this takes a long time, so we output a header first of all
    $smarty->display('_std_begin.tpl');
    echo "<h3><a href=\"recreatemaps.php\">&lt;&lt;</a> Checking Missing GD images...</h3>";
    flush();
    $base =& $_SERVER['DOCUMENT_ROOT'];
    $size = 40;
    $sql = "select gridsquare_id,grid_reference from gridsquare where imagecount>0";
    $recordSet =& $db->Execute($sql);
    while (!$recordSet->EOF) {
        $sql2 = "select * from gridimage where gridsquare_id={$recordSet->fields['gridsquare_id']} " . "and moderation_status<>'rejected' order by moderation_status+0 desc,seq_no limit 1";
        $recordSet2 =& $db->Execute($sql2);
        if ($recordSet2->fields['gridimage_id']) {
            $image = new GridImage();
            $image->fastInit($recordSet2->fields);
            $yz = sprintf("%02d", floor($this->gridimage_id / 1000000));
            $ab = sprintf("%02d", floor($this->gridimage_id % 1000000 / 10000));
            $cd = sprintf("%02d", floor($image->gridimage_id % 10000 / 100));
            $abcdef = sprintf("%06d", $image->gridimage_id);
            $hash = $image->_getAntiLeechHash();
            $thumbpath = "/geophotos/{$yz}/{$ab}/{$cd}/{$abcdef}_{$hash}_{$size}x{$size}.gd";
            if (!file_exists($base . $thumbpath)) {
                print "Missing GD image for: {$recordSet->fields['grid_reference']}<BR>";
            }
        }
        $recordSet->MoveNext();
        $recordSet2->Close();
    }
    $recordSet->Close();
Exemplo n.º 22
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/gridimage.class.php';
require_once 'geograph/gridsquare.class.php';
require_once 'geograph/gridimagetroubleticket.class.php';
init_session();
$smarty = new GeographPage();
//you must be logged in to request changes
$USER->mustHavePerm("basic");
$template = 'licence.tpl';
$cacheid = '';
$image = new GridImage();
if (isset($_REQUEST['id'])) {
    $image->loadFromId($_REQUEST['id']);
    $isowner = $image->user_id == $USER->user_id ? 1 : 0;
    $isadmin = $USER->hasPerm('ticketmod') ? 1 : 0;
    if ($image->isValid()) {
        if ($isowner || $isadmin) {
            //ok, we'll let it lie...
        } 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') {
Exemplo n.º 23
0
function GeographLinks(&$posterText, $thumbs = false)
{
    global $imageCredits, $CONF, $global_thumb_count;
    //look for [[gridref_or_photoid]] and [[[gridref_or_photoid]]]
    if (preg_match_all('/\\[\\[(\\[?)(\\w{0,3} ?\\d+ ?\\d*)(\\]?)\\]\\]/', $posterText, $g_matches)) {
        $thumb_count = 0;
        foreach ($g_matches[2] as $i => $g_id) {
            //photo id?
            if (is_numeric($g_id)) {
                if ($global_thumb_count > $CONF['global_thumb_limit'] || $thumb_count > $CONF['post_thumb_limit']) {
                    $posterText = preg_replace("/\\[?\\[\\[{$g_id}\\]\\]\\]?/", "[[<a href=\"http://{$_SERVER['HTTP_HOST']}/photo/{$g_id}\">{$g_id}</a>]]", $posterText);
                } else {
                    if (!isset($g_image)) {
                        $g_image = new GridImage();
                    }
                    $ok = $g_image->loadFromId($g_id);
                    if ($g_image->moderation_status == 'rejected') {
                        $posterText = str_replace("[[[{$g_id}]]]", '<img src="/photos/error120.jpg" width="120" height="90" alt="image no longer available"/>', $posterText);
                    } elseif ($ok) {
                        $g_title = $g_image->grid_reference . ' : ' . htmlentities2($g_image->title);
                        if ($g_matches[1][$i]) {
                            if ($thumbs) {
                                $g_title .= ' by ' . htmlentities($g_image->realname);
                                $g_img = $g_image->getThumbnail(120, 120, false, true);
                                $posterText = str_replace("[[[{$g_id}]]]", "<a href=\"http://{$_SERVER['HTTP_HOST']}/photo/{$g_id}\" target=\"_blank\" title=\"{$g_title}\">{$g_img}</a>", $posterText);
                                if (isset($imageCredits[$g_image->realname])) {
                                    $imageCredits[$g_image->realname]++;
                                } else {
                                    $imageCredits[$g_image->realname] = 1;
                                }
                            } else {
                                //we don't place thumbnails in non forum links
                                $posterText = str_replace("[[[{$g_id}]]]", "<a href=\"http://{$_SERVER['HTTP_HOST']}/photo/{$g_id}\">{$g_title}</a>", $posterText);
                            }
                        } else {
                            $posterText = preg_replace("/(?<!\\[)\\[\\[{$g_id}\\]\\]/", "<a href=\"http://{$_SERVER['HTTP_HOST']}/photo/{$g_id}\">{$g_title}</a>", $posterText);
                        }
                    }
                    $global_thumb_count++;
                }
                $thumb_count++;
            } else {
                //link to grid ref
                $posterText = str_replace("[[{$g_id}]]", "<a href=\"http://{$_SERVER['HTTP_HOST']}/gridref/{$g_id}\">" . str_replace(' ', '+', $g_id) . "</a>", $posterText);
            }
        }
    }
    if ($CONF['CONTENT_HOST'] != $_SERVER['HTTP_HOST']) {
        $posterText = str_replace($CONF['CONTENT_HOST'], $_SERVER['HTTP_HOST'], $posterText);
    }
    $posterText = preg_replace('/(?<!["\'>F=])(https?:\\/\\/[\\w\\.-]+\\.\\w{2,}\\/?[\\w\\~\\-\\.\\?\\,=\'\\/\\\\+&%\\$#\\(\\)\\;\\:]*)(?<!\\.)(?!["\'])/e', "smarty_function_external(array('href'=>\"\$1\",'text'=>'Link','nofollow'=>1,'title'=>\"\$1\"))", $posterText);
    $posterText = preg_replace('/(?<![\\/F\\.])(www\\.[\\w\\.-]+\\.\\w{2,}\\/?[\\w\\~\\-\\.\\?\\,=\'\\/\\\\+&%\\$#\\(\\)\\;\\:]*)(?<!\\.)(?!["\'])/e', "smarty_function_external(array('href'=>\"http://\$1\",'text'=>'Link','nofollow'=>1,'title'=>\"\$1\"))", $posterText);
    return $posterText;
}
Exemplo n.º 24
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/imagelist.class.php';
require_once 'geograph/gridsquare.class.php';
require_once 'geograph/gridimage.class.php';
$smarty = new GeographPage();
$template = 'gpx.tpl';
$cacheid = '';
if (isset($_GET['id'])) {
    init_session();
    $image = new GridImage();
    $ok = $image->loadFromId($_GET['id'], true);
    if ($ok) {
        //todo non functionional!
        $template = 'gpx_download_gpx.tpl';
        $cacheid = $image->gridimage_id;
        //regenerate?
        if (!$smarty->is_cached($template, $cacheid)) {
            $searchdesc = "squares within {$d}km of {$square->grid_reference} " . ($_REQUEST['type'] == 'with' ? 'with' : 'without') . " photographs";
            $sql = "SELECT grid_reference,x,y,imagecount {$sql_fields}\n\t\t\tFROM gridsquare gs\n\t\t\tWHERE {$sql_where}\n\t\t\tORDER BY {$sql_order}";
            $db = NewADOConnection($GLOBALS['DSN']);
            if (!$db) {
                die('Database connection failed');
            }
            $data = $db->getAll($sql);
            require_once 'geograph/conversions.class.php';
Exemplo n.º 25
0
    die("the servers are currently very busy - moderation is disabled to allow things to catch up, will be automatically re-enabled when load returns to normal");
}
customGZipHandlerStart();
$db = NewADOConnection($GLOBALS['DSN']);
if (!$db) {
    die('Database connection failed');
}
$smarty = new GeographPage();
//doing some moderating?
if (isset($_GET['gridimage_id'])) {
    //user may have an expired session, or playing silly buggers,
    //either way, we want to check for admin status on the session
    if ($USER->hasPerm('moderator') || isset($_GET['remoderate'])) {
        $gridimage_id = intval($_GET['gridimage_id']);
        $status = $_GET['status'];
        $image = new GridImage();
        if ($image->loadFromId($gridimage_id)) {
            if (isset($_GET['remoderate'])) {
                if ($USER->hasPerm('basic')) {
                    $status = $db->Quote($status);
                    $db->Execute("REPLACE INTO moderation_log SET user_id = {$USER->user_id}, gridimage_id = {$gridimage_id}, new_status={$status}, old_status='{$image->moderation_status}',created=now(),type = 'dummy'");
                    print "classification {$status} recorded";
                } else {
                    echo "NOT LOGGED IN";
                }
            } else {
                //we really need this not be interupted
                ignore_user_abort(TRUE);
                set_time_limit(3600);
                $status2 = $db->Quote($status);
                $db->Execute("INSERT INTO moderation_log SET user_id = {$USER->user_id}, gridimage_id = {$gridimage_id}, new_status={$status2}, old_status='{$image->moderation_status}',created=now(),type = 'real'");
Exemplo n.º 26
0
}
$smarty->register_modifier("colerize", "smarty_modifier_colerize");
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');
    }
    if ($imageid) {
        //initialise message
        require_once 'geograph/gridsquare.class.php';
        require_once 'geograph/gridimage.class.php';
        $image = new GridImage();
        $image->loadFromId($imageid);
        if ($image->moderation_status == 'rejected' || $image->moderation_status == 'pending') {
            //clear the image
            $image = new GridImage();
        } else {
            $smarty->assign_by_ref('image', $image);
        }
    }
    if (!empty($month)) {
        $like = sprintf("%04d-%02d", $year, $month);
        $maximages = 0;
        if (isset($_GET['blank'])) {
            $images = array();
            $smarty->assign('blank', 1);
        } else {
Exemplo n.º 27
0
            $encsubject = mb_encode_mimeheader($CONF['mail_subjectprefix'] . $csubject, $CONF['mail_charset'], $CONF['mail_transferencoding']);
            if (!@mail($from_email, $encsubject, $body, $from . $mime, $envfrom)) {
                @mail($CONF['contact_email'], 'Mail Error Report from ' . $_SERVER['HTTP_HOST'], "Original Subject: {$subject}\n" . "Original To: {$from_email}\n" . "Original From: {$from_name} <{$from_email}>\n" . "Copy of message sent to {$recipient->realname}\n" . "Original Subject:\n\n{$body}", $geofrom . $mime, $envfrom);
                $smarty->assign('error', "<a href=\"/contact.php\">Please let us know</a>");
            }
        }
    }
} elseif (isset($_POST['init'])) {
    //initialise message
    $msg = trim(stripslashes($_POST['init']));
    $smarty->assign_by_ref('msg', $msg);
} elseif (isset($_GET['image'])) {
    //initialise message
    require_once 'geograph/gridsquare.class.php';
    require_once 'geograph/gridimage.class.php';
    $image = new GridImage();
    $image->loadFromId($_GET['image']);
    $msg = $MESSAGES['usermsg']['message_template'];
    if (strpos($recipient->rights, 'mod') !== FALSE) {
        $msg .= " {$image->grid_reference} ({$image->title})\r\nhttp://{$_SERVER['HTTP_HOST']}/editimage.php?id={$image->gridimage_id}\r\n";
    } else {
        $msg .= " {$image->grid_reference} ({$image->title})\r\nhttp://{$_SERVER['HTTP_HOST']}/photo/{$image->gridimage_id}\r\n";
    }
    $smarty->assign_by_ref('msg', $msg);
}
if (preg_match('/(DORMANT|DELETED|@.*geograph\\.org\\.uk|@.*geograph\\.co\\.uk)/i', $recipient->email) || strpos($recipient->rights, 'dormant') !== FALSE) {
    $smarty->assign('invalid_email', 1);
    if ($recipient->public_email) {
        $smarty->assign_by_ref('public_email', $recipient->public_email);
    }
}
Exemplo n.º 28
0
require_once 'geograph/gridimagetroubleticket.class.php';
include_messages('moderation');
init_session();
$db = NewADOConnection($GLOBALS['DSN']);
if (!$db) {
    die('Database connection failed');
}
$smarty = new GeographPage();
//doing some moderating?
if (isset($_POST['gridimage_id'])) {
    //user may have an expired session, or playing silly buggers,
    //either way, we want to check for admin status on the session
    if ($USER->hasPerm('basic')) {
        $gridimage_id = intval($_POST['gridimage_id']);
        $status = $_POST['user_status'];
        $image = new GridImage();
        if ($image->loadFromId($gridimage_id)) {
            if ($image->user_id == $USER->user_id) {
                if ($image->moderation_status == 'rejected') {
                    die("CANT EDIT REJECTED IMAGES");
                }
                switch ($status) {
                    case $MESSAGES['moderation']['geograph'] . ($user_status = ''):
                        break;
                    case $MESSAGES['moderation']['supplemental']:
                        $user_status = 'accepted';
                        break;
                    case $MESSAGES['moderation']['reject']:
                        $user_status = 'rejected';
                        break;
                    default:
Exemplo n.º 29
0
 /**
  * render the the special Random Thumbnail Map (in its many variations)
  * @access private
  */
 function _renderRandomGeographMap()
 {
     $root =& $_SERVER['DOCUMENT_ROOT'];
     //first of all, generate or pull in a cached based map
     $basemap = $this->getBaseMapFilename();
     if ($this->caching && @file_exists($root . $basemap)) {
         //load it up!
         $img = imagecreatefromgd($root . $basemap);
     } else {
         //we need to generate a basemap
         $img =& $this->_createBasemap($root . $basemap);
     }
     $target = $this->getImageFilename();
     $colMarker = imagecolorallocate($img, 255, 0, 0);
     $colBorder = imagecolorallocate($img, 255, 255, 255);
     //figure out what we're mapping in internal coords
     $db =& $this->_getDB();
     $dbImg = NewADOConnection($GLOBALS['DSN']);
     $left = $this->map_x;
     $bottom = $this->map_y;
     $right = $left + floor($this->image_w / $this->pixels_per_km) - 1;
     $top = $bottom + floor($this->image_h / $this->pixels_per_km) - 1;
     //size of a marker in pixels
     $markerpixels = 5;
     //size of marker in km
     $markerkm = ceil($markerpixels / $this->pixels_per_km);
     //we scan for images a little over the edges so that if
     //an image lies on a mosaic edge, we still plot the point
     //on both mosaics
     $overscan = $markerkm;
     $scanleft = $left - $overscan;
     $scanright = $right + $overscan;
     $scanbottom = $bottom - $overscan;
     $scantop = $top + $overscan;
     //plot grid square?
     if ($this->pixels_per_km >= 0) {
         $this->_plotGridLines($img, $scanleft, $scanbottom, $scanright, $scantop, $bottom, $left);
     }
     $imagemap = fopen($root . $target . ".html", "w");
     fwrite($imagemap, "<map name=\"imagemap\">\n");
     $rectangle = "'POLYGON(({$scanleft} {$scanbottom},{$scanright} {$scanbottom},{$scanright} {$scantop},{$scanleft} {$scantop},{$scanleft} {$scanbottom}))'";
     if ($this->type_or_user < -2000) {
         if ($this->type_or_user < -2007) {
             $sql = "select x,y,gi.gridimage_id from gridimage_search gi\n\t\t\twhere \n\t\t\tCONTAINS( GeomFromText({$rectangle}),\tpoint_xy) and imagetaken = '" . $this->type_or_user * -1 . "-12-25'\n\t\t\tand( gi.imageclass LIKE '%christmas%') \n\t\t\torder by rand()";
         } else {
             $sql = "select x,y,gi.gridimage_id from gridimage_search gi\n\t\t\twhere \n\t\t\tCONTAINS( GeomFromText({$rectangle}),\tpoint_xy) and imagetaken = '" . $this->type_or_user * -1 . "-12-25'\n\t\t\t order by ( (gi.title LIKE '%xmas%' OR gi.comment LIKE '%xmas%' OR gi.imageclass LIKE '%xmas%') OR (gi.title LIKE '%christmas%' OR gi.comment LIKE '%christmas%' OR gi.imageclass LIKE '%christmas%') ), rand()";
         }
     } elseif (1) {
         $sql = "select x,y,gi.gridimage_id from gridimage_search gi\n\t\t\twhere \n\t\t\tCONTAINS( GeomFromText({$rectangle}),\tpoint_xy)\n\t\t\tand seq_no = 1 group by FLOOR(x/10),FLOOR(y/10) order by rand() limit 600";
         #inner join gridimage_post gp on (gi.gridimage_id = gp.gridimage_id and gp.topic_id = 1006)
     } elseif (1) {
         $sql = "select x,y,gi.gridimage_id from gridimage_search gi\n\t\t\twhere gridimage_id in (80343,74737,74092,84274,80195,48940,46618,73778,47029,82007,39195,76043,57771,28998,18548,12818,7932,81438,16764,84846,73951,79510,15544,73752,86199,4437,87278,53119,29003,36991,74330,29732,16946,10613,87284,52195,41935,26237,30008,10252,62365,83753,67060,34453,20760,26759,59465,118,12449,4455,46898,12805,87014,401,36956,8098,44193,63206,42732,26145,86473,17469,3323,26989,3324,40212,63829,30948,165,41865,36605,25736,68318,26849,51771,30986,27174,37470,31098,65191,44406,82224,71627,22968,59008,35468,7507,53228,80854,10669,47604,75018,42649,9271,1658,11741,60793,78903,22198,7586,88164,12818,14981,21794,74790,3386,40974,72850,77652,47982,39894,38897,25041,81392,63186,81974,41373,86365,44388,80376,13506,42984,45159,14837,71377,35108,84318,84422,36640,2179,22317,5324,32506,20690,71588,85859,50813,19358,84848,18141,78772,21074,13903,39376,45795,88385,55327,907,37266,82510,78594,17708,84855,7175,85453,23513,18493,68120,26201,18508,32531,84327,88204,55537,41942,47117,22922,22315,46412,88542,46241,67475,63752,63511,98) order by rand()";
     } else {
         $sql = "select x,y,grid_reference from gridsquare where \n\t\t\tCONTAINS( GeomFromText({$rectangle}),\tpoint_xy)\n\t\t\tand imagecount>0 group by FLOOR(x/30),FLOOR(y/30) order by rand() limit 500";
     }
     $usercount = array();
     $recordSet =& $db->Execute($sql);
     $lines = array();
     while (!$recordSet->EOF) {
         $gridx = $recordSet->fields[0];
         $gridy = $recordSet->fields[1];
         $imgx1 = ($gridx - $left) * $this->pixels_per_km;
         $imgy1 = $this->image_h - ($gridy - $bottom + 1) * $this->pixels_per_km;
         $photopixels = 40;
         $imgx1 = round($imgx1) - 0.5 * $photopixels;
         $imgy1 = round($imgy1) - 0.5 * $photopixels;
         $imgx2 = $imgx1 + $photopixels;
         $imgy2 = $imgy1 + $photopixels;
         $gridimage_id = $recordSet->fields[2];
         $sql = "select * from gridimage_search where gridimage_id='{$gridimage_id}' and moderation_status<>'rejected' limit 1";
         //echo "$sql\n";
         $rec = $dbImg->GetRow($sql);
         if (count($rec)) {
             $gridimage = new GridImage();
             $gridimage->fastInit($rec);
             $photo = $gridimage->getSquareThumb($photopixels);
             if (!is_null($photo)) {
                 imagecopy($img, $photo, $imgx1, $imgy1, 0, 0, $photopixels, $photopixels);
                 imagedestroy($photo);
                 imagerectangle($img, $imgx1, $imgy1, $imgx2, $imgy2, $colBorder);
                 $lines[] = "<area shape=\"rect\" coords=\"{$imgx1},{$imgy1},{$imgx2},{$imgy2}\" href=\"/photo/{$rec['gridimage_id']}\" title=\"" . htmlentities("{$rec['grid_reference']} : {$rec['title']} by {$rec['realname']}") . "\">";
             }
             $usercount[$rec['realname']]++;
         }
         $recordSet->MoveNext();
     }
     $recordSet->Close();
     fwrite($imagemap, implode("\n", array_reverse($lines)));
     fwrite($imagemap, "</map>\n");
     fclose($imagemap);
     $h = fopen("imagemap.csv", 'w');
     foreach ($usercount as $user => $uses) {
         fwrite($h, "{$user},{$uses}\n");
     }
     fclose($h);
     if (preg_match('/jpg/', $target)) {
         imagejpeg($img, $root . $target);
     } else {
         imagepng($img, $root . $target);
     }
     imagedestroy($img);
 }
    /**
     * run a standard search via sphinxsearch index
     * NOTE: $this->criteria->getSQLParts(...) needs to have been called before this function to populate sphinx criteria
     * @access private
     */
    function ExecuteSphinxRecordSet($pg)
    {
        global $CONF;
        $db = $this->_getDB();
        extract($this->criteria->sql, EXTR_PREFIX_ALL ^ EXTR_REFS, 'sql');
        $sphinx = new sphinxwrapper($this->criteria->sphinx['query']);
        $this->fullText = 1;
        $sphinx->pageSize = $this->criteria->resultsperpage + 0;
        $page = ($pg - 1) * $sphinx->pageSize;
        if ($page > 1000) {
            //todo - hard-coded 1000 needs autodetecting!
            //lets jump to the last page of 'past results'
            $pg = intval(ceil(1000 / $sphinx->pageSize));
            $this->currentPage = $pg;
        }
        //look for suggestions - this needs to be done before the filters are added - the same filters wont work on the gaz index
        if (isset($GLOBALS['smarty'])) {
            $suggestions = array();
            if (empty($this->countOnly) && $sphinx->q && strlen($sphinx->q) < 64 && empty($this->criteria->sphinx['x'])) {
                $suggestions = $sphinx->didYouMean($sphinx->q);
            } elseif ($this->criteria->searchclass == 'Placename' && strpos($this->criteria->searchdesc, $this->criteria->searchq) == FALSE && (empty($this->criteria->searchtext) || $this->criteria->searchq == $this->criteria->searchtext) && isset($GLOBALS['smarty'])) {
                $suggestions = array(array('gr' => '(anywhere)', 'localities' => 'as text search', 'query' => $this->criteria->searchq));
            }
            if (!empty($this->criteria->searchtext)) {
                if (is_numeric($this->criteria->searchtext)) {
                    require_once 'geograph/gridsquare.class.php';
                    require_once 'geograph/gridimage.class.php';
                    $image = new GridImage();
                    $image->loadFromId($this->criteria->searchtext);
                    if ($image->isValid() && ($image->moderation_status != 'rejected' && $image->moderation_status != 'pending' || $image->user_id == $GLOBALS['USER']->user_id)) {
                        $suggestions += array(array('link' => "/photo/{$image->gridimage_id}", 'gr' => '(anywhere)', 'localities' => "Image by " . htmlentities($image->realname) . ", ID: {$image->gridimage_id}", 'query' => htmlentities2($image->title)));
                    }
                } else {
                    require_once "3rdparty/spellchecker.class.php";
                    $correction = SpellChecker::Correct($this->criteria->searchtext);
                    if ($correction != $this->criteria->searchtext && levenshtein($correction, $this->criteria->searchtext) < 0.25 * strlen($correction)) {
                        $suggestions += array(array('gr' => '(anywhere)', 'localities' => '', 'query' => $correction));
                    }
                }
            }
            if (!empty($suggestions) && count($suggestions)) {
                $GLOBALS['smarty']->assign("suggestions", $suggestions);
            }
        }
        //setup the sphinx wrapper
        if (!empty($this->criteria->sphinx['sort'])) {
            $sphinx->setSort($this->criteria->sphinx['sort']);
        }
        if (empty($this->criteria->sphinx['sort']) || $this->criteria->sphinx['sort'] == '@relevance DESC, @id DESC') {
            if (preg_match('/\\w+/', preg_replace('/(@\\w+ |\\w+:)\\w+/', '', $this->criteria->sphinx['query']))) {
                $this->criteria->searchdesc = str_replace('undefined', 'relevance', $this->criteria->searchdesc);
            } elseif (strlen($this->criteria->sphinx['query'])) {
                #$this->criteria->searchdesc = str_replace(', in undefined order','',$this->criteria->searchdesc);
            }
        }
        if (!empty($this->criteria->sphinx['d'])) {
            $sphinx->setSpatial($this->criteria->sphinx);
        }
        //this step is handled internally by search and setSpatial
        //$sphinx->processQuery();
        if (!empty($CONF['fetch_on_demand'])) {
            $sphinx->upper_limit = $db->getOne("SELECT MAX(gridimage_id) FROM gridimage_search");
        }
        if (is_array($this->criteria->sphinx['filters']) && count($this->criteria->sphinx['filters'])) {
            $sphinx->addFilters($this->criteria->sphinx['filters']);
        }
        //run the sphinx search
        $ids = $sphinx->returnIds($pg, empty($this->criteria->sphinx['exact']) ? '_images' : '_images_exact');
        $this->resultCount = $sphinx->resultCount;
        $this->numberOfPages = $sphinx->numberOfPages;
        $this->maxResults = $sphinx->maxResults;
        $this->islimited = true;
        if (isset($GLOBALS['smarty']) && !empty($sphinx->res['words']) && (count($sphinx->res['words']) > 1 || !$this->resultCount)) {
            $GLOBALS['smarty']->assign("statistics", $sphinx->res['words']);
        }
        if ($this->countOnly || !$this->resultCount) {
            return 0;
        }
        if ($sql_order == ' dist_sqd ') {
            $this->sphinx_matches = $sphinx->res['matches'];
            $sql_fields = ',-1 as dist_sqd';
        }
        // fetch from database
        $id_list = implode(',', $ids);
        if ($this->noCache) {
            $sql = <<<END
/* i{$this->query_id} */ SELECT gi.*,x,y,gs.grid_reference,gi.realname as credit_realname,if(gi.realname!='',gi.realname,user.realname) as realname {$sql_fields}
FROM gridimage AS gi INNER JOIN gridsquare AS gs USING(gridsquare_id)
\tINNER JOIN user ON(gi.user_id=user.user_id)
WHERE gi.gridimage_id IN ({$id_list})
ORDER BY FIELD(gi.gridimage_id,{$id_list})
END;
        } else {
            $sql = "/* i{$this->query_id} */ SELECT gi.* {$sql_fields} FROM gridimage_search as gi WHERE gridimage_id IN ({$id_list}) ORDER BY FIELD(gi.gridimage_id,{$id_list})";
        }
        if (!empty($_GET['debug'])) {
            print "<BR><BR>{$sphinx->q}<BR><BR>{$sql}";
        }
        list($usec, $sec) = explode(' ', microtime());
        $querytime_before = (double) $usec + (double) $sec;
        $recordSet =& $db->Execute($sql);
        list($usec, $sec) = explode(' ', microtime());
        $querytime_after = (double) $usec + (double) $sec;
        if ($this->display == 'excerpt') {
            $docs = array();
            foreach ($ids as $c => $id) {
                $row = $rows[$id];
                $docs[$c] = strip_tags(preg_replace('/<i>.*?<\\/i>/', ' ', $row['post_text']));
            }
            $reply = $sphinx->BuildExcerpts($docs, empty($this->criteria->sphinx['exact']) ? 'gridimage' : 'gi_stemmmed', $sphinx->q);
        }
        $this->querytime = $querytime_after - $querytime_before + $sphinx->query_time;
        //finish off
        if (!empty($recordSet) && empty($_GET['BBOX']) && $this->display != 'reveal') {
            $db->Execute("replace into queries_count set id = {$this->query_id},`count` = {$this->resultCount}");
        }
        return $recordSet;
    }