initial commit after server failure
This commit is contained in:
58
controllers/d.admin.php
Executable file
58
controllers/d.admin.php
Executable file
@@ -0,0 +1,58 @@
|
||||
<?
|
||||
|
||||
if(isset($controller->splitted_url[1]) && $user->role >= 800) {
|
||||
switch ($controller->splitted_url[1]) {
|
||||
case '': case 'admin':
|
||||
$head['title'] = "Administration";
|
||||
include ($config['views_folder']."d.admin.html");
|
||||
break;
|
||||
case 'git-pull':
|
||||
if ($user->role >= 1000) {
|
||||
$head['title'] = "Mise à jour";
|
||||
|
||||
$output = array();
|
||||
chdir($config['abs_root_folder']);
|
||||
exec("git pull origin master", $output);
|
||||
|
||||
include ($config['views_folder']."d.admin.git-pull.html");
|
||||
}
|
||||
else {
|
||||
$notfound = 1;
|
||||
}
|
||||
break;
|
||||
case 'logs':
|
||||
if ($user->role >= 800) {
|
||||
$head['title'] = "Logs";
|
||||
|
||||
$files_list = scandir($config['logs_folder']);
|
||||
|
||||
if (isset($controller->splitted_url[2]) && is_numeric($controller->splitted_url[2]) && intval($controller->splitted_url[2]) < count($files_list)-2) {
|
||||
$filenb = $controller->splitted_url[2];
|
||||
}
|
||||
else {
|
||||
$filenb = 0;
|
||||
}
|
||||
|
||||
chdir($config['logs_folder']);
|
||||
exec("tail -n 200 ".$files_list[$filenb+2]." | tac", $output);
|
||||
|
||||
include ($config['views_folder']."d.admin.logs.html");
|
||||
}
|
||||
else {
|
||||
$notfound = 1;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
$notfound = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if($user->role >= 800) {
|
||||
$head['title'] = "Administration";
|
||||
include ($config['views_folder']."d.admin.html");
|
||||
}
|
||||
else {
|
||||
$notfound = 1;
|
||||
}
|
||||
|
||||
?>
|
||||
204
controllers/d.blog.php
Executable file
204
controllers/d.blog.php
Executable file
@@ -0,0 +1,204 @@
|
||||
<?
|
||||
|
||||
require_once($config['models_folder']."d.blog.php");
|
||||
require_once($config['models_folder']."d.users.php");
|
||||
|
||||
$head['css'] = "d.index.css;d.blog.css";
|
||||
|
||||
$blogArticle = new BlogArticle();
|
||||
|
||||
// In case we are in the list of articles, we set url to switch with according parameters
|
||||
if (!isset($controller->splitted_url[1]) OR $controller->splitted_url[1]=="" OR is_numeric($controller->splitted_url[1])) {
|
||||
$head['title'] = "Blog";
|
||||
|
||||
// Get the correct page number
|
||||
if (!isset($controller->splitted_url[1]) OR $controller->splitted_url[1]=="") {
|
||||
$page = 0;
|
||||
} else {
|
||||
$page = $controller->splitted_url[1] - 1;
|
||||
}
|
||||
|
||||
$controller->splitted_url[1] = "list";
|
||||
$list = "html";
|
||||
$articles_per_pages = 5;
|
||||
}
|
||||
|
||||
switch ($controller->splitted_url[1]) {
|
||||
case "rss":
|
||||
$page = 0;
|
||||
$list = "rss";
|
||||
$articles_per_pages = 20;
|
||||
case "list":
|
||||
$blogArticles = new BlogArticles();
|
||||
|
||||
$blogArticles->number(($user->role >= 600));
|
||||
|
||||
// In case the wanted page is too big
|
||||
if($articles_per_pages * $page >= $blogArticles->number)
|
||||
$page = 0;
|
||||
|
||||
$blogArticles->listArticles($page*$articles_per_pages,$articles_per_pages,($user->role >= 600));
|
||||
|
||||
$i = 0;
|
||||
$blogArticles_list = array();
|
||||
foreach ($blogArticles->ids as $row) {
|
||||
$blogArticles_list[$i] = new BlogArticle();
|
||||
$blogArticles_list[$i]->id = $row;
|
||||
$blogArticles_list[$i]->populate();
|
||||
$blogArticles_list[$i]->md2txt();
|
||||
$tempUser = new User();
|
||||
$tempUser->id = $blogArticles_list[$i]->author;
|
||||
$tempUser->populate();
|
||||
$blogArticles_list[$i]->author_name = $tempUser->name;
|
||||
unset($tempUser);
|
||||
$i++;
|
||||
}
|
||||
|
||||
$first = $page*$articles_per_pages+1;
|
||||
$last = (($page+1)*$articles_per_pages > $blogArticles->number ? $blogArticles->number : ($page+1)*$articles_per_pages);
|
||||
|
||||
if ($list == "rss") {
|
||||
include ($config['views_folder']."d.blog.list.rss");
|
||||
} else {
|
||||
include ($config['views_folder']."d.blog.list.html");
|
||||
}
|
||||
break;
|
||||
case "new":
|
||||
if($user->role >= 800) {
|
||||
if(isset($_POST['submit'])) {
|
||||
$blogArticle->content = $_POST['content'];
|
||||
$blogArticle->locale = $_POST['locale'];
|
||||
$blogArticle->title = $_POST['title'];
|
||||
$blogArticle->comments = isset($_POST['comments'])?'t':'f';
|
||||
$blogArticle->author = $user->id;
|
||||
if(!$blogArticle->checkUrl($_POST['url'],1)) {
|
||||
$blogArticle->insert();
|
||||
header('Location: '.$config['rel_root_folder']."blog/".$blogArticle->url);
|
||||
}
|
||||
else {
|
||||
$head['title'] = $blogArticle->title;
|
||||
$error = "url";
|
||||
$new = 1;
|
||||
include ($config['views_folder']."d.blog.edit.html");
|
||||
}
|
||||
}
|
||||
else {
|
||||
$head['title'] = "Nouvel article";
|
||||
$new = 1;
|
||||
include ($config['views_folder']."d.blog.edit.html");
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
// If the page exists
|
||||
if ($blogArticle->checkUrl($controller->splitted_url[1],$user->role >= 600)) {
|
||||
if (isset($controller->splitted_url[2]) && $controller->splitted_url[2] == "delete" && $user->role >= 800) {
|
||||
$blogArticle->delete();
|
||||
header('Location: '.$config['rel_root_folder']."blog/".$blogArticle->url);
|
||||
}
|
||||
else if (isset($controller->splitted_url[2]) && $controller->splitted_url[2] == "edit" && $user->role >= 800) {
|
||||
if(isset($_POST['submit'])) {
|
||||
$blogArticle->content = $_POST['content'];
|
||||
$blogArticle->locale = $_POST['locale'];
|
||||
$blogArticle->title = $_POST['title'];
|
||||
$blogArticle->comments = isset($_POST['comments'])?'t':'f';
|
||||
$blogArticle->author = $user->id;
|
||||
$blogArticle->update();
|
||||
header('Location: '.$config['rel_root_folder']."blog/".$blogArticle->url);
|
||||
}
|
||||
else {
|
||||
$blogArticle->populate();
|
||||
$head['title'] = $blogArticle->title;
|
||||
include ($config['views_folder']."d.blog.edit.html");
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Manage history of an article
|
||||
if($user->role >= 600) {
|
||||
$blogArticles_history = new BlogArticles();
|
||||
$blogArticles_history->getHistory($controller->splitted_url[1]);
|
||||
|
||||
$i = 0;
|
||||
foreach ($blogArticles_history->ids as $row) {
|
||||
$blogArticles_history_list[$i] = new BlogArticle();
|
||||
$blogArticles_history_list[$i]->id = $row;
|
||||
$blogArticles_history_list[$i]->populate();
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
if (isset($controller->splitted_url[2]) && is_numeric($controller->splitted_url[2]))
|
||||
$blogArticle->checkUrl($controller->splitted_url[1],$user->role>=600,$controller->splitted_url[2]);
|
||||
|
||||
// Manage comment creation
|
||||
if (isset($controller->splitted_url[2]) && $controller->splitted_url[2]=="new_comment") {
|
||||
if (isset($_POST['submit']) && $user->role > 0) {
|
||||
$blogComment = new BlogComment();
|
||||
$blogComment->locale = $user->locale;
|
||||
$blogComment->author = $user->id;
|
||||
$blogComment->article = $blogArticle->id;
|
||||
$blogComment->content = $_POST['comment'];
|
||||
$blogComment->insert();
|
||||
}
|
||||
}
|
||||
|
||||
// Manage comment deletion
|
||||
if (isset($controller->splitted_url[2]) && $controller->splitted_url[2]=="delete_comment") {
|
||||
if (isset($controller->splitted_url[3]) && is_numeric($controller->splitted_url[3])) {
|
||||
$blogComment = new BlogComment();
|
||||
$blogComment->id = $controller->splitted_url[3];
|
||||
$blogComment->populate();
|
||||
if ($user->role >= 800 || $user->id == $blogComment->author)
|
||||
$blogComment->delete();
|
||||
}
|
||||
}
|
||||
|
||||
// Manage comment undeletion
|
||||
if (isset($controller->splitted_url[2]) && $controller->splitted_url[2]=="undelete_comment") {
|
||||
if (isset($controller->splitted_url[3]) && is_numeric($controller->splitted_url[3])) {
|
||||
$blogComment = new BlogComment();
|
||||
$blogComment->id = $controller->splitted_url[3];
|
||||
$blogComment->populate();
|
||||
if ($user->role >= 800 || $user->id == $blogComment->author)
|
||||
$blogComment->undelete();
|
||||
}
|
||||
}
|
||||
|
||||
$blogArticle->populate();
|
||||
$blogArticle->md2html();
|
||||
|
||||
// Manage comments
|
||||
if ($blogArticle->comments == "t") {
|
||||
$blogArticles_comments = new BlogComments();
|
||||
$blogArticles_comments->listComments($blogArticle->id, ($user->role>400));
|
||||
|
||||
$i = 0;
|
||||
foreach ($blogArticles_comments->ids as $row) {
|
||||
$blogArticles_comments_list[$i] = new BlogComment();
|
||||
$blogArticles_comments_list[$i]->id = $row;
|
||||
$blogArticles_comments_list[$i]->populate();
|
||||
$blogArticles_comments_list[$i]->md2html();
|
||||
$blogArticles_comments_list[$i]->author_obj = new User();
|
||||
$blogArticles_comments_list[$i]->author_obj->id = $blogArticles_comments_list[$i]->author;
|
||||
$blogArticles_comments_list[$i]->author_obj->populate();
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$tempUser = new User();
|
||||
$tempUser->id = $blogArticle->author;
|
||||
$tempUser->populate();
|
||||
$blogArticle->author_name = $tempUser->name;
|
||||
unset($tempUser);
|
||||
|
||||
$head['title'] = $blogArticle->title;
|
||||
include ($config['views_folder']."d.blog.view.html");
|
||||
}
|
||||
}
|
||||
else {
|
||||
$notfound = 1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
?>
|
||||
77
controllers/d.contact.php
Executable file
77
controllers/d.contact.php
Executable file
@@ -0,0 +1,77 @@
|
||||
<?
|
||||
|
||||
function post($index) {
|
||||
return isset($_POST[$index]) ? $_POST[$index] : '';
|
||||
}
|
||||
|
||||
$error = "no";
|
||||
|
||||
if(isset($_POST['submit'])) {
|
||||
$message = "Message reçu depuis Kabano par ".post('name').".<br>\r\n";
|
||||
$message .= "<hr>\r\n";
|
||||
$message .= "<pre style='padding: 10px; background: #ccc;'>".strip_tags(post('message'))."</pre><br>\r\n";
|
||||
|
||||
$headers = 'From: '. post('mail') . "\r\n" .
|
||||
'Reply-To: '. post('mail') . "\r\n" .
|
||||
'X-Mailer: PHP/' . phpversion() . "\r\n" .
|
||||
'MIME-Version: 1.0' . "\r\n" .
|
||||
'Content-type: text/html; charset=UTF-8' . "\r\n";
|
||||
|
||||
if(post('ns') == '' && $_POST['captcha'] == -2) {
|
||||
$send = true;
|
||||
if(post('name') == '') {
|
||||
$error = "name";
|
||||
$send = false;
|
||||
}
|
||||
if(post('subject') == '') {
|
||||
$error = "subject";
|
||||
$send = false;
|
||||
}
|
||||
if(post('mail') == '') {
|
||||
$error = "mail";
|
||||
$send = false;
|
||||
}
|
||||
if(post('message') == '') {
|
||||
$error = "message";
|
||||
$send = false;
|
||||
}
|
||||
if($send) {
|
||||
if(mail($config['admin_mail'], "Kabano :: ".post('subject'), $message, $headers)) {
|
||||
$error = "none";
|
||||
} else {
|
||||
$error = "unknown";
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
$error = "spam";
|
||||
}
|
||||
}
|
||||
|
||||
if(post('name') != '')
|
||||
$contact['name'] = post('name');
|
||||
else if($user->role > 0)
|
||||
$contact['name'] = $user->name;
|
||||
else
|
||||
$contact['name'] = '';
|
||||
|
||||
if(post('mail') != '')
|
||||
$contact['mail'] = post('mail');
|
||||
else if($user->role > 0)
|
||||
$contact['mail'] = $user->mail;
|
||||
else
|
||||
$contact['mail'] = '';
|
||||
|
||||
$contact['subject'] = post('subject');
|
||||
$contact['message'] = post('message');
|
||||
$contact['ns'] = post('ns');
|
||||
|
||||
|
||||
$head['css'] = "d.index.css;d.user.css";
|
||||
$head['js'] = "d.captcha.js";
|
||||
$head['title'] = "Contact";
|
||||
|
||||
include ($config['views_folder']."d.contact.html");
|
||||
|
||||
|
||||
?>
|
||||
20
controllers/d.map.php
Executable file
20
controllers/d.map.php
Executable file
@@ -0,0 +1,20 @@
|
||||
<?
|
||||
|
||||
$head['css'] = "d.index.css";
|
||||
|
||||
if(isset($controller->splitted_url[1]) && $controller->splitted_url[1] != '') {
|
||||
switch ($controller->splitted_url[1]) {
|
||||
default:
|
||||
$notfound = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$head['title'] = "Carte";
|
||||
$head['third'] = "leaflet/leaflet.js;leaflet-fullscreen/Leaflet.fullscreen.min.js;leaflet-easybutton/easy-button.js";
|
||||
$head['css'] .= ";d.map.css;../third/leaflet/leaflet.css;../third/leaflet-fullscreen/leaflet.fullscreen.css;../third/leaflet-easybutton/easy-button.css";
|
||||
$head['js'] = "d.map.js";
|
||||
include ($config['views_folder']."d.map.html");
|
||||
}
|
||||
|
||||
?>
|
||||
237
controllers/d.users.php
Executable file
237
controllers/d.users.php
Executable file
@@ -0,0 +1,237 @@
|
||||
<?
|
||||
|
||||
require_once($config['models_folder']."d.users.php");
|
||||
|
||||
$head['css'] = "d.index.css;d.user.css";
|
||||
|
||||
if(isset($controller->splitted_url[1])) {
|
||||
switch ($controller->splitted_url[1]) {
|
||||
case 'login':
|
||||
$head['title'] = "Connexion";
|
||||
if ($user->role == 0) {
|
||||
if (isset($_POST['submit'])) {
|
||||
// PROCESS DATA FROM FORM
|
||||
$user = new User();
|
||||
$user->login($_POST['login'], $_POST['password']);
|
||||
|
||||
if($user->id != 0) {
|
||||
// SUCESSFULL LOGIN
|
||||
$_SESSION['userid'] = $user->id;
|
||||
header('Location: '.$_SERVER['HTTP_REFERER']);
|
||||
}
|
||||
else {
|
||||
header('Location: '.$config['rel_root_folder'].'user/login?error=1');
|
||||
}
|
||||
}
|
||||
include ($config['views_folder']."d.user.login.html");
|
||||
} else {
|
||||
header('Location: '.$config['rel_root_folder']);
|
||||
}
|
||||
break;
|
||||
case 'logout':
|
||||
session_destroy();
|
||||
header('Location: '.$_SERVER['HTTP_REFERER']);
|
||||
break;
|
||||
case 'signin':
|
||||
$head['js'] = "d.captcha.js";
|
||||
$head['title'] = "Création de compte";
|
||||
if ($user->role == 0) {
|
||||
if (isset($_POST['submit'])) {
|
||||
// PROCESS DATA FROM FORM
|
||||
$user = new User();
|
||||
$user->password = sha1($_POST['password']);
|
||||
$user->name = $_POST['login'];
|
||||
$user->mail = strtolower($_POST['mail']);
|
||||
$user->role = 400;
|
||||
$user->avatar = 'f';
|
||||
$user->locale = "fr";
|
||||
|
||||
if($_POST['captcha'] == -2) {
|
||||
if($user->availableName()) {
|
||||
if($user->availableMail()) {
|
||||
if($user->password != "" AND $user->name != "" AND $user->mail != "") {
|
||||
$user->create();
|
||||
header('Location: '.$config['rel_root_folder'].'user/login?status=created');
|
||||
}
|
||||
else {
|
||||
header('Location: '.$config['rel_root_folder'].'user/signin?error=empty');
|
||||
}
|
||||
}
|
||||
else {
|
||||
header('Location: '.$config['rel_root_folder'].'user/signin?error=mail');
|
||||
}
|
||||
}
|
||||
else {
|
||||
header('Location: '.$config['rel_root_folder'].'user/signin?error=name');
|
||||
}
|
||||
}
|
||||
else {
|
||||
header('Location: '.$config['rel_root_folder'].'user/signin?error=captcha');
|
||||
}
|
||||
}
|
||||
include ($config['views_folder']."d.user.signin.html");
|
||||
} else {
|
||||
header('Location: '.$config['rel_root_folder']);
|
||||
}
|
||||
break;
|
||||
case 'password_lost':
|
||||
$head['title'] = "Récupération de mot de passe";
|
||||
if ($user->role == 0) {
|
||||
if (isset($_POST['submit'])) {
|
||||
// PROCESS DATA FROM FORM
|
||||
$user = new User();
|
||||
$user->mail = strtolower($_POST['mail']);
|
||||
|
||||
if($user->availableMail()) {
|
||||
header('Location: '.$config['rel_root_folder'].'user/password_lost?error=1');
|
||||
}
|
||||
else {
|
||||
$user->sendPassword();
|
||||
header('Location: '.$config['rel_root_folder'].'user/login?status=password_sent');
|
||||
}
|
||||
}
|
||||
include ($config['views_folder']."d.user.password_lost.html");
|
||||
} else {
|
||||
header('Location: '.$config['rel_root_folder']);
|
||||
}
|
||||
break;
|
||||
case 'p':
|
||||
if ($user->role >= 200) {
|
||||
$userProfile = new User();
|
||||
if (!isset($controller->splitted_url[2]) OR $controller->splitted_url[2]=="") {
|
||||
// WE DISPLAY THE CONNECTED USER PROFILE
|
||||
$userProfile = $user;
|
||||
} else {
|
||||
// WE DISPLAY THE SELECTED USER PROFILE FROM ID
|
||||
$userProfile->checkID(intval($controller->splitted_url[2]));
|
||||
}
|
||||
$head['title'] = "Profil inexistant";
|
||||
if($userProfile->id != 0) {
|
||||
$userProfile->populate();
|
||||
$head['title'] = "Profil de ".$userProfile->name;
|
||||
}
|
||||
|
||||
// If we are editing the profile
|
||||
if(isset($controller->splitted_url[3]) && $controller->splitted_url[3]=="edit" && ($user->role >= 800 || $user->id == $userProfile->id)) {
|
||||
$head['js'] = "d.avatar.js";
|
||||
if (isset($_POST['submit'])) {
|
||||
$receivedUser = new User();
|
||||
$receivedUser->name = $_POST['name'];
|
||||
if($receivedUser->name != $userProfile->name && $receivedUser->availableName())
|
||||
$userProfile->name = $receivedUser->name;
|
||||
else if($receivedUser->name != $userProfile->name)
|
||||
$nameError=1;
|
||||
$receivedUser->mail = strtolower($_POST['mail']);
|
||||
if($receivedUser->mail != $userProfile->mail && $receivedUser->availableMail())
|
||||
$userProfile->mail = $receivedUser->mail;
|
||||
else if ($receivedUser->mail != $userProfile->mail)
|
||||
$mailError=1;
|
||||
if($_POST['password']!='')
|
||||
$userProfile->password=sha1($_POST['password']);
|
||||
$userProfile->locale=$_POST['locale'];
|
||||
if($user->role>=1000)
|
||||
$userProfile->role = $_POST['role'];
|
||||
$userProfile->website=$_POST['website'];
|
||||
|
||||
// Is the file correctly sent to the server ?
|
||||
$pathToFile = $config['medias_folder']."avatars/".$userProfile->id;
|
||||
if(isset($_FILES['avatarfile']['tmp_name']) && $_FILES['avatarfile']['tmp_name']!='' && $_FILES['avatarfile']['size'] < 16000000 && isset($_POST['avatar'])) {
|
||||
|
||||
require_once($config['includes_folder']."images.php");
|
||||
|
||||
if(file_exists($pathToFile)) unlink($pathToFile);
|
||||
move_uploaded_file($_FILES['avatarfile']['tmp_name'], $pathToFile);
|
||||
|
||||
if(file_exists($pathToFile."_p.jpg")) unlink($pathToFile."_p.jpg");
|
||||
generate_image_thumbnail($pathToFile, $pathToFile."_p.jpg", 220, 240);
|
||||
if(file_exists($pathToFile."_s.jpg")) unlink($pathToFile."_s.jpg");
|
||||
generate_image_thumbnail($pathToFile, $pathToFile."_s.jpg", 28, 28);
|
||||
|
||||
$userProfile->avatar = 't';
|
||||
}
|
||||
elseif (!isset($_POST['avatar'])) {
|
||||
if(file_exists($pathToFile)) unlink($pathToFile);
|
||||
if(file_exists($pathToFile."_p.jpg")) unlink($pathToFile."_p.jpg");
|
||||
if(file_exists($pathToFile."_s.jpg")) unlink($pathToFile."_s.jpg");
|
||||
$userProfile->avatar = 'f';
|
||||
}
|
||||
|
||||
$userProfile->update();
|
||||
|
||||
$updated = 1;
|
||||
}
|
||||
include ($config['views_folder']."d.user.profile.edit.html");
|
||||
|
||||
}
|
||||
// If we are displaying the profile
|
||||
else {
|
||||
if (isset($_POST['submit']) && $user->role >= 400) {
|
||||
// PROCESS DATA FROM CONTACT FORM
|
||||
$message = $_POST['message'];
|
||||
|
||||
$userProfile->sendMail($message, $user);
|
||||
$mailsent = 1;
|
||||
}
|
||||
include ($config['views_folder']."d.user.profile.html");
|
||||
}
|
||||
}
|
||||
else {
|
||||
header('Location: '.$config['rel_root_folder']);
|
||||
}
|
||||
break;
|
||||
case 'member_list':
|
||||
if ($user->role >= 200) {
|
||||
$rows_per_pages = 50;
|
||||
// Get the correct page number
|
||||
if (!isset($controller->splitted_url[2]) OR $controller->splitted_url[2]=="" OR $controller->splitted_url[2]=="0" OR !is_numeric($controller->splitted_url[2])) {
|
||||
$page = 0;
|
||||
} else {
|
||||
$page = $controller->splitted_url[2] - 1;
|
||||
}
|
||||
$head['title'] = "Liste des membres";
|
||||
|
||||
$users = new Users();
|
||||
$users->number();
|
||||
|
||||
// In case the wanted page is too big
|
||||
if($rows_per_pages * $page >= $users->number)
|
||||
$page = 0;
|
||||
|
||||
if(isset($_GET['order']))
|
||||
$order = $_GET['order'];
|
||||
else
|
||||
$order = 'ASC';
|
||||
if(isset($_GET['orderby']))
|
||||
$orderby = $_GET['orderby'];
|
||||
else
|
||||
$orderby = 'id';
|
||||
|
||||
$users->list_users($page*$rows_per_pages,$rows_per_pages,$orderby,$order);
|
||||
|
||||
$i = 0;
|
||||
foreach ($users->ids as $row) {
|
||||
$user_list[$i] = new User();
|
||||
$user_list[$i]->id = $row;
|
||||
$user_list[$i]->populate();
|
||||
$i++;
|
||||
}
|
||||
|
||||
$first = $page*$rows_per_pages+1;
|
||||
$last = (($page+1)*$rows_per_pages > $users->number ? $users->number : ($page+1)*$rows_per_pages);
|
||||
|
||||
include ($config['views_folder']."d.user.member_list.html");
|
||||
}
|
||||
else {
|
||||
header('Location: '.$config['rel_root_folder']);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
$notfound = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$notfound = 1;
|
||||
}
|
||||
|
||||
?>
|
||||
77
controllers/d.wiki.php
Executable file
77
controllers/d.wiki.php
Executable file
@@ -0,0 +1,77 @@
|
||||
<?
|
||||
|
||||
require_once($config['models_folder']."d.wiki.php");
|
||||
|
||||
$head['css'] = "d.index.css;d.wiki.css";
|
||||
|
||||
$wikiPage = new WikiPage();
|
||||
// Page doesn't exists
|
||||
if(isset($controller->splitted_url[1]) && !$wikiPage->checkUrl($controller->splitted_url[1],$user->role >= 600) && $controller->splitted_url[1]!="") {
|
||||
if($user->role >= 800) {
|
||||
// Create new page
|
||||
if(isset($_POST['submit'])) {
|
||||
$wikiPage->content = $_POST['content'];
|
||||
$wikiPage->locale = $_POST['locale'];
|
||||
$wikiPage->title = $_POST['title'];
|
||||
$wikiPage->insert();
|
||||
|
||||
header('Location: '.$config['rel_root_folder']."wiki/".$wikiPage->url);
|
||||
}
|
||||
else {
|
||||
$head['title'] = "Nouvelle page";
|
||||
include ($config['views_folder']."d.wiki.edit.html");
|
||||
}
|
||||
}
|
||||
else {
|
||||
$notfound = 1;
|
||||
}
|
||||
}
|
||||
// Page exists
|
||||
else if(isset($controller->splitted_url[1]) && $wikiPage->checkUrl($controller->splitted_url[1],$user->role >= 600)) {
|
||||
if (isset($controller->splitted_url[2]) && $controller->splitted_url[2]=="edit" && $user->role >= 800) {
|
||||
// Edit page
|
||||
if(isset($_POST['submit'])) {
|
||||
$wikiPage->content = $_POST['content'];
|
||||
$wikiPage->locale = $_POST['locale'];
|
||||
$wikiPage->title = $_POST['title'];
|
||||
$wikiPage->update();
|
||||
|
||||
header('Location: '.$config['rel_root_folder']."wiki/".$wikiPage->url);
|
||||
}
|
||||
else {
|
||||
$wikiPage->populate();
|
||||
$head['title'] = $wikiPage->title;
|
||||
include ($config['views_folder']."d.wiki.edit.html");
|
||||
}
|
||||
} else if (isset($controller->splitted_url[2]) && $controller->splitted_url[2]=="delete" && $user->role >= 800) {
|
||||
// Delete page
|
||||
$wikiPage->delete();
|
||||
header('Location: '.$config['rel_root_folder']."wiki/".$wikiPage->url);
|
||||
} else {
|
||||
// Display page
|
||||
if($user->role >= 600) {
|
||||
$wikiHistory = new WikiPages();
|
||||
$wikiHistory->getHistory($controller->splitted_url[1]);
|
||||
|
||||
$i = 0;
|
||||
foreach ($wikiHistory->ids as $row) {
|
||||
$wikiHistory_list[$i] = new WikiPage();
|
||||
$wikiHistory_list[$i]->id = $row;
|
||||
$wikiHistory_list[$i]->populate();
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
if (isset($controller->splitted_url[2]) && is_numeric($controller->splitted_url[2]))
|
||||
$wikiPage->checkUrl($controller->splitted_url[1],$user->role>=600, $controller->splitted_url[2]);
|
||||
|
||||
$wikiPage->populate();
|
||||
$wikiPage->md2html();
|
||||
$head['title'] = $wikiPage->title;
|
||||
include ($config['views_folder']."d.wiki.view.html");
|
||||
}
|
||||
}
|
||||
else {
|
||||
$notfound = 1;
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user