From 52c9a8d7a0c7c68432cdae2dde4f54199397ef10 Mon Sep 17 00:00:00 2001 From: "Michael J. Rubinsky" Date: Fri, 30 Jul 2010 19:13:38 -0400 Subject: [PATCH] Use Horde_Url::redirect() --- ansel/disclamer.php | 6 +-- ansel/faces/claim.php | 4 +- ansel/faces/custom.php | 6 +-- ansel/faces/face.php | 2 +- ansel/faces/gallery.php | 6 +-- ansel/faces/report.php | 4 +- ansel/faces/savecustom.php | 6 +-- ansel/faces/search/image.php | 10 ++-- ansel/faces/search/image_define.php | 2 +- ansel/faces/search/image_save.php | 18 +++---- ansel/faces/search/image_search.php | 4 +- ansel/gallery.php | 34 ++++++------- ansel/gallery/captions.php | 16 +++--- ansel/gallery/delete.php | 15 +++--- ansel/gallery/sort.php | 19 ++++---- ansel/group.php | 12 ++--- ansel/image.php | 97 +++++++++++++++++-------------------- ansel/img/upload.php | 16 +++--- ansel/index.php | 3 +- ansel/lib/Ansel.php | 13 ++--- ansel/lib/View/Gallery.php | 5 +- ansel/lib/View/Image.php | 4 +- ansel/lib/View/List.php | 9 ++-- ansel/lib/View/Results.php | 13 ++--- ansel/protect.php | 4 +- ansel/report.php | 4 +- 26 files changed, 159 insertions(+), 173 deletions(-) diff --git a/ansel/disclamer.php b/ansel/disclamer.php index 09989e941..edde5df33 100644 --- a/ansel/disclamer.php +++ b/ansel/disclamer.php @@ -16,7 +16,7 @@ try { $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($vars->get('gallery')); } catch (Ansel_Exception $e) { $notification->push($gallery->getMessage()); - header('Location: ' . Horde::applicationUrl('view.php?view=List', true)); + Horde::applicationUrl('view.php?view=List', true)->redirect(); exit; } $url = $vars->get('url'); @@ -32,11 +32,11 @@ $form->setButtons(array(sprintf(_("Continue - I'm over %d"), $gallery->get('age' if ($form->isSubmitted()) { if (Horde_Util::getFormData('submitbutton') == _("Cancel")) { $notification->push("You are not authorised to view this photo.", 'horde.warning'); - header('Location: ' . Horde::applicationUrl('view.php?view=List', true)); + Horde::applicationUrl('view.php?view=List', true)->redirect(); exit; } else { $_SESSION['ansel']['user_age'] = (int)$gallery->get('age'); - header('Location: ' . $url, true); + $url->redirect(); exit; } } diff --git a/ansel/faces/claim.php b/ansel/faces/claim.php index c74cdacc4..f48e2a200 100644 --- a/ansel/faces/claim.php +++ b/ansel/faces/claim.php @@ -19,7 +19,7 @@ try { $face = $faces->getFaceById($face_id); } catch (Horde_Exception $e) { $notification->push($e->getMessage()); - header('Location: ' . Horde::applicationUrl('faces/search/all.php')); + Horde::applicationUrl('faces/search/all.php')->redirect(); exit; } @@ -58,7 +58,7 @@ if ($form->validate()) { } } - header('Location: ' . Ansel_Faces::getLink($face)); + Ansel_Faces::getLink($face)->redirect(); exit; } diff --git a/ansel/faces/custom.php b/ansel/faces/custom.php index e6c65d9b6..ea5a29aa2 100644 --- a/ansel/faces/custom.php +++ b/ansel/faces/custom.php @@ -27,14 +27,14 @@ try { $image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($image_id); } catch (Ansel_Exception $e) { $notification->push($image); - header('Location: ' . Horde::applicationUrl('list.php')); + Horde::applicationUrl('list.php')->redirect(); exit; } $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($image->gallery); if (!$gallery->hasPermission($registry->getAuth(), Horde_Perms::EDIT)) { $notification->push(_("Access denied editing the photo.")); - header('Location: ' . Ansel::getUrlFor('view', array('gallery' => $image->gallery))); + Ansel::getUrlFor('view', array('gallery' => $image->gallery))->redirect(); exit; } @@ -57,7 +57,7 @@ if ($face_id) { } } catch (Horde_Exception $e) { $notification->push($e->getMessage()); - header('Location: ' . Horde::applicationUrl('list.php')); + Horde::applicationUrl('list.php')->redirect(); } } diff --git a/ansel/faces/face.php b/ansel/faces/face.php index 38856daa6..b8d0cc84f 100644 --- a/ansel/faces/face.php +++ b/ansel/faces/face.php @@ -22,7 +22,7 @@ try { $face = $faces->getFaceById($face_id); } catch (Horde_Exception $e) { $notification->push($face->getMessage()); - header('Location: ' . Horde::applicationUrl('faces/index.php')); + Horde::applicationUrl('faces/index.php')->redirect(); exit; } diff --git a/ansel/faces/gallery.php b/ansel/faces/gallery.php index 7ff5e2f5e..d59fdddc7 100644 --- a/ansel/faces/gallery.php +++ b/ansel/faces/gallery.php @@ -18,19 +18,19 @@ Horde_Registry::appInit('ansel'); $gallery_id = (int)Horde_Util::getFormData('gallery'); if (empty($gallery_id)) { $notification->push(_("No gallery specified"), 'horde.error'); - header('Location: ' . Ansel::getUrlFor('default_view', array())); + Ansel::getUrlFor('default_view', array())->redirect(); exit; } try { $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($gallery_id); } catch (Ansel_Exception $e) { $notification->push($e->getMessage(), 'horde.error'); - header('Location: ' . Ansel::getUrlFor('view', array('gallery' => $gallery_id))); + Ansel::getUrlFor('view', array('gallery' => $gallery_id))->redirect(); exit; } if (!$gallery->hasPermission($registry->getAuth(), Horde_Perms::EDIT)) { $notification->push(sprintf(_("Access denied editing gallery \"%s\"."), $gallery->get('name')), 'horde.error'); - header('Location: ' . Ansel::getUrlFor('view', array('gallery' => $gallery_id))); + Ansel::getUrlFor('view', array('gallery' => $gallery_id))->redirect(); exit; } $gallery->setDate(Ansel::getDateParameter()); diff --git a/ansel/faces/report.php b/ansel/faces/report.php index 59a112240..9a9393112 100644 --- a/ansel/faces/report.php +++ b/ansel/faces/report.php @@ -20,7 +20,7 @@ try { $face = $faces->getFaceById($face_id); } catch (Horde_Exception $e) { $notification->push($e->getMessage()); - header('Location: ' . Horde::applicationUrl('faces/search/all.php')); + Horde::applicationUrl('faces/search/all.php')->redirect(); exit; } @@ -61,7 +61,7 @@ if ($form->validate()) { $notification->push(_("The owner of the photo was notified."), 'horde.success'); } - header('Location: ' . Ansel_Faces::getLink($face)); + Ansel_Faces::getLink($face)->redirect(); exit; } diff --git a/ansel/faces/savecustom.php b/ansel/faces/savecustom.php index b2a0e0f79..ccd6c0a71 100644 --- a/ansel/faces/savecustom.php +++ b/ansel/faces/savecustom.php @@ -27,7 +27,7 @@ $back_url = empty($url) if (Horde_Util::getPost('submit') == _("Cancel")) { $notification->push(_("Changes cancelled."), 'horde.warning'); - header('Location: ' . $back_url); + $back_url->redirect(); exit; } try { @@ -42,7 +42,7 @@ try { Horde_Util::getFormData('name')); } catch (Horde_Exception $e) { $notification->push($e->getMessage()); - header('Location: ' . $back_url); + $back_url->redirect(); exit; } @@ -52,5 +52,5 @@ if ($face_id == 0) { $notification->push(_("Face successfuly updated"), 'horde.success'); } -header('Location: ' . $back_url); +$back_url->redirect(); exit; diff --git a/ansel/faces/search/image.php b/ansel/faces/search/image.php index c2edb416b..45245cebc 100644 --- a/ansel/faces/search/image.php +++ b/ansel/faces/search/image.php @@ -28,13 +28,13 @@ if ($form->validate()) { $dimensions = $img->getDimensions(); } catch (Horde_Image_Exception $e) { $notification->push($e->getMessage()); - header('Location: ' . Horde::applicationUrl('faces/search/image.php')); + Horde::applicationUrl('faces/search/image.php')->redirect(); exit; } if ($dimensions['width'] < 50 || $dimensions['height'] < 50) { $notification->push(_("Photo is too small. Search photo must be at least 50x50 pixels.")); - header('Location: ' . Horde::applicationUrl('faces/search/image.php')); + Horde::applicationUrl('faces/search/image.php')->redirect(); exit; } @@ -43,16 +43,16 @@ if ($form->validate()) { min($conf['screen']['height'], $dimensions['height'])); } catch (Horde_Image_Exception $e) { $notification->push($e->getMessage()); - header('Location: ' . Horde::applicationUrl('faces/search/image.php')); + Horde::applicationUrl('faces/search/image.php')->redirect(); exit; } $path = $tmp . '/search_face_' . $registry->getAuth() . Ansel_Faces::getExtension(); if (file_put_contents($path, $img->raw())) { - header('Location: ' . Horde::applicationUrl('faces/search/image_define.php')); + Horde::applicationUrl('faces/search/image_define.php')->redirect(); } else { $notification->push(_("Cannot store search photo")); - header('Location: ' . Horde::applicationUrl('faces/search/image.php')); + Horde::applicationUrl('faces/search/image.php')->redirect(); } exit; diff --git a/ansel/faces/search/image_define.php b/ansel/faces/search/image_define.php index 2feef1abf..1d608f6a6 100644 --- a/ansel/faces/search/image_define.php +++ b/ansel/faces/search/image_define.php @@ -17,7 +17,7 @@ $path = $tmp . '/search_face_' . $registry->getAuth() . Ansel_Faces::getExtensio if (file_exists($path) !== true) { $notification->push(_("You must upload the search photo first")); - header('Location: ' . Horde::applicationUrl('faces/search/image.php')); + Horde::applicationUrl('faces/search/image.php')->redirect(); } $title = _("Create a new face"); diff --git a/ansel/faces/search/image_save.php b/ansel/faces/search/image_save.php index 8fc5fdd5d..6ca94b5c6 100644 --- a/ansel/faces/search/image_save.php +++ b/ansel/faces/search/image_save.php @@ -17,7 +17,7 @@ $path = $tmp . '/search_face_' . $registry->getAuth() . Ansel_Faces::getExtensio if (!file_exists($path)) { $notification->push(_("You must upload the search photo first")); - header('Location: ' . Horde::applicationUrl('faces/search/image.php')); + Horde::applicationUrl('faces/search/image.php')->redirect(); } $x1 = (int)Horde_Util::getFormData('x1'); @@ -27,7 +27,7 @@ $y2 = (int)Horde_Util::getFormData('y2'); if ($x2 - $x1 < 50 || $y2 - $y1 < 50) { $notification->push(_("Photo is too small. Search photo must be at least 50x50 pixels.")); - header('Location: ' . Horde::applicationUrl('faces/search/image.php')); + Horde::applicationUrl('faces/search/image.php')->redirect(); exit; } @@ -37,7 +37,7 @@ try { $result = $img->loadFile($path); } catch (Horde_Image_Exception $e) { $notification->push($e->getMessage()); - header('Location: ' . Horde::applicationUrl('faces/search/image.php')); + Horde::applicationUrl('faces/search/image.php')->redirect(); exit; } @@ -46,7 +46,7 @@ try { $result = $img->crop($x1, $y1, $x2, $y2); } catch (Horde_Image_Exception $e) { $notification->push($e->getMessage()); - header('Location: ' . Horde::applicationUrl('faces/search/image.php')); + Horde::applicationUrl('faces/search/image.php')->redirect(); exit; } @@ -58,14 +58,14 @@ try { } } catch (Horde_Image_Exception $e) { $notification->push($e->getMessage()); - header('Location: ' . Horde::applicationUrl('faces/search/image.php')); + Horde::applicationUrl('faces/search/image.php')->redirect(); } /* Save image. */ $path = $tmp . '/search_face_thumb_' . $registry->getAuth() . Ansel_Faces::getExtension(); if (!file_put_contents($path, $img->raw())) { $notification->push(_("Cannot store search photo")); - header('Location: ' . Horde::applicationUrl('faces/search/image.php')); + Horde::applicationUrl('faces/search/image.php')->redirect(); exit; } @@ -73,17 +73,17 @@ if (!file_put_contents($path, $img->raw())) { $signature = $faces->getSignatureFromFile($path); if (empty($signature)) { $notification->push(_("Cannot read photo signature")); - header('Location: ' . Horde::applicationUrl('faces/search/image.php')); + Horde::applicationUrl('faces/search/image.php')->redirect(); exit; } /* Save signature. */ $path = $tmp . '/search_face_' . $registry->getAuth() . '.sig'; if (file_put_contents($path, $signature)) { - header('Location: ' . Horde::applicationUrl('faces/search/image.php')); + Horde::applicationUrl('faces/search/image.php')->redirect(); exit; } $notification->push(_("Cannot save photo signature")); -header('Location: ' . Horde::applicationUrl('faces/search/image.php')); +Horde::applicationUrl('faces/search/image.php')->redirect(); exit; diff --git a/ansel/faces/search/image_search.php b/ansel/faces/search/image_search.php index 99114bbe3..939abeefa 100644 --- a/ansel/faces/search/image_search.php +++ b/ansel/faces/search/image_search.php @@ -21,14 +21,14 @@ if (($face_id = Horde_Util::getGet('face_id')) !== null) { $results = $faces->getSignatureMatches($signature, $face_id, $perpage * $page, $perpage); } catch (Ansel_Exception $e) { $notification->push($e->getMessage()); - header('Location: ' . Horde::applicationUrl('faces/search/image.php')); + Horde::applicationUrl('faces/search/image.php')->redirect(); } } else { $tmp = Horde::getTempDir(); $path = $tmp . '/search_face_' . $registry->getAuth() . '.sig'; if (file_exists($path) !== true) { $notification->push(_("You must upload the search photo first")); - header('Location: ' . Horde::applicationUrl('faces/search/image.php')); + Horde::applicationUrl('faces/search/image.php')->redirect(); } $signature = file_get_contents($path); try { diff --git a/ansel/gallery.php b/ansel/gallery.php index 28dbf3f2d..1e615a2b4 100644 --- a/ansel/gallery.php +++ b/ansel/gallery.php @@ -14,7 +14,7 @@ Horde_Registry::appInit('ansel'); // Redirect to the gallery list if no action has been requested. $actionID = Horde_Util::getFormData('actionID'); if (is_null($actionID)) { - header('Location: ' . Horde::applicationUrl('view.php?view=List', true)); + Horde::applicationUrl('view.php?view=List', true)->redirect(); exit; } @@ -50,14 +50,14 @@ case 'addchild': $parent = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($parentId); } catch (Ansel_Exception $e) { $notification->push($e->getMessage(), 'horde.error'); - header('Location: ' . Horde::applicationUrl('view.php?view=List', true)); + Horde::applicationUrl('view.php?view=List', true)->redirect(); exit; } if (!$parent->hasPermission($registry->getAuth(), Horde_Perms::EDIT)) { $notification->push(sprintf(_("Access denied adding a gallery to \"%s\"."), $parent->get('name')), 'horde.error'); - header('Location: ' . Horde::applicationUrl('view.php?view=List', true)); + Horde::applicationUrl('view.php?view=List', true)->redirect(); exit; } @@ -89,7 +89,7 @@ case 'downloadzip': !$gallery->hasPermission($registry->getAuth(), Horde_Perms::READ)) { $notification->push(sprintf(_("Access denied downloading photos from \"%s\"."), $gallery->get('name')), 'horde.error'); - header('Location: ' . Horde::applicationUrl('view.php?view=List', true)); + Horde::applicationUrl('view.php?view=List', true)->redirect(); exit; } @@ -129,7 +129,7 @@ case 'save': ($injector->getInstance('Horde_Perms')->exists('ansel') && !$injector->getInstance('Horde_Perms')->hasPermission('ansel', $registry->getAuth(), Horde_Perms::EDIT))) { $notification->push(_("Access denied editing galleries."), 'horde.error'); - header('Location: ' . Horde::applicationUrl('view.php?view=List', true)); + Horde::applicationUrl('view.php?view=List', true)->redirect(); exit; } @@ -202,7 +202,7 @@ case 'save': $result = $gallery->setParent($new_parent); } catch (Ansel_Exception $e) { $notification->push($e->getMessage(), 'horde.error'); - header('Location: ' . Horde::applicationUrl(Ansel::getUrlFor('view', array('view' => 'List'), true))); + Horde::applicationUrl(Ansel::getUrlFor('view', array('view' => 'List'), true))->redirect(); exit; } } @@ -220,7 +220,7 @@ case 'save': $parent = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($gallery_parent); } catch (Ansel_Exception $e) { $notification->push($e->getMessage(), 'horde.error'); - header('Location: ' . Horde::applicationUrl(Ansel::getUrlFor('view', array('view' => 'List'), true))); + Horde::applicationUrl(Ansel::getUrlFor('view', array('view' => 'List'), true))->redirect(); exit; } if (!$parent->hasPermission($registry->getAuth(), Horde_Perms::EDIT)) { @@ -228,7 +228,7 @@ case 'save': _("You do not have permission to add children to %s."), $parent->get('name')), 'horde.error'); - header('Location: ' . Horde::applicationUrl(Ansel::getUrlFor('view', array('view' => 'List'), true))); + Horde::applicationUrl(Ansel::getUrlFor('view', array('view' => 'List'), true))->redirect(); exit; } } @@ -289,7 +289,7 @@ case 'save': } elseif (empty($url)) { $url = Horde::applicationUrl('index.php', true); } - header('Location: ' . $url); + $url->redirect(); exit; case 'delete': @@ -310,7 +310,7 @@ case 'empty': } // Return to the gallery list. - header('Location: ' . Horde::applicationUrl(Ansel::getUrlFor('view', array('view' => 'List'), true))); + Horde::applicationUrl(Ansel::getUrlFor('view', array('view' => 'List'), true))->redirect(); exit; case 'generateDefault': @@ -320,11 +320,11 @@ case 'generateDefault': $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($galleryId); $gallery->clearStacks(); $notification->push(_("The gallery's default photo has successfully been reset."), 'horde.success'); - header('Location: ' . Horde::applicationUrl('view.php', true)->add('gallery', $galleryId)); + Horde::applicationUrl('view.php', true)->add('gallery', $galleryId)->redirect(); exit; } catch (Ansel_Exception $e) { $notification->push($e->getMessage(), 'horde.error'); - header('Location: ' . Horde::applicationUrl('index.php', true)); + Horde::applicationUrl('index.php', true)->redirect(); exit; } @@ -335,12 +335,12 @@ case 'generateThumbs': $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($galleryId); } catch (Ansel_Exception $e) { $notification->push($gallery->getMessage(), 'horde.error'); - header('Location: ' . Horde::applicationUrl('index.php', true)); + Horde::applicationUrl('index.php', true)->redirect(); exit; } $gallery->clearThumbs(); $notification->push(_("The gallery's thumbnails have successfully been reset."), 'horde.success'); - header('Location: ' . Horde::applicationUrl('view.php', true)->add('gallery', $galleryId)); + Horde::applicationUrl('view.php', true)->add('gallery', $galleryId)->redirect(); exit; case 'deleteCache': @@ -350,16 +350,16 @@ case 'deleteCache': $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($galleryId); } catch (Ansel_Exception $e) { $notification->push($gallery->getMessage(), 'horde.error'); - header('Location: ' . Horde::applicationUrl('index.php', true)); + Horde::applicationUrl('index.php', true)->redirect(); exit; } $gallery->clearViews(); $notification->push(_("The gallery's views have successfully been reset."), 'horde.success'); - header('Location: ' . Horde::applicationUrl('view.php', true)->add('gallery', $galleryId)); + Horde::applicationUrl('view.php', true)->add('gallery', $galleryId)->redirect(); exit; default: - header('Location: ' . Horde::applicationUrl(Ansel::getUrlFor('view', array('view' => 'List'), true))); + Horde::applicationUrl(Ansel::getUrlFor('view', array('view' => 'List'), true))->redirect(); exit; } diff --git a/ansel/gallery/captions.php b/ansel/gallery/captions.php index c4db7cd95..3657a3abd 100644 --- a/ansel/gallery/captions.php +++ b/ansel/gallery/captions.php @@ -13,21 +13,20 @@ Horde_Registry::appInit('ansel'); $galleryId = Horde_Util::getFormData('gallery'); if (!$galleryId) { - header('Location: ' . Ansel::getUrlFor('view', array('view' => 'List'), - true)); + Ansel::getUrlFor('view', array('view' => 'List'), true)->redirect(); exit; } try { $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($galleryId); } catch (Ansel_Exception $e) { $notification->push(sprintf(_("Error accessing %s: %s"), $galleryId, $e->getMessage()), 'horde.error'); - header('Location: ' . Ansel::getUrlFor('view', array('view' => 'List'), true)); + Ansel::getUrlFor('view', array('view' => 'List'), true)->redirect(); exit; } if (!$gallery->hasPermission($registry->getAuth(), Horde_Perms::EDIT)) { $notification->push(sprintf(_("Access denied setting captions for %s."), $gallery->get('name')), 'horde.error'); - header('Location: ' . Ansel::getUrlFor('view', array('view' => 'List'), true)); + Ansel::getUrlFor('view', array('view' => 'List'), true)->redirect(); exit; } @@ -50,11 +49,10 @@ case 'save': $notification->push(_("Captions Saved."), 'horde.success'); $style = $gallery->getStyle(); - header('Location: ' . Ansel::getUrlFor('view', array_merge( - array('gallery' => $galleryId, - 'slug' => $gallery->get('slug'), - 'view' => 'Gallery'), - $date), true)); + Ansel::getUrlFor('view', array_merge(array('gallery' => $galleryId, + 'slug' => $gallery->get('slug'), + 'view' => 'Gallery'), + $date), true)->redirect(); exit; } diff --git a/ansel/gallery/delete.php b/ansel/gallery/delete.php index 46a16c6a2..9befd25e9 100644 --- a/ansel/gallery/delete.php +++ b/ansel/gallery/delete.php @@ -21,7 +21,7 @@ if ($galleryId) { } catch (Ansel_Exception $e) { $notification->push($e->getMessage(), 'horde.error'); // Return to the default view. - header('Location: ' . Ansel::getUrlFor('default_view', array())); + Ansel::getUrlFor('default_view', array())->redirect(); exit; } switch ($actionID) { @@ -49,7 +49,7 @@ if ($galleryId) { } // Return to the default view. - header('Location: ' . Ansel::getUrlFor('default_view', array())); + Ansel::getUrlFor('default_view', array())->redirect(); exit; case 'empty': @@ -61,12 +61,11 @@ if ($galleryId) { $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->emptyGallery($gallery); $notification->push(sprintf(_("Successfully emptied \"%s\""), $gallery->get('name'))); } - header('Location: ' - . Ansel::getUrlFor('view', - array('view' => 'Gallery', - 'gallery' => $galleryId, - 'slug' => $gallery->get('slug')), - true)); + Ansel::getUrlFor('view', + array('view' => 'Gallery', + 'gallery' => $galleryId, + 'slug' => $gallery->get('slug')), + true)->redirect(); exit; } } diff --git a/ansel/gallery/sort.php b/ansel/gallery/sort.php index 7b1d44cc8..d2f9a518c 100644 --- a/ansel/gallery/sort.php +++ b/ansel/gallery/sort.php @@ -15,15 +15,14 @@ Horde_Registry::appInit('ansel'); * list. */ $galleryId = Horde_Util::getFormData('gallery'); if (!isset($galleryId)) { - header('Location: ' . Ansel::getUrlFor('view', array('view' => 'List'), - true)); + Ansel::getUrlFor('view', array('view' => 'List'), true)->redirect(); exit; } try { $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($galleryId); } catch (Ansel_Excception $e) { $notification->push(_("There was an error accessing the gallery."), 'horde.error'); - header('Location: ' . Ansel::getUrlFor('view', array('view' => 'List'), true)); + Ansel::getUrlFor('view', array('view' => 'List'), true)->redirect(); exit; } @@ -48,12 +47,14 @@ case 'Sort': $notification->push(_("Gallery sorted."), 'horde.success'); $style = $gallery->getStyle(); - header('Location: ' . Ansel::getUrlFor('view', array_merge( - array('view' => 'Gallery', - 'gallery' => $galleryId, - 'slug' => $gallery->get('slug')), - $date), - true)); + Ansel::getUrlFor('view', + array_merge( + array('view' => 'Gallery', + 'gallery' => $galleryId, + 'slug' => $gallery->get('slug')), + $date + ), + true)->redirect(); exit; } diff --git a/ansel/group.php b/ansel/group.php index 93b7a7933..27abb99be 100644 --- a/ansel/group.php +++ b/ansel/group.php @@ -64,12 +64,12 @@ case 'owner': break; default: - header('Location: ' . Ansel::getUrlFor('view', - array( - 'view' => 'List', - 'groupby' => $groupby - ), - true)); + Ansel::getUrlFor('view', + array( + 'view' => 'List', + 'groupby' => $groupby + ), + true)->redirect(); exit; } diff --git a/ansel/image.php b/ansel/image.php index d87a71c31..5aaf5c502 100644 --- a/ansel/image.php +++ b/ansel/image.php @@ -47,8 +47,7 @@ $tags = Horde_Util::getFormData('addtag'); /* Redirect to the image list if no other action has been requested. */ if (is_null($actionID) && is_null($tags)) { - header('Location: ' . Ansel::getUrlFor('view', array('view' => 'List'), - true)); + Ansel::getUrlFor('view', array('view' => 'List'), true)->redirect(); exit; } @@ -57,7 +56,7 @@ try { $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($gallery_id); } catch (Ansel_Exception $e) { $notification->push(sprintf(_("Gallery %s not found."), $gallery_id), 'horde.error'); - header('Location: ' . Ansel::getUrlFor('view', array('view' => 'List'), true)); + Ansel::getUrlFor('view', array('view' => 'List'), true)->redirect(); exit; } @@ -92,7 +91,7 @@ if (!is_null($tags) && strlen($tags)) { true); } - header('Location: ' . $url); + $url->redirect(); exit; } } @@ -122,7 +121,7 @@ case 'deletetags': $eTags = $resource->getTags(); unset($eTags[$tag]); $resource->setTags($eTags); - header('Location: ' . $url); + $url->redirect(); exit; case 'modify': @@ -131,7 +130,7 @@ case 'modify': $ret = Horde_Util::getFormData('ret', 'gallery'); } catch (Ansel_Exception $e) { $notification->push(_("Photo not found."), 'horde.error'); - header('Location: ' . Ansel::getUrlFor('view', array('view' => 'List'), true)); + Ansel::getUrlFor('view', array('view' => 'List'), true)->redirect(); exit; } @@ -166,14 +165,13 @@ case 'save': if (!$gallery->hasPermission($registry->getAuth(), Horde_Perms::EDIT)) { $notification->push(sprintf(_("Access denied saving photo to \"%s\"."), $gallery->get('name')), 'horde.error'); - $imageurl = Ansel::getUrlFor('view', array_merge( - array('gallery' => $gallery_id, - 'slug' => $gallery->get('slug'), - 'view' => 'Gallery', - 'page' => $page), - $date), - true); - header('Location: ' . $imageurl); + Ansel::getUrlFor('view', + array_merge(array('gallery' => $gallery_id, + 'slug' => $gallery->get('slug'), + 'view' => 'Gallery', + 'page' => $page), + $date), + true)->redirect(); exit; } @@ -258,7 +256,7 @@ case 'save': true); if ($actionID == 'save') { /* Return to the image view. */ - header('Location: ' . $imageurl); + $imageurl->redirect(); } elseif ($actionID == 'saveclose') { echo Horde::wrapInlineScript(array( 'window.opener.location.href = window.opener.location.href;', @@ -304,7 +302,7 @@ case 'resizeedit': 'horde.error'); /* Return to the image view. */ - header('Location: ' . $ImageGenerator_url); + $ImageGenerator_url->redirect(); exit; } @@ -356,29 +354,27 @@ case 'watermark': $gallery->get('name')), 'horde.error'); /* Return to the image view. */ - $imageurl = Ansel::getUrlFor('view', array_merge( + Ansel::getUrlFor('view', array_merge( array('gallery' => $gallery_id, 'image' => $image_id, 'view' => 'Image', 'page' => $page, 'slug' => $gallery->get('slug')), $date), - true); - header('Location: ' . $imageurl); + true)->redirect(); exit; } else { $image = &$GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($image_id); $image->watermark('screen', $watermark, $watermark_halign, $watermark_valign, $watermark_font); $image->updateData($image->raw('screen'), 'screen'); - $imageurl = Horde::applicationUrl('image.php', true)->add( + Horde::applicationUrl('image.php', true)->add( array_merge( array('gallery' => $gallery_id, 'image' => $image_id, 'actionID' => 'editimage', 'page' => $page), - $date)); - header('Location: ' . $imageurl); + $date))->redirect(); exit; } @@ -399,7 +395,7 @@ case 'resize': $image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($image_id); } catch (Ansel_Exception $e) { $notification->push($e->getMessage(), 'horde.error'); - header('Location: ' . Ansel::getUrlFor('view', array('view' => 'List'), true)); + Ansel::getUrlFor('view', array('view' => 'List'), true)->redirect(); exit; } @@ -447,14 +443,13 @@ case 'resize': } } - $imageurl = Horde::applicationUrl('image.php', true)->add( + Horde::applicationUrl('image.php', true)->add( array_merge( array('gallery' => $gallery_id, 'image' => $image_id, 'actionID' => 'editimage', 'page' => $page), - $date)); - header('Location: ' . $imageurl); + $date))->redirect(); exit; case 'setwatermark': @@ -463,7 +458,7 @@ case 'setwatermark': $image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getImage($image_id); } catch (Ansel_Exception $e) { $notification->push($image->getMessage(), 'horde.error'); - header('Location: ' . Ansel::getUrlFor('view', array('view' => 'List'), true)); + Ansel::getUrlFor('view', array('view' => 'List'), true)->redirect(); exit; } /* Set up the form object. */ @@ -594,14 +589,14 @@ case 'delete': } /* Return to the image list. */ - $imageurl = Ansel::getUrlFor('view', array_merge( - array('gallery' => $gallery_id, - 'view' => 'Gallery', - 'page' => $page, - 'slug' => $gallery->get('slug')), - $date), - true); - header('Location: ' . $imageurl); + Ansel::getUrlFor('view', + array_merge( + array('gallery' => $gallery_id, + 'view' => 'Gallery', + 'page' => $page, + 'slug' => $gallery->get('slug')), + $date), + true)->redirect(); exit; case 'move': @@ -638,14 +633,13 @@ case 'move': } /* Return to the image list. */ - $imageurl = Ansel::getUrlFor('view', array_merge( + Ansel::getUrlFor('view', array_merge( array('gallery' => $gallery_id, 'view' => 'Gallery', 'page' => $page, 'slug' => $gallery->get('slug')), $date), - true); - header('Location: ' . $imageurl); + true)->redirect(); exit; case 'copy': @@ -674,14 +668,14 @@ case 'copy': } /* Return to the image list. */ - $imageurl = Ansel::getUrlFor('view', array_merge( - array('gallery' => $gallery_id, - 'view' => 'Gallery', - 'page' => $page, - 'slug' => $gallery->get('slug')), - $date), - true); - header('Location: ' . $imageurl); + Ansel::getUrlFor('view', + array_merge( + array('gallery' => $gallery_id, + 'view' => 'Gallery', + 'page' => $page, + 'slug' => $gallery->get('slug')), + $date), + true)->redirect(); exit; case 'downloadzip': @@ -693,7 +687,7 @@ case 'downloadzip': $gallery->hasPasswd() || !$gallery->isOldEnough()) { $notification->push(sprintf(_("Access denied downloading photos from \"%s\"."), $gallery->get('name')), 'horde.error'); - header('Location: ' . Horde::applicationUrl('view.php?view=List', true)); + Horde::applicationUrl('view.php?view=List', true)->redirect(); exit; } } @@ -709,7 +703,7 @@ case 'downloadzip': } else { $url = Ansel::getUrlFor('view', array('view' => 'List')); } - header('Location: ' . $url); + $url->redirect(); exit; } exit; @@ -719,12 +713,11 @@ case 'previewcrop': if (!$gallery->hasPermission($registry->getAuth(), Horde_Perms::EDIT)) { $notification->push(_("Access denied editing the photo."), 'horde.error'); - $imageurl = Ansel::getUrlFor( + Ansel::getUrlFor( 'view', array('gallery' => $gallery_id, 'image' => $image_id, 'view' => 'Image', - 'page' => $page)); - header('Location: ' . $imageurl); + 'page' => $page))->redirect(); } else { $x1 = (int)Horde_Util::getFormData('x1'); $y1 = (int)Horde_Util::getFormData('y1'); @@ -760,7 +753,7 @@ case 'imagecrop': exit; default: - header('Location: ' . Ansel::getUrlFor('default_view', array())); + Ansel::getUrlFor('default_view', array())->redirect(); exit; } diff --git a/ansel/img/upload.php b/ansel/img/upload.php index 165548435..d490f690c 100644 --- a/ansel/img/upload.php +++ b/ansel/img/upload.php @@ -16,7 +16,7 @@ try { $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($gallery_id); } catch (Ansel_Exception $e) { $notification->push(sprintf(_("Gallery %s not found."), $gallery_id), 'horde.error'); - header('Location: ' . Ansel::getUrlFor('view', array('view' => 'List'), true)); + Ansel::getUrlFor('view', array('view' => 'List'), true)->redirect(); exit; } @@ -227,14 +227,12 @@ if ($form->validate($vars)) { if ($valid) { /* Return to the gallery view. */ - $imageurl = Ansel::getUrlFor('view', - array('gallery' => $gallery_id, - 'slug' => $gallery->get('slug'), - 'view' => 'Gallery', - 'page' => $page), - true); - - header('Location: ' . $imageurl); + Ansel::getUrlFor('view', + array('gallery' => $gallery_id, + 'slug' => $gallery->get('slug'), + 'view' => 'Gallery', + 'page' => $page), + true)->redirect(); exit; } } diff --git a/ansel/index.php b/ansel/index.php index 689c02298..2674cfc8b 100644 --- a/ansel/index.php +++ b/ansel/index.php @@ -10,5 +10,4 @@ require_once dirname(__FILE__) . '/lib/Application.php'; Horde_Registry::appInit('ansel'); - -header('Location: ' . Ansel::getUrlFor('default_view', array())); +Ansel::getUrlFor('default_view', array())->redirect(); diff --git a/ansel/lib/Ansel.php b/ansel/lib/Ansel.php index fa0dc15fd..07780e01c 100644 --- a/ansel/lib/Ansel.php +++ b/ansel/lib/Ansel.php @@ -120,7 +120,7 @@ class Ansel $parent = (empty($params['parent'])) ? null : $params['parent']->id; if ((!empty($params['parent']) && !empty($galleries[$params['parent']])) || (empty($params['parent']))) { - + $tree->addNode($gallery->id, $parent, $label, $indents, true, $treeparams); } } @@ -258,7 +258,7 @@ class Ansel if (count($extras)) { $url->add($extras); } - + /* Slight hack until we delegate at least some of the url * generation to the gallery/image/view object. */ if ($data['view'] == 'Image' && @@ -294,10 +294,10 @@ class Ansel } return Horde::applicationUrl($url, $full, $append_session); - + } else { $url = Horde::applicationUrl('view.php', $full, $append_session); - + /* See note above about delegating url generation to gallery/view */ if ($data['view'] == 'Image' && !empty($data['gallery_view']) && @@ -919,7 +919,7 @@ class Ansel if (empty($GLOBALS['conf']['gallery']['downloadzip'])) { $GLOBALS['notification']->push(_("Downloading zip files is not enabled. Talk to your server administrator.")); - header('Location: ' . Horde::applicationUrl('view.php?view=List', true)); + Horde::applicationUrl('view.php?view=List', true)->redirect(); exit; } @@ -942,7 +942,8 @@ class Ansel if (!count($images)) { $notification->push(sprintf(_("There are no photos in %s to download."), $gallery->get('name')), 'horde.message'); - header('Location: ' . Horde::applicationUrl('view.php?view=List', true)); + + Horde::applicationUrl('view.php?view=List', true)->redirect(); exit; } diff --git a/ansel/lib/View/Gallery.php b/ansel/lib/View/Gallery.php index 1f2d163c8..cdba189c7 100644 --- a/ansel/lib/View/Gallery.php +++ b/ansel/lib/View/Gallery.php @@ -55,7 +55,8 @@ class Ansel_View_Gallery extends Ansel_View_Base true); $params = array('gallery' => $this->gallery->id, 'url' => $galleryurl); - header('Location: ' . Horde::applicationUrl('disclamer.php')->add($params)->setRaw(true)); + + Horde::applicationUrl('disclamer.php')->add($params)->setRaw(true)->redirect(); exit; } @@ -77,7 +78,7 @@ class Ansel_View_Gallery extends Ansel_View_Base true); $params = array('gallery' => $this->gallery->id, 'url' => $galleryurl); - header('Location: ' . Horde::applicationUrl('protect.php')->add($params)->setRaw(true)); + Horde::applicationUrl('protect.php')->add($params)->setRaw(true)->redirect(); exit; } diff --git a/ansel/lib/View/Image.php b/ansel/lib/View/Image.php index 3d63608e3..da0fcc6e0 100644 --- a/ansel/lib/View/Image.php +++ b/ansel/lib/View/Image.php @@ -61,7 +61,7 @@ class Ansel_View_Image extends Ansel_View_Base $params = array('gallery' => $this->gallery->id, 'url' => $url); - header('Location: ' . Horde::applicationUrl('disclamer.php')->add($params)->setRaw(true)); + Horde::applicationUrl('disclamer.php')->add($params)->setRaw(true)->redirect(); exit; } @@ -86,7 +86,7 @@ class Ansel_View_Image extends Ansel_View_Base $params = array('gallery' => $this->gallery->id, 'url' => $url); - header('Location: ' . Horde::applicationUrl('protect.php')->add($params)->setRaw(true)); + Horde::applicationUrl('protect.php')->add($params)->setRaw(true)->redirect(); exit; } diff --git a/ansel/lib/View/List.php b/ansel/lib/View/List.php index 076023d00..5403e1ee2 100644 --- a/ansel/lib/View/List.php +++ b/ansel/lib/View/List.php @@ -79,7 +79,7 @@ class Ansel_View_List extends Ansel_View_Base $this->_category = $this->_params['category']; } if (!$this->_owner && !$this->_category && !$this->_special && $this->_groupby != 'none' ) { - header('Location: ' . Ansel::getUrlFor('group', array('groupby' => $this->_groupby), true)); + Ansel::getUrlFor('group', array('groupby' => $this->_groupby))->redirect(); exit; } @@ -90,7 +90,7 @@ class Ansel_View_List extends Ansel_View_Base $this->_page = Horde_Util::getFormData('page', 0); } $this->_g_perPage = $prefs->getValue('tilesperpage'); - + // If we are calling from the api, we can just pass a list of gallery // ids instead of doing grouping stuff. if (!empty($this->_params['api']) && @@ -127,9 +127,8 @@ class Ansel_View_List extends Ansel_View_Base if ($this->_numGalleries == 0 && empty($this->_params['api'])) { if ($this->_owner && $filter == $this->_owner && $this->_owner == $GLOBALS['registry']->getAuth()) { - $notification->push(_("You have no photo galleries, add one!"), - 'horde.message'); - header('Location: ' .Horde::applicationUrl('gallery.php')->add('actionID', 'add')); + $notification->push(_("You have no photo galleries, add one!"), 'horde.message'); + Horde::applicationUrl('gallery.php')->add('actionID', 'add')->redirect(); exit; } $notification->push(_("There are no photo galleries available."), 'horde.message'); diff --git a/ansel/lib/View/Results.php b/ansel/lib/View/Results.php index 3b00675dc..2275552df 100644 --- a/ansel/lib/View/Results.php +++ b/ansel/lib/View/Results.php @@ -76,9 +76,7 @@ class Ansel_View_Results extends Ansel_View_Base } } - header('Location: ' . Ansel::getUrlFor('view', - array('view' => 'Results'), - true)); + Ansel::getUrlFor('view', array('view' => 'Results'), true)->redirect(); exit; case 'move': @@ -119,9 +117,8 @@ class Ansel_View_Results extends Ansel_View_Base $notification->push(_("Bad input."), 'horde.error'); } } - header('Location: ' . Ansel::getUrlFor('view', - array('view' => 'Results'), - true)); + + Ansel::getUrlFor('view', array('view' => 'Results'), true)->redirect(); exit; case 'copy': @@ -160,7 +157,7 @@ class Ansel_View_Results extends Ansel_View_Base $notification->push(_("Bad input."), 'horde.error'); } } - header('Location: ' . Ansel::getUrlFor('view', array('view' => 'Results'), true)); + Ansel::getUrlFor('view', array('view' => 'Results'), true)->redirect(); exit; /* Tag related actions */ @@ -188,7 +185,7 @@ class Ansel_View_Results extends Ansel_View_Base /* Check for empty tag search and redirect if empty */ if ($this->_search->tagCount() < 1) { - header('Location: ' . Horde::applicationUrl('browse.php', true)); + Horde::applicationUrl('browse.php', true)->redirect(); exit; } } diff --git a/ansel/protect.php b/ansel/protect.php index e8a98c000..0a061c006 100644 --- a/ansel/protect.php +++ b/ansel/protect.php @@ -16,7 +16,7 @@ try { $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($vars->get('gallery')); } catch (Ansel_Exception $e) { $notification->push($e->getMessage()); - header('Location: ' . Horde::applicationUrl('list.php')); + Horde::applicationUrl('list.php')->redirect(); exit; } $form = new Horde_Form($vars, _("This gallery is protected by a password. Please enter it below.")); @@ -34,7 +34,7 @@ if ($form->validate()) { if (empty($url)) { $url = Horde::applicationUrl('view.php')->add('gallery', $gallery->id); } - header('Location: ' . $url); + $url->redirect(); exit; } } diff --git a/ansel/report.php b/ansel/report.php index 205ba3ad6..a8821823b 100644 --- a/ansel/report.php +++ b/ansel/report.php @@ -20,7 +20,7 @@ try { $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($gallery_id); } catch (Ansel_Exception $e) { $notification->push($gallery->getMessage()); - header('Location: ' . Horde::applicationUrl('view.php?view=List', true)); + Horde::applicationUrl('view.php?view=List', true)->redirect(); exit; } @@ -78,7 +78,7 @@ if ($form->validate()) { } else { $notification->push(_("Gallery was not reported."), 'horde.warning'); } - header('Location: ' . $return_url); + $return_url->redirect(); exit; } -- 2.11.0