How to write LINKS that cannot be deleted in a PHP file

Posted on 2007-10-12
Last Modified: 2008-01-09
I planned to give some free web templates I made on one of my site .. but they'll be all in PHP (but in simple PHP where it has header.php , footer.php , not complicated written PHP).

And I want to have, let say 5 links written on each template (e.g. in index.php) but the users MAY NOT delete those part otherwise the template wont work at all when they upload it to their hosting (they will be allowed to modify site logo, contents, etc, but not those 5 links).

I imagine that it should work like this:
I stored an HTML file on my hosting (e.g. links.html) which contains only:
<a href="">1st Link</a>
<br />
<a href="">2nd Link</a>
<br />
<a href="">3rd Link</a>
<br />
<a href="">4th Link</a>
<br />
<a href="">5th Link</a>

Next, on each template (e.g. on index.php) I simply add this code so those 5 links will be available on the file (when uploaded somewhere by someone):
<?php include "http://mysite/links.html"; ?>

The problem is of course that code to displayed 'links.html' can be easily deleted by the user.

can someone give a good advice about this? Perhaps the 'links.html' is possible to not stored on my server but secretly written on index.php?
 I hope the solution is not by encrypting the whole index.php ... :(    Thanks.
Question by:planetemails
    LVL 20

    Accepted Solution

    you cant do that as you are using pure .php (open source).
    hmm if you use some encryption in you php coding, would achieve your target

    Author Comment

    Well, can you be more specific on what tricks should I use ... well, on the index.php will contains like this:

    include "header.php";
    include "menu.php";
    include "body.php";
    include "footer.php";
    include "http://mysite/links.html";

    See ... the user might simply delete the last line on the source and what I'm looking for is to keep having it on the page (should not be deleted by user otherwise the template wont work) ...
    Any suggestion?

    Author Comment

    sorry, I misRead your reply .. :p .. I thought you said .. " yes I can do that ... "
    Well, let say in my index.php would have contents as seen above, do you think it will works well if I just encrypt the index.php file?
    The other page should not be encrypted as I want the user to somehow easily modify the contents & layout ...
    LVL 20

    Expert Comment

    yes should work if you just encrypt index.php but wat if the users know the exact contents of index.php ? they can re-write ..... :D
    LVL 5

    Assisted Solution

    I think that cannot be done because there is always a way to crack it.

    The only way i found is to host all that accounts on my servers so they only can change things by a GUI with sessions an permisions.
    LVL 1

    Assisted Solution

    I would try to encrypt "links.html". I mean the FILENAME. So not the document.

    Then include($md5_encrypted_page);

    So they don't see include('');

    Author Comment

    I was thinking of something like that too .. and better, I'll include the links.html in the zip download template so the user will think that they can change (or deleted) or links on links.html BUT actually the correct links.html is stored on my server.

    So, precisely can be said that I need a way to encrypt include('');
    And using your idea > include($md5_encrypted_page);

    But how to not let the user simply delete the codes .. :( .. any more solution?
    LVL 54

    Assisted Solution

    PHP alone can't allow you to do it.  Even encrypting wouldn't prevent this, it would just make the page encrypted, not unchangeable.  To do what you want you need to design and control an overall system.  You might use PHP for the server script and to do the processing but the key and hard part is you need to use the your script and server to make the pages using the files the user provides.  To have this really work you would have to control and even limit the type of content, design, layout, etc of the "pages" the user makes.  The pages they made would need to be compatible with your overall site so everything works together; basically a template type website is what you would provide.

    One important part is you would HAVE to host all the sites/pages.  This wouldn't work if the user has control over all the pages.  I hope this helps.  Let me know if you have a question.

    LVL 2

    Assisted Solution

    As soon as you release your files you lose control over them.

    You could try and encrypt the page or the links using javascript or similiar but this will only slow down a determined user. Personally, I'd just ask the users not to delete them. Chances are if they need to download a simple template then they either:

     a: won't know how to delete them
     b: won't care about them

    As long as the links are not too spammy you'll probably be OK. Depending on the quality of the templates of course. it would have to be a pretty fantastic template to convince me to keep 5 links on it (but that's a different thread) ;)


    Author Comment

    I decided to split the points for all masters who have been giving me their opinion regarding this matter.

    Thanks y'all ...

    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    Join & Write a Comment

    Introduction Many web sites contain image galleries; a common design for these galleries includes a page with a collection of thumbnail images.  You can click on each of the thumbnail images to see the larger version of the image.  This is easily i…
    Consider the following scenario: You are working on a website and make something great - something that lets the server work with information submitted by your users. This could be anything, from a simple guestbook to a e-Money solution. But what…
    Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
    This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now