Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
82 commits
Select commit Hold shift + click to select a range
90caf88
Merge branch 'dev/gmap-v3' into ahpn-main
miceno Dec 8, 2022
0b24053
Add missing static modifier.
miceno Dec 8, 2022
18a8d55
Add more missing static modifier.
miceno Dec 8, 2022
5ce3a51
Merge branch 'dev/allow-portrait-landscape' into ahpn-main
miceno Dec 8, 2022
0edc186
Merge branch 'main' into ahpn-main
miceno Dec 9, 2022
2bfff87
Merge branch 'main' into ahpn-main
miceno Dec 10, 2022
58efe62
Merge branch 'main' into ahpn-main
miceno Dec 16, 2022
022a8c0
Merge branch 'dev/comments' into ahpn-main
miceno Dec 16, 2022
68b23bc
Merge branch 'dev/adodb-float' into ahpn-main
miceno Dec 16, 2022
a5b5ce7
Merge branch 'main' into ahpn-main
miceno Dec 17, 2022
46180e4
Merge branch 'dev/fix-square-thumbs' into ahpn-main
miceno Dec 17, 2022
7d2126b
Merge branch 'main' into ahpn-main
miceno Dec 18, 2022
db5c4ed
Merge branch 'main' into ahpn-main
miceno Dec 22, 2022
0edad7c
Merge branch 'dev/po-files' into ahpn-main
miceno Dec 26, 2022
35143bf
Merge branch 'dev/modules-po-files' into ahpn-main
miceno Dec 27, 2022
f56b635
Merge branch 'dev/themes-po-files' into ahpn-main
miceno Dec 27, 2022
19c422b
Merge branch 'dev/update-step' into ahpn-main
miceno Dec 28, 2022
be2176b
Merge branch 'dev/fix-minor' into ahpn-main
miceno Dec 28, 2022
18d466a
Merge branch 'main' into ahpn-main
miceno Jan 2, 2023
4fcc2e5
Merge branch 'dev/fix-searchtests' into ahpn-main
miceno Jan 2, 2023
ac8058f
Merge branch 'dev/fix-slugtests' into ahpn-main
miceno Jan 2, 2023
4a9bf8d
Merge branch 'dev/fix-keywords' into ahpn-main
miceno Jan 2, 2023
81078b1
Merge branch 'main' into ahpn-main
miceno Jan 4, 2023
14c7076
Merge branch 'dev/update-step' into ahpn-main
miceno Jan 4, 2023
cbe5756
Merge branch 'dev/graphicsmagick-compat' into ahpn-main
miceno Jan 4, 2023
d735b99
Merge branch 'main' into ahpn-main
miceno Jan 5, 2023
76c5a12
Merge branch 'fix/update-pathcomponent' into ahpn-main
miceno Jan 17, 2023
4b160db
Add additional version numbers for watermark modules.
miceno Jan 18, 2023
0dcbd5c
Merge branch 'dev/fix-rewritetests' into ahpn-main
miceno Jan 18, 2023
cd0a613
Merge branch 'dev/fix-rewritetests' into ahpn-main
miceno Jan 18, 2023
ab828aa
Merge branch 'main' into ahpn-main
miceno Jan 20, 2023
4dcb8d6
Merge branch 'fix/error-on-search-results' into ahpn-main
miceno Feb 5, 2023
69f6510
Merge branch 'fix/watermark-compat' into ahpn-main
miceno Jun 16, 2023
653d7f2
Add .htaccess file
miceno Jun 16, 2023
4996fdc
Update gitignore file to ignore custom modules and themes.
miceno Jun 16, 2023
e3b9661
Merge branch 'main' into ahpn-main
miceno Jun 16, 2023
a536c98
Merge branch 'dev/addtoany' into ahpn-main
miceno Jun 16, 2023
d77284d
Merge branch 'main' into ahpn-main
miceno Jun 17, 2023
cb0148d
Merge branch 'fix/geturls-unbound-p' into ahpn-main
miceno Jun 17, 2023
d725020
Merge branch 'main' into ahpn-main
miceno Jun 18, 2023
a722943
Merge branch 'fix/pregmatch' into ahpn-main
miceno Jun 18, 2023
1eb8e7b
Merge branch 'fix/broken-map' into ahpn-main
miceno Jun 18, 2023
18333c2
Merge branch 'fix/more-smarty-strftime' into ahpn-main
miceno Jun 18, 2023
e1f66c9
Merge branch 'dev/docker-refactor' into ahpn-main
miceno Jun 22, 2023
dc482b1
Some fixes for install on PHP 8.1
miceno Jun 22, 2023
6d3cbda
Merge branch 'fix/json-premature-header' into ahpn-main
miceno Jun 22, 2023
d37d97b
Merge branch 'fix/setup' into ahpn-main
miceno Jun 22, 2023
9f43e0b
Merge branch 'fix/json-premature-header' into ahpn-main
miceno Jun 23, 2023
ad8ed34
Refactor to avoid PHP 8.1 warning on var reference.
miceno Jun 24, 2023
29a5b1c
Add a check in case an error on creating the entity.
miceno Jun 24, 2023
d12ab7d
Merge branch 'main' into fix/setup
miceno Jun 24, 2023
df8a823
Merge branch 'main' into ahpn-main
miceno Jun 24, 2023
34fc417
Merge branch 'fix/more-pregmatch' into ahpn-main
miceno Jun 24, 2023
5c9f09c
Merge branch 'fix/setup' into ahpn-main
miceno Jun 24, 2023
c76dfb2
Update htaccess config
miceno Jun 24, 2023
6c32bfd
Rename file to avoid clash on deployment.
miceno Jun 24, 2023
4cf0314
Merge branch 'doc/update-devel-doc' into ahpn-main
miceno Jun 24, 2023
feff0ba
Merge branch 'fix/https-tests' into ahpn-main
miceno Jun 24, 2023
3fee60b
Fix protocol in tests.
miceno Jun 24, 2023
f153e07
Fix protocol in tests.
miceno Jun 24, 2023
b35f6ea
Fix protocol in tests.
miceno Jun 24, 2023
319e425
Merge branch 'fix/rewrite' into ahpn-main
miceno Jun 24, 2023
dec2b64
Fix to avoid null params deprecated usage warnings.
miceno Jun 24, 2023
ea45d1a
Merge branch 'fix/unserialize' into ahpn-main
miceno Jun 24, 2023
8921822
Merge branch 'fix/keyalbum-test' into ahpn-main
miceno Jun 24, 2023
7ae72c7
Merge branch 'fix/keyalbum-test' into ahpn-main
miceno Jun 24, 2023
aab2aad
Merge branch 'main' into ahpn-main
miceno Jun 26, 2023
1834b63
Merge branch 'main' into fix/rewrite
miceno Jun 26, 2023
1cf8673
Merge branch 'main' into fix/setup
miceno Jun 26, 2023
45ff3a0
Add docker volume copy script.
miceno Jun 26, 2023
7906f15
Add docker volume copy script.
miceno Jun 26, 2023
62e78c6
Update docker compose to use a volume and not a mount point.
miceno Jun 26, 2023
d662c7d
Merge branch 'fix/setup' into ahpn-main
miceno Jun 26, 2023
d834e18
Merge branch 'fix/rewrite' into ahpn-main
miceno Jun 26, 2023
6ce8064
Fix access to array elements
miceno Oct 10, 2025
0d8fe13
Update addtoany translations
miceno Oct 10, 2025
9b9dc5c
Add sample apache file
miceno Oct 10, 2025
45b2593
Add sample Google Analytics file
miceno Oct 10, 2025
6103c4b
Add dev tools
miceno Oct 10, 2025
6fe6c15
Add sample php ini file
miceno Oct 10, 2025
7df6368
Add sample php ini file
miceno Oct 10, 2025
92c8393
Remove duplicated sample file
miceno Oct 10, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@ login.txt
*.swp
gallery2-data
mysqldata
modules/bulkexcelupload
themes/bootstrap_matrix
modules/mapv3/images/routes
56 changes: 56 additions & 0 deletions .htaccess-sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#{gallerySection}

RewriteEngine On
# Redirect all requests to HTTPS
RewriteCond %{HTTPS} "!=on"
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]

RedirectMatch 404 \.(md|txt|ini|Dockerfile|git|htaccess|inc)
RedirectMatch 404 (docker|config\.php|phpinfo|README|LICENSE)

# BEGIN Url Rewrite section
# (Automatically generated. Do not edit this section)
<IfModule mod_rewrite.c>
RewriteEngine On

RewriteBase /

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} gallery\_remote2\.php
RewriteCond %{REQUEST_URI} !/main\.php$
RewriteRule . - [L]

RewriteCond %{QUERY_STRING} g2_view=core.DownloadItem
RewriteCond %{QUERY_STRING} g2_itemId=([0-9]+)
RewriteCond %{HTTP:Referer} !^[a-zA-Z0-9\+\.\-]+://%{SERVER_NAME}/ [NC]
RewriteCond %{HTTP:Referer} !^$
RewriteRule . /main.php?g2_view=watermark.DownloadItem&g2_itemId=%1 [L]
RewriteCond %{THE_REQUEST} /sitemap(\?.|\ .)
RewriteCond %{REQUEST_URI} !/main\.php$
RewriteRule . /main.php?g2_view=sitemap.Sitemap [QSA,L]
RewriteCond %{THE_REQUEST} /mapa/(G{1}[0-9]+)*(\?.|\ .)
RewriteCond %{REQUEST_URI} !/main\.php$
RewriteRule . /main.php?g2_view=mapv3.ShowMap&g2_Group=%1 [QSA,L]
RewriteCond %{THE_REQUEST} /fotografia/([^?]+)(\?.|\ .)
RewriteCond %{REQUEST_URI} !/main\.php$
RewriteRule . /main.php?g2_path=%1 [QSA,L]
RewriteCond %{THE_REQUEST} /paraules/([^?/]+)(\?.|\ .)
RewriteCond %{REQUEST_URI} !/main\.php$
RewriteRule . /main.php?g2_view=keyalbum.KeywordAlbum&g2_keyword=%1 [QSA,L]
</IfModule>

# END Url Rewrite section

<ifmodule mod_expires.c>
ExpiresActive On
ExpiresDefault A30600
</ifmodule>
<filesmatch ".(jpg|JPG|gif|GIF|png|css|ico|js|gz|gzip|swf)$">
<ifmodule mod_headers.c>
Header append Cache-Control "public"
</ifmodule>
<ifmodule mod_expires.c>
ExpiresDefault "access plus 7 day"
</ifmodule>
</filesmatch>
15 changes: 15 additions & 0 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,21 @@ for `ca_ES` locale. Add a line like it using your locale:
&& sed -i -e 's/# ca_ES ISO-8859-1/ca_ES ISO-8859-1/' /etc/locale.gen \
```

## Copy volumes

You can create a backup copy of the `mysqldata` and `gallery2-data` volumes to start afresh.

There is a `copy-volumes.sh` script that allows you to create a copy of the volume.

In case you would like to reset the state to the one in the vanilla volumes, you just need to copy data from the
vanilla volumes to the new volumes.

You will need to add the volume as an external volume in docker-compose config file:
```yaml
gallery2-php8_mysqldata-fresh:
external: true
```

# Release management

Tools for release management are on folder `lib/tools/release`.
Expand Down
8 changes: 6 additions & 2 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ services:
PHP_IDE_CONFIG: "serverName=docker"
volumes:
- .:/app
- ./gallery2-data:/gallery2-data
- gallery2-data:/gallery2-data
- ./docker/php.ini:/usr/local/etc/php/conf.d/custom.ini
- ./docker/xdebug.ini:/usr/local/etc/php/conf.d/xdebug.ini
links:
Expand All @@ -32,6 +32,10 @@ services:
MYSQL_PASSWORD: 'secret'
MYSQL_DATABASE: 'gallery2'
volumes:
- ./mysqldata:/var/lib/mysql
- mysqldata:/var/lib/mysql
ports:
- "13306:3306"

volumes:
mysqldata: { }
gallery2-data: { }
9 changes: 9 additions & 0 deletions docker/copy-volumes.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash

set -u
set -a

SOURCE_VOLUME=$1
TARGET_VOLUME=$2

docker container run --rm -it -v $SOURCE_VOLUME:/from -v $TARGET_VOLUME:/to alpine ash -c "cd /from ; cp -av . /to"
20 changes: 20 additions & 0 deletions ga.js.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-XXXXYYYY-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());

gtag('config', 'UA-XXXXYYYY-1');
</script>

<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-ABCDEFGHIJ"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());

gtag('config', 'G-ABCDEFGHIJ');
</script>

2 changes: 1 addition & 1 deletion install/steps/AuthenticateStep.class
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class AuthenticateStep extends InstallStep {

function processRequest() {
if (!empty($_GET['downloadLogin'])) {
GallerySetupUtilities::generateTextFileForDownload('login.txt', $this->_uniqueKey);
GallerySetupUtilities::generateTextFileForDownload('login.txt', $this::_uniqueKey);
return false;
}

Expand Down
4 changes: 2 additions & 2 deletions install/steps/CreateConfigFileStep.class
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class CreateConfigFileStep extends InstallStep {
function processRequest() {
if (!empty($_GET['downloadConfig'])) {
GallerySetupUtilities::generateTextFileForDownload(
'config.php', $this->_getConfigContents());
'config.php', $this::_getConfigContents());
return false;
}

Expand Down Expand Up @@ -132,7 +132,7 @@ class CreateConfigFileStep extends InstallStep {
$this->_firstTime = false;
}

function _getConfigContents() {
static function _getConfigContents() {
global $galleryStub;
$configDir = $_SESSION['configPath'];
$baseDir = dirname(dirname(dirname(__FILE__)));
Expand Down
13 changes: 7 additions & 6 deletions install/steps/DatabaseSetupStep.class
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ class DatabaseSetupStep extends InstallStep {
$this->_config['type'] = 'mysqli';
$mysqltType = 'mysqli';
}
if ($this->_config['type'] == 'pdo_sqlite') {
$this->_config['database'] =
'sqlite:' . $galleryStub->getConfig('data.gallery.base') . 'gallery2.db';
if ($this->_config['type'] == 'pdo_sqlite') {
$this->_config['database'] =
'sqlite:' . $galleryStub->getConfig('data.gallery.base') . 'gallery2.db';
}
switch ($this->_config['type']) {
case 'mysql':
Expand Down Expand Up @@ -154,15 +154,16 @@ class DatabaseSetupStep extends InstallStep {
require_once(dirname(__FILE__) . '/../../lib/adodb/adodb.inc.php');

$this->_captureStart();
$this->_db =& ADONewConnection($this->_config['type']);
$ADOConnection = ADONewConnection($this->_config['type']);
$this->_db =& $ADOConnection;
$this->_captureEnd();

if (empty($this->_db)) {
$templateData['errors'][] = sprintf(
_('Unable to create a database connection of type %s'),
$this->_config['type']);
}

if (empty($templateData['errors'])) {
$this->_captureStart();
$this->_db->debug = true;
Expand Down Expand Up @@ -616,7 +617,7 @@ class DatabaseSetupStep extends InstallStep {
$GLOBALS['gallery']->setConfig('plugins.dirname',
$galleryStub->getConfig('plugins.dirname'));
$GLOBALS['gallery']->setConfig('data.gallery.version', $configPath . 'versions.dat');
$GLOBALS['gallery']->setConfig('data.gallery.locale', $configPath . 'locale'
$GLOBALS['gallery']->setConfig('data.gallery.locale', $configPath . 'locale'
. DIRECTORY_SEPARATOR);
}
global $gallery;
Expand Down
15 changes: 8 additions & 7 deletions lib/support/GallerySetupUtilities.class
Original file line number Diff line number Diff line change
Expand Up @@ -290,13 +290,14 @@ class GallerySetupUtilities {
* @param string $name the file's name
* @param string $contents the file's contents
*/
function generateTextFileForDownload($name, $contents) {
header('Content-Type: text/plain');
header('Content-Length: ' . strlen($contents));
header("Content-Description: Download $name to your computer.");
header("Content-Disposition: attachment; filename=$name");
print $contents;
}
static function generateTextFileForDownload($name, $contents)
{
header('Content-Type: text/plain');
header('Content-Length: ' . strlen($contents));
header("Content-Description: Download $name to your computer.");
header("Content-Disposition: attachment; filename=$name");
print $contents;
}

/**
* Cleanly start up our session.
Expand Down
2 changes: 2 additions & 0 deletions lib/tools/bin/.htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Order allow,deny
Deny from all
42 changes: 42 additions & 0 deletions lib/tools/bin/GNUmakefile.GalleryStorage
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
CLASSDIR ?= ..
TOOLDIR ?= ../../../../lib/tools
TMPDIR ?= tmp
RXP ?= $(shell which rxp 2>/dev/null)
XMLLINT ?= $(shell which xmllint 2>/dev/null)
XMLFILES = $(wildcard xml-src/*.xml)
PHP ?= php

all: validate tmp dbxml sql

tmp:
@if [ ! -d tmp ]; then mkdir tmp; fi
@if [ ! -d tmp/classxml ]; then mkdir tmp/classxml; fi
@if [ ! -d tmp/dbxml ]; then mkdir tmp/dbxml; fi

dbxml:
@if [ "x" != "$(wildcard $(CLASSDIR)/*.class)x" ]; then \
perl $(TOOLDIR)/bin/extractClassXml.pl --dtd=$(TOOLDIR)/dtd/GalleryClass2.1.dtd --quiet --out-dir=tmp/classxml $(CLASSDIR)/*.class; \
else \
echo "No .class files to parse!"; \
fi
@if [ "x" != "$(XMLFILES)x" ]; then cp xml-src/*.xml tmp/dbxml; fi
$(PHP) -q -C -f $(TOOLDIR)/bin/generate-dbxml.php

sql:
$(PHP) -q -C -f $(TOOLDIR)/bin/generate-sql.php

clean:
rm -rf tmp

validate:
@if [ "x" != "$(XMLFILES)x" ]; then \
if [ -x "$(XMLLINT)" ]; then \
xmllint --valid --noout $(XMLFILES); \
elif [ -x "$(RXP)" ]; then \
for xmlfile in $(XMLFILES); do \
rxp -sV $$xmlfile; \
done \
else \
echo "No available XML validators (need xmllint or rxp)"; \
fi \
fi
26 changes: 26 additions & 0 deletions lib/tools/bin/GNUmakefile.classes
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
RXP ?= $(shell which rxp 2>/dev/null)
XMLLINT ?= $(shell which xmllint 2>/dev/null)
PHP ?= php
CLASSES = $(shell ls *.class 2>/dev/null)

all: Entities.inc
if [ -f Maps.xml ]; then $(MAKE) Maps.inc; fi
if [ -f GalleryStorage/GNUmakefile ]; then cd GalleryStorage && $(MAKE); fi

%:
if [ -f GalleryStorage/GNUmakefile ]; then cd GalleryStorage && $(MAKE) $@; fi

Maps.inc: Maps.xml ../../../lib/tools/bin/maps.tpl
@if [ -x "$(XMLLINT)" ]; then \
xmllint --valid --noout Maps.xml; \
elif [ -x "$(RXP)" ]; then \
for xmlfile in $(XMLFILES); do \
rxp -sV Maps.xml; \
done \
else \
echo "No available XML validators (need xmllint or rxp)"; \
fi
$(PHP) -q -C ../../../lib/tools/bin/generate-maps.php

Entities.inc: $(CLASSES) ../../../lib/tools/bin/entities.tpl
$(PHP) -q -C ../../../lib/tools/bin/generate-entities.php
84 changes: 84 additions & 0 deletions lib/tools/bin/XmlParser.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
<?php
/*
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2008 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.
*
* XmlParser class adapted from a version by Monte Ohrt (monte at NOT-SP-AM dot ohrt dot com)
* published at http://php.net/xml
*/
class XmlParser {
public $_xmlObject;
public $_output = array();

public function __construct() {
$this->_xmlObject = xml_parser_create();
xml_set_object($this->_xmlObject, $this);
xml_set_character_data_handler($this->_xmlObject, 'dataHandler');
xml_set_element_handler($this->_xmlObject, 'startHandler', 'endHandler');
}

public function parse($path) {
$data = file_get_contents($path);

if ($data === false) {
die('Cannot open XML data file: ' . $path);
}

if (!xml_parse($this->_xmlObject, $data, 1)) {
die(
sprintf(
'XML error: %s at line %d',
xml_error_string(xml_get_error_code($this->_xmlObject)),
xml_get_current_line_number($this->_xmlObject)
)
);
xml_parser_free($this->_xmlObject);
}

return $this->_output;
}

public function startHandler($parser, $name, $attribs) {
$content = array(
'name' => $name,
);

if (!empty($attribs)) {
$content['attrs'] = $attribs;
}
array_push($this->_output, $content);
}

public function dataHandler($parser, $data) {
if (isset($data)) {
$outputIndex = count($this->_output) - 1;
$this->_output[$outputIndex]['content'] = $data;
}
}

public function endHandler($parser, $name) {
if (count($this->_output) > 1) {
$data = array_pop($this->_output);
$outputIndex = count($this->_output) - 1;
$this->_output[$outputIndex]['child'][] = $data;
}
}

public function cleanUp() {
xml_parser_free($this->_xmlObject);
}
}
Loading