草庐IT

Contents

全部标签

php - 为 file_get_contents 清理用户提供的 URL

我想使用file_get_contents来实现代理,这样我就可以执行跨域AJAX请求。查询字符串将用于为file_get_contents提供URL。现在的问题是人们可以随意使用查询字符串来读取服务器上的本地文件。我不想要这个。有人可以给我一个函数来清理查询字符串,以便只接受URL而不是本地文件,即:?url=http://google.com.au-确定?url=./passwords.txt-不正常 最佳答案 $url=filter_var($_GET['url'],FILTER_SANITIZE_URL);或if($_GET

php - 使用自签名证书的 MAMP 中的 file_get_contents 失败

我使用file_get_contents()在我的站点中包含svg文件。通常这在http上工作正常,但我将此站点设置为在本地使用https。当我这样做时,出现此错误:Warning:file_get_contents():SSLoperationfailedwithcode1.OpenSSLErrormessages:error:14090086:SSLroutines:ssl3_get_server_certificate:certificateverifyfailedonline226Warning:file_get_contents():Failedtoenablecryptoo

php file_get_contents 向 Bugzilla 安装发送错误的内容类型

我正在创建一个脚本,该脚本应向bugzilla安装发送请求,以便登录用户并发布错误。我正在使用Google代码上提供的BugzillaPHPhttp://code.google.com/p/bugzillaphp/在我的本地服务器上一切正常,但在应该运行脚本的远程服务器上却不行。我从Bugzilla返回的错误是:Content-Typemustbe'text/xml,''multipart/*,''application/soap+xml,''or'application/dime'insteadof'application/x-www-form-urlencoded'这意味着我的脚本

php - preg_replace file_get_contents 中不包含单词的所有链接

这个问题在这里已经有了答案:Regularexpressiontomatchalinethatdoesn'tcontainaword(33个答案)关闭9年前。我正在将一个页面读入一个变量,我想禁用地址中不包含单词“remedy”的所有链接。到目前为止,我的代码获取了所有链接,包括带有“补救措施”的链接。我做错了什么?$page=preg_replace('~(.*?)~i','$1',$page);--解决方案--$page=preg_replace('~(.*?)~i','$2',$page);

php - 如何防止 curl 或 file_get_contents 从服务器端访问我的页面

我在大约2小时内遇到了一个问题。谁能提供解决方案,我将不胜感激。http://mydowmin.com/userdatapage.php注意:我不想使用Curl函数从外部世界访问此页面如何避免这个脚本$ch=curl_init("http://mydowmin.com/userdatapage.php");curl_setopt($ch,CURLOPT_CERTINFO,1);curl_setopt($ch,CURLOPT_VERBOSE,1);curl_exec($ch)ordie;print_r(curl_getinfo($ch));http://mydomain.com/data

php - file_get_contents 的超时在 PHP 中不起作用

我创建了一个类来在PHP中包含一些HTTP方法。在这里,我有一个用于HTTPPOST的方法publicfunctionpost($content,$timeout=null){$timeInit=newDateTime();$this->method='POST';$header=array();$header['header']=null;$header['content']=is_array($content)?http_build_query($content):$content;$header['method']=$this->method;if($timeout!=NULL)

php - file_get_contents https 超时 1 分钟?

当通过https访问某些资源时,我遇到了PHP的file_get_contents挂起60秒的问题。我不确定这是客户端还是服务器端问题。在客户端在命令行上工作:$URL="https://example.com/some/path"$wget"$URL"-O/dev/null-q#takesafewmilliseconds$curl"$URL">/dev/null#takesafewmilliseconds$php-r'file_get_contents("'"$URL"'")'#takes61s!在服务器上为正确的SSLvhost立即向Apache(2.4)访问日志写入一行,并返回2

php - 使用 PHP 的 file_get_contents 后将类添加到 SVG 元素

我需要获取SVG图像并将图像插入页面。我正在使用以下方法获取图像:输出类似插入到页面后如何向SVG元素添加类?如:或定位到路径元素:任何帮助都会很好,谢谢! 最佳答案 您可以将svg存储为PHP变量,然后使用DOMDocument()功能来完成此操作。$svg=file_get_contents("logo.svg");$dom=newDOMDocument();$dom->loadHTML($svg);foreach($dom->getElementsByTagName('svg')as$element){$element->se

php - 是否有比 file_get_contents 占用更少内存或更有效的合并 MP3 的方法?

我需要将几个mp3文件合并为一个。我目前正在这样做:$combinedFiles="";$dir=$_POST['dir'];if($handle=opendir($dir)){while(false!==($entry=readdir($handle))){if($entry!="."&&$entry!=".."){$combinedFiles.=file_get_contents(urldecode($dir."/".$entry));}}closedir($handle);}file_put_contents("mp3/".$dir.".mp3",($combinedFiles)

php - 以 url 作为变量的 file_get_contents

我可以使用类似这样的方法来检索域外部的页面吗?我传递了一个变量并想从abc.com检索结果。是否可以将$fetcher传递给file_get_contents以检索页面内容?当我点击这个php页面时,我得到了空白页面。但是如果我使用类似的东西,它又可以正常工作了这里发生了什么?对此有一些技术解释吗? 最佳答案 您应该在$q_pass上使用urlencode。我猜你在query_passed中传递了一个带有空格的值。 关于php-以url作为变量的file_get_contents,我们在