Announcement

#1 2013-05-30 23:15:30

hoedlmoser
Member
Dingelberg, Austria
2013-05-30
10

physical albums are not multisite save

hi!

on a multisite installation, as I described in [Forum, topic 22170] multisite, wrong documentation in wiki, physical albums will access from every single multisite the same galleries directory.

so, for example, with Tools -> Site Manager two different single multisites can just choose the same galleries directory. which is in fact already immediatly after installing the single multisite, because first directory is always ./galleries/.

the only simple way I see to correct this is at that time when the user setups a new galleries directory with automatically prefixing the path with the multisites path.

Code:

--- admin/site_manager.php  2013-01-01 13:35:02.000000000 +0100
+++ admin/site_manager.php  2013-05-30 22:24:05.000000000 +0200
@@ -55,6 +55,10 @@
   }
   $url = preg_replace('/[\/]*$/', '', $_POST['galleries_url']);
   $url.= '/';
+  if (isset($conf['site_dir']))
+  {
+    $url = $conf['site_dir'] . '/' . $url;
+  }
   if ( ! (strpos($url, '.') === 0 ) )
   {
     $url = './' . $url;

and set site_dir in local/config/config.inc.php

Code:

if (preg_match('/^piwigo.kmp.or.at$/', $_SERVER['SERVER_NAME']))
{
  $site_dir = 'gallery/kmp';
}

if (isset($site_dir))
{
  define('PWG_LOCAL_DIR', $site_dir.'/local/');
  $conf['upload_dir'] = './'.$site_dir.'/upload';
  $conf['data_location'] = $site_dir.'/_data/';
  $conf['site_dir'] = $site_dir;
  
  # in case there is a specific configuration file for each "site"
  @include(PHPWG_ROOT_PATH.PWG_LOCAL_DIR. 'config/config.inc.php');
}

in any case you need to adapt the path of the first galleries directory ./galleries in the database itself.

what Do you think of my solution?

gre3tings, Klaus

Offline

 

#2 2013-05-31 11:24:36

flop25
Piwigo Team
2006-07-06
7037

Re: physical albums are not multisite save

I think you should add it in the wiki first


To get a better help : Politeness like Hello-A link-Your past actions precisely described
Check my extensions : more than 30 available
who I am and what I do : http://fr.gravatar.com/flop25
My gallery : an illustration of how to integrate Piwigo in your website

Offline

 

#3 2013-05-31 14:55:06

plg
Piwigo Team
Nantes, France, Europe
2002-04-05
13786

Re: physical albums are not multisite save

I fully agree that multisite feature is not compatible with synchronization. I have implemented it with synchronization disabled in mind.

I think the idea of introducing $conf['site_dir'] is smart.

I'm not sure that it's what you meant, but it would be good if the site_dir was invisible to the user. For example, we should have only "galleries" and it would automatically mean $conf['site_dir']/galleries (in site_update + site_manager)

I would also like that (if multisite) directories added in the directory manager could only be within site_dir. The idea is to avoid ../others_site/galleries if you understand what I mean.

Offline

 

#4 2013-05-31 17:14:02

hoedlmoser
Member
Dingelberg, Austria
2013-05-30
10

Re: physical albums are not multisite save

hugh!

plg wrote:

I think the idea of introducing $conf['site_dir'] is smart.

thanks, it was just the fastest way for me.

plg wrote:

I'm not sure that it's what you meant, but it would be good if the site_dir was invisible to the user. For example, we should have only "galleries" and it would automatically mean $conf['site_dir']/galleries (in site_update + site_manager)

you are completly right for a huge site as piwigo.com, but I'd like to host here maximum 6 piwigos. and all of them are friends. :-) and anyhow, you will get the path from the html source code eg:

Code:

<link rel="stylesheet" type="text/css" href="gallery/kmp/_data/combined/15bx769.css">

plg wrote:

I would also like that (if multisite) directories added in the directory manager could only be within site_dir. The idea is to avoid ../others_site/galleries if you understand what I mean.

understood, but this shoud be achievable with just some normalizing the path. means some regex in removing everything with . and / afterwards, multiple / and / at beginning and end.

Code:

--- admin/site_manager.php  2013-01-01 13:35:02.000000000 +0100
+++ admin/site_manager.php  2013-05-31 17:06:31.000000000 +0200
@@ -33,6 +33,11 @@
 // +-----------------------------------------------------------------------+
 check_status(ACCESS_ADMINISTRATOR);
 
+if (!$conf['enable_synchronization'])
+{
+  die ('synchronization is disabled');
+}
+
 if (!empty($_POST) or isset($_GET['action']))
 {
   check_pwg_token();
@@ -53,8 +58,12 @@
   {
     fatal_error('remote sites not supported');
   }
-  $url = preg_replace('/[\/]*$/', '', $_POST['galleries_url']);
+  $url = preg_replace(array('/\/+/', '/(\.+\/)|(^\/)|(\/$)/'), array('/', ''), $_POST['galleries_url']);
   $url.= '/';
+  if (isset($conf['site_dir']))
+  {
+    $url = $conf['site_dir'] . '/' . $url;
+  }
   if ( ! (strpos($url, '.') === 0 ) )
   {
     $url = './' . $url;

gre3tings, Klaus

Offline

 

#5 2013-05-31 21:34:38

hoedlmoser
Member
Dingelberg, Austria
2013-05-30
10

Re: physical albums are not multisite save

hi to all!

just documented also that topic in Wiki: Multiple Site (Multisite) - Physical Albums.

I would be pleased to receive your feedback.

gre3tings, Klaus

Offline

 

Board footer

Powered by FluxBB

github twitter newsletter Donate Piwigo.org © 2002-2024 · Contact