我正在尝试寻找阅读 php://input 的替代方法。我使用它从 CURL PUT 获取 XML 数据。
我通常这样做:
$xml = file_get_contents('php://input');
Run Code Online (Sandbox Code Playgroud)
但是,我file_get_contents()在 Windows 上遇到了一些问题。
有没有替代方案,也许使用fopen()或fread()?
我有一个文件config.ini,其中包含以下内容:
@ndbd
Run Code Online (Sandbox Code Playgroud)
我想替换@ndbd一些其他文本来完成文件.下面是我的bash脚本代码:
ip_ndbd=(108.166.104.204 108.166.105.47 108.166.56.241)
ip_temp=""
for ip in $ip_ndbd
do
ip_temp+="\n\[ndbd\]\nHostname=$ip\n"
done
perl -0777 -i -pe "s/\@ndbd/$ip_temp/" /var/lib/mysql-cluster/config.ini
Run Code Online (Sandbox Code Playgroud)
基本上,我只想以特定格式获取所有IP地址,然后@ndbd用生成的子字符串替换.
但是,我的for循环似乎并没有连接所有数据$ip_ndbd,只是列表中的第一项.
所以不要得到:
[ndbd]
HostName=108.166.104.204
[ndbd]
HostName=108.166.105.47
[ndbd]
HostName=108.166.56.241
Run Code Online (Sandbox Code Playgroud)
我越来越:
[ndbd]
HostName=108.166.104.204
Run Code Online (Sandbox Code Playgroud)
我很确定有更好的方式来写这个,但我不知道怎么做.
我很感激一些帮助.
提前致谢.
我正在使用Ubuntu Natty.
我使用以下命令从命令行运行mysqld:
mysqld -ndbcluster --console -umysql
Run Code Online (Sandbox Code Playgroud)
我得到以下内容:
120314 0:09:49 [Warning] option 'new': boolean value 'dbcluster' wasn't recognized. Set to OFF.
120314 0:09:49 [Note] Plugin 'ndbcluster' is disabled.
120314 0:09:49 [Note] Plugin 'FEDERATED' is disabled.
120314 0:09:50 InnoDB: The InnoDB memory heap is disabled
120314 0:09:50 InnoDB: Mutexes and rw_locks use GCC atomic builtins
120314 0:09:50 InnoDB: Compressed tables use zlib 1.2.3
120314 0:09:50 InnoDB: Using Linux native AIO
120314 0:09:50 InnoDB: Initializing buffer pool, size = 128.0M
120314 0:09:50 …Run Code Online (Sandbox Code Playgroud) I recently upgraded my XAMPP from PHP 5.2 to 5.3.1
I seem to be having a problem with file_get_contents().
I can use the function to get something like "http://www.google.com", but it times out when I use it on a domain I have setup locally e.g. "http://localhost/my_dir/my_css_file.css".
我不确定问题是什么.如果这是一个错误,是否有可行的替代方案?
好心提醒.
我正在尝试用文件进行CURL PUT,但是我遇到了问题.
这是我的代码:
$url_path_str = 'http://my_url';
$file_path_str = '/my_file_path';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, ''.$url_path_str.'');
curl_setopt($ch, CURLOPT_PUT, 1);
$fh_res = fopen($file_path_str, 'r');
$file_data_str = fread($fh_res, filesize($file_path_str));
curl_setopt($ch, CURLOPT_INFILE, $fh_res);
curl_setopt($ch, CURLOPT_INFILESIZE, filesize($file_path_str));
fclose($fh_res);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$curl_response_res = curl_exec ($ch);
Run Code Online (Sandbox Code Playgroud)
脚本保持超时,我不知道为什么.
我很感激一些帮助.谢谢.
我在运行Ubuntu Linux Natty的VMWare Workstation中安装了Riak(1.0.2).这是一台机器安装而不是集群.
我将后端从BitCask更改为LevelDB以利用二级索引.但是,现在我的所有其他数据都无法访问(我确定它仍然存在,可能与新的后端不兼容).
如何备份Riak数据并使其可以在后端之间访问?!
提前致谢.
我有以下代码:
$str_val = "L(ine 1(
L(ine 2)
Line 3
Line 4)";
$regex = '/\(([^\)]*?)\)/i';
preg_match($regex, $str_val, $matches_arr);
print_r($matches_arr);
Run Code Online (Sandbox Code Playgroud)
此代码匹配第一个(和第一个之间的所有内容)。
我正在寻找我要放入的内容$regex来匹配第一个(和最后一个之间的所有内容)。
我将不胜感激的帮助。
提前致谢。
在用于身份验证的Houndify API文档中,您有以下内容块:
我们假设我们有以下信息:
UserID: ae06fcd3-6447-4356-afaa-813aa4f2ba41
RequestID: 70aa7c25-c74f-48be-8ca8-cbf73627c05f
Timestamp: 1418068667
ClientID: KFvH6Rpy3tUimL-pCUFpPg==
ClientKey: KgMLuq-k1oCUv5bzTlKAJf_mGo0T07jTogbi6apcqLa114CCPH3rlK4c0RktY30xLEQ49MZ-C2bMyFOVQO4PyA==
Run Code Online (Sandbox Code Playgroud)
以下列格式连接UserID字符串,RequestID字符串和TimeStamp字符串: {user_id};{request_id}{timestamp}
使用示例中的值,在这种情况下,预期输出将是: ae06fcd3-6447-4356-afaa-813aa4f2ba41;70aa7c25-c74f-48be-8ca8-cbf73627c05f1418068667
使用已解码的ClientKey对消息进行签名.结果是一个32字节的二进制字符串(我们无法直观地表示).但是,在base-64编码之后,签名是:myWdEfHJ7AV8OP23v8pCH1PILL_gxH4uDOAXMi06akk=
然后,客户端生成两个身份验证标头Hound-Request-Authentication和Hound-Client-Authentication.
Hound-Request-Authentication头是通过以下列格式连接UserID和RequestID组成的:{user-id};{request-id}.继续上面的示例,此标头的值为:Hound-Request-Authentication:ae06fcd3-6447-4356-afaa-813aa4f2ba41;70aa7c25-c74f-48be-8ca8-cbf73627c05f
Hound-Client-Authentication标头是通过以下格式连接ClientID,TimeStamp字符串和签名组成的:{client-id};{timestamp};{signature}.继续上面的示例,此标头的值将是:Hound-Client-Authentication: KFvH6Rpy3tUimL-pCUFpPg==;1418068667;myWdEfHJ7AV8OP23v8pCH1PILL_gxH4uDOAXMi06akk=
对于Number 3,它表示"使用已解码的ClientKey对消息进行签名"."message"和"ClientKey"是两个不同的字符串.
我的问题:你如何用另一个字符串签署一个字符串,这究竟是什么意思?你会怎么用JavaScript做到这一点?
var message = 'my_message';
var key = 'signing_key';
//??what next??
Run Code Online (Sandbox Code Playgroud)
我试图弄清楚这一切,所以我可以在Postman中创建一个预先请求脚本来做一个正确的HmacSHA256哈希.
我已经使用Basho Riak几周了.我只需要存储字符串数据.
但是,我正在使用它来存储图像,我想知道如何使用PHP客户端执行此操作.
以下是存储数据的基本代码:
require_once('riak-php-client/riak.php');
# Connect to Riak
$client = new RiakClient('127.0.0.1', 8098);
# Choose a bucket name
$bucket = $client->bucket('test');
# Supply a key under which to store your data
$person = $bucket->newObject('string_key', 'string_data');
# Save the object to Riak
$person->store();
Run Code Online (Sandbox Code Playgroud)
我只是对图像进行base64_encode,然后存储结果字符串吗?!或者,还有更好的方法?!
提前致谢.
我在尝试着:
我有以下代码:
$(document).ready(function(){
function _parse(html_str_or_obj)
{
var elem_obj, elem_dom_obj;
//Convert to DOM element
elem_obj = document.createElement("div");
elem_obj.innerHTML = html_str_or_obj;
elem_dom_obj = elem_obj.firstChild;
return elem_dom_obj;
}
var html_str = '<div id="body-wrapper">\
<div id="container-1">\
<div id="container-1x"><div id="container-2x"><div id="container-3x"><p>First Paragraph</p></div></div></div>\
<p>This is the first container - Line 1</p>\
<p>This is the first container - Line 2</p>\
<p>This is the first container - Line 3</p>\
</div>\
<div id="container-2">\
<p>This is the second container - Line …Run Code Online (Sandbox Code Playgroud)