コード例 #1
0
     }
 }
 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");
 }
コード例 #2
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);
 }
コード例 #3
0
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();
    print "<h3>Done</h3>";
コード例 #4
0
     $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']);
             }
         }
     }
 }
 $smarty->assign_by_ref("results", $results);
コード例 #5
0
ファイル: browse.php プロジェクト: s-a-r-id/geograph-project
         $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));
         $end = $start + 20;
コード例 #6
0
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']);
    }
    $Region = $placemark->addChild('Region');
コード例 #7
0
 /**
  * get image list for particular list
  */
 function getImagesByIdList($ids)
 {
     $sql = "SELECT * FROM gridimage_search WHERE gridimage_id IN(" . join(",", $ids) . ") LIMIT " . count($ids);
     $i = 0;
     if ($sql) {
         $db =& $this->_getDB();
         $prev_fetch_mode = $ADODB_FETCH_MODE;
         $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
         $rows = $db->getAssoc($sql);
         $ADODB_FETCH_MODE = $prev_fetch_mode;
         if (count($rows)) {
             $this->images = array();
             foreach ($ids as $c => $id) {
                 if (!empty($rows[$id])) {
                     $gridimage = new GridImage();
                     $row = array('gridimage_id' => $id) + $rows[$id];
                     $gridimage->fastInit($row);
                     $this->images[] = $gridimage;
                     $i++;
                 }
             }
         }
     }
     return $i;
 }