LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 02-21-2005, 06:35 PM   #1
Paiway
LQ Newbie
 
Registered: Dec 2004
Location: Sweden
Distribution: Debian ' Sid' 2.6.9
Posts: 14

Rep: Reputation: 0
Apache/php4 - disabling direct viewing of text files


Hello.

I am running Apache 1.3.33 and PHP4 on Debian Sid 2.6.9. My page uses PHP to determine what page to view in the following fashion:
PHP Code:
    if (isset($_GET['main'])) {
      
$maindisplay basename($_GET['main']) . ".txt";
      
$main $_GET['main'];
    }
      else {
          
$maindisplay "main.txt";
    
$main main;
    }
    
    if (!
file_exists ($maindisplay)) {
      
$maindisplay "404.txt";
    } 
...and displays the selected page like this:
PHP Code:
    <div id="main">
    <?php include($maindisplay); ?>
    </div>
The problem is that anyone can view the raw text files instead of the ones produced by PHP by entering, for example, url.to.my.page/news.txt instead of url.to.my.page?main=news. This can be a Very Bad Thing if I have a script that I want to protect, or something like that.

How do i counter this? I will switch to using a MySQL database soon enough, but right now that isn't an option.

Thank you.
 
Old 02-21-2005, 10:09 PM   #2
aznluvsmc
Member
 
Registered: Aug 2004
Location: Newmarket, Ontario
Distribution: OpenSuse 10.2
Posts: 184

Rep: Reputation: 30
Two options:
1. Don't put new.txt in any folder that is accessible from the net.
2. Don't give read permissions to the Others group on the file
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert DOS text files to UNIX text files ta0kira Linux - Software 7 03-15-2011 11:42 AM
viewing text in foreign languages h/w Linux - General 8 04-14-2004 09:49 PM
Aterm eror viewing text cav Linux - General 5 04-20-2003 11:19 PM
Best way to ALOT of files in a direct to other direct? packman Linux - General 2 10-21-2002 07:31 PM
default font for viewing text files glock19 Linux - General 6 02-04-2002 02:36 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 12:58 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration