Beginning framework for the remote module
This commit is contained in:
parent
b1119d82f1
commit
07bb2625df
3
modules/remote/README
Normal file
3
modules/remote/README
Normal file
@ -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.
|
45
modules/remote/controllers/gallery_remote.php
Normal file
45
modules/remote/controllers/gallery_remote.php
Normal file
@ -0,0 +1,45 @@
|
||||
<?php defined("SYSPATH") or die("No direct script access.");
|
||||
/**
|
||||
* Gallery - a web based photo album viewer and editor
|
||||
* Copyright (C) 2000-2009 Bharat Mediratta
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
class Gallery_Remote_Controller extends Controller {
|
||||
public function index() {
|
||||
gallery_remote::check_protocol_version();
|
||||
|
||||
$input = Input::instance();
|
||||
// TODO: Validate protocol version here
|
||||
switch($input->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";
|
||||
}
|
||||
}
|
||||
}
|
38
modules/remote/helpers/gallery_remote.php
Normal file
38
modules/remote/helpers/gallery_remote.php
Normal file
@ -0,0 +1,38 @@
|
||||
<?php defined("SYSPATH") or die("No direct script access.");
|
||||
/**
|
||||
* Gallery - a web based photo album viewer and editor
|
||||
* Copyright (C) 2000-2009 Bharat Mediratta
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
class gallery_remote_Core {
|
||||
const GR_STAT_SUCCESS = 0;
|
||||
const PROTO_MAJ_VER_INVAL = 101;
|
||||
const PROTO_MIN_VER_INVAL= 102;
|
||||
const PROTO_VER_FMT_INVAL = 103;
|
||||
const PROTO_VER_MISSING = 104;
|
||||
const PASSWD_WRONG = 201;
|
||||
const LOGIN_MISSING = 202;
|
||||
const UNKNOWN_CMD = 301;
|
||||
const NO_ADD_PERMISSION = 401;
|
||||
const NO_FILENAME = 402;
|
||||
const UPLOAD_PHOTO_FAIL = 403;
|
||||
const NO_WRITE_PERMISSION = 404;
|
||||
const NO_VIEW_PERMISSION = 405;
|
||||
const NO_CREATE_ALBUM_PERMISSION = 501;
|
||||
const CREATE_ALBUM_FAILED = 502;
|
||||
const MOVE_ALBUM_FAILED = 503;
|
||||
const ROTATE_IMAGE_FAILED = 504;
|
||||
}
|
40
modules/remote/libraries/GalleryRemoteReply.php
Normal file
40
modules/remote/libraries/GalleryRemoteReply.php
Normal file
@ -0,0 +1,40 @@
|
||||
<?php defined("SYSPATH") or die("No direct script access.");
|
||||
/**
|
||||
* Gallery - a web based photo album viewer and editor
|
||||
* Copyright (C) 2000-2009 Bharat Mediratta
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
class GalleryRemoteReply_Core {
|
||||
/**
|
||||
* Constructor.
|
||||
* @param int $status a Gallery Remote status code
|
||||
*/
|
||||
public static function factory($status) {
|
||||
$reply = new GalleryRemoteReply();
|
||||
$reply->status = $status;
|
||||
return $reply;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a property on this reply
|
||||
* @chainable
|
||||
*/
|
||||
public static function set($key, $value) {
|
||||
$this->$key = $value;
|
||||
return $this;
|
||||
}
|
||||
}
|
3
modules/remote/module.info
Normal file
3
modules/remote/module.info
Normal file
@ -0,0 +1,3 @@
|
||||
name = "Gallery Remote"
|
||||
description = "Use Gallery Remote and other similar applications to control your Gallery"
|
||||
version = 1
|
13
modules/remote/patches/cookie.patch
Normal file
13
modules/remote/patches/cookie.patch
Normal file
@ -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);
|
||||
}
|
||||
|
||||
/**
|
4
modules/remote/patches/gallery_remote2.php
Normal file
4
modules/remote/patches/gallery_remote2.php
Normal file
@ -0,0 +1,4 @@
|
||||
<?
|
||||
$_GET["kohana_uri"] = "/gallery_remote";
|
||||
include("index.php");
|
||||
?>
|
15
modules/remote/patches/htaccess.patch
Normal file
15
modules/remote/patches/htaccess.patch
Normal file
@ -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]
|
||||
# </IfModule>
|
||||
+
|
||||
+# URL rewriting for Gallery Remote
|
||||
+#<IfModule mod_rewrite.c>
|
||||
+# RewriteEngine On
|
||||
+# RewriteBase /~bharat/gallery3/
|
||||
+# RewriteRule ^gallery_remote2.php$ index.php?kohana_uri=/remote [QSA,PT,L]
|
||||
+#</IfModule>
|
Reference in New Issue
Block a user