草庐IT

a_function_that_may_fail

全部标签

PHP:fopen 失败 "HTTP Request Failed",但响应 header 的状态代码为 200

我有一个PHP脚本,它应该连接到一个从代理列表中选择的代理并下载一个文件。一些代理(在200-400个工作代理中)工作完美,但其他的则不能,我无法找出原因。这里是通过代理连接的代码:$proxy=determine_proxy($proxyList);$proxyString='tcp://'.$proxy['ip'].':'.$proxy['port'];$userAgent=$userAgents[rand(0,$agentsCount-1)];//setupourheaders$hdrs=array('http'=>array('method'=>"GET",'header'=>

php - Joomla : Can a super administrator get the ftp password of that site (from configuration file or any other way)?

我可以作为super管理员访问joomla1.5制作的网站后端。现在我想做的是,关闭该站点并将一个简单的html文件设置为站点主页。为此,我认为我需要ftp用户/密码。有什么办法可以从joomla后端获得该通行证吗?我可以在帮助>系统信息>配置文件中看到一些条目,其中$ftp_user:'xxxxxx'和$ftp_pass:'xxxxxx'。有没有办法知道这些值?即使我无法获得ftp用户/密码,我能否以某种方式使用joomla后端编辑/浏览任何文件/目录? 最佳答案 是的,如果FTP用户/密码保存在Joomlaconfigurati

php - Google map 地理编码问题 : Certain Encoded URLs Failing

我正在尝试从地址中获取位置列表的纬度/经度。它适用于大多数地址,但某些地址会失败并返回零结果。以这个地址为例:1045MonoWay,Sonora,CA95370如您所见,这是Googlemap上的有效地址-没有问题。当pingGeocoderApi时,我使用urlencode()对地址进行编码。这是编码地址:1045%20Mono%20Way%2C%20Sonora%2C%20CA%2095370这是我正在访问的链接:https://maps.googleapis.com/maps/api/geocode/xml?address=1045%20Mono%20Way%2C%20Sono

php - 下载 zip 文件 "Failed network error"(PHP/NGINX)

当我尝试从我的实时服务器下载zip文件时,我的浏览器(Chrome和Firefox)出现以下错误,https://mysite.com:失败的网络错误。令人困惑的是,在我的本地主机上使用来self的实时服务器的相同代码(如下)允许我成功下载相同的zip文件:$path=$data['path_new']='uploads/some-path/';$file_name='test.zip';$file=$path.$file_name;header("Content-Disposition:attachment;filename=".$file_name);header("Content

PHP/SQLite3 : Fatal error: Call to undefined function sqlite_num_rows()

当我调用函数sqlite_num_rows时出现此错误。它一定不是依赖性问题,因为其他Sqlite函数正在运行。我能够打开连接并从数据库获取数据。 最佳答案 晚了4年,但我遇到了同样的问题,所以这是我为遇到同样问题的任何人提供的解决方案//$dbisthedatabasehandle$result=$db->query("SELECT*FROMtable_name");$rows=0;//setrowcounterto0while($row=$result->fetchArray()){$rows+=1;//+1tothecount

php - SQL 错误 : SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails

我在使用PHP和SQL时遇到一些问题,PHP对我来说是新手,而且我缺乏SQL。我想在我的数据库表中添加值:值要么取自一个表单,要么取自另一个表(如FK)。这是数据库:createdatabaseAAA;useAAA;createtableassure(id_assurevarchar(13)notnull,nomvarchar(20),adressevarchar(50),mdpvarchar(60),primarykey(id_assure));createtablevehicule(id_vehiculevarchar(13)notnull,immatriculationvarch

php - Laravel 错误 - 未知 : Failed opening required '. ./public' (include_path ='.;C:\php\pear\' ) in Unknown on line 0

我正在使用Laravel5,我正在使用PHP函数php-Slocalhost:8888folder-name-t来显示网站。在我更新到Window10之前一切正常。现在,我尝试在我的浏览器中运行该项目,我在我的cmd中看到一个空白页面和这条消息:[MonAug0300:17:052015]PHPFatalerror:Unknown:Failedopeningrequired'public'(include_path='.;C:\php\pear\')inUnknownonline0出了什么问题? 最佳答案 听起来像是权限问题。我在W

php - 拉维尔 5.2 : Creating a custom route function - extending route

基本上,我想创建自己的Route::custom函数。这是因为我一直在为整个站点的多个路由使用相同的组和中间件(我还使用带有子域的模块,所以我们正在谈论为每个路由节省5-6行代码)我只想让Route::custom调用两个或三个其他Route函数。例如:Route::Module('forum')替换为Route::group(['middleware'=>['web','auth'],'domain'=>'forum.'.env('SITE_DOMAIN','example.com')],function(){Route::group(['middleware'=>'permissi

php - Laravel 5.2 curl_init() 抛出错误 "Call to undefined function"

我正在尝试使用curl在laravel中使用FCM,但出现错误。首先,我在我的一个Controller中编写了一个php代码:$first_name=$request->input('first_name');//FCMapiURL$url='https://fcm.googleapis.com/fcm/send';//api_keyavailableinFirebaseConsole->ProjectSettings->CLOUDMESSAGING->Serverkey$server_key='AIzaSyA1RyuAGGPASh_flFCwiyd9ZHEMYlhQOho';$tar

php - 正则表达式帮助 : how to match only either pattern in a regex that contains "or" operator?

我正在使用php的preg_replace().基本上我有2种可能的字符串匹配:你好现实世界问候这是我希望完成的:HelloRealWorldGreetings规则解释:如果字符串包含空格,插入在第一个空格字符之后。如果字符串不包含空格(一个单词),则插入就在字符串的中间(+/-如果奇数字符计数)。到目前为止,我已经想出了一个长期有效的解决方案:",$str,1):preg_replace("/.{".round(strlen($str)/2)."}/","$0",$str,1);?>但是,我相信它可以通过一个更短、更优雅的正则表达式来完成,只有一个preg_replace()。打电话