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

    Join Date
    Sep 2013
    Location
    Blackburn, Lancashire.
    Posts
    8
    Rep Power
    0

    PHP GD Library with fonts in a protected directory.


    Hi,

    Please bear with me, this is my first post.

    I am starting a project using the PHP GD library. I have created a font that I don't want copying or downloading so it is in a protected directory. Is there a way I can access this font using the PHP GD library?

    If I try accessing the font, nothing happens, but if I unprotect the directory, everything works as expected.

    It is vital this font is protected.

    Does anyone have any ideas?

    Thank-you in advance,

    petemaxi.
  2. #2
  3. Sarcky
    Devshed Supreme Being (6500+ posts)

    Join Date
    Oct 2006
    Location
    Pennsylvania, USA
    Posts
    10,907
    Rep Power
    6351
    How is it "protected"? You should put it in an
    "unprotected" directory outside of the web root, so its inaccessible via URL but accessible to other applications running on your server.
    HEY! YOU! Read the New User Guide and Forum Rules

    "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin

    "The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002

    Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2013
    Location
    Blackburn, Lancashire.
    Posts
    8
    Rep Power
    0
    Hi,

    Thank-you for your reply. It is protected, I presume, using .htaccess. Your idea is great in theory, but unfortunately, I don't have access outside the web root. That would work on my home server, but not on my hosting and my home server is not a viable option.

    Thanks again for your reply.

    petemaxi.
  6. #4
  7. Sarcky
    Devshed Supreme Being (6500+ posts)

    Join Date
    Oct 2006
    Location
    Pennsylvania, USA
    Posts
    10,907
    Rep Power
    6351
    If you don't know how the protection is done, it's difficult to recommend how to circumvent it. How are you loading these font files? Are you using relative local directory paths or URLs?
    HEY! YOU! Read the New User Guide and Forum Rules

    "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin

    "The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002

    Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2013
    Location
    Blackburn, Lancashire.
    Posts
    8
    Rep Power
    0
    Originally Posted by ManiacDan
    If you don't know how the protection is done, it's difficult to recommend how to circumvent it. How are you loading these font files? Are you using relative local directory paths or URLs?
    I've just had a snoop, and it is protected using .htaccess. It's new hosting with a new control panel, so I'm still getting used to it.

    I am using relative paths to load the font file.

    Thanks for your reply,

    petemaxi.
  10. #6
  11. Wiser? Not exactly.
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    May 2001
    Location
    Bonita Springs, FL
    Posts
    5,945
    Rep Power
    4033
    .htaccess based protection has no effect on PHP, provided you access the file via a filesystem path and not a URL. Post your code so we can see what you are doing.

    Comments on this post

    • petemaxi agrees : Thank-you, you solved my problem, but for some reason it won't let me give you any reputation points. Sorry.
    Recycle your old CD's, don't just trash them



    If I helped you out, show some love with some reputation, or tip with Bitcoins to 1N645HfYf63UbcvxajLKiSKpYHAq2Zxud
  12. #7
  13. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2013
    Location
    Blackburn, Lancashire.
    Posts
    8
    Rep Power
    0
    Hi,

    Thank-you kitchen! You resolved my problem, was so simple in the end! I used a filesystem path and not a URL and that solved it. Made a test page at maxiwebs.co.uk/png-captcha-test and a password protected directory maxiwebs.co.uk/png-captcha-test/fonts, username = username and password = password.

    P.S. If anyone wants the code for the CAPTCHA just let me know.

    Thanks again, Kitchen.

    petemaxi.
  14. #8
  15. Sarcky
    Devshed Supreme Being (6500+ posts)

    Join Date
    Oct 2006
    Location
    Pennsylvania, USA
    Posts
    10,907
    Rep Power
    6351
    I am using relative paths to load the font file.
    How were you using relative paths and still using URLs? That's...what Kicken said was exactly what I was saying. URLs were wrong, relative file paths were right.

    Confused.

    Few people will want a captcha since reCaptcha is generally free, but if you're proud of your work post it to github and use it as part of your portfolio.
    HEY! YOU! Read the New User Guide and Forum Rules

    "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin

    "The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002

    Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.
  16. #9
  17. No Profile Picture
    Contributing User
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Dec 2004
    Posts
    2,987
    Rep Power
    375
    ha ha, the guy wanted to protect his font yet gave us it anyway!
  18. #10
  19. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2013
    Location
    Blackburn, Lancashire.
    Posts
    8
    Rep Power
    0
    I'm not that daft! That one's not my font, it was a totally different project I was using that on.

    Comments on this post

    • paulh1983 agrees : sorry :)

IMN logo majestic logo threadwatch logo seochat tools logo