4images Forum & Community

4images Issues / Ausgaben => Installation, Update & Configuration => Topic started by: airliner on September 07, 2009, 10:07:24 AM

Title: install 2 galleries
Post by: airliner 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

Title: Re: install 2 galleries
Post by: V@no 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]
Title: Re: install 2 galleries
Post by: airliner on September 08, 2009, 08:32:53 AM
Thanx ... worked fine ..
I missed the session key part :)

Thank you very much Sir.
Title: Re: install 2 galleries
Post by: V@no 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)
Title: Re: install 2 galleries
Post by: airliner on September 08, 2009, 09:36:20 AM
Fantastic Sir! :)
Title: Re: install 2 galleries
Post by: Sunny C. on September 13, 2009, 02:01:35 AM
Nice!
Added to my List:
http://www.4homepages.de/forum/index.php?topic=24888.0

Thanks V@no!
Title: Re: install 2 galleries
Post by: Kurman 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)?
Title: Re: install 2 galleries
Post by: V@no 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.
Title: Re: install 2 galleries
Post by: Kurman 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?

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.
Title: Re: install 2 galleries
Post by: V@no 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
Title: Re: install 2 galleries
Post by: Kurman 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!
Title: Re: install 2 galleries
Post by: weedray on January 24, 2010, 08:21:35 PM
I figured out now what i was missing :)
Title: Re: install 2 galleries
Post by: paule 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
Title: Re: install 2 galleries
Post by: Jan-Lukas 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!
Title: Re: install 2 galleries
Post by: paule 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
Title: Re: install 2 galleries
Post by: Sunny C. on April 03, 2011, 10:21:42 PM
Dont work:

Galleri: One
Prefix: 4images_
Domain: http://mysite.de
Location: /

Galleri: Two
Prefix: media_
Domain: http://mysite.de/media
Location: /media

Galleri: Three
Prefix: forum_
Domain: http://mysite.de/forum
Location: /forum

Gallerie Two and Three Files:
constants.php
define('SESSIONS_TABLE', '4images_sessions');
define('SESSIONVARS_TABLE', '4images_sessions');
define('USERS_TABLE', '4images_sessions');

sessions.php
//-----------------------------------------------------
//--- Start Session -----------------------------------
//-----------------------------------------------------
define('COOKIE_NAME', '4images_');
define('COOKIE_PATH', '/');
define('COOKIE_DOMAIN', '');
define('COOKIE_SECURE', '0');

Error:
Quote
An unexpected error occured. Please try again later.
ERROR: Could not load configuration settings!

Quote
Bad SQL Query: SELECT setting_name, setting_value
        FROM SETTINGS_TABLE
Table 'd0105be8.SETTINGS_TABLE' doesn't exist

I could fix the problem. The login works now, but the logout does not work.

Gallery Two + Three Files:
constants.php
define('SESSIONS_TABLE', '4images_sessions');
define('SESSIONVARS_TABLE', '4images_sessionvars');
define('USERS_TABLE', '4images_users');

sessions.php
define('COOKIE_NAME', '4images_');
define('COOKIE_PATH', '/www/htdocs/w00b2576/gnv2/');
define('COOKIE_DOMAIN', '');
define('COOKIE_SECURE', '0');

config.php
define('SESSION_KEY', "this is a random string, must be identical in each gallery");

I have forgotten in the "gallery one" enter the session key. Now it works as desired
Title: Re: install 2 galleries
Post by: brez on October 26, 2011, 02:53:42 AM
So, is the code on the first post all i need to do? (Up to date)

and...

Does the second gallery appear beside or under the first on Homepage?

Brez
Title: Re: install 2 galleries
Post by: V@no on October 26, 2011, 04:31:05 AM
So, is the code on the first post all i need to do? (Up to date)
yes

Does the second gallery appear beside or under the first on Homepage?
mmmm if the "homepage" is your first gallery, then second will be under different directory, otherwise they could be beside of each other, it's all up to you.
Title: Re: install 2 galleries
Post by: Bob_62 on October 02, 2012, 07:52:26 AM
This is my first post and I'm not sure how to post this where I need it to go!!!

At the Image Box I insert the image from the browser and then in the box under it "URL" I don't know what to put there to upload the image.  Without the right information in the text box, I get an error message.  Can you walk me through the process as I have about 30 images for my first category.

Thank You