-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlib_LinkRemover.php
227 lines (214 loc) · 8 KB
/
lib_LinkRemover.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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
<?php
//CREATE TABLE `alirezaz_Robots`.`LinkRemoverHistory` ( `id` INT NOT NULL AUTO_INCREMENT , `Guid_U` VARCHAR(50) NOT NULL , `All` VARCHAR(2000) NOT NULL , `Today` VARCHAR(2000) NOT NULL , PRIMARY KEY (`id`)) ENGINE = InnoDB;.0
// define('SERVER_NAME','localhost:3306');
// define("USER_NAME","alirezaz");
// define("USER_PASSWORD","Ab_4317247");
// define("DB_NM","alirezaz_Robots");
class lib_LinkRemover{
private $SERVER_NAME;
private $USER_NAME;
private $USER_PASSWORD;
private $DB_NM;
public function __Construct($SERVER_NAME,$USER_NAME,$USER_PASSWORD,$DB_NM){
$this->SERVER_NAME = $SERVER_NAME;
$this->USER_NAME = $USER_NAME;
$this->USER_PASSWORD = $USER_PASSWORD;
$this->DB_NM = $DB_NM;
}
private function cov(){
$SERVER_NAME = $this->SERVER_NAME;
$USER_NAME = $this->USER_NAME;
$USER_PASSWORD = $this->USER_PASSWORD;
$DB_NM = $this->DB_NM;
$all = array(
'S'=>$SERVER_NAME,
'UN'=>$USER_NAME,
'UP'=>$USER_PASSWORD,
'D'=>$DB_NM
);
return $all;
}
private function connect(){
$all = $this->cov();
$link = mysqli_connect($all['S'],$all['UN'],$all['UP'],$all['D']);
if (mysqli_connect_errno($link)){
echo "Failed to connect to MySQL: " . mysqli_connect_error($link);
}
return $link;
}
private function query($qr){
$link = $this->connect();
$result = mysqli_query($link,$qr);
mysqli_close($link);
return $result;
}
// INSERT INTO `LinkRemoverHistory` (`id`, `Guid_U`, `All`, `Today`) VALUES (NULL, 'Guid_U', 'All', 'Today')
public function insert($pats){
$Guid_U = $pats['Guid_U'];
$All = $pats['All'];
$Date = $pats['Date'];
$Setting = $pats['Setting'];
$Max = $pats['Max'];
$TXTS = $pats['TXTS'];
$AMS = $pats['AMS'];
$Name = $pats['Name'];
$LastMessage = $pats['LastMessage'];
$qr = "INSERT INTO `".LINKST."` (`id`, `Guid_U`, `All`, `Date`, `Setting`, `Max`, `TXTS`, `AMS`, `Name`, `LastMessage`) VALUES (NULL, '$Guid_U', '$All', '$Date', '$Setting', '$Max', '$TXTS', '$AMS', '$Name', '$LastMessage');";
$result = $this->query($qr);
return $result;
}
public function select($id){
$qr = "SELECT `Guid_U`, `All` FROM `".LINKST."` WHERE id = '$id'";
$result = $this->query($qr);
$row = mysqli_fetch_array($result);
return $row;
}
public function select_Guid($GUID_U){
$qr = "SELECT `All` FROM `".LINKST."` WHERE Guid_U = '$GUID_U'";
$result = $this->query($qr);
$row = mysqli_fetch_array($result);
return $row;
}
public function select_LastMessage($GUID_U){
$qr = "SELECT `LastMessage` FROM `".LINKST."` WHERE Guid_U = '$GUID_U'";
$result = $this->query($qr);
$row = mysqli_fetch_array($result);
return $row;
}
public function select_Alls(){
$qr = "SELECT `All` FROM `".LINKST."` WHERE 1";
$result = $this->query($qr);
$array = [];
while($rows = mysqli_fetch_row($result)){
foreach($rows as $row){
$array[] = $row;
}
}
return $array;
}
public function select_AllsGuids(){
$qr = "SELECT `GUID_U` , `All`, `Name` FROM `".LINKST."` WHERE 1";
$result = $this->query($qr);
$array = [];
while($rows = mysqli_fetch_row($result)){
$array[] = $rows;
}
return $array;
}
public function selectAll_GUID($GUID_U){
$qr = "SELECT `All` FROM `".LINKST."` WHERE `Guid_U` = '$GUID_U'";
$result = $this->query($qr);
$row = mysqli_fetch_array($result);
return $row;
}
public function selectName_GUID($GUID_U){
$qr = "SELECT `Name` FROM `".LINKST."` WHERE `Guid_U` = '$GUID_U'";
$result = $this->query($qr);
$row = mysqli_fetch_array($result);
$Name = $row['Name'];
$Name = utf8_decode($Name);
return $Name;
}
public function selectAllTXTS_GUID($GUID_U){
$qr = "SELECT `All` , `TXTS` FROM `".LINKST."` WHERE `Guid_U` = '$GUID_U'";
$result = $this->query($qr);
$row = mysqli_fetch_array($result);
return $row;
}
public function selectTXTS_GUID($GUID_U){
$qr = "SELECT `TXTS` FROM `".LINKST."` WHERE `Guid_U` = '$GUID_U'";
$result = $this->query($qr);
$row = mysqli_fetch_array($result);
return $row;
}
public function selectAMS_GUID($GUID_U){
$qr = "SELECT `AMS` FROM `".LINKST."` WHERE `Guid_U` = '$GUID_U'";
$result = $this->query($qr);
$row = mysqli_fetch_array($result);
return $row;
}
public function selectSetting_GUID($GUID_U){
$qr = "SELECT `Setting` FROM `".LINKST."` WHERE `Guid_U` = '$GUID_U'";
$result = $this->query($qr);
$row = mysqli_fetch_array($result);
return $row;
}
public function selectMax_GUID($GUID_U){
$qr = "SELECT `Max` FROM `".LINKST."` WHERE `Guid_U` = '$GUID_U'";
$result = $this->query($qr);
$row = mysqli_fetch_array($result);
return $row;
}
public function delete($id){
$qr = "DELETE FROM `".LINKST."` WHERE id = '$id'";
$result = $this->query($qr);
$row = mysqli_fetch_array($result);
return $row;
}
// `id`, `Guid_U`, `All`, `Today`
public function update($id,$pats){
$Guid_U = $pats['Guid_U'];
$All = $pats['All'];
$qr = "UPDATE `".LINKST."` SET `Guid_U`='$Guid_U',`All`='$All' WHERE `id`='$id'";
$result = $this->query($qr);
$row = mysqli_fetch_array($result);
return $row;
}
public function update_GUID($GUID_U,$pats){
$All = $pats['All'];
$qr = "UPDATE `".LINKST."` SET `All`='$All' WHERE `Guid_U`='$GUID_U'";
$result = $this->query($qr);
return $result;
}
// update_options
public function updateAll_GUiD($GUID_U,$All){
$qr = "UPDATE `".LINKST."` SET `All` = '$All' WHERE `GUID_U`='$GUID_U'";
$result = $this->query($qr);
return $result;
}
public function updateTXTS_GUiD($GUID_U,$TXTS){
$qr = "UPDATE `".LINKST."` SET `TXTS` = '$TXTS' WHERE `GUID_U`='$GUID_U'";
$result = $this->query($qr);
return $result;
}
public function updateSetting_GUiD($GUID_U,$Setting){
$qr = "UPDATE `".LINKST."` SET `Setting` = '$Setting' WHERE `GUID_U`='$GUID_U'";
$result = $this->query($qr);
return $result;
}
public function updateDateLimit_GUiD($GUID_U,$DateLimit){
$qr = "UPDATE `".LINKST."` SET `DateLimit` = '$DateLimit' WHERE `GUID_U`='$GUID_U'";
$result = $this->query($qr);
return $result;
}
public function updateMax_GUiD($GUID_U,$Max){
$qr = "UPDATE `".LINKST."` SET `Max` = '$Max' WHERE `GUID_U`='$GUID_U'";
$result = $this->query($qr);
return $result;
}
public function updateName_GUiD($GUID_U,$Name){
$qr = "UPDATE `".LINKST."` SET `Name` = '$Name' WHERE `GUID_U`='$GUID_U'";
$result = $this->query($qr);
return $result;
}
public function updateAMS_GUiD($GUID_U,$AMS){
$qr = "UPDATE `".LINKST."` SET `AMS` = '$AMS' WHERE `GUID_U`='$GUID_U'";
$result = $this->query($qr);
return $result;
}
public function updateLastMessage_GUiD($GUID_U,$LastMessage){
$qr = "UPDATE `".LINKST."` SET `LastMessage` = '$LastMessage' WHERE `GUID_U`='$GUID_U'";
$result = $this->query($qr);
return $result;
}
public function updateAMSLMS_GUiD($GUID_U,$AMS,$LastMessage){
$qr = "UPDATE `".LINKST."` SET `AMS`='$AMS',`LastMessage` = '$LastMessage' WHERE `GUID_U`='$GUID_U'";
$result = $this->query($qr);
return $result;
}
public function count(){
$qr = "select * from ".LINKST;
$result = $this->query($qr);
return mysqli_num_rows($result);
}
}