From 06bd5cd878ac99e5eeb18de44b98f56b76f69509 Mon Sep 17 00:00:00 2001 From: "Thomas E. Horner" Date: Sat, 25 Aug 2012 09:32:14 +0200 Subject: [PATCH] updated the protocol version check --- .../remote/controllers/gallery_remote.php | 16 ++++++++++++---- 3.0/modules/remote/helpers/gallery_remote.php | 5 ++++- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/3.0/modules/remote/controllers/gallery_remote.php b/3.0/modules/remote/controllers/gallery_remote.php index 26170cc2..6a41f657 100644 --- a/3.0/modules/remote/controllers/gallery_remote.php +++ b/3.0/modules/remote/controllers/gallery_remote.php @@ -77,6 +77,7 @@ class Gallery_Remote_Controller extends Controller { private function _check_protocol(&$input, &$reply) { $version = trim($input->post('protocol_version')); + $reply->set('status_text', 'Minimum protocol version required: '.gallery_remote::GR_PROT_MAJ.'.'.gallery_remote::GR_PROT_MIN.' - your client\'s protocol version: '.$version); if($version=='') { $reply->send(gallery_remote::PROTO_VER_MISSING); return false; @@ -85,14 +86,21 @@ class Gallery_Remote_Controller extends Controller { $reply->send(gallery_remote::PROTO_MAJ_FMT_INVAL); return false; } - else if($version<'2') { + else if($versionsend(gallery_remote::PROTO_MAJ_VER_INVAL); return false; } - else if($version<'2.3') { - $reply->send(gallery_remote::PROTO_MIN_VER_INVAL); + else if(strpos($version, '.')===false) { + $reply->send(gallery_remote::PROTO_MAJ_FMT_INVAL); return false; } + else { + $ver = explode('.', $version); + if($ver[0]==gallery_remote::GR_PROT_MAJ && $ver[1]send(gallery_remote::PROTO_MIN_VER_INVAL); + return false; + } + } return true; } @@ -357,7 +365,7 @@ class Gallery_Remote_Controller extends Controller { catch (ORM_Validation_Exception $e) { $validation = $e->validation; //print_r($validation->errors()); exit; - $reply->set('status_text', t('Failed to save item %item: %errors', array('item' => $filename, 'errors' => str_replace("\n", ' ', print_r($validation->errors(),true))) )); + $reply->set('status_text', t('Failed to validate item %item: %errors', array('item' => $filename, 'errors' => str_replace("\n", ' ', print_r($validation->errors(),true))) )); $reply->send(gallery_remote::UPLOAD_PHOTO_FAIL); //FIXME gallery remote ignores this return value and continues to wait } catch (Exception $e) { diff --git a/3.0/modules/remote/helpers/gallery_remote.php b/3.0/modules/remote/helpers/gallery_remote.php index 744b6b27..c0621ddf 100644 --- a/3.0/modules/remote/helpers/gallery_remote.php +++ b/3.0/modules/remote/helpers/gallery_remote.php @@ -18,6 +18,9 @@ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ class gallery_remote_Core { + const GR_PROT_MAJ = 2; + const GR_PROT_MIN = 3; + const GR_STAT_SUCCESS = 0; const PROTO_MAJ_VER_INVAL = 101; const PROTO_MIN_VER_INVAL= 102; @@ -35,4 +38,4 @@ class gallery_remote_Core { const CREATE_ALBUM_FAILED = 502; const MOVE_ALBUM_FAILED = 503; const ROTATE_IMAGE_FAILED = 504; -} \ No newline at end of file +}