Changeset 4


Ignore:
Timestamp:
Nov 26, 2008, 9:56:46 PM (15 years ago)
Author:
maron
Message:
 
Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • config.sample.php

    r2 r4  
    1212  'Charset' => 'utf-8',
    1313  'BaseURL' => '',
     14  'webpass' => '',
    1415);
    1516
  • frontend.php

    r3 r4  
    1212        function show_mass() {
    1313                global $database;
    14                 $Query = $database->select('mass', '*');
     14                $Query = $database->select('mass', '*', 'time > now()');
    1515              while($DbRow = $Query->fetch_array())
    1616                {
     
    1818                }
    1919        }
     20
     21        function show_login() {
     22                echo '<form action="?admin" method="post">'.GIF_PASS.'<input name="pass"></form>';
     23        }
     24
     25        function show_upload_mass() {
     26                echo UPLOAD_MASS.'<form action="?admin" method="post">
     27                        '.GIF_DATE.' <input name="date"><br>
     28                        '.GIF_FILE.' <input name="file" type="file"><br>
     29                        <input value="Uložit" type="submit">
     30                        </form>';
     31        }
     32
     33        function save_file() {
     34        if (array_key_exists('date',$_POST) ) {
     35                if (is_uploaded_file($_FILES['file']['tmp_name'])) {
     36                        echo "Soubor ". $_FILES['file']['name'] ." Byl nahrán";
     37                        $tmp_name = $_FILES["file"]["tmp_name"];
     38                        move_uploaded_file($tmp_name, "mass/".$_POSS['date']);
     39                } else {
     40                        echo "Possible file upload attack: ";
     41                        echo "filename '". $_FILES['file']['tmp_name'] . "'.";
     42                }
     43        }
     44
     45        }
    2046?>
  • global.php

    r3 r4  
    11<?php
     2session_start();
     3
    24        include('config.php');
    35
  • index.php

    r3 r4  
    1717                echo ROZPIS;
    1818                show_mass();
     19                echo '<br><br>';
     20                $files = scandir('mass');
     21                for ($i=0;$i<count($files);++$i) {
     22                  $file = 'mass/'.$files[$i];
     23                  if (filetype($file) <> 'dir') echo '<a href="?img='.$file.'"><img width="200" src='.$file.' title="'.FILE_SAVED . date ("m d Y H:i:s.", filemtime($file)).'"></a>';
     24                }
    1925                show_article(3);
    2026
     
    2632        } else if (array_key_exists('admin',$_GET)) {
    2733                echo ADMIN;
    28                 show_article(5);
     34                if (array_key_exists('pass',$_POST) ) {
     35                  if ($_POST['pass'] == $Config['webpass'])  {
     36                        $_SESSION['pass'] = $_POST['pass'];
     37                  } else {
     38                        echo BAD_PASS;
     39                  }
     40                }
     41                if (isset($_SESSION['pass'])) {
     42                        if ($_SESSION['pass'] == $Config['webpass']) {
     43                                //administrátorská část
     44                                show_upload_mass();  //nahrání rozpisu
     45                                save_file();
     46                                show_article(5);
     47                        }
     48                } else {
     49                  show_login();
     50                }
     51
     52
     53        } else if (array_key_exists('img',$_GET)) {
     54                $file = $_GET['img'];
     55                echo '<img width="100%" src='.$file.' title="'."Soubor byl vložen " . date ("m d Y H:i:s.", filemtime($file)).'">';
    2956
    3057
  • language_cz.php

    r3 r4  
    2727define('ADMIN', '<h2>Administrace stránek</h2>');
    2828
     29
     30//message
     31define('BAD_PASS', 'Zadali jste špatné heslo');
     32define('FILE_SAVED', "Soubor byl vložen ");
     33define('GIF_PASS', ' Zadejte heslo: ');
     34define('GIF_FILE', ' Soubor ');
     35define('GIF_DATE', ' Datum od - do ');
     36define('UPLOAD_MASS', ' <b>Nahrání rozpisu mší</b> ');
    2937?>
Note: See TracChangeset for help on using the changeset viewer.