草庐IT

BASE_FILE

全部标签

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 - 文件存在于/tmp,但 PHP 在 CentOS 上返回 "No such file or directory"

在PHP中,我收到此消息:警告:fopen(/tmp/mydir/file.txt):无法打开流:没有此类文件或目录调用fopen时('/tmp/mydir/file.txt',"r");但是:cd/tmpls-l.drwxrwxr-x2user4.0KAug1914:09mydirls-lmydir-rw-rw-r--1user41KAug1914:09file.txt如果我尝试执行print_r(scandir('/tmp/'));我得到一个空数组。执行print_r(scandir('/tmp/mydir/'));我得到无法打开目录:没有这样的文件或目录。然而,执行print_r

php - 无效配置 - yii\base\InvalidConfigException - Yii2

我刚刚通过此命令将Yii2-User模块/Dektrium安装到我的Yii2-app-basic应用程序中composerrequire"dektrium/yii2-user:0.9.*@dev"config/console.phpreturn[..'modules'=>['gii'=>'yii\gii\Module','user'=>['class'=>'dektrium\user\Module',],],..]config/web.php'components'=>[../*'user'=>['identityClass'=>'app\models\User','enableAut

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 - __FILE__ Windows 上 PHP 中的魔术常量不返回斜杠

我是PHP的新手。我正在对在Apache中开发和运行的PHP应用程序进行故障排除。我们正在将应用程序移动到在IIS下运行php的Windows服务器。index.php的顶部有以下代码会引发错误:当我使用警报检查__FILE_时,它显示了没有任何斜线的整个路径。';echo'alert("'.__FILE__.'")';echo'';?>所以不是显示c:\directory\subdirectory\theapp\index.php它显示c:directorysubdirectorytheappindex.php我猜这就是我收到以下错误的原因:注意:第3行C:\Directory\su

php - (Docker) 收到错误 : docker-php-source: no such file or directory when building docker file

当我尝试构建docker文件时:https://github.com/docker-library/php/blob/3f43309a0d5a427f54dc885e0812068ee767c03e/7.1/Dockerfile命令:dockerbuild-tphp_image.我遇到了以下错误:Step14:COPYdocker-php-source/usr/local/bin/lstatdocker-php-source:nosuchfileordirectory谁能帮我找出问题所在?谢谢 最佳答案 您没有正确的dockerbu

php - 重写 URL : remove sub folders and file extension from URL

我正在尝试从URL中删除.php文件扩展名和文件夹&&子文件夹(如果存在)。案例一输入:127.0.0.1/project/folder/alfa.php输出:127.0.0.1/project/alfa案例二输入:127.0.0.1/project/folder/subfolder/beta.php输出:127.0.0.1/project/beta这是我到目前为止得到的:只删除扩展名工作正常,删除文件夹有问题#Turnmod_rewriteonRewriteEngineOnRewriteCond%{REQUEST_FILENAME}!-dRewriteCond%{REQUEST_FI

PHP eval(gzinflate(base64_decode(..))) hack - 如何防止它再次发生?

我们最近有一个网站被黑了,一些PHP代码被注入(inject)到index.php文件中,看起来像这样:eval(gzinflate(base64_decode('s127ezsS/...bA236UA1')));该代码导致包含另一个PHP文件(cnfg.php),这导致显示一些与药物相关的垃圾邮件(但仅对googlebot等人可见)。这看起来像是WordPress的pharmahack,只是我们没有运行WordPress。该代码已被删除,但我想防止将来发生此类事件。我意识到这是一个相当广泛的问题,可能存在无数的安全漏洞,但我认为我会把它放在那里,以防任何人过去遇到过此类问题。允许上传