-
Notifications
You must be signed in to change notification settings - Fork 13
/
radiomobile.php
144 lines (74 loc) · 3.65 KB
/
radiomobile.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
include 'config.php';
include 'function.php';
$target_dir = "/tmp/svxportal/";
$covrige_folder ="/var/www/svx/covrige";
$target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
$uploadOk = 1;
$imageFileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION));
// Check if image file is a actual image or fake image
function delTree($dir) {
$files = array_diff(scandir($dir), array('.','..'));
foreach ($files as $file) {
(is_dir("$dir/$file")) ? delTree("$dir/$file") : unlink("$dir/$file");
}
return rmdir($dir);
}
if($_SESSION['is_admin'] >0 && $_SESSION['loginid'] >0 )
{
if(isset($_POST["site_id"]) && $_POST['site_id'] !="" ) {
$unzip = new ZipArchive;
$out = $unzip->open($_FILES["fileToUpload"]["tmp_name"]);
if ($out === TRUE) {
$target_dir ="/tmp/svxportal/".$_FILES["fileToUpload"]["tmp_name"];
//echo getcwd();
// requers tmp foler not for widows server
$unzip->extractTo($target_dir);
$unzip->close();
$radiomobie_str_to_db = "";
foreach( glob( $target_dir.'/*.html' ) as $html_file ) {
//echo $html_file . '<br />';
$myfile = fopen($html_file, "r") or die("Unable to open file!");
while(!feof($myfile)) {
$line = fgets($myfile);
if (str_contains($line, 'rmap1=addimage')) {
//echo $line;
$rm_funtion_1 = explode( "rmap1=", $line, 2);
$rm_funtion_2 = explode( ";", $rm_funtion_1[1], 2);
$radiomobie_str_to_db = $rm_funtion_2[0].";";
// var_dump($radiomobie_str_to_db);
$radiomobie_str_to_db = $link->real_escape_string($radiomobie_str_to_db);
$station = $link->real_escape_string($_POST['site_id']);
$link->query(" DELETE FROM `covrige` WHERE `Name` = '$station';");
$link->query(" INSERT INTO `covrige` (`Id`, `Name`, `Radiomobilestring`) VALUES (NULL, '$station', '$radiomobie_str_to_db'); ");
}
}
chdir($target_dir);
if($radiomobie_str_to_db != "")
{
foreach( glob( '*.png' ) as $html_file )
{
copy($html_file, $covrige_folder."/".$html_file);
}
}
fclose($myfile);
delTree($target_dir);
}
?>
<script>
alert("<?php echo _('Uplad sucess!'); ?>");
window.close();
</script>
<?php
} else {
echo '<b>'._('Error').'</b>';
}
}
}
else
{
echo "not admin";
}