Created
June 23, 2012 13:23
-
-
Save imjacobclark/2978295 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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()); | |
} | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require 'lib.php'; | |
$connect = new Gallery(); | |
$uniqueID = $connect->uniqueID(); | |
$getImages = $connect->getImage(); | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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