View Single Post
  #1  
Old 11-30-2005, 11:26 AM
lemuelf Offline
forum loafer
 
Join Date: Nov 2005
Posts: 2
Incorrect detection of $images_path in includes/create_tables.php during installation

Not a serious problem, since it seems that I'm the only one having this kind of setup, but I think it's better if we could also eliminate this...

I am setting up pixelpost for a friend and I downloaded version 1.4.3 and installed it on our test server here at work, for my friend to try it first before installing in his own webspace.

We are using apache2's mod_userdir, which means that each user on our server has their own 'document_root' in their own homes. On our current setup it's the 'public_html' subdirectory and it is accessible thru a URI like http://example.org/~lemuelf. I followed the installation instructions and after logging in as the admin user and tried posting a photo, it went through _without any errors_ but no photo got uploaded and no entry in the database. I checked the configs and found that the images path was set to '/srv/www/htdocs/~lemuelf/pixelpost_1.4.3/images/', which I have to change then to '/home/lemuelf/public_html/pixelpost_1.4.3/images/' to make posting photos work.

Although, this kind of setup is rare and the problem can be easily fixed by changing the configuration settings, I'd like to suggest a little modification in the $images_path detection code in the 'includes/create_tables.php' script so it will also work in a server setup just like ours (and those that don't have the scripts and 'images' directory under the 'document_root', like 'alias' setups) immediately after running the install script.

In the function 'Set_Configuration()' in 'includes/create_tables.php'
replace lines 147-150:
PHP Code:
$images_path $_SERVER['DOCUMENT_ROOT'];
$images_path .= $_SERVER['SCRIPT_NAME'];
$images_path pathinfo($images_path);
$images_path $images_path['dirname']; 
with
PHP Code:
$images_path realpath('./'); 
(not sure if function 'realpath' works in windows, though. We only have GNU/Linux boxes )

or, if realpath doesn't work, in lines 147-148 instead of
PHP Code:
$images_path $_SERVER['DOCUMENT_ROOT'];
$images_path .= $_SERVER['SCRIPT_NAME']; 
change it to
PHP Code:
$images_path $_SERVER['SCRIPT_FILENAME'
which is the real filesystem path of the script file. (Check the output of phpinfo() to see if the 'SCRIPT_FILENAME' variable is available with other web servers, we only have apache2 )
Reply With Quote