Title = 'Historie chatu'; $this->Description = 'Výpis historie chatu'; $this->ParentClass = 'PagePortal'; } function dechexr($Num) { $Num = dechex($Num); return substr($Num, 4, 2).substr($Num, 2, 2).substr($Num, 0, 2); } function Show(): string { global $MonthNames; if (!ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission('Chat', 'Display')) return 'Nemáte oprávnění'; if (array_key_exists('date', $_GET)) $Date = $_GET['date']; else $Date = date('Y-m-d'); $DateParts = explode('-', $Date); $DbResult = $this->Database->select('ChatHistory', 'MAX(Time), MIN(Time)'); $RowTotal = $DbResult->fetch_array(); $StartDateTimeParts = explode(' ', $RowTotal['MIN(Time)']); $StartDateParts = explode('-', $StartDateTimeParts[0]); $EndDateTimeParts = explode(' ', $RowTotal['MAX(Time)']); $EndDateParts = explode('-', $EndDateTimeParts[0]); if (!array_key_exists('year', $_SESSION)) $_SESSION['year'] = date('Y', time()); if (array_key_exists('year', $_GET)) $_SESSION['year'] = addslashes($_GET['year']); if (!array_key_exists('month', $_SESSION)) $_SESSION['month'] = date('n', time()); if (array_key_exists('month', $_GET)) $_SESSION['month'] = addslashes($_GET['month']); $Output = '
'; for ($Year = $EndDateParts[0]; $Year >= $StartDateParts[0]; $Year--) { if ($_SESSION['year'] == $Year) { $Output .= '
'.$Year.'
'; if ($Year == $StartDateParts[0]) $StartMonth = ($StartDateParts[1] + 0); else $StartMonth = 1; if ($Year == $EndDateParts[0]) $EndMonth = ($EndDateParts[1] + 0); else $EndMonth = 12; for ($Month = $EndMonth; $Month >= $StartMonth; $Month--) { if ($_SESSION['month'] == $Month) { $Output .= '
'.$MonthNames[$Month].''; if (($Year == $StartDateParts[0]) and ($Month == $StartDateParts[1])) $StartDay = ($StartDateParts[2]+0); else $StartDay = 1; if (($Year == $EndDateParts[0]) and ($Month == $EndDateParts[1])) $EndDay = ($EndDateParts[2]+0); else $EndDay = date('t',mktime(0,0,0,$Month,0,$Year)); for ($Day = $StartDay; $Day <= $EndDay; $Day++) { $Text = ''.$Day.' '; if (($DateParts[0] == $Year) and ($DateParts[1] == $Month) and ($DateParts[2] == $Day)) $Text = ''.$Text.''; $Output .= $Text; } $Output .= '
'; } else $Output .= ''.$MonthNames[$Month].' '; } $Output .='
'; } else $Output .= '
'.$Year.'
'; } $Output .= '
'; $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"); $Output .= '
'; if ($DbResult->num_rows > 0) while ($Row = $DbResult->fetch_array()) { $Text = $Row['Text'];; // StrTr($Row['text'], "\x8A\x8D\x8E\x9A\x9D\x9E", "\xA9\xAB\xAE\xB9\xBB\xBE"); $Output .= '['.date('d.m.Y H:i:s',$Row['UNIX_TIMESTAMP(Time)']).'] <'.$Row['Nick'].'> '.(htmlspecialchars($Text)).'
'; } else $Output .= 'V daném dni nebyly zaznamenány žádné zprávy.'; $Output .= '
'; return $Output; } } class ModuleChat extends Module { function __construct(System $System) { parent::__construct($System); $this->Name = 'Chat'; $this->Version = '1.0'; $this->Creator = 'Chronos'; $this->License = 'GNU/GPLv3'; $this->Description = 'Show history of IRC chat and previous SunriseChat'; $this->Models = array(ChatHistory::GetClassName()); } function DoStart(): void { $this->System->Pages['chat'] = 'PageChatHistory'; } } class ChatHistory extends Model { static function GetModelDesc(): ModelDesc { $Desc = new ModelDesc(self::GetClassName()); $Desc->AddString('Nick'); $Desc->AddText('Text'); $Desc->AddDateTime('Time'); $Desc->AddInteger('Color'); $Desc->AddString('RoomName'); $Desc->AddInteger('RoomType'); $Desc->AddString('Host'); return $Desc; } }