Results 1 to 8 of 8

Thread: script protection

  1. #1
    User
    Join Date
    01-26-10.
    Posts
    37

    Default script protection

    Hi

    I have a php script that displays some information to members of our site and which I'd like to protect so that it cannot be run by everyone. The script is called by ajax.
    Is there a simple way to use the authentification done by contao ?

    Thank you in advance

    Aïda

  2. #2
    User
    Join Date
    06-29-09.
    Posts
    271

    Default Re: script protection

    You cannot protect a php script using contao without changing the php file to include, like you ask, the authentication done by contao. It does require running part of the contao code.

    I've done this, but when replying I realized the sourcecode is not on this laptop, so I'll post it later this weekend

  3. #3
    User
    Join Date
    06-29-09.
    Posts
    271

    Default Re: script protection

    As promised "later this weekend" here is the code.

    *edit*
    The code proved impossible to post because the forum kept crashing. I attached it in my next reply as a compressed php file because attaching php is not allowed. Sure hope this is what you are looking for considering the trouble it took me

  4. #4
    User
    Join Date
    01-26-10.
    Posts
    37

    Default Re: script protection

    Thank you Vera for your reply even if you have not been allowed to put the code
    Can someone help ?

  5. #5
    Community-Moderator xchs's Avatar
    Join Date
    06-19-09.
    Posts
    1,287

    Default Re: script protection

    Hi aida,

    Quote Originally Posted by aida
    I have a php script that displays some information to members of our site and which I'd like to protect so that it cannot be run by everyone.
    If you have a member section on your site you can include the script using a module of type "Custom HTML" with file insert tag "{{file::myscript.php}}". The script file must be located in Contaos "/templates" folder.

    To grant access to who's allowed to view the information in question, you can set up an allowed member group.
    Contao Community Moderator
    → Support options

  6. #6
    User
    Join Date
    01-26-10.
    Posts
    37

    Default Re: script protection

    Thank you xchs

    The thing is that the script is called by ajax. I'm not sure of how to set up your solution ?

  7. #7
    User
    Join Date
    06-29-09.
    Posts
    271

    Default Re: script protection

    For some reason or the other the forum crashes whenever I try to add the code. So I attached a file. You need to add the contents to the top of the php file so it cannot be run if you do not have the correct permissions.

    I am pretty sure this is not the best or preferred way to do this. So if someone would like to improve on my reply, please do so! :D

  8. #8
    User
    Join Date
    01-26-10.
    Posts
    37

    Default Re: script protection

    Thank you Vera !

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
  •