コード例 #1
0
$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);
$ok = true;
コード例 #2
0
}
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'");
                $info = $image->setModerationStatus($status, $USER->user_id);
コード例 #3
0
ファイル: usermsg.php プロジェクト: s-a-r-id/geograph-project
            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);
    }
}
$smarty->display($template);
コード例 #4
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);
                     }
                 }
                 $global_thumb_count++;
             }
コード例 #5
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;
}
コード例 #6
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 {
            if (isset($_GET['both'])) {
コード例 #7
0
ファイル: view.php プロジェクト: s-a-r-id/geograph-project
    header("Location: /");
    exit;
}
customGZipHandlerStart();
$smarty = new GeographPage();
$template = 'view.tpl';
$cacheid = 0;
if ($smarty->caching) {
    $smarty->caching = 2;
    // lifetime is per cache
    $smarty->cache_lifetime = 3600 * 3;
    //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;
        }
    }
コード例 #8
0
ファイル: event.php プロジェクト: s-a-r-id/geograph-project
        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');
$prev_fetch_mode = $ADODB_FETCH_MODE;
コード例 #9
0
ファイル: gpx.php プロジェクト: s-a-r-id/geograph-project
 * 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';
            $conv = new Conversions();
コード例 #10
0
ファイル: reuse.php プロジェクト: s-a-r-id/geograph-project
 * 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 = '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;
            }
コード例 #11
0
ファイル: kml.php プロジェクト: s-a-r-id/geograph-project
 * 
 * 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']) {
            $version42plus = true;
コード例 #12
0
    /**
     * 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;
    }
コード例 #13
0
ファイル: places.php プロジェクト: s-a-r-id/geograph-project
        } elseif ($_GET['ri'] == 1) {
            $sql = "SELECT REPLACE(REPLACE(REPLACE(REPLACE(os_gaz_county.name,'&','_'),',','_'),'-','_'),' ','_') as adm1,\n\t\t\tos_gaz_county.name as name,placename_id,full_name,\n\t\t\tsum(gridimage_os_gaz.c) as images,count(distinct (placename_id)) as places,gridimage_id \n\t\t\tFROM gridimage_os_gaz INNER JOIN os_gaz_county USING (co_code)\n\t\t\tGROUP BY co_code\n\t\t\tORDER BY name";
            $counts = $db->GetAssoc($sql);
            unset($counts['XXXXXXXX']);
            //not a real county
            $smarty->assign_by_ref('counts', $counts);
        } else {
            $sql = "SELECT concat(gridimage_loc_placenames.country,'-',gridimage_loc_placenames.adm1) as adm1,coalesce(loc_adm1.name,'Northern Ireland') as name,\n\t\t\tplacename_id,full_name,\n\t\t\tsum(gridimage_loc_placenames.c) as images,count(distinct (placename_id)) as places,gridimage_id \n\t\t\tFROM gridimage_loc_placenames\n\t\t\tLEFT JOIN loc_adm1 ON(loc_adm1.adm1 = gridimage_loc_placenames.adm1 AND loc_adm1.country = gridimage_loc_placenames.country)\n\t\t\tGROUP BY adm1";
            $counts = $db->GetAssoc($sql);
            unset($counts['0']);
            //adm1 0 is bogus!
            $smarty->assign_by_ref('counts', $counts);
        }
        if (count($counts)) {
            $key = array_rand($counts, 1);
            $val = $counts[$key];
            $image = new GridImage();
            if ($image->loadFromId($val['gridimage_id'], true)) {
                $image->county = $val['name'];
                $image->placename = $val['full_name'];
                $smarty->assign_by_ref('image', $image);
            }
        }
    } else {
        $sql = "SELECT reference_index,count(*) as c \n\t\tFROM gridimage_search\n\t\tGROUP BY reference_index";
        $counts = $db->GetAssoc($sql);
        $smarty->assign_by_ref('counts', $counts);
    }
    $smarty->assign_by_ref('references', $CONF['references']);
}
$smarty->display($template, $cacheid);
コード例 #14
0
ファイル: restapi.php プロジェクト: s-a-r-id/geograph-project
 function handlePhoto()
 {
     $gridimage_id = intval($this->params[0]);
     $_GET['key'] = $this->params[1];
     $image = new GridImage();
     if ($image->loadFromId($gridimage_id, 1)) {
         #FIXME title1,title2,comment1,comment2
         if ($image->moderation_status == 'geograph' || $image->moderation_status == 'accepted') {
             $this->beginResponse();
             if ($this->output == 'json') {
                 require_once '3rdparty/JSON.php';
                 $json = new Services_JSON();
                 $obj = new EmptyClass();
                 $obj->title = $image->title;
                 $obj->grid_reference = $image->grid_reference;
                 $obj->profile_link = $image->profile_link;
                 $obj->realname = $image->realname;
                 $details = $image->getThumbnail(120, 120, 2);
                 $obj->imgserver = $details['server'];
                 $obj->thumbnail = $details['url'];
                 $obj->image = $image->_getFullpath();
                 $obj->sizeinfo = $image->_getFullSize();
                 $obj->sizeinfo[3] = "0";
                 $obj->taken = $image->imagetaken;
                 $obj->submitted = strtotime($image->submitted);
                 $obj->category = $image->category;
                 $obj->comment = $image->comment;
                 $obj->wgs84_lat = $image->wgs84_lat;
                 $obj->wgs84_long = $image->wgs84_long;
                 print $json->encode($obj);
             } else {
                 echo '<status state="ok"/>';
                 echo '<title>' . xmlentities($image->title) . '</title>';
                 echo '<gridref>' . htmlentities($image->grid_reference) . '</gridref>';
                 echo "<user profile=\"http://{$_SERVER['HTTP_HOST']}{$image->profile_link}\">" . xmlentities($image->realname) . '</user>';
                 echo preg_replace('/alt=".*?" /', '', $image->getFull());
                 $details = $image->getThumbnail(120, 120, 2);
                 echo '<thumbnail>' . $details['server'] . $details['url'] . '</thumbnail>';
                 echo '<taken>' . htmlentities($image->imagetaken) . '</taken>';
                 echo '<submitted>' . htmlentities($image->submitted) . '</submitted>';
                 echo '<category>' . xmlentities($image->imageclass) . '</category>';
                 echo '<comment><![CDATA[' . xmlentities($image->comment) . ']]></comment>';
                 $size = $image->_getFullSize();
                 //uses cached_size
                 if (!empty($size[4])) {
                     echo "<original width=\"{$size[4]}\" height=\"{$size[5]}\"/>";
                 }
             }
             $this->endResponse();
         } else {
             $this->error("Image {$gridimage_id} unavailable ({$image->moderation_status})");
         }
     } else {
         $this->error("Invalid image id {$gridimage_id}");
     }
 }