Closed Thread
Results 1 to 4 of 4

Thread: Protecting PHP Files!

  1. #1
    Bioshox is offline Programmer
    Join Date
    Oct 2009
    Location
    Manchester, UK
    Posts
    196
    Rep Power
    10

    Protecting PHP Files!

    Hey guys!

    Okay so at the moment I'm half way through working on a huge web script, and I have files that are included in certain pages.

    But I don't want these pages to be accessed individually, as they just display an error anyway.

    So how would I create a script that displayed an error message if say getposts.php was accessed?

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Location
    Advertising world
    Posts
    Many

     
  3. #2
    Join Date
    Jul 2006
    Posts
    16,491
    Blog Entries
    75
    Rep Power
    143

    Re: Protecting PHP Files!

    You could set a variable in index.php and check it with each page as the first step.
    Programming is a branch of mathematics.
    My CodeCall Blog | My Personal Blog

  4. #3
    Bioshox is offline Programmer
    Join Date
    Oct 2009
    Location
    Manchester, UK
    Posts
    196
    Rep Power
    10

    Re: Protecting PHP Files!

    Okay, so could I create a file named protect.php and within that have the code

    Code:
    <?php
    define
    ('protect'1);
    ?>
    And then another file named protectmsg.php with the code

    Code:
    <?php
    if(!defined('protect')){
    echo 
    'Denied.';
    die;
    }
    ?>
    and if I don't want the file public accessible just include protectmsg.php and if I do want the script to be ran include protect.php?

  5. #4
    Jaan Guest

    Re: Protecting PHP Files!

    Yea.. here I made a little tutorial months ago that explains Bioshox's method :

    Protect Php Files - Trill Designs

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Protecting PHP scripts
    By Misanthrope in forum PHP Development
    Replies: 3
    Last Post: 11-25-2010, 10:56 PM
  2. Help with protecting software while developing
    By Superfish in forum Business and Legal
    Replies: 7
    Last Post: 12-18-2009, 01:21 PM
  3. Differences between text files and binary files.
    By LoneWolf in forum C and C++
    Replies: 3
    Last Post: 02-24-2009, 04:36 PM
  4. Protecting your software
    By NeedHelp in forum Software Security
    Replies: 3
    Last Post: 11-12-2007, 03:31 AM
  5. Selling and Protecting PHP
    By falco85 in forum PHP Development
    Replies: 5
    Last Post: 09-03-2006, 02:55 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts