Ignore:
Timestamp:
May 29, 2014, 11:59:39 PM (10 years ago)
Author:
chronos
Message:
  • Opraveno: Zobrazení hodnoty času trvání změn stavu rozhraní.
  • Upraveno: Vzdálenou IP klienta nezjišťovat z proxy adres. Tyto adresy se dají falšovat a tedy nejsou spolehlivé.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Modules/News/NewsPage.php

    r614 r659  
    1414    $this->UploadedFilesFolder = $this->System->ModuleManager->Modules['News']->UploadedFilesFolder;
    1515    if(count($this->System->PathItems) > 1)
    16     { 
     16    {
    1717      if($this->System->PathItems[1] == 'subscription') return($this->ShowSubscription());
    1818        else if($this->System->PathItems[1] == 'rss') return($this->ShowRSS());
     
    2020    } else return($this->ShowMain());
    2121  }
    22  
     22
    2323  function ShowView()
    2424  {
     
    5252          foreach($Enclosures as $Enclosure)
    5353          {
    54             if(file_exists($this->UploadedFilesFolder.$Enclosure)) 
     54            if(file_exists($this->UploadedFilesFolder.$Enclosure))
    5555              $Output .= ' <a href="'.$this->System->Link('/'.$this->UploadedFilesFolder.$Enclosure).'">'.$Enclosure.'</a>';
    5656          }
     
    6161    return($Output);
    6262  }
    63  
     63
    6464  function ShowAdd()
    6565  {
     
    7878        if($this->System->User->CheckPermission('News', 'Insert', 'Group', $DbRow['Id']))
    7979        {
    80           if($DbRow['Id'] == $Category['Id']) $Selected = ' selected="1"'; 
     80          if($DbRow['Id'] == $Category['Id']) $Selected = ' selected="1"';
    8181            else $Selected = '';
    8282          $Output .= '<option value="'.$DbRow['Id'].'"'.$Selected.'>'.$DbRow['Caption'].'</option>';
     
    9696    return($Output);
    9797  }
    98  
     98
    9999  function ShowAdd2()
    100100  {
     
    122122        }
    123123        $Enclosures = substr($Enclosures, 1);
    124    
     124
    125125        $_POST['content'] = str_replace("\n",'<br />',$_POST['content']);
    126126        $this->Database->insert('News', array('Category' => $Category['Id'], 'Title' => $_POST['title'],
    127127          'Content' => $_POST['content'], 'Date' => 'NOW()', 'IP' => $RemoteAddr,
    128           'Enclosure' => $Enclosures, 'Author' => $this->System->User->User['Name'], 
     128          'Enclosure' => $Enclosures, 'Author' => $this->System->User->User['Name'],
    129129          'User' => $this->System->User->User['Id'], 'Link' => $_POST['link']));
    130130        $Output .= 'Aktualita přidána!<br />Pokud budete chtít vaši aktualitu smazat, klikněte na odkaz Smazat v seznamu všech aktualit v kategorii.<br /><br />';
     
    134134    return($Output);
    135135  }
    136  
     136
    137137  function ShowEdit()
    138138  {
     
    159159    return($Output);
    160160  }
    161  
     161
    162162  function ShowUpdate()
    163163  {
    164164    $Output = '';
    165     $RemoteAddr = GetRemoteAddress(); 
     165    $RemoteAddr = GetRemoteAddress();
    166166    $Category = $this->GetCategory();
    167167    if($this->System->User->CheckPermission('News', 'Insert', 'Group', $Category['Id']))
     
    175175        {
    176176          $_POST['content'] = str_replace("\n", '<br />', $_POST['content']);
    177           $this->Database->update('News', 'Id='.$_POST['id'], array('Title' => $_POST['title'], 
     177          $this->Database->update('News', 'Id='.$_POST['id'], array('Title' => $_POST['title'],
    178178            'Content' => $_POST['content'], 'Link' => $_POST['link']));
    179179          $Output .= 'Aktualita uložena!<br />';
     
    184184    return($Output);
    185185  }
    186  
     186
    187187  function ShowDelete()
    188188  {
     
    197197        // TODO: Make upload using general File class
    198198        if($Row['Enclosure'] != '')
    199         { 
     199        {
    200200          $Output .= '<br />Přílohy: ';
    201201          $Enclosures = explode(';', $Row['Enclosure']);
     
    211211    return($Output);
    212212  }
    213  
     213
    214214  function ShowList()
    215215  {
     
    226226      $Output .= '<strong>Seznam aktualit kategorie '.$Category['Caption'].':</strong><div style="font-size: small;">';
    227227      $Output .= PagesList('?category='.$Category['Id'].'&amp;page=', $Page, $PageMax, $PerPage);
    228    
     228
    229229      $DbResult = $this->Database->query('SELECT `News`.*, `User`.`Name` FROM `News` '.
    230230        'LEFT JOIN `User` ON `User`.`Id`=`News`.`User` WHERE `Category`='.$Category['Id'].' ORDER BY `News`.`Id` DESC LIMIT '.($Page * $PerPage).','.$PerPage);
     
    249249          foreach($Enclosures as $Enclosure)
    250250          {
    251             if(file_exists($this->UploadedFilesFolder.$Enclosure)) 
     251            if(file_exists($this->UploadedFilesFolder.$Enclosure))
    252252              $Output .= ' <a href="'.$this->System->Link('/'.$this->UploadedFilesFolder.$Enclosure).'">'.$Enclosure.'</a>';
    253253          }
     
    260260    return($Output);
    261261  }
    262  
     262
    263263  function GetCategory()
    264264  {
     
    267267    if(array_key_exists('category', $_POST)) $Category['Id'] = $_POST['category'] * 1;
    268268    //if(is_null($Category)) throw new Exception('Kategorie neurčena');
    269     else 
     269    else
    270270    {
    271271      $DbResult = $this->Database->select('NewsCategory', '*', '`Id`='.$Category['Id'].' ORDER BY `Sequence`');
     
    275275    return($Category);
    276276  }
    277  
     277
    278278  function ShowMain()
    279279  {
    280     $Output = '';   
     280    $Output = '';
    281281    if(array_key_exists('action',$_GET)) $Action = $_GET['action'];
    282282      else $Action = '';
     
    290290    return($Output);
    291291  }
    292  
     292
    293293  function ShowSubscription()
    294   {     
     294  {
    295295    if(array_key_exists('build', $_GET))
    296296    {
     
    302302      $Select = $this->System->Config['Web']['RootFolder'].'/aktuality/rss/?select='.substr($Select, 1);
    303303      $Output = 'Výsledný RSS kanál: <a href="'.$Select.'">'.$Select.'</a>';
    304     } else 
     304    } else
    305305    {
    306306      $Output = 'Vytvořte si vlastní RSS kanál, díky kterému budete moci automaticky sledovat novinky pomocí vaší RSS čtečky. Informace o technologii RSS a programech pro čtení kanálů najdete např. <a href="http://www.lupa.cz/clanky/prehled-rss-ctecek/">zde</a><br />'.
     
    314314      $Output.= '<input type="submit" value="Sestavit"/>'.
    315315        '</form>';
    316     } 
    317     return($Output);
    318   }
    319  
     316    }
     317    return($Output);
     318  }
     319
    320320  function ShowRSS()
    321321  {
     
    332332    $CategoryName = '';
    333333
    334     // Prepare WHERE condition 
    335     if(array_key_exists('select', $_GET)) 
     334    // Prepare WHERE condition
     335    if(array_key_exists('select', $_GET))
    336336    {
    337337      $Where = '';
     
    339339      foreach($Parts as $Part)
    340340      {
    341         $Where .= 'OR (`Category`='.($Part * 1).')'; 
     341        $Where .= 'OR (`Category`='.($Part * 1).')';
    342342      }
    343343      $Where = substr($Where, 2);
     
    354354    // Update news from discussion forum
    355355    /*
    356     $ForumCategory = 4;   
     356    $ForumCategory = 4;
    357357    $Database->select_db('forum');
    358358    $DbResult = $Database->query('SELECT posts.post_time, posts_text.post_subject, posts_text.post_text, users.username, topics.topic_title FROM posts JOIN posts_text ON posts.post_id = posts_text.post_id JOIN users ON users.user_id = posts.poster_id JOIN topics ON topics.topic_id= posts.topic_id ORDER BY post_time DESC LIMIT '.$NewsCount);
     
    361361    while($Row = $DbResult->fetch_array())
    362362    {
    363       $Row['post_text'] = StrTr($Row['post_text'], "\x8A\x8D\x8E\x9A\x9D\x9E", "\xA9\xAB\xAE\xB9\xBB\xBE"); 
    364       $Row['post_text'] = str_replace("\n","<br>", $Row['post_text']); 
    365       $Row['post_subject'] = StrTr($Row['post_subject'], "\x8A\x8D\x8E\x9A\x9D\x9E", "\xA9\xAB\xAE\xB9\xBB\xBE"); 
    366       $Row['topic_title'] = StrTr($Row['topic_title'], "\x8A\x8D\x8E\x9A\x9D\x9E", "\xA9\xAB\xAE\xB9\xBB\xBE"); 
    367       $Index = $Index + 1;   
    368      
     363      $Row['post_text'] = StrTr($Row['post_text'], "\x8A\x8D\x8E\x9A\x9D\x9E", "\xA9\xAB\xAE\xB9\xBB\xBE");
     364      $Row['post_text'] = str_replace("\n","<br>", $Row['post_text']);
     365      $Row['post_subject'] = StrTr($Row['post_subject'], "\x8A\x8D\x8E\x9A\x9D\x9E", "\xA9\xAB\xAE\xB9\xBB\xBE");
     366      $Row['topic_title'] = StrTr($Row['topic_title'], "\x8A\x8D\x8E\x9A\x9D\x9E", "\xA9\xAB\xAE\xB9\xBB\xBE");
     367      $Index = $Index + 1;
     368
    369369      $Title = $Row['topic_title'].'-'.$Row['post_subject'];
    370370      $Content = $Row['post_text'];
     
    374374      //echo('category='.$ForumCategory.' AND title="'.addslashes($Title).'" AND content="'.addslashes($Content).'" AND author="'.addslashes($Author).'" AND date="'.$Date.'"');
    375375      $DbResult2 = $Database->select('news', '*', 'category='.$ForumCategory.' AND title="'.addslashes($Title).'" AND content="'.addslashes($Content).'" AND author="'.addslashes($Author).'" AND date="'.$Date.'"');
    376       if($DbResult2->num_rows == 0) //echo('.'); else echo('x'); 
     376      if($DbResult2->num_rows == 0) //echo('.'); else echo('x');
    377377        $Database->insert('news', array('category' => $ForumCategory, 'title' => $Title, 'content' => $Content, 'author' => $Author, 'date' => $Date));
    378         //echo($Date); 
     378        //echo($Date);
    379379      $Database->select_db('forum');
    380380    }
     
    388388      $EnclosuresText = '';
    389389      if($Row['Enclosure'] != '')
    390       { 
     390      {
    391391        $EnclosuresText .= '<br />Přílohy: ';
    392392        $Enclosures = explode(';', $Row['Enclosure']);
    393393        foreach($Enclosures as $Enclosure)
    394394        {
    395           if(file_exists($this->UploadedFilesFolder.$Enclosure)) 
    396             $EnclosuresText .= ' <a href="'.$this->System->Link('/aktuality/'.$UploadedFilesFolder.$Enclosure).'">'.$Enclosure.'</a>';
     395          if(file_exists($this->UploadedFilesFolder.$Enclosure))
     396            $EnclosuresText .= ' <a href="'.$this->System->Link('/aktuality/'.$this->UploadedFilesFolder.$Enclosure).'">'.$Enclosure.'</a>';
    397397        }
    398398      }
     
    409409    $RSS = new RSS();
    410410    $RSS->Title = $this->System->Config['Web']['Title'].' - Aktuality';
    411     $RSS->Link = 'http://'.$this->System->Config['Web']['Host'].'/'; 
    412     $RSS->Description = 'Aktuality '.$this->System->Config['Web']['Description']; 
    413     $RSS->WebmasterEmail = $this->System->Config['Web']['AdminEmail']; 
     411    $RSS->Link = 'http://'.$this->System->Config['Web']['Host'].'/';
     412    $RSS->Description = 'Aktuality '.$this->System->Config['Web']['Description'];
     413    $RSS->WebmasterEmail = $this->System->Config['Web']['AdminEmail'];
    414414    $RSS->Items = $Items;
    415     return($RSS->Generate());     
    416   } 
     415    return($RSS->Generate());
     416  }
    417417}
Note: See TracChangeset for help on using the changeset viewer.