Home N-13 News Forums Help Search
RegisterForgot password?
How to add image to post necklacesdiscou
Known bugs - 4.0.3 necklacesdiscou

Latest N-13 News 4.0.3

What is N-13 News?
Where can I get help?
Known bugs

Forums Help & Support Problem downloading attached files
Sputnik
Posted on 08 Mar 2011, 01:32:45

Access: Member
Total Posts: 6
Joined: 2010-12-20

Hello Chris, I have a problem with the downloads. It seems that when I click an attached file in an article, the script ignores the path between the web address and the uploads folder. Instead of accessing www.mysite.com/n13news/uploads/myfile.pdf, it tries to access www.mysite.comuploads/myfile.pdf which is -obviously- wrong. I have checked that the correct script & uploads location is set in the "options" section and it is correct, since I can upload files and see the news articles.

I suspect that this is happening because I have installed the script and then moved it to another, more permanent location. Any ideas on how to fix this problem? Thanks in advance!
#3327
Chris
Posted on 08 Mar 2011, 06:37:06

Access: Admin
Total Posts: 1395
Joined: 2006-05-19

That's very odd. Would you be able to access your database directly using a program like phpmyadmin? Reason I ask is I want to see if the download URL for each file is being stored incorrectly in the database in the table "news30_files".

The files that have the wrong download URL, are these files that were already added before you moved the script? can you test by adding a new file to see if the problem persists for that file too?
#3329
Last edited by Chris at 2011-03-08 06:39:03 Reason:
Sputnik
Posted on 08 Mar 2011, 14:31:19

Access: Member
Total Posts: 6
Joined: 2010-12-20

Quote:
That's very odd. Would you be able to access your database directly using a program like phpmyadmin? Reason I ask is I want to see if the download URL for each file is being stored incorrectly in the database in the table "news30_files".

Unfortunately I can't. If it helps you, the website uses IIS and I had the same problem when I was testing the script in my computer -again using IIS. Maybe I can check it on my computer when I get home.
*Update: yes, in the table "news30_files" the path is wrong as you predicted. I am suspecting that something is wrong with the PHP configuration of the server, because the same thing happens with a new install of the script using a new database name. After installing, I entered the admin area and no path was correct (smileys, Image uploads path, Script path). It just displayed www.mysite.com instead of www.mysite.com/n13news/. Manually correcting the path does not solve the problem.

Quote:
The files that have the wrong download URL, are these files that were already added before you moved the script? can you test by adding a new file to see if the problem persists for that file too?

The files with the wrong download url are both the ones before I moved the script as well as after. Yes, I have tried adding a new file and the problem persists.
#3331
Last edited by Sputnik at 2011-03-08 23:24:13 Reason:
Chris
Posted on 09 Mar 2011, 01:11:13

Access: Admin
Total Posts: 1395
Joined: 2006-05-19

Well I discovered the problem. When installing the script, it stores a few variables in the database, image upload path & script path. The way it gets both of these values to begin with is it uses the $_SERVER['HTTP_HOST'] & $_SERVER['REQUEST_URI'] variables which would output something like this

Code:
<?php
echo $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
// outputs example.com/news/file.php
?>


What I found out, is that IIS does NOT support $_SERVER['REQUEST_URI'] so the above could would instead output like this

Code:
<?php
echo $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
// outputs example.com
?>


So there lies the problem. The solution? use a bit of hackery to manually define the $_SERVER['REQUEST_URI'] variable somewhere in the script.

If you edit config.php, anywhere near the top add the following code

Code:
if(isset($_SERVER['REQUEST_URI'])){
    $_SERVER['REQUEST_URI'] = substr($_SERVER['PHP_SELF'], 0);
    if(isset($_SERVER['QUERY_STRING']) AND $_SERVER['QUERY_STRING'] != "") {
        $_SERVER['REQUEST_URI'] .= '?' .$_SERVER['QUERY_STRING'];
    }
}


This will manually set the $_SERVER['REQUEST_URI'] variable so that it should work as expected throughout the script. Previously uploaded files will need to be manually changed directly in the database and if you haven't done so already change the "Image upload path" & "Script path" in the Options > System.
#3332
Sputnik
Posted on 09 Mar 2011, 14:02:43

Access: Member
Total Posts: 6
Joined: 2010-12-20

Very helpful Chris. I tried your solution but it didn't work. However, with a little bit of googling, I found that the code that works for me is
Code:
if (!isset($_SERVER['REQUEST_URI'])) {
$_SERVER['REQUEST_URI'] = substr($_SERVER['PHP_SELF'],1 );
if (isset($_SERVER['QUERY_STRING']) AND $_SERVER['QUERY_STRING'] != "") {
$_SERVER['REQUEST_URI'] = substr($_SERVER['PHP_SELF'],0 );
}
}

Still, I had to manually edit the correct location for the downloads and the smilies, but the script path itself was correct. I will give it another try in a different machine using a freshly created database and report.

I must add that I experienced this problem in IIS 5.1 (Windows XP Pro) and in IIS 6 (Windows Server 2003). Installing and running the script in IIS 7.5 (Windows 7) showed no problem.

Cheers!
#3333
Last edited by Sputnik at 2011-03-09 22:11:30 Reason:
maxtoor
Posted on 07 Jan 2012, 14:25:22

Access: Member
Total Posts: 1
Joined: 2012-01-07

I have the same problem with Apache 2, but I solved the same way. (ver. 4.0.2)

#3677
Network-13.com © 2013