간단한 메일 링리스트의 경우 데이터를 .txt
파일에 저장 합니다. txt 파일에는 5 줄이 있습니다. 그 중 2 개 (이름과 이메일 포함)가 암호화됩니다. 보안상의 이유로 이름과 이메일을 암호화하여 저장했습니다.
다음은 파일을 검색하는 방법입니다.
/* EMAIL SEARCH */
$email_search = $_GET['email_search']; // get string from url for search
if (isset($email_search)) {
$searchthis = strtolower($email_search);
$email_matches = array();
$files = glob("subscribers/*.txt"); // Specify the file directory by extension (.txt)
foreach($files as $file) { // Loop the files in the directory {
$handle = @fopen($file, "r");
if ($handle) {
$lines = file($file);
$grab_email = strtolower($lines[3]); // for sorting only
while (!feof($handle)) {
$buffer = fgets($handle);
if(strpos(strtolower($buffer), $searchthis) !== FALSE) // strtolower; search word not case sensitive
$email_matches[$file] = $grab_email; // put all lines in array indexed by email
}
fclose($handle);
}
}
}
asort($email_matches);
<!-- search form -->
<form class="search-form form-inline" action="admin.php" method="GET">
<div class="input-group mb-3">
<input class="form-control" type="text" name="email_search" placeholder="Search for..." />
<div class="input-group-append">
<button class="btn btn-primary" type="submit">Search</button>
</div>
</div>
</form>
txt 파일은 다음과 같습니다.
id-5e0786c07c802 // id
Friends //category
ygkKcL/jz9U= // name (encrypted)
6gkKcL/jz9XuVRNayyIVcFbLw3ord0nc7IJj // email (encrypted)
902d95a9bf1c3f59a3996e4e7b4dec79 // token
이전에는 데이터가 암호화되지 않았을 때이 검색이 제대로 작동했습니다! 그러나 각 파일의 이름과 이메일 줄이 암호화 된 상태에서 지금 검색하려면 어떻게해야합니까?
암호화 된 값으로 검색하는 것은 어떻습니까?
코드에서 $_GET['email_search']
에 검색하려는 단어 또는 값이 포함됩니다. 암호화가 어떻게 생겼는지 모르겠지만 검색중인 단어를 다음과 같이 암호화 할 수 있습니다.
$email_search = openssl_encrypt($_GET['email_search'], $ciphering, $encryption_key, $options, $encryption_iv); // get string from url for search
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다