Changeset 63 for trunk/Global.php


Ignore:
Timestamp:
Aug 3, 2021, 11:20:41 AM (3 years ago)
Author:
chronos
Message:
  • Modified: Used explicit types where possible for better error reporting.
  • Modified: Updated Common packaged to newer version.
  • Modified: Simplified pages title.
  • Added: Simple keyword based spam filter for meet items.
Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

    • Property svn:ignore
      •  

        old new  
        1 nbproject
        2 Config.php
        31.settings
        42.project
        53.buildpath
         4.htaccess
  • trunk/Global.php

    r55 r63  
    11<?php
    22
    3 function HumanDate($Time)
     3function HumanDate(int $Time): string
    44{
    55  return date('j.n.Y', $Time);
    66}
    77
    8 function HumanTime($Time)
     8function HumanTime(int $Time): string
    99{
    1010  return date('H:i:s', $Time);
    1111}
    1212
    13 function HumanDateTime($Time)
     13function HumanDateTime(int $Time): string
    1414{
    1515  $Output = HumanDate($Time);
     
    1919}
    2020
    21 function Link2($URL)
     21function Link2(string $URL): string
    2222{
    2323  global $Config;
     
    2626}
    2727
    28 function ProcessURL()
     28function ProcessURL(): array
    2929{
    3030  if (array_key_exists('REDIRECT_QUERY_STRING', $_SERVER))
     
    4040}
    4141
    42 function GetQueryStringArray($QueryString)
     42function GetQueryStringArray(string $QueryString): array
    4343{
    4444  $Result = array();
     
    5656}
    5757
    58 function SetQueryStringArray($QueryStringArray)
     58function SetQueryStringArray(array $QueryStringArray): string
    5959{
    6060  $Parts = array();
     
    6666}
    6767
    68 function GetPageList($TotalCount)
     68function HumanSize(int $Value): string
     69{
     70  global $UnitNames;
     71
     72  $UnitIndex = 0;
     73  while ($Value > 1024)
     74  {
     75    $Value = round($Value / 1024, 3);
     76    $UnitIndex++;
     77  }
     78  return $Value.' '.$UnitNames[$UnitIndex];
     79}
     80
     81function GetPageList(int $TotalCount): array
    6982{
    7083  global $Config;
     
    7285  $QueryItems = GetQueryStringArray($_SERVER['QUERY_STRING']);
    7386
    74   $ItemPerPage = $Config['ItemsPerPage'];
    75   $Around = round($Config['VisiblePagingItems'] / 2);
     87  $ItemPerPage = (int)$Config['ItemsPerPage'];
     88  $Around = round((int)$Config['VisiblePagingItems'] / 2);
    7689  $Result = '';
    7790  $PageCount = floor($TotalCount / $ItemPerPage) + 1;
     
    131144$OrderArrowImage = array('sort_asc.png', 'sort_desc.png');
    132145
    133 function GetOrderTableHeader($Columns, $DefaultColumn, $DefaultOrder = 0)
     146function GetOrderTableHeader(array $Columns, string $DefaultColumn, int $DefaultOrder = 0): array
    134147{
    135148  global $OrderDirSQL, $OrderArrowImage, $Config;
     
    179192}
    180193
    181 function GetMicrotime()
     194function GetMicrotime(): float
    182195{
    183196  list($Usec, $Sec) = explode(' ', microtime());
     
    189202  var $Items = array();
    190203
    191   function GetOutput($Link)
     204  function GetOutput(string $Link): string
    192205  {
    193206    $Output = '';
     
    355368            '<input value="'.$_SESSION[$Item['Name'].'do'].'" onkeyup="'.
    356369            'if (event.keyCode!=9) upf(\''.$Item['Name'].'do\',$(this).val(),(event.keyCode==13?0:1));" '.
    357             'id="'.$Item['Name'].'do" autocomplete="off" type="text"/>'.
    358             '<div class="label-box">'.$Item['Units'].'</div>'.
    359             '</div> ';
     370            'id="'.$Item['Name'].'do" autocomplete="off" type="text"/>';
     371            if (array_key_exists('Units', $Item))
     372            {
     373              $Output .= '<div class="label-box">'.$Item['Units'].'</div>';
     374            }
     375            $Output .= '</div> ';
    360376        }
    361377      }
     
    365381  }
    366382
    367   function GetWhere($Database)
     383  function GetWhere(Database $Database): string
    368384  {
    369385    $Where = '';
Note: See TracChangeset for help on using the changeset viewer.