Php 如何在我的站点上使用fsockopen?

Php 如何在我的站点上使用fsockopen?,php,eval,fopen,fsockopen,Php,Eval,Fopen,Fsockopen,我在我的网站上使用curreny代码。以下是: <?php $contents = file_get_contents('http://www.tcmb.gov.tr/kurlar/today.html'); $contents = iconv("windows-1254" , "utf8" , $contents); $dollar = preg_match('~ABD DOLARI\s+(.+?)\s+(.+?)\s+~i', $contents, $matches) ? arra

我在我的网站上使用curreny代码。以下是:

<?php
$contents = file_get_contents('http://www.tcmb.gov.tr/kurlar/today.html'); 
$contents = iconv("windows-1254" , "utf8" , $contents);

$dollar = preg_match('~ABD DOLARI\s+(.+?)\s+(.+?)\s+~i', $contents, $matches) ? array('buying' => $matches[1], 'selling' => $matches[2]) : ''; 
$euro = preg_match('~EURO\s+(.+?)\s+(.+?)\s+~i', $contents, $matches) ? array('buying' => $matches[1], 'selling' => $matches[2]) : ''; 
$gbp = preg_match('~İNGİLİZ STERLİNİ\s+(.+?)\s+(.+?)\s+~i', $contents, $matches) ? array('buying' => $matches[1], 'selling' => $matches[2]) : ''; 
$chf = preg_match('~İSVİÇRE FRANGI\s+(.+?)\s+(.+?)\s+~i', $contents, $matches) ? array('buying' => $matches[1], 'selling' => $matches[2]) : ''; 

echo ' 
    <table class="form" style="background:#fff;width:300px;margin-left:14px;"> 
        <tr style="border-bottom:1px solid #e4e4e4;">
        ..
我确实向我的主机支持人员询问了这个问题,他们说:

“不要使用fopen选项,请使用'fsockopen'”但我不知道如何才能做到这一点


请帮帮我。谢谢。

请改用
curl
。从远程服务器替换
文件\u获取\u内容的功能是:

function get_web_page( $url ) {
    $options = array(
    CURLOPT_RETURNTRANSFER => true,     // return web page
    CURLOPT_HEADER         => false,    // don't return headers
    CURLOPT_FOLLOWLOCATION => true,     // follow redirects
    CURLOPT_ENCODING       => "",       // handle all encodings
    CURLOPT_USERAGENT      => "spider", // who am i
    CURLOPT_AUTOREFERER    => true,     // set referer on redirect
    CURLOPT_CONNECTTIMEOUT => 120,      // timeout on connect
    CURLOPT_TIMEOUT        => 120,      // timeout on response
    CURLOPT_MAXREDIRS      => 10,       // stop after 10 redirects
    );

    $ch      = curl_init( $url );
    curl_setopt_array( $ch, $options );
    $content = curl_exec( $ch );
    $err     = curl_errno( $ch );
    $errmsg  = curl_error( $ch );
    $header  = curl_getinfo( $ch );
    curl_close( $ch );

    $header['errno']   = $err;
    $header['errmsg']  = $errmsg;
    $header['content'] = $content;
        //If you want error information, 'return $header;' instead.
    return $content;
}

从那里更改
$contents=file\u get\u contents('http://www.tcmb.gov.tr/kurlar/today.html');
$contents=获取网页('http://www.tcmb.gov.tr/kurlar/today.html');

我不知道在哪里可以更改代码?使用
fsockopen
不是一个好的解决方案。用卷曲代替。您可能还想告诉您的托管公司,只要禁用url include,url\u fopen\u包装器是完全安全的。偏执狂再次袭击了安全!
function get_web_page( $url ) {
    $options = array(
    CURLOPT_RETURNTRANSFER => true,     // return web page
    CURLOPT_HEADER         => false,    // don't return headers
    CURLOPT_FOLLOWLOCATION => true,     // follow redirects
    CURLOPT_ENCODING       => "",       // handle all encodings
    CURLOPT_USERAGENT      => "spider", // who am i
    CURLOPT_AUTOREFERER    => true,     // set referer on redirect
    CURLOPT_CONNECTTIMEOUT => 120,      // timeout on connect
    CURLOPT_TIMEOUT        => 120,      // timeout on response
    CURLOPT_MAXREDIRS      => 10,       // stop after 10 redirects
    );

    $ch      = curl_init( $url );
    curl_setopt_array( $ch, $options );
    $content = curl_exec( $ch );
    $err     = curl_errno( $ch );
    $errmsg  = curl_error( $ch );
    $header  = curl_getinfo( $ch );
    curl_close( $ch );

    $header['errno']   = $err;
    $header['errmsg']  = $errmsg;
    $header['content'] = $content;
        //If you want error information, 'return $header;' instead.
    return $content;
}