diff options
Diffstat (limited to 'apps/gallery')
-rw-r--r-- | apps/gallery/ajax/cover.php | 7 | ||||
-rw-r--r-- | apps/gallery/ajax/createAlbum.php | 9 | ||||
-rw-r--r-- | apps/gallery/ajax/getAlbums.php | 9 | ||||
-rw-r--r-- | apps/gallery/ajax/getCovers.php | 13 | ||||
-rw-r--r-- | apps/gallery/ajax/scanForAlbums.php | 11 | ||||
-rw-r--r-- | apps/gallery/ajax/thumbnail.php | 7 | ||||
-rw-r--r-- | apps/gallery/appinfo/app.php | 4 | ||||
-rw-r--r-- | apps/gallery/index.php | 1 |
8 files changed, 25 insertions, 36 deletions
diff --git a/apps/gallery/ajax/cover.php b/apps/gallery/ajax/cover.php index 44d73028510..d83f4daaa52 100644 --- a/apps/gallery/ajax/cover.php +++ b/apps/gallery/ajax/cover.php @@ -1,5 +1,7 @@ <?php require_once('../../../lib/base.php'); +OC_JSON::checkLoggedIn(); +OC_JSON::checkAppEnabled('gallery'); function CroppedThumbnail($imgSrc,$thumbnail_width,$thumbnail_height) { //$imgSrc is a FILE - Returns an image resource. //getting the image dimensions @@ -36,11 +38,6 @@ function CroppedThumbnail($imgSrc,$thumbnail_width,$thumbnail_height) { //$imgSr return $thumb; } -// Check if we are a user -if( !OC_User::isLoggedIn()){ - echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => 'You need to log in.'))); - exit(); -} $box_size = 200; $album_name = $_GET['album']; $x = $_GET['x']; diff --git a/apps/gallery/ajax/createAlbum.php b/apps/gallery/ajax/createAlbum.php index 3a490bdc3bd..610f761b72a 100644 --- a/apps/gallery/ajax/createAlbum.php +++ b/apps/gallery/ajax/createAlbum.php @@ -1,14 +1,11 @@ <?php require_once('../../../lib/base.php'); - -if( !OC_User::isLoggedIn()){ - echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => 'You need to log in.'))); - exit(); -} +OC_JSON::checkLoggedIn(); +OC_JSON::checkAppEnabled('gallery'); $stmt = OC_DB::prepare('INSERT INTO *PREFIX*gallery_albums ("uid_owner", "album_name") VALUES ("'.OC_User::getUser().'", "'.$_GET['album_name'].'")'); $stmt->execute(array()); -echo json_encode(array( 'status' => 'success', 'name' => $_GET['album_name'])); +OC_JSON::success(array('name' => $_GET['album_name'])); ?> diff --git a/apps/gallery/ajax/getAlbums.php b/apps/gallery/ajax/getAlbums.php index 2829dae81f3..38bea74636f 100644 --- a/apps/gallery/ajax/getAlbums.php +++ b/apps/gallery/ajax/getAlbums.php @@ -1,10 +1,7 @@ <?php require_once('../../../lib/base.php'); - -if (!OC_User::IsLoggedIn()) { - echo json_encode(array('status' => 'error', 'message' => 'You need to log in')); - exit(); -} +OC_JSON::checkLoggedIn(); +OC_JSON::checkAppEnabled('gallery'); $a = array(); $stmt = OC_DB::prepare('SELECT * FROM *PREFIX*gallery_albums WHERE `uid_owner` = ?'); @@ -17,6 +14,6 @@ while ($r = $result->fetchRow()) { $a[] = array('name' => $album_name, 'numOfItems' => min($tmp_res->numRows(), 10)); } -echo json_encode(array('status'=>'success', 'albums'=>$a)); +OC_JSON::success(array('albums'=>$a)); ?> diff --git a/apps/gallery/ajax/getCovers.php b/apps/gallery/ajax/getCovers.php index 57737f2fdd6..d84bf2a7903 100644 --- a/apps/gallery/ajax/getCovers.php +++ b/apps/gallery/ajax/getCovers.php @@ -1,5 +1,7 @@ <?php require_once('../../../lib/base.php'); +OC_JSON::checkLoggedIn(); +OC_JSON::checkAppEnabled('gallery'); function CroppedThumbnail($imgSrc,$thumbnail_width,$thumbnail_height, $tgtImg, $shift) { //getting the image dimensions @@ -38,11 +40,6 @@ function CroppedThumbnail($imgSrc,$thumbnail_width,$thumbnail_height, $tgtImg, $ imagedestroy($myImage); } -// Check if we are a user -if( !OC_User::isLoggedIn()){ - echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => 'You need to log in.'))); - exit(); -} $box_size = 200; $album_name= $_GET['album_name']; @@ -61,6 +58,12 @@ while (($i = $result->fetchRow()) && $counter < $numOfItems) { header('Content-Type: image/png'); +$offset = 3600 * 24; +// calc the string in GMT not localtime and add the offset +header("Expires: " . gmdate("D, d M Y H:i:s", time() + $offset) . " GMT"); +header('Cache-Control: max-age=3600, must-revalidate'); +header('Pragma: public'); + imagepng($targetImg); imagedestroy($targetImg); ?> diff --git a/apps/gallery/ajax/scanForAlbums.php b/apps/gallery/ajax/scanForAlbums.php index a04ad62b1bf..de0b141a367 100644 --- a/apps/gallery/ajax/scanForAlbums.php +++ b/apps/gallery/ajax/scanForAlbums.php @@ -1,14 +1,11 @@ <?php require_once('../../../lib/base.php'); +OC_JSON::checkLoggedIn(); +OC_JSON::checkAppEnabled('gallery'); require_once('../lib_scanner.php'); -if (!OC_User::IsLoggedIn()) { - echo json_encode(array('status' => 'error', 'message' => 'You need to log in')); - exit(); -} - -echo json_encode(array( 'status' => 'success', 'albums' => OC_GALLERY_SCANNER::scan(''))); -//echo json_encode(array('status' => 'success', 'albums' => array(array('name' => 'test', 'imagesCount' => 1, 'images' => array('dupa'))))); +OC_JSON::success(array('albums' => OC_GALLERY_SCANNER::scan(''))); +//OC_JSON::success(array('albums' => array(array('name' => 'test', 'imagesCount' => 1, 'images' => array('dupa'))))); ?> diff --git a/apps/gallery/ajax/thumbnail.php b/apps/gallery/ajax/thumbnail.php index db428eeff34..f24782390f6 100644 --- a/apps/gallery/ajax/thumbnail.php +++ b/apps/gallery/ajax/thumbnail.php @@ -1,5 +1,7 @@ <?php require_once('../../../lib/base.php'); +OC_JSON::checkLoggedIn(); +OC_JSON::checkAppEnabled('gallery'); function CroppedThumbnail($imgSrc,$thumbnail_width,$thumbnail_height) { //$imgSrc is a FILE - Returns an image resource. //getting the image dimensions @@ -40,11 +42,6 @@ function CroppedThumbnail($imgSrc,$thumbnail_width,$thumbnail_height) { //$imgSr return $thumb; } -// Check if we are a user -if( !OC_User::isLoggedIn()){ - echo json_encode( array( 'status' => 'error', 'data' => array( 'message' => 'You need to log in.'))); - exit(); -} $box_size = 200; $img = $_GET['img']; diff --git a/apps/gallery/appinfo/app.php b/apps/gallery/appinfo/app.php index 5760bb149d8..8f855c470e5 100644 --- a/apps/gallery/appinfo/app.php +++ b/apps/gallery/appinfo/app.php @@ -8,7 +8,7 @@ OC_App::addNavigationEntry( array( 'id' => 'gallery_index', 'order' => 20, 'href' => OC_Helper::linkTo('gallery', 'index.php'), - 'icon' => OC_Helper::linkTo('', 'core/img/filetypes/image.png'), + 'icon' => OC_Helper::imagePath('core', 'places/picture.svg'), 'name' => 'Gallery')); class OC_GallerySearchProvider extends OC_Search_Provider{ @@ -17,7 +17,7 @@ OC_App::addNavigationEntry( array( $result = $stmt->execute(array(OC_User::getUser(),'%'.$query.'%')); $results=array(); while($row=$result->fetchRow()){ - $results[]=new OC_Search_Result($row['album_name'],'',OC_Helper::linkTo( 'apps/gallery', 'index.php?view='.$row['album_name']),'Galleries'); + $results[]=new OC_Search_Result($row['album_name'],'',OC_Helper::linkTo('apps/gallery', 'index.php?view='.$row['album_name']),'Galleries'); } return $results; } diff --git a/apps/gallery/index.php b/apps/gallery/index.php index c8d5892e555..87fdafcf13c 100644 --- a/apps/gallery/index.php +++ b/apps/gallery/index.php @@ -2,6 +2,7 @@ require_once('../../lib/base.php'); OC_Util::checkLoggedIn(); +OC_Util::checkAppEnabled('gallery'); OC_App::setActiveNavigationEntry( 'gallery_index' ); |