[Last Call] Learn how to a build a cloud-first strategyRegister Now


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

Posted on 2007-10-12
Medium Priority
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="http://link1.com">1st Link</a>
<br />
<a href="http://link2.com">2nd Link</a>
<br />
<a href="http://link3.com">3rd Link</a>
<br />
<a href="http://link4.com">4th Link</a>
<br />
<a href="http://link5.com">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

Gawai earned 300 total points
ID: 20070371
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

ID: 20070794
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

ID: 20070806
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 ...
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

LVL 20

Expert Comment

ID: 20070817
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

Assisted Solution

administradores earned 300 total points
ID: 20070903
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.

Assisted Solution

Novitsh earned 300 total points
ID: 20070913
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('site.com/links.html');

Author Comment

ID: 20074420
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('site.com/links.html');
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

b0lsc0tt earned 300 total points
ID: 20083352
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.


Assisted Solution

peterb23 earned 300 total points
ID: 20099594
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

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

Thanks y'all ...

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The title says it all. Writing any type of PHP Application or API code that provides high throughput, while under a heavy load, seems to be an arcane art form (Black Magic). This article aims to provide some general guidelines for producing this typ…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
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.
Suggested Courses

830 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