Changeset 880 for trunk/Modules/Referrer
- Timestamp:
- Apr 7, 2020, 10:15:48 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/Referrer/Referrer.php
r860 r880 34 34 function Log() 35 35 { 36 if (array_key_exists('HTTP_REFERER', $_SERVER))36 if (array_key_exists('HTTP_REFERER', $_SERVER)) 37 37 { 38 38 $Referrer = addslashes($_SERVER['HTTP_REFERER']); 39 39 $HostName = substr($Referrer, strpos($Referrer, '/') + 2); 40 40 $HostName = substr($HostName, 0, strpos($HostName, '/')); 41 if (!in_array($HostName, $this->Excludes))41 if (!in_array($HostName, $this->Excludes)) 42 42 { 43 43 $IP = GetRemoteAddress(); … … 46 46 $DbResult = $this->System->Database->query('SELECT COUNT(*) FROM `BlackList` WHERE `IP` = "'.$IP.'"'); 47 47 $DbRow = $DbResult->fetch_row(); 48 if ($DbRow[0] == 0)48 if ($DbRow[0] == 0) 49 49 { 50 50 $Visible = '1'; … … 58 58 // Check if host name is already stored and need just to update hit counter 59 59 $DbResult = $this->System->Database->query('SELECT `Id` FROM `Referrer` WHERE `Web` = "'.$HostName.'"'); 60 if ($DbResult->num_rows > 0)60 if ($DbResult->num_rows > 0) 61 61 { 62 62 $DbRow = $DbResult->fetch_assoc(); … … 92 92 $Output .= $BannerSmall.' <textarea rows="2" cols="30">'.htmlspecialchars($BannerSmall).'</textarea><br />'; 93 93 94 if ($this->System->User->Licence(LICENCE_ADMIN)) {94 if ($this->System->User->Licence(LICENCE_ADMIN)) { 95 95 96 96 $MonthAge = 3; … … 99 99 <div style="font-size: 10px;">Seznam je automaticky aktualizován a zobrazeny jsou servery, ze kterých přišli uživatelé během posledních třech měsíců řazený sestupně dle nejnovějších.</div><br />'; 100 100 101 if (!$this->System->User->Licence(LICENCE_ADMIN)) $Where = ' WHERE (`Visible`=1) AND (`Parent` IS NULL)';101 if (!$this->System->User->Licence(LICENCE_ADMIN)) $Where = ' WHERE (`Visible`=1) AND (`Parent` IS NULL)'; 102 102 else $Where = ''; 103 103 $Query = 'SELECT *, (SELECT Web FROM `Referrer` AS T4 WHERE T4.Id = T3.Parent) AS ParentName '. … … 123 123 array('Name' => 'TotalHits', 'Title' => T('Hits')), 124 124 ); 125 if ($this->System->User->Licence(LICENCE_ADMIN))125 if ($this->System->User->Licence(LICENCE_ADMIN)) 126 126 { 127 127 $TableColumns[] = array('Name' => 'Visible', 'Title' => T('Visible')); … … 137 137 138 138 $DbResult = $this->Database->query($Query); 139 while ($Line = $DbResult->fetch_assoc())139 while ($Line = $DbResult->fetch_assoc()) 140 140 { 141 141 $Output .= '<tr><td><a href="'.$Line['LastURL'].'">'.$Line['Web'].'</a></td>'. 142 142 '<td>'.HumanDate($Line['MaxDateLast']).'</td>'. 143 143 '<td>'.$Line['TotalHits'].'</td>'; 144 if ($this->System->User->Licence(LICENCE_ADMIN))144 if ($this->System->User->Licence(LICENCE_ADMIN)) 145 145 { 146 146 $Output .= … … 158 158 159 159 } 160 return ($Output);160 return $Output; 161 161 } 162 162 … … 165 165 $Output = '<select name="Parent">'; 166 166 $Output .= '<option value=""'; 167 if ($Selected == '')167 if ($Selected == '') 168 168 $Output .= ' selected="selected"'; 169 169 $Output .= '></option>'; 170 170 $DbResult = $this->Database->select('Referrer', '`Id`, `Web`', '`Parent` IS NULL ORDER BY `Web`'); 171 while ($Language = $DbResult->fetch_assoc())172 if ($Language['Id'] != $Self)171 while ($Language = $DbResult->fetch_assoc()) 172 if ($Language['Id'] != $Self) 173 173 { 174 174 $Output .= '<option value="'.$Language['Id'].'"'; 175 if ($Selected == $Language['Id'])175 if ($Selected == $Language['Id']) 176 176 $Output .= ' selected="selected"'; 177 177 $Output .= '>'.$Language['Web'].'</option>'; 178 178 } 179 179 $Output .= '</select>'; 180 return ($Output);180 return $Output; 181 181 } 182 182 183 183 function Spam() 184 184 { 185 if ($this->System->User->Licence(LICENCE_ADMIN))186 { 187 if (array_key_exists('id', $_GET))185 if ($this->System->User->Licence(LICENCE_ADMIN)) 186 { 187 if (array_key_exists('id', $_GET)) 188 188 { 189 189 $DbResult = $this->Database->select('Referrer', '*', 'Id='.$_GET['id']); 190 if ($DbResult->num_rows > 0)190 if ($DbResult->num_rows > 0) 191 191 { 192 192 $Item = $DbResult->fetch_assoc(); 193 193 $this->Database->update('Referrer', 'Id='.$_GET['id'], array('Visible' => 0, 'Description' => 'Spam')); 194 194 $DbResult2 = $this->Database->select('BlackList', '*', 'IP="'.$Item['LastIP'].'"'); 195 if ($DbResult2->num_rows == 0)195 if ($DbResult2->num_rows == 0) 196 196 { 197 197 $this->Database->insert('BlackList', array('Time' => 'NOW()', 'IP' => $Item['LastIP'])); … … 202 202 } else $Output = ShowMessage(T('Item not specified'), MESSAGE_CRITICAL); 203 203 } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL); 204 return ($Output);204 return $Output; 205 205 } 206 206 207 207 function Edit() 208 208 { 209 if ($this->System->User->Licence(LICENCE_ADMIN))210 { 211 if (array_key_exists('id', $_GET))209 if ($this->System->User->Licence(LICENCE_ADMIN)) 210 { 211 if (array_key_exists('id', $_GET)) 212 212 { 213 213 $DbResult = $this->Database->select('Referrer', '*', 'Id='.$_GET['id']); 214 if ($DbResult->num_rows > 0)214 if ($DbResult->num_rows > 0) 215 215 { 216 216 $Item = $DbResult->fetch_assoc(); 217 if ($Item['Visible'] == 1) $Visible = ' checked ';217 if ($Item['Visible'] == 1) $Visible = ' checked '; 218 218 else $Visible = ''; 219 219 $Output = '<form action="?action=editsave&id='.$_GET['id'].'" method="post"><table>'. … … 227 227 } else $Output = ShowMessage(T('Item not specified'), MESSAGE_CRITICAL); 228 228 } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL); 229 return ($Output);229 return $Output; 230 230 } 231 231 232 232 function EditSave() 233 233 { 234 if ($this->System->User->Licence(LICENCE_ADMIN))235 { 236 if ($_POST['Parent'] == '') $_POST['Parent'] = null;234 if ($this->System->User->Licence(LICENCE_ADMIN)) 235 { 236 if ($_POST['Parent'] == '') $_POST['Parent'] = null; 237 237 $_POST['Visible'] = array_key_exists('Visible', $_POST); 238 238 $DbResult = $this->Database->update('Referrer', 'Id='.$_GET['id'], array( … … 243 243 $Output .= $this->ShowList(); 244 244 } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL); 245 return ($Output);245 return $Output; 246 246 } 247 247 … … 249 249 { 250 250 $this->Title = T('Promotion'); 251 if (array_key_exists('action', $_GET))252 { 253 if ($_GET['action'] == 'edit') $Output = $this->Edit();254 else if ($_GET['action'] == 'spam') $Output = $this->Spam();255 else if ($_GET['action'] == 'editsave') $Output = $this->EditSave();251 if (array_key_exists('action', $_GET)) 252 { 253 if ($_GET['action'] == 'edit') $Output = $this->Edit(); 254 else if ($_GET['action'] == 'spam') $Output = $this->Spam(); 255 else if ($_GET['action'] == 'editsave') $Output = $this->EditSave(); 256 256 else $Output = $this->ShowList(); 257 257 } else $Output = $this->ShowList(); 258 return ($Output);258 return $Output; 259 259 } 260 260 }
Note:
See TracChangeset
for help on using the changeset viewer.