[英]Find password in file
I have a piece of php code that upon a page load request finds a corresponding file which contains information about the page including the password. 我有一段PHP代码,在页面加载请求后会找到一个相应的文件,其中包含有关页面的信息,包括密码。
The syntax in the file is as follows: 该文件中的语法如下:
Pagename:
PageInfo:
Password: SecretPassword
How would I get around finding the password following the Password:? 在“密码:”之后如何找到密码?
My PHP code looks like this: 我的PHP代码如下所示:
$filepath = absolute_url("page/info.php");
$infoFile = fopen("$filepath", "r");
$contents = stream_get_contents($infoFile);
Seems a very strange way to store the data. 似乎是一种非常奇怪的数据存储方式。 Assuming this can't be helped though, you could RegEx this with something like: 假设这还是无济于事,您可以使用以下方式进行RegEx:
$matches = array();
preg_match('/Password:\s(.*)$/', $contents, $matches);
// ^ Assuming there's only ever 1 space
echo $matches[1]
will print SecretPassword
echo $matches[1]
将打印SecretPassword
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.