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))
if(file_get_contents($file) == $_GET['key']) {
echo reset(explode('.', $file));
break;
}
closedir($handle);