0

What I'm trying to do is to include a external .php file into a project.

I am about to begin a project for a client that is an online store. I've created some classes and functions that I would like to use in this and other projects, but I don't want to give these functions and classes to the clients because they could remove some restrictions that for many reasons (price reasons mostly) I've applied to the website.

Even being the most obvious way to protect my files, I really don't want to use ionCube or Zend Guard, because I would have to increase the price (not good for the business) and also because some shared hosting providers does not support this features, and using dedicated servers are expensive too (also not good for business). So finally what I want to do is to include this files from my own server, for example, I have a file called cart.php on my server and include it on the clients project that is hosted in a different server.

I hope you understand my weird explanation.

Thank's.

Andrés Orozco
  • 2,490
  • 5
  • 32
  • 48
  • 1
    In general this is not a good idea. If you can't trust your clients with your code then get new clients or setup a hosted service. – Mike B Apr 12 '13 at 18:28
  • You have a business, not a programming problem. There is not much we can do for you here. If your model is just not good for business, then your model is just not good for business. Period. Moan with your customer how bad this all his. – M8R-1jmw5r Apr 12 '13 at 18:31

1 Answers1

1

If you allowed other scripts to include PHP files you would have an important security issue.
Everybody else, who have got a glimpse at your "remote PHP files", would be able to hack your website because he might see passwords.

But I think you did the wrong attempt: Creating a "secret API". An example:
If you want to see what a user have at her/his cart you must only write:

<?php
json_decode(file_get_contents("http://yourShop.example/api/get_cart.json?userID=123&apiKey=someVerySecretValue");
?>

It might return:

[
    {
        "name": "article 1",
        "price": "$ 152"
    },
    {
        "name": "article 1",
        "price": "$ 152"
    },
    {
        "name": "article 1",
        "price": "$ 152"
    }
]

So, I think it returns exactly what you want.
If you want to learn more about APIs Google should help you to come upon some information about it :)

If you have got any questions, feel free to contact me :)

Matt3o12
  • 4,192
  • 6
  • 32
  • 47