Beispiel #1
0
function getPhotos()
{
    global $config;
    $dbPhotos = getAllPhotos();
    foreach ($dbPhotos as $p) {
        $p->photo_path = $config["photoDir"] . $p->photo_path;
        $photos[] = array("id" => $config["fotoramaIdPrefix"] . $p->id, "img" => $p->photo_path, "caption" => $p->caption, "url" => $p->url);
    }
    $json = json_encode($photos);
    return $json;
}
Beispiel #2
0
     # Functions returns the list of photos
     global $newWidth;
     global $newHeight;
     # Get photos that do not have a medium size photo
     $query = Database::prepare(Database::get(), "SELECT id, width, height, url, medium FROM ? WHERE medium=0 AND (width > ? OR height > ?)", array(LYCHEE_TABLE_PHOTOS, $newWidth, $newHeight));
     $photos = Database::get()->query($query);
     $data = array();
     while ($photo = $photos->fetch_assoc()) {
         # Parse photo
         $photo['filename'] = $photo['url'];
         $photo['url'] = LYCHEE_URL_UPLOADS_BIG . $photo['url'];
         $data[] = $photo;
     }
     return $data;
 }
 $photos = getAllPhotos();
 if (empty($photos)) {
     exit('done :)');
 }
 # for each photo we create the medium size photo
 # when reached the maximum number of photo, we reload the page
 foreach ($photos as $photo) {
     if (createMedium($photo['url'], $photo['filename'], $photo['width'], $photo['height'])) {
         $query = Database::prepare(Database::get(), "UPDATE ? SET medium=1 WHERE id=?", array(LYCHEE_TABLE_PHOTOS, $photo['id']));
         $result = Database::get()->query($query);
         echo 'success: ' . $photo['id'] . ' ' . $photo['filename'] . "\n";
     } else {
         exit('error:   ' . $photo['id'] . ' ' . $photo['filename']);
     }
     $maxPhoto -= 1;
     if ($maxPhoto == 0 || count($photos) - (4 - $maxPhoto) == 0) {