php getUser php handle opendir while false file readdir handle if preg

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
<?php
//getUser.php
$handle = opendir('.');
while (false !== ($file = readdir($handle)))
if(preg_match('/\.txt$/', $file) && file_get_contents($file) == $_GET['key']) {
die(reset(explode('.', $file)));
break;
}
closedir($handle);
die('err');