熊猫购彩

<meter id="pgsoe"></meter>

<code id="pgsoe"><u id="pgsoe"></u></code>

<acronym id="pgsoe"><video id="pgsoe"></video></acronym>
    1. <label id="pgsoe"></label>
  • <acronym id="pgsoe"><legend id="pgsoe"><blockquote id="pgsoe"></blockquote></legend></acronym>
      <label id="pgsoe"></label>
    <acronym id="pgsoe"></acronym>
  • <meter id="pgsoe"><u id="pgsoe"><option id="pgsoe"></option></u></meter>
    <output id="pgsoe"></output>
  • <var id="pgsoe"><ol id="pgsoe"></ol></var>
    LaravelConf Taiwan 2020 CFP Started

    Using remote files

    As long as allow_url_fopen is enabled in php.ini, you can use HTTP and FTP URLs with most of the functions that take a filename as a parameter. In addition, URLs can be used with the include, include_once, require and require_once statements (since PHP 5.2.0, allow_url_include must be enabled for these). See Supported Protocols and Wrappers for more information about the protocols supported by PHP.

    For example, you can use this to open a file on a remote web server, parse the output for the data you want, and then use that data in a database query, or simply to output it in a style matching the rest of your website.

    Example #1 Getting the title of a remote page

    <?php
    $file 
    fopen ("http://www.example.com/""r");
    if (!
    $file) {
        echo 
    "<p>Unable to open remote file.\n";
        exit;
    }
    while (!
    feof ($file)) {
        
    $line fgets ($file1024);
        
    /* This only works if the title and its tags are on one line */
        
    if (preg_match ("@\<title\>(.*)\</title\>@i"$line$out)) {
            
    $title $out[1];
            break;
        }
    }
    fclose($file);
    ?>

    You can also write to files on an FTP server (provided that you have connected as a user with the correct access rights). You can only create new files using this method; if you try to overwrite a file that already exists, the fopen() call will fail.

    To connect as a user other than 'anonymous', you need to specify the username (and possibly password) within the URL, such as 'ftp://user:password@ftp.example.com/path/to/file'. (You can use the same sort of syntax to access files via HTTP when they require Basic authentication.)

    Example #2 Storing data on a remote server

    <?php
    $file 
    fopen ("ftp://ftp.example.com/incoming/outputfile""w");
    if (!
    $file) {
        echo 
    "<p>Unable to open remote file for writing.\n";
        exit;
    }
    /* Write the data here. */
    fwrite ($file$_SERVER['HTTP_USER_AGENT'] . "\n");
    fclose ($file);
    ?>

    Note:

    You might get the idea from the example above that you can use this technique to write to a remote log file. Unfortunately that would not work because the fopen() call will fail if the remote file already exists. To do distributed logging like that, you should take a look at syslog().

    add a note add a note

    User Contributed Notes 4 notes

    up
    8
    slva dot web dot sit at gmail dot com
    6 years ago
    If  allow_url_fopen is disabled in php.ini you can use CURL function for check file exist:

    <?php
    $ch
    = curl_init("http://www.example.com/favicon.ico");

    curl_setopt($ch, CURLOPT_NOBODY, true);
    curl_exec($ch);
    $retcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    // $retcode >= 400 -> not found, $retcode = 200, found.
    curl_close($ch);
    ?>
    up
    -4
    anon
    9 months ago
    The following functions can't access external files if allow_url_fopen is disabled:

    - fopen
    - file_put_contents
    - copy

    I don't know if this is documented anywhere else, but I couldn't find it. Feel free to delete this post if so.
    up
    -33
    kalidass dot jst at gmail dot com
    4 years ago
    public function get_url($request_url) {

    $curl_handle = curl_init();
        curl_setopt($curl_handle, CURLOPT_URL, $request_url);
        curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 0);
        curl_setopt($curl_handle, CURLOPT_TIMEOUT, 0);
        curl_setopt($curl_handle, CURLOPT_SSL_VERIFYPEER, FALSE); 
        curl_setopt($curl_handle, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
        curl_setopt($curl_handle, CURLOPT_FOLLOWLOCATION, 1);
        curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, TRUE);
        $JsonResponse = curl_exec($curl_handle);
        $http_code = curl_getinfo($curl_handle);

      return($JsonResponse);
    }
    get_url("http://www.example.com");
    up
    -70
    heck at fas dot harvard dot edu
    15 years ago
    The previous post is part right, part wrong. It's part right because it's true that the php script will run on the remote server, if it's capable of interpreting php scripts. You can see this by creating this script on a remote machine:
    <?php
    echo system("hostname");
    ?>
    Then include that in a php file on your local machine. When you view it in a browser, you'll see the hostname of the remote machine.

    However, that does not mean there are no security worries here. Just try replacing the previous script with this one:
    <?php
    echo "<?php system(\"hostname\"); ?>";
    ?>
    I'm guessing you can figure out what that's gonna do.

    So yes, remote includes can be a major security problem.
    To Top
    新余| 通山| 塘头| 达日| 巴中| 广州| 余江| 稻城| 香格里拉| 鹤山| 邹城| 云龙| 瓜州| 星子| 鹤庆| 平坝| 汤河口| 晋城| 普兰| 呼中| 巴马| 荣县| 大方| 安泽| 崇州| 野牛沟| 合川| 临泉| 交口| 永修| 石屏| 封开| 潞江坝| 万宁| 茫崖| 留坝| 大通| 柳林| 柳河| 奉节| 修文| 广丰| 正兰旗| 麻阳| 宁远| 铜锣湾| 旺苍| 中泉子| 遂川| 阳城| 芮城| 米脂| 邗江| 千阳| 野牛沟| 平台| 武隆| 杭锦后旗| 清河| 开江| 张家口| 黔阳| 新竹市| 鸡东| 濮阳| 法库| 富平| 盐城| 荆州| 临夏| 阳朔| 勃利| 安福| 梓潼| 阿拉山口| 阜阳| 新都| 涟水| 蛟河| 凤凰| 勐海| 广宗| 开平| 西乌珠穆沁旗| 马尔康| 新巴尔虎左旗| 肇庆| 开原| 广平| 长海| 桃江| 巧家| 揭阳| 汉寿| 富川| 永靖| 宁武| 白云| 共和| 富裕| 哈密| 宝丰| 德清| 皮口| 台安| 农安| 龙陵| 大港| 广昌| 武威| 鸡西| 从化| 交城| 建平| 临夏| 北海| 祁县| 嘉兴| 临武| 天河| 和顺| 青田| 会泽| 安义| 泸州| 平凉| 贵南| 太仆寺旗| 陵水| 桑植| 托勒| 开阳| 广灵| 石首| 珙县| 永署礁| 甘孜| 托里| 吕梁| 满洲里| 阿尔山| 常山| 吴县| 滁州| 杂多| 阿鲁科尔沁旗| 定海| 头道湖| 怀仁| 南沙岛| 阳江| 任县| 沁阳| 达尔罕茂明安联合旗| 望谟| 梅县| 红原| 新田| 长乐| 东安| 玛多| 满洲里| 平顶山| 资兴| 墨玉| 莒南| 花都| 固阳| 宜昌县| 祁门| 察哈尔右翼后旗| 宜兴| 乐东| 皮口| 大名| 任县| 平陆| 玉田| 鄂托克前旗| 沁县| 鞍山| 郫县| 鄂州| 鄂托克旗| 包头| 兴安| 鄯善| 勃利| 舟曲| 大埔| 唐山| 菏泽| 滨海| 罗甸| 宜宾县| 海西| 同心| 麦盖提| 石林| 正镶白旗| 西乡| 草河口| 阿勒泰| 禹州| 宾县| 岳西| 南宫| 海盐| 化州| 开封| 姚安| 范县| 永州| 南坪| 平昌| 永福| 宝鸡| 海拉尔| 会理| 文山| 光山| 成山头| 鼎新| 巴马| 许昌| 琼山| 吉安县| 灌南| 南雄| 金佛山| 恩平| 漠河| 景泰| 泰宁| 三明| 东莞| 武胜| 漳浦| 休宁| 武都| 雄县| 平果| 巴塘| 汶上| 隆安| 广元| 承德县| 奉节| 东营| 麻城| 河间| 临潭| 泰兴| 靖江| 滁州| 石浦| 漳县| 芒康| 吕泗渔场| 通山| 托克逊| 江川| 贵定| 清徐| 沂源| 吉兰太| 西丰| 余杭| 巴林左旗| 保靖| 富裕| 临朐| 曹县| 秭归| 天祝| 阳信| 喀什| 甘谷| 莒南| 高力板| 老河口| 会昌| 玉门镇| 甘德| 九龙| 兰州| 石屏| 平顶山| 岗子| 霞浦| 金堂| 理塘| 邕宁| 南汇| 永德| 松桃| 连江| 濮阳| 章丘| 铁力| 长沙| 石岛| 延边| 黄泛区| 秦安| 丰都| 甘谷| 雷州| 锡林浩特| 师宗| 肇源| 本溪| 高陵| 尉犁| 塔城| 托托河| 醴陵| 阳新| 济阳| 清原| 红原| 登封| 珲春| 应城| 金山| 普兰| 揭阳| 鄂温克旗| 望谟| 武强| 盱眙| 邵东| 廉江| 乡城| 施秉| 辽阳县| 吐鲁番东坎| 南坪| 界首| 中牟| 怀安| 峨眉山| 硇洲| 湟源| 海丰| 内黄| 阳山| 高邑| 涟水| 红河| 大安| 石家庄| 临武| 高州| 叙永| 龙泉驿| 通什| 威信| 永修| 博爱| 天镇| 田阳| 依安| 睢宁| 林西| 吉首| 徐水| 天祝| 南澳| 娄烦| 湘潭| 桂林| 阿城| 绥化| 兴城| 铜锣湾| 平鲁| 嘉黎| 盖州| 连南| 九华山| 扬中| 蓝田| 大姚| 林芝| 平果| 崆峒| 荣县| 雅布赖| 犍为| 石楼| 中心站| 阿坝| 本溪| 魏县| 中阳| 普兰店| 双城| 凌云| 衡阳县