Ignore:
Timestamp:
Apr 7, 2020, 10:15:48 PM (4 years ago)
Author:
chronos
Message:
  • Modified: Improved code formatting.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Modules/Referrer/Referrer.php

    r860 r880  
    3434  function Log()
    3535  {
    36     if(array_key_exists('HTTP_REFERER', $_SERVER))
     36    if (array_key_exists('HTTP_REFERER', $_SERVER))
    3737    {
    3838      $Referrer = addslashes($_SERVER['HTTP_REFERER']);
    3939      $HostName = substr($Referrer, strpos($Referrer, '/') + 2);
    4040      $HostName = substr($HostName, 0, strpos($HostName, '/'));
    41       if(!in_array($HostName, $this->Excludes))
     41      if (!in_array($HostName, $this->Excludes))
    4242      {
    4343        $IP = GetRemoteAddress();
     
    4646        $DbResult = $this->System->Database->query('SELECT COUNT(*) FROM `BlackList` WHERE `IP` = "'.$IP.'"');
    4747        $DbRow = $DbResult->fetch_row();
    48         if($DbRow[0] == 0)
     48        if ($DbRow[0] == 0)
    4949        {
    5050          $Visible = '1';
     
    5858        // Check if host name is already stored and need just to update hit counter
    5959        $DbResult = $this->System->Database->query('SELECT `Id` FROM `Referrer` WHERE `Web` = "'.$HostName.'"');
    60         if($DbResult->num_rows > 0)
     60        if ($DbResult->num_rows > 0)
    6161        {
    6262          $DbRow = $DbResult->fetch_assoc();
     
    9292    $Output .= $BannerSmall.' &nbsp;&nbsp;<textarea rows="2" cols="30">'.htmlspecialchars($BannerSmall).'</textarea><br />';
    9393
    94     if($this->System->User->Licence(LICENCE_ADMIN)) {
     94    if ($this->System->User->Licence(LICENCE_ADMIN)) {
    9595
    9696    $MonthAge = 3;
     
    9999    <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 />';
    100100
    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)';
    102102    else $Where = '';
    103103    $Query = 'SELECT *, (SELECT Web FROM `Referrer` AS T4 WHERE T4.Id = T3.Parent) AS ParentName '.
     
    123123        array('Name' => 'TotalHits', 'Title' => T('Hits')),
    124124    );
    125     if($this->System->User->Licence(LICENCE_ADMIN))
     125    if ($this->System->User->Licence(LICENCE_ADMIN))
    126126    {
    127127      $TableColumns[] = array('Name' => 'Visible', 'Title' => T('Visible'));
     
    137137
    138138    $DbResult = $this->Database->query($Query);
    139     while($Line = $DbResult->fetch_assoc())
     139    while ($Line = $DbResult->fetch_assoc())
    140140    {
    141141      $Output .= '<tr><td><a href="'.$Line['LastURL'].'">'.$Line['Web'].'</a></td>'.
    142142          '<td>'.HumanDate($Line['MaxDateLast']).'</td>'.
    143143          '<td>'.$Line['TotalHits'].'</td>';
    144       if($this->System->User->Licence(LICENCE_ADMIN))
     144      if ($this->System->User->Licence(LICENCE_ADMIN))
    145145      {
    146146        $Output .=
     
    158158
    159159    }
    160     return($Output);
     160    return $Output;
    161161  }
    162162
     
    165165    $Output = '<select name="Parent">';
    166166    $Output .= '<option value=""';
    167     if($Selected == '')
     167    if ($Selected == '')
    168168      $Output .= ' selected="selected"';
    169169    $Output .= '></option>';
    170170    $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)
    173173    {
    174174      $Output .= '<option value="'.$Language['Id'].'"';
    175       if($Selected == $Language['Id'])
     175      if ($Selected == $Language['Id'])
    176176        $Output .= ' selected="selected"';
    177177      $Output .= '>'.$Language['Web'].'</option>';
    178178    }
    179179    $Output .= '</select>';
    180     return($Output);
     180    return $Output;
    181181  }
    182182
    183183  function Spam()
    184184  {
    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))
    188188      {
    189189        $DbResult = $this->Database->select('Referrer', '*', 'Id='.$_GET['id']);
    190         if($DbResult->num_rows > 0)
     190        if ($DbResult->num_rows > 0)
    191191        {
    192192          $Item = $DbResult->fetch_assoc();
    193193          $this->Database->update('Referrer', 'Id='.$_GET['id'], array('Visible' => 0, 'Description' => 'Spam'));
    194194          $DbResult2 = $this->Database->select('BlackList', '*', 'IP="'.$Item['LastIP'].'"');
    195           if($DbResult2->num_rows == 0)
     195          if ($DbResult2->num_rows == 0)
    196196          {
    197197            $this->Database->insert('BlackList', array('Time' => 'NOW()', 'IP' => $Item['LastIP']));
     
    202202      } else $Output = ShowMessage(T('Item not specified'), MESSAGE_CRITICAL);
    203203    } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL);
    204     return($Output);
     204    return $Output;
    205205  }
    206206
    207207  function Edit()
    208208  {
    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))
    212212      {
    213213        $DbResult = $this->Database->select('Referrer', '*', 'Id='.$_GET['id']);
    214         if($DbResult->num_rows > 0)
     214        if ($DbResult->num_rows > 0)
    215215        {
    216216          $Item = $DbResult->fetch_assoc();
    217           if($Item['Visible'] == 1) $Visible = ' checked ';
     217          if ($Item['Visible'] == 1) $Visible = ' checked ';
    218218            else $Visible = '';
    219219          $Output = '<form action="?action=editsave&amp;id='.$_GET['id'].'" method="post"><table>'.
     
    227227      } else $Output = ShowMessage(T('Item not specified'), MESSAGE_CRITICAL);
    228228    } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL);
    229     return($Output);
     229    return $Output;
    230230  }
    231231
    232232  function EditSave()
    233233  {
    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;
    237237      $_POST['Visible'] = array_key_exists('Visible', $_POST);
    238238      $DbResult = $this->Database->update('Referrer', 'Id='.$_GET['id'], array(
     
    243243      $Output .= $this->ShowList();
    244244    } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL);
    245     return($Output);
     245    return $Output;
    246246  }
    247247
     
    249249  {
    250250    $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();
    256256      else $Output = $this->ShowList();
    257257    } else $Output = $this->ShowList();
    258     return($Output);
     258    return $Output;
    259259  }
    260260}
Note: See TracChangeset for help on using the changeset viewer.