/**
  * returns an image with appropriate headers
  * @access public
  */
 function returnImage()
 {
     //if thumbs level on depeth map, can just use normal render.
     if ($this->type_or_user == -1 && $this->pixels_per_km > 4) {
         $this->type_or_user = 0;
     }
     $file = $this->getImageFilename();
     $full = $_SERVER['DOCUMENT_ROOT'] . $file;
     if (!$this->caching || !@file_exists($full)) {
         $this->_renderMap();
     }
     if (!@file_exists($full)) {
         $full = $_SERVER['DOCUMENT_ROOT'] . "/maps/errortile.png";
     }
     $type = "image/png";
     if (strpos($full, ".jpg") > 0) {
         $type = "image/jpeg";
     }
     //Last-Modified: Sun, 20 Mar 2005 18:19:58 GMT
     $t = filemtime($full);
     //use the filename as a hash
     //can use if-last-mod as file is not unique per user
     customCacheControl($t, $full, true);
     customExpiresHeader(3600 * 6, true);
     $size = filesize($full);
     header("Content-Type: {$type}");
     header("Content-Size: {$size}");
     header("Content-Length: {$size}");
     //header("Cache-Control: no-store, no-cache, must-revalidate");  // HTTP/1.1
     //header("Cache-Control: post-check=0, pre-check=0", false);
     //header("Pragma: no-cache");
     readfile($full);
 }
    $r = '';
    if (mysql_num_rows($result) > 0) {
        $rows = array();
        while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
            $rows[$row['id']] = $row;
        }
        foreach ($ids as $id) {
            $row = $rows[$id];
            $lines = wordwrap($row['localities'], 50, "\n");
            $row['localities'] = preg_replace("/\n.*/s", '', $lines);
            $r .= join("\t", array_values($row)) . "\n";
        }
        $r .= "\t{$query_info}\t\t\tGreat Britain results (c) Crown copyright Ordnance Survey. All Rights Reserved. 100045616";
    } else {
        $r = "\t--none--";
    }
}
if ($r) {
    if ($encoding) {
        $r = gzencode($r, 9, $encoding == 'gzip' ? FORCE_GZIP : FORCE_DEFLATE);
    }
    customExpiresHeader(3600 * 24 * 24, true);
    if (empty($nocache)) {
        file_put_contents($cachepath, $r);
        $mtime = @filemtime($cachepath);
        customCacheControl($mtime, $cachepath);
    }
    header('Content-length: ' . strlen($r));
    print $r;
}
exit;
    $_GET['days'] = 10;
}
if (!$smarty->is_cached($template, $cacheid)) {
    $db = NewADOConnection($GLOBALS['DSN']);
    if (empty($db)) {
        die('Database connection failed');
    }
    if ($u) {
        $where = "where submitted > date_sub(now(),interval {$_GET['days']} day) and user_id = {$u}";
        $having = isset($_GET['full']) ? '' : 'having cnt>5';
        $table = 'gridimage';
        $smarty->assign('varname', 'catListUser');
        $arr = $db->getCol("select imageclass,count(*) as cnt from {$table} {$where} group by imageclass {$having}");
    } else {
        $where = isset($_GET['full']) ? '' : 'where c>5';
        $table = 'category_stat';
        $smarty->assign('varname', 'catList');
        $arr = $db->getCol("select imageclass,c as cnt from {$table} {$where}");
    }
    $smarty->assign_by_ref('classes', $arr);
}
if ($u) {
    customExpiresHeader(300, false);
} else {
    customExpiresHeader(3600 * 3, true);
}
header("Content-type: text/javascript");
customGZipHandlerStart();
//always turn off debugging, it will break the js
$smarty->debugging = false;
$smarty->display($template, $cacheid);
            //already set
        } elseif (isset($uploadmanager->exifdate)) {
            $smarty->assign('imagetaken', $uploadmanager->exifdate);
            //$smarty->assign('imagetakenmessage', ' ('.$uploadmanager->exifdate.' stated in exif header)');
        } else {
            $smarty->assign('imagetaken', '--');
        }
        if (isset($_SESSION['last_imagetaken'])) {
            $smarty->assign('last_imagetaken', $_SESSION['last_imagetaken']);
        }
        $smarty->assign('today_imagetaken', date("Y-m-d"));
    }
    //which step to display?
    $smarty->assign('step', $step);
    if ($_SERVER['REQUEST_METHOD'] == 'GET') {
        customExpiresHeader(3600, false, true);
    }
} elseif (!empty($_POST['rss'])) {
    $xh = new xmlHandler();
    $nodeNames = array("PHOTO:THUMBNAIL", "PHOTO:IMGSRC", "TITLE");
    $xh->setElementNames($nodeNames);
    $xh->setStartTag("ITEM");
    $xh->setVarsDefault();
    $xh->setXmlParser();
    $xh->setXmlData(stripslashes($_POST['rss']));
    $pData = $xh->xmlParse();
    $smarty->assign_by_ref('pData', array_slice($pData, 0, 10));
} else {
    $template = "puploader_login.tpl";
}
$smarty->display($template, $cacheid);
Exemple #5
0
 }
 /////////////////////////
 //check if we have a cached tile
 $mustgenerate = false;
 if ($memcache->valid && !isset($_GET['refresh'])) {
     $mkey = "{$_GET['l']}:{$e},{$n},{$reference_index},{$widthdist}";
     $lastmod =& $memcache->name_get('tl', $mkey);
     if (!$lastmod) {
         $lastmod = time();
         $mustgenerate = true;
     }
 } else {
     $lastmod = time();
 }
 customCacheControl($lastmod, "{$e},{$n},{$reference_index}");
 customExpiresHeader(86400, true);
 if ($memcache->valid && $mkey && !$mustgenerate) {
     $data =& $memcache->name_get('td', $mkey);
     if ($data) {
         if ($data == 'blank') {
             header("HTTP/1.0 302 Found");
             header("Status: 302 Found");
             header("Location: http://{$CONF['CONTENT_HOST']}/maps/blank.png");
         } else {
             header("Content-Type: image/png");
             print $data;
         }
         exit;
     }
 }
 /////////////////////////
function customNoCacheHeader($type = 'nocache', $disable_auto = false)
{
    //none/nocache/private/private_no_expire/public
    if ($type == 'nocache') {
        header("Cache-Control: no-store, no-cache, must-revalidate");
        // HTTP/1.1
        header("Cache-Control: post-check=0, pre-check=0", false);
        header("Pragma: no-cache");
        customExpiresHeader(-1);
    }
    if ($disable_auto) {
        //call to disable the auto session one, could then call another here if needbe
        session_cache_limiter('none');
    }
}
 /**
  * returns an image with appropriate headers
  * @access public
  */
 function returnImage()
 {
     $mappath = $this->getMapPath($this->service);
     if (!$mappath || !file_exists($mappath)) {
         $expires = strftime("%a, %d %b %Y %H:%M:%S GMT", time() + 604800);
         header("Expires: {$expires}");
         header("Location: /maps/errortile.png");
         exit;
     }
     #there is a suggestion that as we setting an expires, we can do without mod checks (by not sending etag/lastmod), and avoid needless 304's
     #//Last-Modified: Sun, 20 Mar 2005 18:19:58 GMT
     #$t=filemtime($mappath);
     #//use the filename as a hash (md5'ed)
     #//can use if-last-mod as file is not unique per user
     #customCacheControl($t,$mappath,true);
     customExpiresHeader(604800, true);
     header("Content-Type: image/png");
     $size = filesize($mappath);
     header("Content-Size: {$size}");
     header("Content-Length: {$size}");
     readfile($mappath);
 }
 /**
  * @since 1.4
  * @access private
  */
 function _redirect($filename)
 {
     //uses Geograph specific functions, get them seperatly or just comment out.
     $mtime = filemtime($filename);
     customCacheControl($mtime, $mtime);
     $timeout = 3600;
     if (!empty($GLOBALS['rss_timeout'])) {
         $timeout = $GLOBALS['rss_timeout'];
     }
     customExpiresHeader($timeout - (time() - $mtime), true);
     //end;
     if ($filesize = filesize($filename)) {
         header('Content-Length: ' . $filesize);
     }
     Header("Content-Type: " . $this->contentType . "; charset=" . $this->encoding);
     if (preg_match("/\\.(kml|gpx)\$/", $filename)) {
         Header("Content-Disposition: attachment; filename=" . basename($filename));
     } else {
         Header("Content-Disposition: inline; filename=" . basename($filename));
     }
     readfile($filename, "r");
     die;
 }
 /**
  * outputs jpeg data for upload id $id and exits
  */
 function outputPreviewImage($id)
 {
     global $USER;
     $err = "";
     if ($this->validUploadId($id)) {
         $uploadfile = $this->_pendingJPEG($id);
         if (file_exists($uploadfile)) {
             customExpiresHeader(3600 * 48);
             header("Content-Type:image/jpeg");
             readfile($uploadfile);
             exit;
         } else {
             $err = "Upload image not found";
         }
     } else {
         $err = "Bad preview id";
     }
     //generate an error message image if we reach here///
     $im = imagecreate(320, 240);
     $bgc = imagecolorallocate($im, 255, 255, 255);
     $tc = imagecolorallocate($im, 0, 0, 0);
     imagefilledrectangle($im, 0, 0, 320, 240, $bgc);
     imagestring($im, 1, 5, 5, $err, $tc);
     imagejpeg($im);
     imagedestroy($im);
     exit;
 }
Exemple #10
0
 function beginResponse($skip = null)
 {
     customGZipHandlerStart();
     if ($this->output == 'json') {
         if (!empty($this->callback)) {
             customExpiresHeader(3600 * 24, true, true);
             echo "{$this->callback}(";
         } else {
             customExpiresHeader(360, true, true);
         }
     } else {
         customExpiresHeader(360, true, true);
         header("Content-Type:text/xml");
         echo '<?xml version="1.0" encoding="UTF-8"?>';
         if (empty($skip)) {
             echo '<geograph>';
         }
     }
 }