Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Parser
- {
- private $base = array();
- private $path = array();
- private function LoadBase()
- {
- $s = file_get_contents('info/base.txt');
- $arr = explode("====================", $s);
- for ($i = 0, $n = sizeof($arr); $i < $n; $i++) {
- $arr[$i] = explode("\n", $arr[$i]);
- }
- $accounts = $arr;
- $all = sizeof($accounts);
- for ($i = 0; $i < $all; $i++) {
- if (sizeof($accounts[$i]) < 4) {
- unset($accounts[$i]);
- }
- }
- sort($accounts);
- return $accounts;
- }
- private function createdir()
- {
- $this->path = date("F j, Y, g:i:s a");
- mkdir($this->path, 0777);
- }
- function templatetext($massive)
- {
- $s = $massive;
- $all = sizeof($s);
- $string = "====================\n";
- for ($i = 0; $i < $all; $i++) {
- $keys = sizeof($s[$i]);
- for ($k = 1; $k < $keys; $k++) {
- $string = $string . $s[$i][$k] . "\n";
- }
- $string = $string . "====================\n";
- $string = $string . "====================\n";
- }
- return $string;
- }
- function save($massive, $file)
- {
- $s = $massive;
- $all = sizeof($s);
- $string = "====================\n";
- for ($i = 0; $i < $all; $i++) {
- $keys = sizeof($s[$i]);
- for ($k = 1; $k < $keys; $k++) {
- $string = $string . $s[$i][$k] . "\n";
- }
- $string = $string . "\n====================\n";
- $string = $string . "====================\n";
- }
- $file = fopen($this->path . "/" . $file . ".txt", "a+");
- fwrite($file, print_r($string, 1000));
- fclose($file);
- }
- function save2($massive, $file)
- {
- $s = $massive;
- $string = "====================\n";
- $string = $string . $s . "\n";
- $string = $string . "\n====================\n";
- $string = $string . "====================\n";
- $file = fopen($this->path . "/" . $file . ".txt", "a+");
- fwrite($file, print_r($string, 1));
- fclose($file);
- }
- /*private function check_Limited()
- {
- $limitedarr = $this->base;
- $all = sizeof($limitedarr);
- $lim = array();
- for($i = 0; $i < $all;$i++)
- {
- $sum = $limitedarr[$i][13];
- $string = preg_replace('~[^0-9,.]+~','',$sum);
- if($string > 100)
- {
- $string = $limitedarr[$i][6];
- $s = preg_replace('~[^+-]+~','',$string);
- if (strcmp($s,"+") == 0)
- {
- array_push($lim,$limitedarr[$i]);
- }
- }
- }
- $this->createdir();
- $file=fopen($this->path . "/Limited_good.txt","w");
- $text = $this->templatetext($lim);
- fwrite($file,print_r($text,1000));
- fclose($file);
- }*/
- private
- function check_Limited()
- {
- $limitedarr = $this->base;
- $all = sizeof($limitedarr);
- $lim = array();
- for ($i = 0; $i < $all; $i++) {
- if ($this->check_Balance($limitedarr[$i][13])) {
- $string = $limitedarr[$i][6];
- $s = preg_replace('~[^+-]+~', '', $string);
- if (strcmp($s, "+") == 0) {
- array_push($lim, $limitedarr[$i]);
- }
- }
- }
- $file = fopen($this->path . "/Limited_good.txt", "w");
- $text = $this->templatetext($lim);
- fwrite($file, print_r($text, 1));
- fclose($file);
- }
- private
- function check_Balance($massive)
- {
- $sum = $massive;
- $string = preg_replace('~[^0-9,.]+~', '', $sum);
- if ($string > 100) {
- return true;
- }
- }
- private function getCountryCode($c)
- {
- $code = explode("-",$c);
- $sizz = sizeof($code);
- if($sizz == 2)
- {
- return trim($code[1]);
- }
- else
- {
- return "Unknown";
- }
- }
- private function getBank($b)
- {
- $bank = explode("-",$b);
- $sizz = sizeof($bank);
- if($sizz == 2)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- function check_Country()
- {
- $base = $this->base;
- $all = sizeof($base);
- $country = array();
- for ($i = 0; $i < $all; $i++) {
- //1 === proverka po balansy;
- $balance = $base[$i][13];
- $t = preg_replace('~[^0-9,.]+~', '', $balance);
- if ($t > 100)
- {
- $lol = $this->getCountryCode($base[$i][7]);
- $file = fopen($this->path . "/" . $lol . ".txt", "a+");
- $t = implode("\n", $base[$i]);
- fwrite($file, print_r("====================\n". trim($t) . "\n====================\n" , 1));
- fclose($file);
- unset($base[$i]);
- sort($base);
- }
- //1 ==========================
- // === proverka po gody
- $all = sizeof($base);
- $card = $base[$i][14];
- $c = preg_replace('~[^0-9/]+~', '', $card);
- $d_e = explode("/", $c);
- $allde = sizeof($d_e);
- if ($allde > 1) {
- if ($d_e[0] > 0 or $d_e[1] > 0) {
- $min_card = mktime(0, 0, 0, 2017, 01, 0);
- $max_card = mktime(0, 0, 0, $d_e[1], $d_e[0], 0);
- if ($min_card < $max_card)
- {
- $lol = $this->getCountryCode($base[$i][7]);
- $file = fopen($this->path . "/" . $lol . ".txt", "a+");
- $t = implode("\n", $base[$i]);
- fwrite($file, print_r("====================\n". trim($t) . "\n====================\n" , 1));
- fclose($file);
- unset($base[$i]);
- sort($base);
- }
- }
- }
- //============================
- // === proverka po banky
- $all = sizeof($base)-1;
- $bank = $this->getBank($base[$i][15]);
- $b = explode("-", $bank);
- if(sizeof($b) > 2)
- {
- if (trim($b[1]) != null)
- {
- $lol = $this->getCountryCode($base[$i][7]);
- $file = fopen($this->path . "/" . $lol . ".txt", "a+");
- $t = implode("\n", $base[$i]);
- fwrite($file, print_r("====================\n". trim($t) . "\n====================\n" , 1));
- fclose($file);
- }
- }
- //===========================
- }
- /*print_r($country);
- $allc = sizeof($country);
- for($l=0; $l < $allc; $l++)
- {
- $file = fopen($this->path . "/" . $country[$l] . ".txt","a+");
- print_r($base[3]);
- //$text = $this->templatetext($base[1]);
- //write($file,print_r($text,1000));
- fclose($file);
- //print_r($base[$l]);
- $l = $l + 1;
- }*/
- }
- public
- function run()
- {
- echo "<pre>";
- echo '<script language="JavaScript">
- alert("Файл успешно загружен! начинаю работу!");
- </script>
- ';
- $this->base = $this->LoadBase();
- $this->createdir();
- $this->check_Limited();
- $this->check_Country();
- echo '<script language="JavaScript">
- alert("Парсер успешно закочил свою работу!");
- </script>
- ';
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement