Author Topic: install 2 galleries  (Read 42125 times)

0 Members and 1 Guest are viewing this topic.

Offline airliner

  • Newbie
  • *
  • Posts: 21
    • View Profile
install 2 galleries
« on: September 07, 2009, 10:07:24 AM »
Hi folks,

It it possible to install two galleries in the same database with different table prefixes and let them share login sessions ???
Is it hard to modify ??
I'm a bit of a newbie guys .. but I gues that constant, session.php has to be modified pretty much?

Thanx


Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Administrator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: install 2 galleries
« Reply #1 on: September 07, 2009, 10:02:16 PM »
assuming database prefix for you first 4images is 4images1 and for your second 4images is 4images2, then you can try replace in your second 4images includes/constants.php
define('SESSIONS_TABLE'$table_prefix.'sessions');
define('SESSIONVARS_TABLE'$table_prefix.'sessionvars');
define('USERS_TABLE'$table_prefix.'users');

with:
define('SESSIONS_TABLE''4images1_sessions');
define('SESSIONVARS_TABLE''4images1_sessionvars');
define('USERS_TABLE''4images1_users');


In includes/sessions.php find:
define('COOKIE_PATH''');

Replace with:
define('COOKIE_PATH''/path/to/first/4images/');


i.e. if your first 4images located at http://yourdomain.com/blah/4images1/, then the line would be:
define('COOKIE_PATH''/blah/4images1/');


not sure if it's going to work though
[EDIT]
just tested it, works fine, but you'll need add into config.php of each gallery:
define('SESSION_KEY'"this is a random string, must be identical in each gallery");

[/EDIT]
« Last Edit: December 20, 2009, 08:13:40 AM by V@no »
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline airliner

  • Newbie
  • *
  • Posts: 21
    • View Profile
Re: install 2 galleries
« Reply #2 on: September 08, 2009, 08:32:53 AM »
Thanx ... worked fine ..
I missed the session key part :)

Thank you very much Sir.

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Administrator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: install 2 galleries
« Reply #3 on: September 08, 2009, 08:58:19 AM »
I just discovered, that auto login will not work in second 4images. One more change needed in second 4images to fix that. (added to the instructions above)
« Last Edit: December 20, 2009, 08:13:04 AM by V@no »
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline airliner

  • Newbie
  • *
  • Posts: 21
    • View Profile
Re: install 2 galleries
« Reply #4 on: September 08, 2009, 09:36:20 AM »
Fantastic Sir! :)

Offline Benny Change

  • Addicted member
  • ******
  • Posts: 1.787
  • #WWG1WGA
    • View Profile
    • Qlobal-Change
Re: install 2 galleries
« Reply #5 on: September 13, 2009, 02:01:35 AM »
Beste Grüße
Benny

Offline Kurman

  • Newbie
  • *
  • Posts: 42
    • View Profile
    • www.kurman.ru
Re: install 2 galleries
« Reply #6 on: December 20, 2009, 07:03:45 AM »
Good job! Works perfectly!

Only one correction - the posts above have a mistyping:

If we use for first gallery database table prefix "4images1", then we must have no prefix in database of second gallery.

##############

A question:
Can we use as well 3 or more galleries with one user table? (just like above, but more than 2)?
« Last Edit: December 20, 2009, 07:52:24 AM by Kurman »
4images running as a music portal http://music.kurman.ru/

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Administrator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: install 2 galleries
« Reply #7 on: December 20, 2009, 08:08:04 AM »
The point behind prefixes is to have different tables on the same database. A table name without prefix would be automatically different from a table name with a prefix...and besides, using prefixes makes it easier to manage afterwards ;)

Theoretically this method should work for unlimited number of galleries, as long as they all on same database.
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline Kurman

  • Newbie
  • *
  • Posts: 42
    • View Profile
    • www.kurman.ru
Re: install 2 galleries
« Reply #8 on: December 20, 2009, 10:58:29 PM »
Not quite right, V@no.

Look:

We use users table from the first gallery, and we've prefix 4images1 for first gallery, and prefix 4images2 for the second, right?
  • in config.php of the first gallery we have $table_prefix = "4images1_";
  • in config.php of the second gallery we have $table_prefix = "4images2_";

So, if we call in constants.php in the second gallery for
Code: [Select]
define('SESSIONS_TABLE', '4images1_sessions');
define('SESSIONVARS_TABLE', '4images1_sessionvars');
define('USERS_TABLE', '4images1_users');

We will recieve mysql error, for script (second gallery) will search for
Code: [Select]
define('SESSIONS_TABLE', '4images2_4images1_sessions');
define('SESSIONVARS_TABLE', '4images2_4images1_sessionvars');
define('USERS_TABLE', '4images2_4images1_users');

Because in config of the second gallery we already put  $table_prefix = "4images2_";
and constats.php looks for 4images2_(its own prefix, defined in root config)+4images1_bla-bla.

So, if we do in that way, we must not use table prefix for second gallery. Then it will search correctly for tables and find them
Code: [Select]
define('SESSIONS_TABLE', '4images1_sessions');
define('SESSIONVARS_TABLE', '4images1_sessionvars');
define('USERS_TABLE', '4images1_users');

Because there is no prefix in its own config.php.

Practically it is it. I thought for 3 or more galleries, but there is no way to do it in the similar way :? Because each gallery, when calls for user table of the main gallery, adds its own prefix to path, and we get mysql error 116.. And only prefixless gallery finds right way for other user table.
« Last Edit: December 20, 2009, 11:14:31 PM by Kurman »
4images running as a music portal http://music.kurman.ru/

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Administrator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: install 2 galleries
« Reply #9 on: December 21, 2009, 12:11:11 AM »
You misunderstand this.
The original line (4images1) is:
define('SESSIONS_TABLE', $table_prefix.'sessions');

then in second 4images (with prefix 4images2) we change it to:
define('SESSIONS_TABLE', '4images1_sessions');
see, no more $table_prefix used, therefor there is no "4images2_4images1_sessions" issue
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline Kurman

  • Newbie
  • *
  • Posts: 42
    • View Profile
    • www.kurman.ru
Re: install 2 galleries
« Reply #10 on: December 21, 2009, 04:34:41 AM »
Now I see.

It is great feature of 4images, and amazing flexibility!  :wink:

Thank you, V@no!
4images running as a music portal http://music.kurman.ru/

Offline weedray

  • Pre-Newbie
  • Posts: 1
    • View Profile
Re: install 2 galleries
« Reply #11 on: January 24, 2010, 08:21:35 PM »
I figured out now what i was missing :)

Offline paule

  • Jr. Member
  • **
  • Posts: 65
    • View Profile
Re: install 2 galleries
« Reply #12 on: January 02, 2011, 08:41:16 PM »
Hallo,

ich habe die Änderungen vorgenommen und bekomme folgende Fehlermeldung wenn ich 4images2 aufrufen will:

Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in /Library/WebServer/Documents/4images2/includes/db_mysql.php on line 116

db_mysql.php Line 116 = return mysql_num_rows($this->query_id);

Gruß paule

1.7.7 / www.kosecki.de

Offline Jan-Lukas

  • Addicted member
  • ******
  • Posts: 1.284
    • View Profile
    • Discover the New World of Kindersurprise
Re: install 2 galleries
« Reply #13 on: January 03, 2011, 12:10:30 AM »
Hi Paule,
versuche das mal

http://www.4homepages.de/forum/index.php?topic=22668.0

LG

Backup nicht vergessen!
Danke Harald




Offline paule

  • Jr. Member
  • **
  • Posts: 65
    • View Profile
Re: install 2 galleries
« Reply #14 on: January 03, 2011, 01:13:41 PM »
Hallo Harald,

vielen Dank. Hab´s versucht. Es gibt keine Änderung der Fehlermeldung:

An unexpected error occured. Please try again later.
An unexpected error occured. Please try again later.
An unexpected error occured. Please try again later.
An unexpected error occured. Please try again later.
Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in /Library/WebServer/Documents/4images2/includes/db_mysql.php on line 116

Gibt´s noch eine Idee wie ich das Problem lösen kann?

beste Grüße paule