Ignore:
Timestamp:
Apr 6, 2020, 11:17:40 PM (5 years ago)
Author:
chronos
Message:
  • Modified: Improved code format.
File:
1 edited

Legend:

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

    r790 r873  
    1414  {
    1515    $Num = dechex($Num);
    16     return(substr($Num, 4, 2).substr($Num, 2, 2).substr($Num, 0, 2));
     16    return (substr($Num, 4, 2).substr($Num, 2, 2).substr($Num, 0, 2));
    1717  }
    1818
     
    2121    global $MonthNames;
    2222
    23     if(!$this->System->User->CheckPermission('Chat', 'Display')) return('Nemáte oprávnění');
     23    if (!$this->System->User->CheckPermission('Chat', 'Display')) return ('Nemáte oprávnění');
    2424
    25     if(array_key_exists('date', $_GET)) $Date = $_GET['date'];
     25    if (array_key_exists('date', $_GET)) $Date = $_GET['date'];
    2626      else $Date = date('Y-m-d');
    2727    $DateParts = explode('-', $Date);
     
    3535    $EndDateParts = explode('-', $EndDateTimeParts[0]);
    3636
    37     if(!array_key_exists('year', $_SESSION)) $_SESSION['year'] = date('Y', time());
    38     if(array_key_exists('year', $_GET)) $_SESSION['year'] = addslashes($_GET['year']);
     37    if (!array_key_exists('year', $_SESSION)) $_SESSION['year'] = date('Y', time());
     38    if (array_key_exists('year', $_GET)) $_SESSION['year'] = addslashes($_GET['year']);
    3939
    40     if(!array_key_exists('month', $_SESSION)) $_SESSION['month'] = date('n', time());
    41     if(array_key_exists('month', $_GET)) $_SESSION['month'] = addslashes($_GET['month']);
     40    if (!array_key_exists('month', $_SESSION)) $_SESSION['month'] = date('n', time());
     41    if (array_key_exists('month', $_GET)) $_SESSION['month'] = addslashes($_GET['month']);
    4242
    4343    $Output = '<div class="ChatHistory">';
    44     for($Year = $EndDateParts[0]; $Year >= $StartDateParts[0]; $Year--)
     44    for ($Year = $EndDateParts[0]; $Year >= $StartDateParts[0]; $Year--)
    4545    {
    46       if($_SESSION['year'] == $Year)
     46      if ($_SESSION['year'] == $Year)
    4747      {
    4848        $Output .= '<div class="Year">'.$Year.'<div class="YearContent">';
    49         if($Year == $StartDateParts[0]) $StartMonth = ($StartDateParts[1] + 0); else $StartMonth = 1;
    50         if($Year == $EndDateParts[0]) $EndMonth = ($EndDateParts[1] + 0); else $EndMonth = 12;
    51         for($Month = $EndMonth; $Month >= $StartMonth; $Month--)
     49        if ($Year == $StartDateParts[0]) $StartMonth = ($StartDateParts[1] + 0); else $StartMonth = 1;
     50        if ($Year == $EndDateParts[0]) $EndMonth = ($EndDateParts[1] + 0); else $EndMonth = 12;
     51        for ($Month = $EndMonth; $Month >= $StartMonth; $Month--)
    5252        {
    53           if($_SESSION['month'] == $Month)
     53          if ($_SESSION['month'] == $Month)
    5454          {
    5555            $Output .= '<div class="Months">'.$MonthNames[$Month].'<span>';
    56             if(($Year == $StartDateParts[0]) and ($Month == $StartDateParts[1])) $StartDay = ($StartDateParts[2]+0); else $StartDay = 1;
    57             if(($Year == $EndDateParts[0]) and ($Month == $EndDateParts[1])) $EndDay = ($EndDateParts[2]+0); else $EndDay = date('t',mktime(0,0,0,$Month,0,$Year));
    58             for($Day = $StartDay; $Day <= $EndDay; $Day++)
     56            if (($Year == $StartDateParts[0]) and ($Month == $StartDateParts[1])) $StartDay = ($StartDateParts[2]+0); else $StartDay = 1;
     57            if (($Year == $EndDateParts[0]) and ($Month == $EndDateParts[1])) $EndDay = ($EndDateParts[2]+0); else $EndDay = date('t',mktime(0,0,0,$Month,0,$Year));
     58            for ($Day = $StartDay; $Day <= $EndDay; $Day++)
    5959            {
    6060              $Text = '<a href="?date='.$Year.'-'.$Month.'-'.$Day.'">'.$Day.'</a> ';
    61               if(($DateParts[0] == $Year) and ($DateParts[1] == $Month) and ($DateParts[2] == $Day)) $Text = '<strong>'.$Text.'</strong>';
     61              if (($DateParts[0] == $Year) and ($DateParts[1] == $Month) and ($DateParts[2] == $Day)) $Text = '<strong>'.$Text.'</strong>';
    6262              $Output .= $Text;
    6363            }
     
    7272    $DbResult = $this->Database->select('ChatHistory', 'Nick, Color, Text, UNIX_TIMESTAMP(Time)', "RoomType = 0 AND Time > '".$Date." 00:00:00' AND Time < '".$Date." 23:59:59' ORDER BY Time DESC");
    7373    $Output .= '<div class="ChatHistoryText">';
    74     if($DbResult->num_rows > 0)
    75     while($Row = $DbResult->fetch_array())
     74    if ($DbResult->num_rows > 0)
     75    while ($Row = $DbResult->fetch_array())
    7676    {
    7777      $Text = $Row['Text'];;
     
    8181    else $Output .= 'V daném dni nebyly zaznamenány žádné zprávy.';
    8282    $Output .= '</div>';
    83     return($Output);
     83    return ($Output);
    8484  }
    8585}
Note: See TracChangeset for help on using the changeset viewer.