Advertisement
zaksya

Email Extractor

Mar 30th, 2018
1,011
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.33 KB | None | 0 0
  1. <?php
  2. trait Email {
  3.     public function _h(){
  4.         $h[] = "\t Email Extractor V.1";
  5.         $h[] = "\t Code By ZakirDotID";
  6.         $h[] = "\t Don`t Change CopyRight!";
  7.         $head = implode("\n", $h);
  8.         return $head;
  9.     }
  10.     public static function _v($email){
  11.         if (filter_var($email,FILTER_VALIDATE_EMAIL)) {
  12.             return true;
  13.         } else {
  14.             return false;
  15.         }
  16.     }
  17.     public static function run(){
  18.         echo self::_h();
  19.         echo "\n\t Input File : ";
  20.         $file = trim(fgets(STDIN));
  21.         $files = file_get_contents($file) or exit("\nError Fatal!\n");
  22.         $ext = explode(".", $file);
  23.         $email = explode("\r\n", $files);
  24.         if ($ext[1] == "csv") {
  25.         self::_csv($file); 
  26.         } else {
  27.         echo "Found ( ".count($email)." )\n ";
  28.             foreach ($email as $data) {
  29.             echo "[+] $data \n";
  30.             self::save("email.log",$data); 
  31.             }  
  32.         }
  33.     }
  34.     public static function _csv($file){
  35.     $target = fopen($file, 'r');
  36.     while($baris = fgetcsv($target, 0, ';')){
  37.         for($i=0,$kolom=count($baris); $i<$kolom; $i++){
  38.             if (self::_v($baris[$i]) == true) {
  39.                 echo " [+] $baris[$i] \n";
  40.                 self::save("email.log",$baris[$i]);
  41.             } else {
  42.                 // Error Tidak Valid
  43.             }
  44.            
  45.         }
  46.     }
  47.         fclose($target);
  48.     }
  49.     public static function save($file,$data){
  50.         $fp = @fopen(date("d").$file, "a+");
  51.         fwrite($fp, $data."\r\n");
  52.         fclose($fp);   
  53.     }
  54.  
  55. }
  56. Email::run();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement