4images Forum & Community
4images Issues / Ausgaben => Installation, Update & Configuration => Topic started 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
-
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]
-
Thanx ... worked fine ..
I missed the session key part :)
Thank you very much Sir.
-
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)
-
Fantastic Sir! :)
-
Nice!
Added to my List:
http://www.4homepages.de/forum/index.php?topic=24888.0
Thanks V@no!
-
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)?
-
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.
-
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
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
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
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.
-
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
-
Now I see.
It is great feature of 4images, and amazing flexibility! :wink:
Thank you, V@no!
-
I figured out now what i was missing :)
-
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
-
Hi Paule,
versuche das mal
http://www.4homepages.de/forum/index.php?topic=22668.0
LG
Backup nicht vergessen!
-
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
-
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:
An unexpected error occured. Please try again later.
ERROR: Could not load configuration settings!
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
-
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
-
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.
-
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