douren9077 2013-04-12 18:23
浏览 36

包含外部PHP文件[重复]

This question already has an answer here:

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.

</div>
  • 写回答

1条回答 默认 最新

  • duan62819774 2013-04-12 18:55
    关注

    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 :)

    评论

报告相同问题?

悬赏问题

  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 AT89C51控制8位八段数码管显示时钟。
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题