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;
 }
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;
}
         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);
                     }
                 }
                 $global_thumb_count++;
             }
             $thumb_count++;
         } else {
             $postText2 = str_replace("[[{$g_id}]]", "<a href=\"http://{$_SERVER['HTTP_HOST']}/gridref/" . str_replace(' ', '+', $g_id) . "\" target=\"_blank\">{$g_id}</a>", $postText2);
         }
     }
 }
         $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');
 $Region->setPoint($point, 0.01);
 $delta = $entry['gridimage_id'] % 30;
 $Region->setLod(1200 + $delta * $delta, -1);
 $Region->setFadeExtent(100, 0);
示例#5
0
 function handleGridref($more = false)
 {
     $square = new GridSquare();
     $grid_given = true;
     $grid_ok = $square->setByFullGridRef($this->params[0]);
     $_GET['key'] = $this->params[1];
     ini_set('memory_limit', '64M');
     $image = new GridImage();
     if ($grid_ok) {
         $this->beginResponse();
         if ($square->imagecount) {
             if (!empty($_GET['limit']) || !empty($_GET['offset'])) {
                 $offset = @intval($_GET['offset']);
                 $limit = empty($_GET['limit']) ? 20 : intval($_GET['limit']);
                 $order = "order by null limit {$offset},{$limit}";
             } else {
                 $order = "order by null";
             }
             $images = $square->getImages(false, '', $order);
             $count = count($images);
             if ($this->output == 'json') {
                 require_once '3rdparty/JSON.php';
                 $json = new Services_JSON();
                 $whitelist = array('gridimage_id' => 1, 'seq_no' => 1, 'user_id' => 1, 'ftf' => 1, 'moderation_status' => 1, 'title' => 1, 'comment' => 1, 'submitted' => 1, 'realname' => 1, 'nateastings' => 1, 'natnorthings' => 1, 'natgrlen' => 1, 'imageclass' => 1, 'imagetaken' => 1, 'upd_timestamp' => 1, 'viewpoint_eastings' => 1, 'viewpoint_northings' => 1, 'viewpoint_grlen' => 1, 'view_direction' => 1, 'use6fig' => 1, 'credit_realname' => 1, 'profile_link' => 1);
                 #$whitelist = array('gridimage_id'=>1, 'seq_no'=>1, 'user_id'=>1, 'ftf'=>1, 'moderation_status'=>1, 'title'=>1, 'comment'=>1, 'submitted'=>1, 'realname'=>1, 'tags'=>1, 'nateastings'=>1, 'natnorthings'=>1, 'natgrlen'=>1, 'imageclass'=>1, 'imagetaken'=>1, 'upd_timestamp'=>1, 'viewpoint_eastings'=>1, 'viewpoint_northings'=>1, 'viewpoint_grlen'=>1, 'view_direction'=>1, 'use6fig'=>1, 'credit_realname'=>1, 'profile_link'=>1);
                 #FIXME title1,title2,comment1,comment2
                 foreach ($images as $i => $image) {
                     foreach ($image as $k => $v) {
                         if (empty($v) || empty($whitelist[$k])) {
                             unset($images[$i]->{$k});
                         }
                     }
                     $images[$i]->thumbnail = $image->getThumbnail(120, 120, true);
                 }
                 print $json->encode($images);
             } else {
                 echo '<status state="ok" count="' . $count . '"/>';
                 #FIXME title1,title2,comment1,comment2
                 foreach ($images as $i => $image) {
                     if ($image->moderation_status == 'geograph' || $image->moderation_status == 'accepted') {
                         echo " <image url=\"http://{$_SERVER['HTTP_HOST']}/photo/{$image->gridimage_id}\">";
                         echo ' <title>' . utf8_encode(htmlentities($image->title)) . '</title>';
                         echo " <user profile=\"http://{$_SERVER['HTTP_HOST']}{$image->profile_link}\">" . utf8_encode(htmlentities($image->realname)) . '</user>';
                         echo ' ' . preg_replace('/alt=".*?" /', '', $image->getThumbnail(120, 120));
                         if ($more) {
                             echo '<taken>' . htmlentities($image->imagetaken) . '</taken>';
                             echo '<submitted>' . htmlentities($image->submitted) . '</submitted>';
                             echo '<category>' . utf8_encode(htmlentities2($image->imageclass)) . '</category>';
                             echo '<comment><![CDATA[' . utf8_encode(htmlentities2($image->comment)) . ']]></comment>';
                             echo '<view_direction>' . htmlentities($image->view_direction) . '</view_direction>';
                         }
                         echo ' <location grid="' . $square->reference_index . '" eastings="' . $image->nateastings . '" northings="' . $image->natnorthings . '" figures="' . $image->natgrlen . '"/>';
                         echo '</image>';
                     }
                 }
             }
         } else {
             if ($this->output == 'json') {
                 print "{error: '0 results'}";
             } else {
                 echo '<status state="ok" count="0"/>';
             }
         }
         $this->endResponse();
     } else {
         $this->error("Invalid grid reference " . $this->params[0]);
     }
 }