#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Location
    UK
    Posts
    67
    Rep Power
    12

    Question Deny web access to PHP WML files


    Hi all,

    Could someone please tell me how to deny a PC user access to WML files that are written in PHP with a .php extension?

    Eg, if someone using a PC accesses the WML website, it prompts the user to download the .php file - I would rather they were not able to download the coding.

    I assume it is related to setting up mime types or identifying the browser and redirecting it to a proper HTML page.

    Any suggestions would be greatly appreciated.

    Thanks!

    Best Regards,

    - Chris
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Posts
    18
    Rep Power
    0
    I had the same problem.
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Posts
    3
    Rep Power
    0
    Did you ever get a workaround for this ? I have a similar problem.

    I have a WML file I want to access from both a WAP and regular PC browser. The file has a .php extension with the WML headers set at the top. I can access the the script from a WAP phone fine and also from the PC, except that I get the messagebox stating the the file format is unknown. The script does what it's supposed to - its just that I get this ugly message. I want to be able to run the script as a cron job as well as a manual job from both PC and WAP. Therefore I need to be able to determine what type of device is accessing the page and then do something appropriate. Unfortunatly, as far as I know you cannot do any processing before setting the header info.

    Any ideas (apart from having to seperate scripts) ?
  6. #4
  7. Retired
    Devshed Supreme Being (6500+ posts)

    Join Date
    Feb 2002
    Location
    Finland
    Posts
    9,143
    Rep Power
    2493
    I got this from Evil Walrus, I haven't tried it yet though (essentially, just stick it at the top of your page before html is outputted. I am sure this is apaptable if you are using a template system or the likes):

    PHP Code:
    <?php 
    $mobilephone 
    preg_match("!Nokia|KDDI|SHARP|portalmmm|UP.Browser|Wapagsim|DoCoMo|Alcatel|ATTWS|Doris|Hutc3G|J-PHONE|Java|KGT|LGE|MOT|ReqwirelessWeb|SAGEM|SIE-|SonyEricsson|Teleport Pro|UPG1!"$HTTP_USER_AGENT); 

    //parts of some different user_agent strings are between the |'s. 
        
    if ($mobilephone)   
          include(
    "cellphone.php"); 

    //If a cellphone is detected you see this page. 
       
    else 
          include(
    "computer.php"); 

    //If a computer is detected you see this page. 
    ?>

    Cheers,
    Jamie

    >_ skiFFie ? | Twitter

    __________________

    Let the might of your compassion arise to bring a quick end
    to the flowing stream of the blood and tears .....
    Please hear my anguished words of truth.

    __________________

IMN logo majestic logo threadwatch logo seochat tools logo