From 07bb2625df9a516214e2cd5e189acb6ca970e8eb Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Mon, 23 Nov 2009 22:30:55 -0800 Subject: [PATCH] Beginning framework for the remote module --- modules/remote/README | 3 ++ modules/remote/controllers/gallery_remote.php | 45 +++++++++++++++++++ modules/remote/helpers/gallery_remote.php | 38 ++++++++++++++++ .../remote/libraries/GalleryRemoteReply.php | 40 +++++++++++++++++ modules/remote/module.info | 3 ++ modules/remote/patches/cookie.patch | 13 ++++++ modules/remote/patches/gallery_remote2.php | 4 ++ modules/remote/patches/htaccess.patch | 15 +++++++ 8 files changed, 161 insertions(+) create mode 100644 modules/remote/README create mode 100644 modules/remote/controllers/gallery_remote.php create mode 100644 modules/remote/helpers/gallery_remote.php create mode 100644 modules/remote/libraries/GalleryRemoteReply.php create mode 100644 modules/remote/module.info create mode 100644 modules/remote/patches/cookie.patch create mode 100644 modules/remote/patches/gallery_remote2.php create mode 100644 modules/remote/patches/htaccess.patch diff --git a/modules/remote/README b/modules/remote/README new file mode 100644 index 00000000..456a2e4c --- /dev/null +++ b/modules/remote/README @@ -0,0 +1,3 @@ +This is a preliminary work. To use it, you need to apply the changes +in the patches directory. It's got limited functionality and is only +the beginning of the effort. diff --git a/modules/remote/controllers/gallery_remote.php b/modules/remote/controllers/gallery_remote.php new file mode 100644 index 00000000..c12b02c2 --- /dev/null +++ b/modules/remote/controllers/gallery_remote.php @@ -0,0 +1,45 @@ +post("cmd")) { + case "login": + print "#__GR2PROTO__\n"; + $uname = $input->post("uname"); + if (empty($uname)) { + print "status=202\n"; + } else { + $user = user::lookup_by_name($uname); + $password = $input->post("password"); + if ($user && user::is_correct_password($user, $password)) { + print "status=0\n"; + user::login($user); + } else { + print "status=201\n"; + } + } + print "server_version=2.15\n"; + } + } +} diff --git a/modules/remote/helpers/gallery_remote.php b/modules/remote/helpers/gallery_remote.php new file mode 100644 index 00000000..65b301bf --- /dev/null +++ b/modules/remote/helpers/gallery_remote.php @@ -0,0 +1,38 @@ +status = $status; + return $reply; + } + + /** + * Set a property on this reply + * @chainable + */ + public static function set($key, $value) { + $this->$key = $value; + return $this; + } +} diff --git a/modules/remote/module.info b/modules/remote/module.info new file mode 100644 index 00000000..c526165b --- /dev/null +++ b/modules/remote/module.info @@ -0,0 +1,3 @@ +name = "Gallery Remote" +description = "Use Gallery Remote and other similar applications to control your Gallery" +version = 1 diff --git a/modules/remote/patches/cookie.patch b/modules/remote/patches/cookie.patch new file mode 100644 index 00000000..95b16f69 --- /dev/null +++ b/modules/remote/patches/cookie.patch @@ -0,0 +1,13 @@ +diff --git a/system/helpers/cookie.php b/system/helpers/cookie.php +index 901b6d8..df276ee 100644 +--- a/system/helpers/cookie.php ++++ b/system/helpers/cookie.php +@@ -45,7 +45,7 @@ class cookie_Core { + // Expiration timestamp + $expire = ($expire == 0) ? 0 : time() + (int) $expire; + +- return setcookie($name, $value, $expire, $path, $domain, $secure, $httponly); ++ return setcookie($name, $value, $expire, $path, $domain, $secure, 0); + } + + /** diff --git a/modules/remote/patches/gallery_remote2.php b/modules/remote/patches/gallery_remote2.php new file mode 100644 index 00000000..db39124b --- /dev/null +++ b/modules/remote/patches/gallery_remote2.php @@ -0,0 +1,4 @@ + diff --git a/modules/remote/patches/htaccess.patch b/modules/remote/patches/htaccess.patch new file mode 100644 index 00000000..b2b33617 --- /dev/null +++ b/modules/remote/patches/htaccess.patch @@ -0,0 +1,15 @@ +diff --git a/.htaccess b/.htaccess +index 1d8bcb3..8229928 100644 +--- a/.htaccess ++++ b/.htaccess +@@ -56,3 +56,10 @@ + # RewriteRule ^(.*)$ index.php?kohana_uri=$1 [QSA,PT,L] + # RewriteRule ^$ index.php?kohana_uri=$1 [QSA,PT,L] + # ++ ++# URL rewriting for Gallery Remote ++# ++# RewriteEngine On ++# RewriteBase /~bharat/gallery3/ ++# RewriteRule ^gallery_remote2.php$ index.php?kohana_uri=/remote [QSA,PT,L] ++#