$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\"><<</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(); $smarty->display('_std_end.tpl'); exit; }
$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') { $filepath = $image->_getOriginalpath(); } else { $filepath = $image->_getFullpath(); } $filename = basename($filepath); $filename = "geograph-" . preg_replace('/_\\w+(\\.jpg)/', " by {$image->realname}\$1", $filename); $filename = preg_replace('/ /', '-', trim($filename)); $filename = preg_replace('/[^\\w-\\.,]+/', '', $filename); $lastmod = filemtime($_SERVER['DOCUMENT_ROOT'] . $filepath); header("Content-Type: image/jpeg"); header("Content-Disposition: attachment; filename=\"{$filename}\""); customExpiresHeader(86400, true); customCacheControl($lastmod, $image->gridimage_id); readfile($_SERVER['DOCUMENT_ROOT'] . $filepath); exit; } $smarty->assign_by_ref('msg', $msg); require_once 'geograph/conversions.class.php';
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}"); } }
$description = $linkTag . $thumbTag . "</a><br/>" . GeographLinks($image->comment) . " (" . $linkTag . "view full size</a>)" . "<br/><br/> © 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->setItem('visibility', 1); $placemark->useImageAsIcon($thumb); if (!empty($image->imagetaken) && strpos($image->imagetaken, '-00') === FALSE) { $placemark->setTimeStamp(str_replace('-00', '', $image->imagetaken)); } $different_square_true = intval($image->nateastings / 1000) != intval($image->viewpoint_eastings / 1000) || intval($image->natnorthings / 1000) != intval($image->viewpoint_northings / 1000); $show_viewpoint = intval($image->viewpoint_grlen) > 4 || $different_square_true && $image->viewpoint_grlen == '4'; if ($image->viewpoint_eastings && $show_viewpoint) { list($line['eLat'], $line['eLong']) = $conv->national_to_wgs84($image->viewpoint_eastings, $image->viewpoint_northings, $image->grid_square->reference_index); $point2 = new kmlPoint($line['eLat'], $line['eLong']); if ($version42plus) { $placemark->addPhotographerPhoto($point2, $image->view_direction, $image->realname, $image->_getFullpath(true, true)); } else { $placemark->addPhotographerPoint($point2, $image->view_direction, $image->realname); } } elseif (isset($image->view_direction) && strlen($image->view_direction) && $image->view_direction != -1) { $placemark->addViewDirection($image->view_direction); } $kml->outputKML(); } else { header("HTTP/1.0 404 Not Found"); header("Status: 404 Not Found"); } exit; } init_session(); $smarty = new GeographPage();
list($destwidth, $destheight, $destdim, $changedim) = $uploadmanager->_new_size($image->original_width, $image->original_height, $cursize); if (!$changedim) { break; } $sizes[] = $cursize; $widths[] = $destwidth; $heights[] = $destheight; $maxdim = $destdim; } $maxdim = max($image->original_width, $image->original_height); } } else { $maxdim = max($imagesize[0], $imagesize[1]); } $smarty->assign('sizes', $sizes); $smarty->assign('widths', $widths); $smarty->assign('heights', $heights); $smarty->assign('stdsize', $CONF['img_max_size']); $smarty->assign('showorig', $showorig); $smarty->assign('ratio', $maxdim / $CONF['prev_size']); $smarty->assign('preview_width', $imagesize[0]); $smarty->assign('preview_height', $imagesize[1]); $smarty->assign('preview_url', $image->_getFullpath()); } $smarty->assign_by_ref('image', $image); } else { header("HTTP/1.0 404 Not Found"); header("Status: 404 Not Found"); $template = "static_404.tpl"; } $smarty->display($template);