Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/229.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
php-文本文件,从文本文件回显密码_Php - Fatal编程技术网

php-文本文件,从文本文件回显密码

php-文本文件,从文本文件回显密码,php,Php,你好,我正在使用一个文本文件作为数据库。我的文本文件的内容如下 SRC ---> M ---> 11/22/1995 ---> myPassword ---> 11/29/2013 我想做的是编写一个php代码来搜索src,并返回我正在使用以下代码搜索文本文件的密码 <?php $file = 'Database.txt'; $searchfor = 'src'; // the following line prevents the browser from p

你好,我正在使用一个文本文件作为数据库。我的文本文件的内容如下

SRC ---> M ---> 11/22/1995 ---> myPassword ---> 11/29/2013
我想做的是编写一个
php
代码来搜索
src
,并返回我正在使用以下代码搜索文本文件的密码

<?php
$file = 'Database.txt';
$searchfor = 'src';

// the following line prevents the browser from parsing this as HTML.
header('Content-Type: text/plain');

// get the file contents, assuming the file to be readable (and exist)
$contents = file_get_contents($file);
// escape special characters in the query
$pattern = preg_quote($searchfor, '/');
// finalise the regular expression, matching the whole line
$pattern = "/^.*$pattern.*\$/m";
// search, and store all matching occurences in $matches
if(preg_match_all($pattern, $contents, $matches)){
   echo implode("\n", $matches[0]);
}
else{
   echo "No matches found";
}
?>


我如何让它回显密码。。。。任何帮助都将不胜感激。。。提前感谢……:)我知道使用文本文件作为数据库是不安全的,但仍然…

我刚刚输入了以下代码:

$strArray = explode(' ---> ',implode($matches[0]));
$name = $strArray[3];
echo "\n" . $name;
之后:

if(preg_match_all($pattern, $contents, $matches)){

虽然我从“如何让它回显密码”中得到了一些帮助-相信我,你不会想这么做的。永远不要将密码存储为明文。弗雷德说的……我希望代码中不是你的真实电子邮件地址。如果你想把你的电脑连接到互联网上,你需要变得多疑一点。哈哈。。。。我知道。。。。。好。。。它不会回显密码。。。。它会做其他的事情。。。。我所需要的只是得到密码。。。“我说了,”弗洛里斯:是的。幸运的是,现在不是了。只是想澄清一下其他人所说的:如果你使用的是密码,它们永远不应该以纯文本的形式存储,即使它在你的数据库中,并且永远不会显示在屏幕上。处理密码的最佳方法是在第一次输入密码时立即使用哈希算法,如bcrypt。然后,任何后续的密码检查都应该对其输入进行散列并比较散列。原始密码应保持即使系统管理员也无法恢复的状态。如果没有,您的系统就不安全:有很多黑客发布密码数据的案例:不要成为其中之一