initial commit after server failure

This commit is contained in:
Léo
2017-12-20 21:49:11 +01:00
commit a14390f8f5
109 changed files with 27898 additions and 0 deletions

65
includes/config.example.php Executable file
View File

@@ -0,0 +1,65 @@
<?
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
/*****
** Management of folder names
*****/
// It is the include folder name
$config['include_folder']=basename(__DIR__);
// This is the absolute folder to the root of the website
$config['abs_root_folder']=str_replace($config['include_folder'],"",__DIR__);
// This is the relative folder to the root of the website from the DocumentRoot (can also be called subfolder)
$config['rel_root_folder']=str_replace($_SERVER['DOCUMENT_ROOT'],"",$config['abs_root_folder']);
if($config['rel_root_folder']=="") $config['rel_root_folder']="/";
// Here all the absolute paths to specific folders
$config['views_folder'] = $config['abs_root_folder']."views/";
$config['controllers_folder'] = $config['abs_root_folder']."controllers/";
$config['models_folder'] = $config['abs_root_folder']."models/";
$config['medias_folder'] = $config['abs_root_folder']."medias/";
$config['includes_folder'] = $config['abs_root_folder']."includes/";
$config['third_folder'] = $config['abs_root_folder']."third/";
$config['logs_folder'] = $config['abs_root_folder']."logs/";
// Here all the relative url to specific folders
$config['views_url'] = $config['rel_root_folder']."views/";
/*****
** SQL Database configuration
*****/
$config['SQL_host'] = "localhost";
$config['SQL_user'] = "kabano";
$config['SQL_pass'] = "PASSWORD";
$config['SQL_db'] = "postgres";
/*****
** Mail configuration
*****/
$config['admin_mail'] = "leo@lstronic.com";
$config['bot_mail'] = "robot@kabano.com";
/*****
** Locales configuration
*****/
$config['locales'] = array(
"fr" => array("fr","fr_FR.UTF8","french","fr_FR","fr_FR.UTF-8", "Français")
);
$config['roles'] = array(
1000 => array(1000,"Administrateur", "red"),
800 => array(800,"Modérateur", "orangered"),
600 => array(600,"Membre premium", "orange"),
400 => array(400,"Utilisateur", "green"),
200 => array(200,"Membre archivé", "#aaa"),
0 => array(0,"Visiteur", "black")
);
?>

42
includes/images.php Executable file
View File

@@ -0,0 +1,42 @@
<?
function generate_image_thumbnail($source_image_path, $thumbnail_image_path, $width, $height)
{
list($source_image_width, $source_image_height, $source_image_type) = getimagesize($source_image_path);
switch ($source_image_type) {
case IMAGETYPE_GIF:
$source_gd_image = imagecreatefromgif($source_image_path);
break;
case IMAGETYPE_JPEG:
$source_gd_image = imagecreatefromjpeg($source_image_path);
break;
case IMAGETYPE_PNG:
$source_gd_image = imagecreatefrompng($source_image_path);
break;
}
if ($source_gd_image === false) {
return false;
}
$src_x = 0;
$src_y = 0;
$thumbnail_image_height = $height;
$thumbnail_image_width = $width;
// If the limitation is on the height (cuts on the width)
if($height*$source_image_width/$source_image_height > $width) {
$src_x = (int)(($source_image_width - $source_image_height * $width / $height) / 2);
$source_image_width = $source_image_height * $width / $height;
} else {
$src_y = (int)(($source_image_height - $source_image_width * $height / $width) / 2);
$source_image_height = $source_image_width * $height / $width;
}
$thumbnail_gd_image = imagecreatetruecolor($thumbnail_image_width, $thumbnail_image_height);
imagecopyresampled($thumbnail_gd_image, $source_gd_image, 0, 0, $src_x, $src_y, $thumbnail_image_width, $thumbnail_image_height, $source_image_width, $source_image_height);
imagejpeg($thumbnail_gd_image, $thumbnail_image_path, 90);
imagedestroy($source_gd_image);
imagedestroy($thumbnail_gd_image);
return true;
}
?>

71
includes/routes.php Executable file
View File

@@ -0,0 +1,71 @@
<?
/*****
** This file contains the routing from any request to the correct view and controller
*****/
$controller = new stdClass;
$view = new stdClass;
$controller->full_url = $_SERVER['REQUEST_URI'];
$controller->url_no_param = explode('?',$controller->full_url);
// URL without ?parameters and /subfolder/
$controller->base_url=str_replace('RACINE'.$config['rel_root_folder'],'','RACINE'.$controller->url_no_param[0]);
$controller->splitted_url = explode ('/',$controller->base_url);
// By default we use the desktop
$view->prefix = "d.";
$controller->prefix = "d.";
$notfound = 0;
$session = 1;
// Routing to the correct page from the correct link
switch ($controller->splitted_url[0])
{
case "index": case "" :
$controller->name="";
$view->name="index";
break;
case "user" :
$controller->name="users";
$view->name="";
break;
case "contact" :
case "wiki" :
case "blog" :
case "map" :
case "admin" :
$controller->name=$controller->splitted_url[0];
$view->name="";
break;
default :
$controller->name="";
$view->name="";
$notfound = 1;
break;
}
if($session==1) {
require_once('session.php');
}
if($controller->name != "") {
include ($config['controllers_folder'].$controller->prefix.$controller->name.".php");
}
if($view->name != "") {
include ($config['views_folder'].$view->prefix.$view->name.".html");
}
if($notfound) {
require_once('session.php');
require_once($config['models_folder']."d.wiki.php");
$wikiPage = new WikiPage();
$wikiPage->checkUrl('404');
$wikiPage->populate();
$wikiPage->md2html();
$head['css'] = "d.index.css;d.wiki.css";
$head['title'] = $wikiPage->title;
include ($config['views_folder']."d.wiki.view.html");
}
?>

23
includes/session.php Executable file
View File

@@ -0,0 +1,23 @@
<?
require_once($config['models_folder']."d.users.php");
ini_set("session.cookie_lifetime",60*60*24*30);
session_start();
$user = new User();
$user->role == 0; // All users are visitors
if(isset($_SESSION['userid'])) {
$user->checkID($_SESSION['userid']);
if ($user->id != 0) {
$user->updateLoginDate();
$user->populate();
setlocale(LC_ALL, $config['locales'][$user->locale][4]);
}
else {
session_destroy();
}
}
?>