Skip to content

Commit

Permalink
Merge branch 'master' of github.com:gallery/gallery3-contrib
Browse files Browse the repository at this point in the history
  • Loading branch information
ckieffer committed Nov 26, 2009
2 parents 6d8f000 + 07bb262 commit 24ad098
Show file tree
Hide file tree
Showing 8 changed files with 161 additions and 0 deletions.
3 changes: 3 additions & 0 deletions 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.
45 changes: 45 additions & 0 deletions modules/remote/controllers/gallery_remote.php
@@ -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 changes: 38 additions & 0 deletions modules/remote/helpers/gallery_remote.php
@@ -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 changes: 40 additions & 0 deletions modules/remote/libraries/GalleryRemoteReply.php
@@ -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 changes: 3 additions & 0 deletions 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
13 changes: 13 additions & 0 deletions 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);
}

/**
4 changes: 4 additions & 0 deletions modules/remote/patches/gallery_remote2.php
@@ -0,0 +1,4 @@
<?
$_GET["kohana_uri"] = "/gallery_remote";
include("index.php");
?>
15 changes: 15 additions & 0 deletions 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]
# </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>

0 comments on commit 24ad098

Please sign in to comment.