This repository has been archived on 2024-06-20. You can view files and clone it, but cannot push or open issues or pull requests.
peryoudow/index.php

97 lines
2.9 KiB
PHP
Raw Permalink Normal View History

2020-01-06 14:14:28 +01:00
<?php
session_start();
/**
* /mnt/Stock/http/img.local/photos/;/mnt/Stock/http/img.local/photos/Vidéos/test/
*/
/**
* Améliore la sortie print.
*
* @author Tatane http://www.tatane.info/index.php/print_rn
* @author http://www.blog.cactuscrew.com/77-print_rn.html
*
* @param $data (array) tableau à examiner
* @param $name (string) nom a affiché
*
* @return false affiche les clef valeur du tableau $data
*/
function n_print($data, $name = '')
{
$aBackTrace = debug_backtrace();
echo '<h2>', $name, '</h2>';
echo '<fieldset style="border: 1px solid orange; padding: 5px;color: #333; background-color: #fff;">';
echo '<legend style="border:1px solid orange;padding: 1px;background-color:#eee;color:orange;">', basename($aBackTrace[0]['file']), ' ligne => ', $aBackTrace[0]['line'], '</legend>';
echo '<pre>', htmlentities(print_r($data, 1)), '</pre>';
echo '</fieldset><br />';
}
require 'vendor/autoload.php';
require 'apps/config.php';
$templates = new League\Plates\Engine('template');
if (file_exists('config/config.php')) {
$config = MyConfig::read('config');
} else {
$page = 'install';
}
require 'apps/input.php';
if (!empty($page) && $page === 'about') {
echo $templates->render($page);
}
if (!empty($page) && $page === 'install' && !file_exists('config/config.php')) {
if (!isset($createLogin) && empty($createLogin)) {
echo $templates->render($page, ['missing' => 'login']);
exit();
}
if (!isset($createPassword) && empty($createPassword)) {
echo $templates->render($page, ['missing' => 'password']);
exit();
}
if (!isset($createPath) && empty($createPath)) {
echo $templates->render($page, ['missing' => 'path']);
exit();
}
$conf = array('login' => $createLogin, 'password' => $createPassword, 'listOfDestPath' => $createPath);
$config = MyConfig::write('config', $conf);
$page = 'login';
}
if (!empty($page) && $page === 'login') {
$loginError = false;
if (!empty($_POST['login'])) {
$login = filter_input(INPUT_POST, 'login', FILTER_SANITIZE_SPECIAL_CHARS);
if ($login !== $config['login']) {
$loginError = true;
}
} else {
$loginError = true;
}
if (!empty($_POST['password'])) {
if (!password_verify($_POST['password'], $config['password'])) {
$loginError = true;
}
} else {
$loginError = true;
}
if ($loginError) {
echo $templates->render('login');
} else {
echo $templates->render('addVideo', array('listOfDestPath' => $config['listOfDestPath']));
}
$_SESSION['login'] = 'logged';
}
if (empty($page)) {
if (isset($_SESSION['login']) && $_SESSION['login'] === 'logged') {
echo $templates->render('addVideo', array('listOfDestPath' => $config['listOfDestPath']));
} else {
echo $templates->render('login');
}
}
//echo $templates->render($page);