Advertisement
Squito

Untitled

Feb 25th, 2020
282
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.54 KB | None | 0 0
  1. <?PHP
  2. $kepek=array("jpg", "jpeg", "png", "webp", "gif");
  3. $konyvtar="./neko/";
  4. $dir=opendir($konyvtar);
  5. while($file=readdir($dir))
  6. {
  7.     if(is_file($konyvtar.$file))
  8.     {
  9.         if(in_array(pathinfo($konyvtar.$file, PATHINFO_EXTENSION), $kepek))
  10.         {
  11.             $fajlok[]=$file;
  12.         }
  13.     }
  14. }
  15. $feltolt=fopen("lista.txt", "w");
  16. fwrite($feltolt, implode(PHP_EOL, $fajlok));
  17. fclose($feltolt);
  18. ?>
  19.  
  20. <?PHP
  21. //API
  22. $lista=file("lista.txt");
  23. $x=mt_rand(0, count($lista)-1);
  24. echo '{"url": "http://www.domainnev.com/neko/'.urlencode(trim($lista[$x])).'"}';
  25. unset($lista);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement