MovieDatabase/gori.php

45 lines
1.4 KiB
PHP
Raw Normal View History

2016-05-22 14:58:34 +00:00
<?php
session_start();
$openShiftFolder = $_ENV['OPENSHIFT_DATA_DIR'];
if(isset($_POST['username']) && isset($_POST['password'])) {
$file = file_get_contents("users");
$file = str_replace("\n", "", $file);
$niz = explode(",", $file);
$username = $_POST['username'];
$password = $_POST['password'];
if($niz[0] == $username && $niz[1] == sha1($password)) {
$_SESSION['user']=$_POST['username'];
}
}
if(isset($_POST['vijest'])) {
2016-05-22 15:23:22 +00:00
$vijestiFile = file_get_contents($openShiftFolder."vijesti.csv");
2016-05-22 14:58:34 +00:00
$vijest = $_POST['vijest'];
if(strpos($vijest, ',') !== FALSE) {
$vijest = str_replace('"', '""', $vijest);
$vijest = '"'.$vijest.'"';
}
$slike = (isset($_POST['slika']))?$_POST['slika']:'';
if(isset($_POST['slika'])) {
if(strpos($slike, ',') !== FALSE) {
$slike = str_replace('"', '""', $slike);
$slike = '"'.$slike.'"';
}
}
print_r($slike);
$time = date(DATE_ISO8601, strtotime("now"));
$vijestiFile = $time.','.$slike.','.$vijest."\n".$vijestiFile;
$vijestiFile = strip_tags($vijestiFile);
2016-05-22 15:23:22 +00:00
file_put_contents($openShiftFolder."vijesti.csv", $vijestiFile);
2016-05-22 14:58:34 +00:00
}
if(isset($_POST['logout'])) {
unset($_SESSION['user']);
}
2016-05-22 15:23:22 +00:00
if(($_SERVER['REQUEST_URI'] == "/add.php" && !isset($_SESSION['user'])) || ($_SERVER['REQUEST_URI'] == "/register.php" && isset($_SESSION['user']))) {
2016-05-22 14:58:34 +00:00
header('Location: index.php');
}
?>