Skip to content

Instantly share code, notes, and snippets.

@imjacobclark
Created June 23, 2012 13:23
Show Gist options
  • Save imjacobclark/2978295 to your computer and use it in GitHub Desktop.
Save imjacobclark/2978295 to your computer and use it in GitHub Desktop.
<?php
try {
$posted_id = $_GET['unique_id'];
$conn = new Mongo;
$db = $conn->thundergallery;
$grid = $db->getGridFS();
$file = $grid->findOne(array('unique_id' => $posted_id));
echo $file->getBytes();
exit;
$conn->close();
}catch(MongoConnectionException $e){
die('Error connecting to MongoDB server');
}catch(MongoException $e){
die('Error: ' . $e->getMessage());
}
?>
<?php
require 'lib.php';
$connect = new Gallery();
$uniqueID = $connect->uniqueID();
$getImages = $connect->getImage();
?>
<?php
class Gallery extends Mongo{
public $unique_id;
function uniqueID(){
$db = $this->thundergallery;
$collection = $db->images;
$cursor = $collection->find();
foreach ($cursor as $obj) {
$unique_id = $obj['unique_id'];
echo " <a href='getimage.php?unique_id=".$unique_id."' class='lightbox_trigger'><img height='100px' width='100px' src='getimage.php?unique_id=".$unique_id."'></a> ";
}
}
function getImage(){
global $unique_id;
$unique_id = $_GET['unique_id'];
$db = $this->thundergallery;
$grid = $db->getGridFS();
$file = $grid->findOne(array('unique_id' => $unique_id));
//echo $file->getBytes();
exit;
$conn->close();
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment