Archived
1
0

Changes of the last few months including restructuring system from using only ranks to permissions

This commit is contained in:
Marcel 2018-12-26 18:19:28 +01:00
parent 72f3434803
commit 1a1ac17ecf
38 changed files with 845 additions and 361 deletions

View File

@ -102,7 +102,7 @@ class Blog extends MY_Controller {
} }
function add() { function add() {
if(isset($_SESSION['user']) && $_SESSION['user']['rank'] >= 6) { if(isset($_SESSION['user']) && $this->hasPermission('blog.create')) {
redirect('/admin/blog/add'); redirect('/admin/blog/add');
} else { } else {
redirect('/blog'); redirect('/blog');

View File

@ -1,17 +1,19 @@
<?php <?php
defined('BASEPATH') OR exit('No direct script access allowed'); defined('BASEPATH') OR exit('No direct script access allowed');
class Faq extends MY_Controller { class Faq extends MY_Controller
{
public function __construct() { public function __construct()
parent::__construct('faq'); {
parent::__construct('faq');
}
public function index()
{
$this->load->view('header', ['active' => 'faq', 'title' => 'FAQ - Frequently Asked Questions']);
$this->load->view('faq');
$this->load->view('footer');
}
} }
public function index()
{
$this->load->view('header', ['active' => 'faq', 'title' => 'FAQ - Frequently Asked Questions']);
$this->load->view('faq');
$this->load->view('footer');
}
}

View File

@ -25,7 +25,12 @@ class File extends MY_Controller
header("Content-Disposition: attachment; filename=" . $file['name'] . '.' . explode('/', $file['type'])[1]); header("Content-Disposition: attachment; filename=" . $file['name'] . '.' . explode('/', $file['type'])[1]);
} }
$imagePath = 'files/' . ($file['isUserData'] ? 'userContent/' : '') . (isset($_GET['w']) || isset($_GET['h']) ? 'thumbs/' : '') . $file['name'] . (isset($_GET['w']) ? '_w' . $_GET['w'] : '') . (isset($_GET['h']) ? '_h' . $_GET['h'] : '') . '.' . explode('.', $file['path'])[1]; $imagePath = 'files' . DIRECTORY_SEPARATOR .
($file['isUserData'] ? 'userContent' . DIRECTORY_SEPARATOR : '') .
(isset($_GET['w']) || isset($_GET['h']) ? 'thumbs' . DIRECTORY_SEPARATOR : '') .
$file['name'] . (isset($_GET['w']) ? '_w' . $_GET['w'] : '') .
(isset($_GET['h']) ? '_h' . $_GET['h'] : '') . '.' .
explode('.', $file['path'])[1];
if (!file_exists($imagePath)) { if (!file_exists($imagePath)) {
$config['image_library'] = 'gd2'; $config['image_library'] = 'gd2';

View File

@ -143,8 +143,8 @@
{ {
unset($_SESSION['user']); unset($_SESSION['user']);
$this->load->helper('cookie'); $this->load->helper('cookie');
delete_cookie('rememberMe'); // delete_cookie('rememberMe');
delete_cookie('token'); // delete_cookie('token');
$notice = '<div class="alert alert-warning alert-dismissible"><button type="button" class="close" data-dismiss="alert" aria-label="Schließen"><span aria-hidden="true">&times;</span></button><strong>Abgemeldet!</strong> Du wurdest erfolgreich abgemeldet! Ich hoffe wir sehen uns bald wieder.</div>'; $notice = '<div class="alert alert-warning alert-dismissible"><button type="button" class="close" data-dismiss="alert" aria-label="Schließen"><span aria-hidden="true">&times;</span></button><strong>Abgemeldet!</strong> Du wurdest erfolgreich abgemeldet! Ich hoffe wir sehen uns bald wieder.</div>';
$_SESSION['notice'] = $notice; $_SESSION['notice'] = $notice;
$_SESSION['loggedOut'] = true; $_SESSION['loggedOut'] = true;

View File

@ -8,7 +8,7 @@
public function __construct() public function __construct()
{ {
parent::__construct('home'); parent::__construct('home', 'profile');
$this->load->model('YoutubePlayerModel', '', TRUE); $this->load->model('YoutubePlayerModel', '', TRUE);
$this->load->model('SocialMediaModel', '', TRUE); $this->load->model('SocialMediaModel', '', TRUE);
$this->load->model('UserModel', '', TRUE); $this->load->model('UserModel', '', TRUE);

View File

@ -1,45 +1,48 @@
<?php <?php
defined('BASEPATH') OR exit('No direct script access allowed'); defined('BASEPATH') OR exit('No direct script access allowed');
class Redirect extends CI_Controller { class Redirect extends MY_Controller
{
public function __construct() { public function __construct()
parent::__construct(); {
$this->load->model('RedirectModel', '', TRUE); parent::__construct();
} $this->load->model('RedirectModel', '', TRUE);
public function index($redirect = null) {
if($redirect == null) {
redirect(base_url());
} else {
redirect("/r/p/" . $redirect);
} }
}
public function p($redirect = null) { public function index($redirect = null)
var_dump($redirect); {
if($redirect == null) { if ($redirect == null) {
if(isset($_SESSION['user']) && $_SESSION['user']['rank'] >= 9) { redirect(base_url());
$returnMessage = '';
if(isset($_POST['redirectInput']) && !empty($_POST['redirectInput']) && isset($_POST['redirectUrl']) && !empty($_POST['redirectUrl'])) {
$feedback = $this->redirect->insertRedirect($_POST['redirectUrl'], $_POST['redirectInput']);
if($feedback['feedback'] == 'success') {
$returnMessage = '<div class="alert alert-success" role="alert"><strong>Umleitung hinzugefügt!</strong> Code: "' .$_POST['redirectInput']. '" Ziel-Url: "' .$_POST['redirectUrl']. '"</div>';
} else {
$returnMessage = '<div class="alert alert-danger" role="alert"><strong>Error!</strong> ' .$feedback['message']. '</div>';
}
}
$this->load->view('header', ['title' => 'Redirect-Manager', 'active' => '']);
$this->load->view('redirect', ['message' => $returnMessage, 'allItems' => $this->RedirectModel->getItems()]);
$this->load->view('footer');
} else { } else {
header("Location: /"); redirect("/r/p/" . $redirect);
} }
} else {
$url = $this->RedirectModel->getUrl($redirect);
header("Location: " . $url);
} }
}
} public function p($redirect = null)
{
if ($redirect != null) {
$url = $this->RedirectModel->getUrl($redirect);
redirect($url);
}
if (!$this->hasPermission('redirect.view')) {
redirect(base_url());
}
$returnMessage = '';
if (isset($_POST['redirectInput']) && !empty($_POST['redirectInput']) && isset($_POST['redirectUrl']) && !empty($_POST['redirectUrl'])) {
$feedback = $this->redirect->insertRedirect($_POST['redirectUrl'], $_POST['redirectInput']);
if ($feedback['feedback'] == 'success') {
$returnMessage = '<div class="alert alert-success" role="alert"><strong>Umleitung hinzugefügt!</strong> Code: "' . $_POST['redirectInput'] . '" Ziel-Url: "' . $_POST['redirectUrl'] . '"</div>';
} else {
$returnMessage = '<div class="alert alert-danger" role="alert"><strong>Error!</strong> ' . $feedback['message'] . '</div>';
}
}
$this->load->view('header', ['title' => 'Redirect-Manager', 'active' => '']);
$this->load->view('redirect', ['message' => $returnMessage, 'allItems' => $this->RedirectModel->getItems()]);
$this->load->view('footer');
}
}

View File

@ -499,14 +499,17 @@ class User extends MY_Controller
$_SESSION['profileEditNotification'] .= "<div class='alert alert-danger' role='alert'><b>Bitte gib dein Passwort ein!</b> Das Ändern der E-Mail-Adresse ist ein tiefgreifender Eingriff in den Account. Daher benötigen wir zur Sicherheit nochmal dein Passwort.</div>"; $_SESSION['profileEditNotification'] .= "<div class='alert alert-danger' role='alert'><b>Bitte gib dein Passwort ein!</b> Das Ändern der E-Mail-Adresse ist ein tiefgreifender Eingriff in den Account. Daher benötigen wir zur Sicherheit nochmal dein Passwort.</div>";
} }
} }
// Notifications // Notifications
if (isset($_POST['email-notifications'])) { if (isset($_POST['email-notifications'])) {
$newData['receiveEmails'] = filter_var($_POST['email-notifications'], FILTER_VALIDATE_BOOLEAN); $newData['receiveEmails'] = filter_var($_POST['email-notifications'], FILTER_VALIDATE_BOOLEAN);
} }
// Newsletter // Newsletter
if (isset($_POST['newsletter'])) { if (isset($_POST['newsletter'])) {
$newData['receiveNewsletter'] = filter_var($_POST['newsletter'], FILTER_VALIDATE_BOOLEAN); $newData['receiveNewsletter'] = filter_var($_POST['newsletter'], FILTER_VALIDATE_BOOLEAN);
} }
// Password // Password
if (isset($_POST['passwordNew'])) { if (isset($_POST['passwordNew'])) {
if (isset($_POST['passwordOld'])) { if (isset($_POST['passwordOld'])) {
@ -536,7 +539,7 @@ class User extends MY_Controller
} }
} }
if (isset($_POST['showAds'])) { if (isset($_POST['showAds'])) {
if (isset($_SESSION['user']) && $_SESSION['user']['rank'] >= 2) { if ($this->hasPermission('user.disableAds')) {
$newData['showAds'] = filter_var($_POST['email-notifications'], FILTER_VALIDATE_BOOLEAN); $newData['showAds'] = filter_var($_POST['email-notifications'], FILTER_VALIDATE_BOOLEAN);
} else { } else {
$_SESSION['profileEditNotification'] .= "<div class='alert alert-danger' role='alert'><b>Du bist dazu nicht berechtigt!</b> Um diese Einstellung zu verändern, musst du mindestens ein Premium-Nutzer oder höher sein!</div>"; $_SESSION['profileEditNotification'] .= "<div class='alert alert-danger' role='alert'><b>Du bist dazu nicht berechtigt!</b> Um diese Einstellung zu verändern, musst du mindestens ein Premium-Nutzer oder höher sein!</div>";

View File

@ -298,7 +298,7 @@ class Blog extends CI_Controller
$categories = $this->BlogModel->getCategories(); $categories = $this->BlogModel->getCategories();
$this->load->view('admin/sidebar', ['title' => 'Blog-Post erstellen', 'additionalStyles' => ['lib/medium-editor.min.css', 'lib/default.min.css', 'lib/medium-editor-insert-plugin.min.css']]); $this->load->view('admin/sidebar', ['title' => 'Blog-Post erstellen', 'additionalStyles' => ['lib/medium-editor.min.css', 'lib/default.min.css', 'lib/medium-editor-insert-plugin.min.css']]);
$this->load->view('admin/blog_edit', ['categories' => $categories, 'postID' => $postID, 'contents' => $contents, 'translations' => $translations, 'postLanguage' => $lang]); $this->load->view('admin/blog_edit', ['categories' => $categories, 'postID' => $postID, 'contents' => $contents, 'translations' => $translations, 'postLanguage' => $lang]);
$this->load->view('admin/footer', ['additionalScripts' => 'lib/medium-editor.min.js,lib/handlebars.runtime-v4.0.10.js,lib/jquery-sortable.min.js,lib/jquery.ui.widget.js,lib/jquery.iframe-transport.js,lib/jquery.fileupload.js,lib/medium-editor-insert-plugin.min.js,lib/autolist.min.js,lib/highlight.pack.js,lib/quill.min.js,blog-edit.js']); $this->load->view('admin/footer', ['additionalScripts' => ['lib/medium-editor.min.js', 'lib/handlebars.runtime-v4.0.10.js', 'lib/jquery-sortable.min.js', 'lib/jquery.ui.widget.js', 'lib/jquery.iframe-transport.js', 'lib/jquery.fileupload.js', 'lib/medium-editor-insert-plugin.min.js', 'lib/autolist.min.js', 'lib/highlight.pack.js', 'lib/quill.min.js', 'blog-edit.js']]);
} }
public function history($postID = NULL) public function history($postID = NULL)

View File

@ -1,7 +1,7 @@
<?php <?php
defined('BASEPATH') OR exit('No direct script access allowed'); defined('BASEPATH') OR exit('No direct script access allowed');
class Dashboard extends CI_Controller { class Dashboard extends MY_Controller {
public function __construct() { public function __construct() {
parent::__construct(); parent::__construct();
@ -9,7 +9,8 @@ class Dashboard extends CI_Controller {
public function index() public function index()
{ {
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 6) redirect(base_url('login')); $this->neededPermission('dashboard.view');
$this->load->view('admin/sidebar', ['title' => 'Dashboard']); $this->load->view('admin/sidebar', ['title' => 'Dashboard']);
$this->load->view('admin/dashboard'); $this->load->view('admin/dashboard');
$this->load->view('admin/footer'); $this->load->view('admin/footer');

View File

@ -1,74 +0,0 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Downloads extends CI_Controller
{
public function __construct()
{
parent::__construct();
$this->load->model('downloadsModel', '', TRUE);
$this->load->model('FileModel', '', TRUE);
}
public function index()
{
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 9) redirect(base_url('login'));
$downloads = $this->downloadsModel->getDownloads();
$this->load->view('admin/sidebar', ['title' => 'Alle Downloads']);
$this->load->view('admin/downloads', ['downloads' => $downloads]);
$this->load->view('admin/footer');
}
public function edit($id = NULL)
{
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 9) redirect(base_url('login'));
$edit = $id === NULL ? false : true;
$p = $this->input->post(['title', 'description', 'descriptionEnglish', 'image', 'url', 'datetime']);
if ($edit) {
if ($this->downloadsModel->checkIfExists($id)) {
$downloadContent = $this->downloadsModel->getDownload($id);
} else {
redirect(base_url('admin/downloads/edit'));
}
if ($p['title'] != NULL && $p['description'] != NULL && $p['datetime'] != NULL && $p['url'] !== NULL) {
$imgurl = '/assets/images/placeholder.jpg';
if (isset($_FILES['downloadImage']) && $_FILES['downloadImage']['size'] > 0) {
$fileName = $_FILES['downloadImage']['name'];
$tmpName = $_FILES['downloadImage']['tmp_name'];
$fileSize = $_FILES['downloadImage']['size'];
$fileType = $_FILES['downloadImage']['type'];
unset($_FILES['downloadImage']);
$imgurl = $this->FileModel->uploadFile($fileName, $tmpName, $fileSize, $fileType);
}
$this->downloadsModel->addNewDownload($p['datetime'], $p['title'], $p['description'], $p['descriptionEnglish'], $imgurl, $p['url']);
redirect(base_url('admin/downloads/edit/' . $id));
}
$this->load->view('admin/sidebar', ['title' => 'Download-Eintrag bearbeiten']);
$this->load->view('admin/download_edit', ['edit' => $edit, 'content' => $downloadContent]);
$this->load->view('admin/footer');
} else {
if ($p['title'] != NULL && $p['description'] != NULL && $p['datetime'] != NULL && isset($_FILES['downloadImage']) && $_FILES['downloadImage']['size'] > 0 && $p['url'] !== NULL) {
$fileName = $_FILES['downloadImage']['name'];
$tmpName = $_FILES['downloadImage']['tmp_name'];
$fileSize = $_FILES['downloadImage']['size'];
$fileType = $_FILES['downloadImage']['type'];
$imgurl = $this->FileModel->uploadFile($fileName, $tmpName, $fileSize, $fileType);
unset($_FILES['downloadImage']);
$this->downloadsModel->addNewDownload($p['datetime'], $p['title'], $p['description'], $p['descriptionEnglish'], $imgurl, $p['url']);
redirect(base_url('admin/downloads/edit'));
}
$this->load->view('admin/sidebar', ['title' => 'Download-Eintrag erstellen']);
$this->load->view('admin/download_edit', ['edit' => $edit]);
$this->load->view('admin/footer');
}
}
}

View File

@ -1,7 +1,7 @@
<?php <?php
defined('BASEPATH') OR exit('No direct script access allowed'); defined('BASEPATH') OR exit('No direct script access allowed');
class Feedback extends CI_Controller class Feedback extends MY_Controller
{ {
public function __construct() public function __construct()
@ -11,7 +11,7 @@ class Feedback extends CI_Controller
} }
public function index() { public function index() {
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 9) redirect(base_url('login')); $this->neededPermission('feedback.receive');
$feedback = $this->MessageModel->getFeedbackMessages(); $feedback = $this->MessageModel->getFeedbackMessages();
@ -21,7 +21,7 @@ class Feedback extends CI_Controller
} }
public function takeover($id = null, $state = 1) { public function takeover($id = null, $state = 1) {
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 9) redirect(base_url('login')); $this->neededPermission('feedback.reply');
if($id != null) { if($id != null) {
$this->MessageModel->setFeedbackSupporter($id, $_SESSION['user']['ID'], $state); $this->MessageModel->setFeedbackSupporter($id, $_SESSION['user']['ID'], $state);
@ -31,7 +31,7 @@ class Feedback extends CI_Controller
} }
public function change($id) { public function change($id) {
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 9) redirect(base_url('login')); $this->neededPermission('feedback.reply');
if($id != null) { if($id != null) {
$newStatus = $this->input->post('feedbackState'); $newStatus = $this->input->post('feedbackState');
@ -44,7 +44,7 @@ class Feedback extends CI_Controller
public function archive() { public function archive() {
// header('Content-Type: application/json'); // header('Content-Type: application/json');
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 9) { if (!$this->hasPermission('feedback.reply')) {
echo json_encode(['type' => 'error', 'message' => 'Du musst eingeloggt sein, um Feedbacks zu beantworten.']); echo json_encode(['type' => 'error', 'message' => 'Du musst eingeloggt sein, um Feedbacks zu beantworten.']);
exit; exit;
} }

View File

@ -1,7 +1,7 @@
<?php <?php
defined('BASEPATH') OR exit('No direct script access allowed'); defined('BASEPATH') OR exit('No direct script access allowed');
class Files extends CI_Controller class Files extends MY_Controller
{ {
public function __construct() public function __construct()
@ -12,7 +12,7 @@ class Files extends CI_Controller
public function index() public function index()
{ {
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 9) redirect(base_url('login')); $this->neededPermission('file.view');
if(isset($_FILES['fileUpload'])) { if(isset($_FILES['fileUpload'])) {
$fileName = $_FILES['fileUpload']['name']; $fileName = $_FILES['fileUpload']['name'];
@ -20,7 +20,7 @@ class Files extends CI_Controller
$fileSize = $_FILES['fileUpload']['size']; $fileSize = $_FILES['fileUpload']['size'];
$fileType = $_FILES['fileUpload']['type']; $fileType = $_FILES['fileUpload']['type'];
$this->FileModel->uploadFile($fileName, $tmpName, $fileSize, $fileType); $this->FileModel->uploadFile($fileName, $tmpName, $fileSize, $fileType, false);
unset($_FILES['fileUpload']); unset($_FILES['fileUpload']);
@ -36,7 +36,8 @@ class Files extends CI_Controller
} }
public function delete() { public function delete() {
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 9) redirect(base_url('login')); $this->neededPermission('file.delete');
$id = filter_input(INPUT_POST, "id"); $id = filter_input(INPUT_POST, "id");
$this->FileModel->delete($id); $this->FileModel->delete($id);
} }
@ -44,7 +45,7 @@ class Files extends CI_Controller
public function uploadImage() public function uploadImage()
{ {
header("Content-Type: application/json"); header("Content-Type: application/json");
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 6) { if (!$this->hasPermission('file.uploadManual')) {
echo json_encode([ echo json_encode([
'success' => false, 'success' => false,
'message' => '<b>Fehler beim Upload!</b> Aufgrund von zu geringen Zugriffsrechten konnte das Bild leider nicht hochgeladen werden. Sollte es sich dabei um ein Irrtum handeln, kontaktiere bitte einen Admin über das Kontaktformular.' 'message' => '<b>Fehler beim Upload!</b> Aufgrund von zu geringen Zugriffsrechten konnte das Bild leider nicht hochgeladen werden. Sollte es sich dabei um ein Irrtum handeln, kontaktiere bitte einen Admin über das Kontaktformular.'

View File

@ -1,7 +1,7 @@
<?php <?php
defined('BASEPATH') OR exit('No direct script access allowed'); defined('BASEPATH') OR exit('No direct script access allowed');
class Projects extends CI_Controller class Projects extends MY_Controller
{ {
public function __construct() public function __construct()
@ -13,7 +13,7 @@
public function index() public function index()
{ {
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 9) redirect(base_url('login')); $this->neededPermission('projects.view');
$entries = $this->ProjectsModel->getEntries('all'); $entries = $this->ProjectsModel->getEntries('all');
$categories = $this->ProjectsModel->getCategories('all'); $categories = $this->ProjectsModel->getCategories('all');
@ -25,12 +25,17 @@
public function edit($id = NULL) public function edit($id = NULL)
{ {
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 9) redirect(base_url('login')); $this->neededPermission('projects.create');
$edit = $id === NULL ? false : true; $edit = $id === NULL ? false : true;
$content = null; $content = null;
$projectCategories = []; $projectCategories = [];
if ($edit) { if ($edit) {
// TODO: Check if project is created by user or not
$this->neededPermission('projects.edit');
if ($this->ProjectsModel->checkIfExists($id)) { if ($this->ProjectsModel->checkIfExists($id)) {
$content = $this->ProjectsModel->getEntry($id); $content = $this->ProjectsModel->getEntry($id);
$content = $this->ProjectsModel->mergeFullTranslationData($content)[0]; $content = $this->ProjectsModel->mergeFullTranslationData($content)[0];
@ -50,8 +55,16 @@
public function sendEdit() public function sendEdit()
{ {
header('Content-Type: application/json'); header('Content-Type: application/json');
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 9) { if (!$this->hasPermission('projects.create')) {
echo json_encode(['success' => false, 'message' => 'Du hast nicht genügend Rechte, um Projekte zu erstellen bzw. bearbeiten.']); echo json_encode(['success' => false, 'message' => 'Du hast nicht genügend Rechte, um Projekte zu erstellen.']);
exit;
}
$editingID = $this->input->post('editingID');
// TODO: Check if user is author of project
if($editingID !== '-1' && !$this->hasPermission('projects.edit')) {
echo json_encode(['success' => false, 'message' => 'Du hast nicht genügend Rechte, um Projekte zu bearbeiten.']);
exit; exit;
} }
@ -83,7 +96,6 @@
$date = date('Y-m-d H:i:s', strtotime($this->input->post('date'))); $date = date('Y-m-d H:i:s', strtotime($this->input->post('date')));
$image = $this->input->post('image'); $image = $this->input->post('image');
$editingID = $this->input->post('editingID');
if($editingID == '-1' && $this->ProjectsModel->checkIfNameExists($url)) { if($editingID == '-1' && $this->ProjectsModel->checkIfNameExists($url)) {
echo json_encode(['success' => false, 'message' => 'Die angegebene URL ist bereits vergeben.']); echo json_encode(['success' => false, 'message' => 'Die angegebene URL ist bereits vergeben.']);
@ -102,14 +114,17 @@
public function delete() public function delete()
{ {
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 9) redirect(base_url('login')); // TODO: Check if user is author of project
$this->neededPermission('projects.delete');
$id = filter_input(INPUT_POST, "id"); $id = filter_input(INPUT_POST, "id");
$this->ProjectsModel->delete($id); $this->ProjectsModel->delete($id);
} }
public function delete_category() public function delete_category()
{ {
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 9) redirect(base_url('login')); $this->neededPermission('projects.deleteCategory');
$id = filter_input(INPUT_POST, "id"); $id = filter_input(INPUT_POST, "id");
$this->ProjectsModel->deleteCategory($id); $this->ProjectsModel->deleteCategory($id);
} }

View File

@ -1,7 +1,7 @@
<?php <?php
defined('BASEPATH') OR exit('No direct script access allowed'); defined('BASEPATH') OR exit('No direct script access allowed');
class Redirects extends CI_Controller class Redirects extends MY_Controller
{ {
public function __construct() public function __construct()
@ -12,7 +12,8 @@ class Redirects extends CI_Controller
public function index() public function index()
{ {
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 9) redirect(base_url('login')); $this->neededPermission('redirect.view');
$redirects = $this->RedirectModel->getItems(); $redirects = $this->RedirectModel->getItems();
$this->load->view('admin/sidebar', ['title' => 'Alle Weiterleitungen']); $this->load->view('admin/sidebar', ['title' => 'Alle Weiterleitungen']);
$this->load->view('admin/redirects', ['redirects' => $redirects]); $this->load->view('admin/redirects', ['redirects' => $redirects]);
@ -20,7 +21,7 @@ class Redirects extends CI_Controller
} }
public function addRedirect() { public function addRedirect() {
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 9) redirect(base_url('login')); $this->neededPermission('redirect.create');
$id = $this->input->post('redirectID'); $id = $this->input->post('redirectID');
$name = $this->input->post('redirectName'); $name = $this->input->post('redirectName');
@ -28,6 +29,8 @@ class Redirects extends CI_Controller
if(isset($name) && isset($url)) { if(isset($name) && isset($url)) {
if(isset($id)) { if(isset($id)) {
$this->neededPermission('redirect.edit');
$this->RedirectModel->editRedirect($id, $url, $name); $this->RedirectModel->editRedirect($id, $url, $name);
} else { } else {
$this->RedirectModel->insertRedirect($url, $name); $this->RedirectModel->insertRedirect($url, $name);
@ -38,7 +41,7 @@ class Redirects extends CI_Controller
} }
public function removeRedirect($id = null) { public function removeRedirect($id = null) {
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 9) redirect(base_url('login')); $this->neededPermission('redirect.delete');
if($id != null) { if($id != null) {
$this->RedirectModel->removeRedirect($id); $this->RedirectModel->removeRedirect($id);

View File

@ -3,27 +3,89 @@ defined('BASEPATH') OR exit('No direct script access allowed');
class Users extends MY_Controller class Users extends MY_Controller
{ {
private $availablePermissions;
public function __construct() public function __construct()
{ {
parent::__construct(); parent::__construct();
$this->load->model('UserModel', '', TRUE); $this->load->model('UserModel', '', TRUE);
$this->availablePermissions = [
'projects' => [
'view',
'create',
'editOwn',
'edit',
'deleteOwn',
'delete',
'deleteCategory',
],
'blog' => [
'view',
'create',
'editOwn',
'edit',
'deleteOwn',
'delete',
'deleteOwnFinally',
'deleteFinally',
'createCategory',
'publishNow',
'publish',
'publishSelf',
],
'file' => [
'view',
'upload',
'uploadManually',
'delete',
],
'redirect' => [
'view',
'create',
'edit',
'delete',
],
'user' => [
'disableAds',
'view',
'viewDetails',
'changeRank',
'editPermissions',
'ban',
'deletePost',
],
'reports' => [
'receive',
],
'feedback' => [
'receive',
'reply',
],
'contact' => [
'view',
'answer',
],
'dashboard' => [
'view',
],
];
} }
public function index() public function index()
{ {
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 9) redirect(base_url('login')); $this->neededPermission('user.view');
$usersData = $this->UserModel->getUserList(50, 0); $usersData = $this->UserModel->getUserList(50, 0);
$this->load->view('admin/sidebar', ['title' => 'Alle Nutzer']); $this->load->view('admin/sidebar', ['title' => 'Alle Nutzer']);
$this->load->view('admin/users', ['users' => $usersData]); $this->load->view('admin/users', ['users' => $usersData]);
$this->load->view('admin/footer'); $this->load->view('admin/footer', ['additionalScripts' => ['admin_users.js']]);
} }
public function details($userID = NULL) public function details($userID = NULL)
{ {
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 9) redirect(base_url('login')); $this->neededPermission('user.viewDetails');
if ($userID == NULL) redirect(base_url('admin/users')); if ($userID == NULL) redirect(base_url('admin/users'));
@ -39,7 +101,7 @@ class Users extends MY_Controller
public function settings($userID = NULL) public function settings($userID = NULL)
{ {
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 9) redirect(base_url('login')); $this->neededPermission('user.viewDetails');
if ($userID == NULL) redirect(base_url('admin/users')); if ($userID == NULL) redirect(base_url('admin/users'));
@ -48,7 +110,9 @@ class Users extends MY_Controller
if ($userData == null) redirect(base_url('admin/users')); if ($userData == null) redirect(base_url('admin/users'));
$userData = $userData[0]; $userData = $userData[0];
if (isset($_POST['rank'])) { $reload = false;
if ($this->hasPermission('user.changeRank') && isset($_POST['rank'])) {
$rank = intval($_POST['rank']); $rank = intval($_POST['rank']);
if (($rank < 1) || ($rank > 3 && $rank < 6) || $rank > 10) { if (($rank < 1) || ($rank > 3 && $rank < 6) || $rank > 10) {
redirect(base_url(uri_string())); redirect(base_url(uri_string()));
@ -74,11 +138,40 @@ class Users extends MY_Controller
$this->UserModel->insertIntoHistory($historyData); $this->UserModel->insertIntoHistory($historyData);
// Update profile // Update profile
$this->UserModel->updateProfile(['rank' => $rank], $userID); $this->UserModel->updateProfile(['rank' => $rank], $userID);
$reload = true;
}
if($this->hasPermission('user.editPermissions') && isset($_POST['permissions'])) {
$perms = array_keys($_POST['permissions']);
foreach ($this->availablePermissions as $group => $permissions) {
foreach ($permissions as $permission) {
$userHasPermission = $this->UserModel->hasPermission($userID, $group, $permission);
if(in_array($group . $permission, $perms)) { // Permission was given by user
if(!$userHasPermission) { // Subject hasn't got the permission already
$this->UserModel->addPermission($userID, $group, $permission, $_SESSION['user']['ID']);
}
} else {
if($userHasPermission) {
$this->UserModel->revokePermission($userID, $group, $permission);
}
}
}
}
$reload = true;
}
if($reload) {
redirect(base_url(uri_string())); redirect(base_url(uri_string()));
} }
$permissions = $this->UserModel->getPermissions($userID);
$this->load->view('admin/sidebar', ['title' => 'Nutzer-Einstellungen - ' . $userData['displayname']]); $this->load->view('admin/sidebar', ['title' => 'Nutzer-Einstellungen - ' . $userData['displayname']]);
$this->load->view('admin/user_settings', ['user' => $userData]); $this->load->view('admin/user_settings', ['user' => $userData, 'permissions' => $permissions, 'availablePermissions' => $this->availablePermissions]);
$this->load->view('admin/footer'); $this->load->view('admin/footer', ['additionalScripts' => ['user-edit.js']]);
} }
} }

View File

@ -8,6 +8,7 @@ class MY_Controller extends CI_Controller
{ {
parent::__construct(); parent::__construct();
$this->load->helper('cookie'); $this->load->helper('cookie');
$this->load->model('LoginModel', '', TRUE);
$lang = isset($_SESSION['site_lang']) ? $_SESSION['site_lang'] : 'de'; $lang = isset($_SESSION['site_lang']) ? $_SESSION['site_lang'] : 'de';
$_SESSION['site_lang'] = $lang; $_SESSION['site_lang'] = $lang;
@ -29,8 +30,27 @@ class MY_Controller extends CI_Controller
$rememberMe = get_cookie('rememberMe'); $rememberMe = get_cookie('rememberMe');
if($rememberMe != NULL) { if($rememberMe != NULL) {
$token = get_cookie('token'); $this->LoginModel->autoLogin();
var_dump($rememberMe, $token); }
}
public function hasPermission(...$permissions) {
if(!isset($_SESSION['user']) || empty($_SESSION['user'])) {
return false;
}
foreach ($permissions as $permission) {
if(!in_array($permission, $_SESSION['user']['permissions'])) {
return false;
}
}
return true;
}
public function neededPermission($permission) {
if(!$this->hasPermission($permission)) {
redirect(base_url());
} }
} }
} }

View File

@ -16,10 +16,12 @@ $lang['home_slider_video_des'] = 'Regieanweisung: <i>Bedenken Sie, einen Drücke
$lang['home_slider_video_btn'] = 'Jetzt ansehen'; $lang['home_slider_video_btn'] = 'Jetzt ansehen';
$lang['home_channels_title'] = 'YouTube-Kanäle'; $lang['home_channels_title'] = 'YouTube-Kanäle';
$lang['home_kingofdog_des'] = 'KingOfDog ist mein erster YouTube-Kanal und besteht mittlerweile schon seit über 4 Jahren. Hier gibt es Gaming, Fakten, Informationen, News, Meinungen, Reviews, Vlogs und vieles mehr. Über 600 Abonnenten können sich hier ca. 350 Videos ansehen.'; $lang['home_kingofdog_des'] = 'KingOfDog ist mein erster YouTube-Kanal und besteht mittlerweile schon seit Ende 2013. Ging es früher hier um Gaming und Let\'s Plays, so dreht sich dieser Kanal heute eher um die Programmierwelt, Wissen, Politik sowie verschiedene andere Themen.';
$lang['home_zeybefx_des'] = 'Auf ZeybeFX gibt es seit über anderthalb Jahren Speedarts, Design-Tutorials, Giveaways und alle möglichen anderen Videos, die mit Design zu tun haben. Der Kanal ist englischsprachig und ist derzeit noch etwas inaktiv.'; $lang['home_zeybefx_des'] = 'ZeybeFX ist leider aus Zeitgründen etwas inaktiver. Der eigentliche Zweck des Kanals sind Videos rund ums Thema Design. So gibt es auf ZeybeFX Speedarts, Tutorials, Tipps und Tricks für das Designen von Grafiken, Webseiten, Nutzerinterfaces, Spielen und so weiter.';
$lang['home_zeybeofficial_des'] = 'Der neueste Kanal von mir existiert erst seit Anfang 2017, ist dafür jedoch sehr aktiv. Täglich um 15 Uhr gibt es ein neues Video mit copyright-freier Musik, die jeder für seine eigenen Videos, Spiele, Webseiten, Podcasts oder ähnliches nutzen kann. Teilweise gibt es auch eigene Musik, die ich selbst erstellt habe.'; $lang['home_zeybeofficial_des'] = 'Dieser Kanal, ZeybeOfficial, konzentriert sich auf die klangvolle Welt der Musik. Mit einigen selbstkomponierten Songs, aber auch Musik von anderen Künstlern bietet ZeybeOfficial eine Plattform für Copyright-freie Musik, die jeder in seinen Videos, Spielen oder Programmen kostenlos nutzen darf.';
$lang['home_kingofdogint_des'] = 'KingOfDog International ist die internationale bzw. englische Version meines Hauptkanals KingOfDog. Hier gibt es übersetzte Videos vom deutschen Kanal, um mehr Menschen erreichen zu können.'; $lang['home_kingofdogint_des'] = 'KingOfDog International ist die internationale bzw. englische Version meines Hauptkanals KingOfDog. Hier gibt es übersetzte Videos vom deutschen Kanal, um mehr Menschen erreichen zu können.';
$lang['home_kingofdogtv_des'] = 'KingOfDogTV ist mein Kanal für Livestreams aller Art. Zwar streame ich nicht sonderlich regelmäßig, aber wenn ich dann doch mal live sein sollte, wird das Resultat später auf KingOfDogTV hochgeladen.';
$lang['home_minepoint_des'] = 'Der Kanal MinePoint ist die offizielle YouTube-Präsenz des mittlerweile nicht mehr fortgeführten Minecraft-Servers MinePoint, an dem ich vor einigen Jahren als Administrator, Entwickler und Video-Cutter mitgewirkt habe.';
$lang['home_active_users'] = 'Derzeit aktive Nutzer'; $lang['home_active_users'] = 'Derzeit aktive Nutzer';
$lang['home_newest_users'] = 'Neueste Nutzer'; $lang['home_newest_users'] = 'Neueste Nutzer';

View File

@ -16,10 +16,12 @@ $lang['home_slider_video_des'] = 'Stage direction: <i>Press the left mouse butto
$lang['home_slider_video_btn'] = 'Watch now'; $lang['home_slider_video_btn'] = 'Watch now';
$lang['home_channels_title'] = 'YouTube Channels'; $lang['home_channels_title'] = 'YouTube Channels';
$lang['home_kingofdog_des'] = 'KingOfDog is my very first YouTube channel and have existed meanwhile for more than 3 years. On this channel you get access to the newest games, facts, information, news, opinions, reviews, vlogs and much more. Over 600 subscribers can watch around 350 videos here.'; $lang['home_kingofdog_des'] = 'KingOfDog is my very first YouTube channel and already exists since the end of 2013. While gaming and let\'s plays played a major role on this channel a few years ago, the main focus of KingOfDog are topics like programming, knowledge, politics and many more.';
$lang['home_zeybefx_des'] = 'There have been speedarts, design tutorials, giveaways, and much more videos dealing with design on ZeybeFX for more than one and a half years. This channel is in English and currently a little bit inactive.'; $lang['home_zeybefx_des'] = 'ZeybeFX sadly has not very much uploads because of a lack of time. However, this channel centres around design, as there are speedarts, tutorials, tips and tricks about making graphics, websites, user interfaces, games or else.';
$lang['home_zeybeofficial_des'] = 'The most recent channel of mine has existed since the beginning of 2017, but is very active. Each of the daily videos at 3 pm delivers you a new copyright free music track, which you can use in your own videos, games, websites, podcast, and similar things. Partially I upload my own music, which I created on my own, also.'; $lang['home_zeybeofficial_des'] = 'This channel focuses on the wonderful world of music. With partly self-composed music it is supposed to evolve to a practical platform with royalty-free music for everyon to use in their games, videos, programs and so on.';
$lang['home_kingofdogint_des'] = 'KingOfDog International is the (as the name already tells) international, English version of my main channel KingOfDog. Here you can discover translated videos from the German channel - because subtitles aren\'t that cool.'; $lang['home_kingofdogint_des'] = 'KingOfDog International is the (as the name already tells) international, English version of my main channel KingOfDog. Here you can discover translated videos from the German channel - because subtitles aren\'t that cool.';
$lang['home_kingofdogtv_des'] = 'KingOfDogTV is my channel for all the livestreams. Admittedly, I\'m not going live very often but if I do then the resulting video is uploaded to this channel so that everyone has an archive with all the previous livestreams.';
$lang['home_minepoint_des'] = 'The channel MinePoint is the official YouTube page of the Minecraft server MinePoint which no longer exists. Anyways, I was administrator, developer and video creator of this server project a few years ago.';
$lang['home_active_users'] = 'Currently Active Users'; $lang['home_active_users'] = 'Currently Active Users';
$lang['home_newest_users'] = 'Newly Registered Users'; $lang['home_newest_users'] = 'Newly Registered Users';

View File

@ -17,7 +17,7 @@
$config['mailtype'] = 'html'; $config['mailtype'] = 'html';
$this->email->initialize($config); $this->email->initialize($config);
$this->email->from('no-reply@kingofdog.eu', 'KingOfDog'); $this->email->from('no-reply@kingofdog.eu', 'KingOfDog.eu');
$this->email->to($recipient); $this->email->to($recipient);
$this->email->subject($subject); $this->email->subject($subject);

View File

@ -17,18 +17,22 @@ class FileModel extends CI_Model
public function uploadFile($original_name, $tmpname, $size, $type, $userContent = true) public function uploadFile($original_name, $tmpname, $size, $type, $userContent = true)
{ {
$target_dir = "files" . DIRECTORY_SEPARATOR . ($userContent ? 'userContent' . DIRECTORY_SEPARATOR : ''); $target_dir = 'files' . DIRECTORY_SEPARATOR . ($userContent ? 'userContent' . DIRECTORY_SEPARATOR : '');
$filetype = pathinfo(basename($original_name), PATHINFO_EXTENSION); $filetype = pathinfo(basename($original_name), PATHINFO_EXTENSION);
$target_file = $target_dir . $this->generateName() . '.' . $filetype; $name = $this->generateName();
$name = explode('.' . $filetype, explode(DIRECTORY_SEPARATOR, $target_file)[1])[0]; $target_file = $target_dir . $name . '.' . $filetype;
if (!move_uploaded_file($tmpname, $target_file)) { if (!move_uploaded_file($tmpname, $target_file)) {
die('File couldn\'t be uploaded!'); die('File couldn\'t be uploaded!');
} }
$target_file = str_replace('\\', '/', $target_file);
$this->db->query('INSERT INTO files (name, original_name, type, size, path, isUserData) VALUES (?, ?, ?, ?, ?, ?)', [$name, $original_name, $type, $size, $target_file, $userContent]); $this->db->query('INSERT INTO files (name, original_name, type, size, path, isUserData) VALUES (?, ?, ?, ?, ?, ?)', [$name, $original_name, $type, $size, $target_file, $userContent]);
echo shell_exec(escapeshellcmd('python /var/www/codeigniter/duplicates.py')); $this->db->cache_delete('admin', 'files');
echo shell_exec('python /var/www/codeigniter/duplicates.py');
return "/f/" . $name; return "/f/" . $name;
} }
@ -58,7 +62,9 @@ class FileModel extends CI_Model
$this->db->query('INSERT INTO files (name, original_name, type, size, path, isUserData) VALUES (?, ?, ?, ?, ?, ?)', [$data['raw_name'], $originalname, $data['file_type'], $data['file_size'] * 1024, $this->getPath($data['file_name'], $userContent), $userContent]); $this->db->query('INSERT INTO files (name, original_name, type, size, path, isUserData) VALUES (?, ?, ?, ?, ?, ?)', [$data['raw_name'], $originalname, $data['file_type'], $data['file_size'] * 1024, $this->getPath($data['file_name'], $userContent), $userContent]);
echo shell_exec(escapeshellcmd('python /var/www/codeigniter/duplicates.py')); $this->db->cache_delete('admin', 'files');
echo shell_exec('python /var/www/codeigniter/duplicates.py');
return '/f/' . $data['raw_name']; return '/f/' . $data['raw_name'];
} }
@ -113,25 +119,31 @@ class FileModel extends CI_Model
$this->db->query('INSERT INTO files (name, original_name, type, size, path, isUserData) VALUES (?, ?, ?, ?, ?, ?)', [$data['raw_name'], $originalname, $data['file_type'], $data['file_size'] * 1024, $this->getPath($data['file_name'], $userContent), $userContent]); $this->db->query('INSERT INTO files (name, original_name, type, size, path, isUserData) VALUES (?, ?, ?, ?, ?, ?)', [$data['raw_name'], $originalname, $data['file_type'], $data['file_size'] * 1024, $this->getPath($data['file_name'], $userContent), $userContent]);
echo shell_exec(escapeshellcmd('python /var/www/codeigniter/duplicates.py')); $this->db->cache_delete('admin', 'files');
echo shell_exec('python /var/www/codeigniter/duplicates.py');
return '/f/' . $data['raw_name']; return '/f/' . $data['raw_name'];
} }
} }
public function uploadFileByContent($content, $original_name, $fullType, $fileSize, $userContent = true) { public function uploadFileByContent($content, $original_name, $fullType, $fileSize, $userContent = true) {
$target_dir = "files" . DIRECTORY_SEPARATOR . ($userContent ? 'userContent' . DIRECTORY_SEPARATOR : ''); $target_dir = 'files' . DIRECTORY_SEPARATOR . ($userContent ? 'userContent' . DIRECTORY_SEPARATOR : '');
$filetype = pathinfo(basename($original_name), PATHINFO_EXTENSION); $filetype = pathinfo(basename($original_name), PATHINFO_EXTENSION);
$target_file = $target_dir . $this->generateName() . '.' . $filetype; $name = $this->generateName();
$name = explode('.' . $filetype, explode(DIRECTORY_SEPARATOR, $target_file)[1])[0]; $target_file = $target_dir . $name . '.' . $filetype;
$fp = fopen($target_file, 'w'); $fp = fopen($target_file, 'w');
fwrite($fp, $content); fwrite($fp, $content);
fclose($fp); fclose($fp);
$target_file = str_replace('\\', '/', $target_file);
$this->db->query('INSERT INTO files (name, original_name, type, size, path, isUserData) VALUES (?, ?, ?, ?, ?, ?)', [$name, $original_name, $fullType, $fileSize, $target_file, $userContent]); $this->db->query('INSERT INTO files (name, original_name, type, size, path, isUserData) VALUES (?, ?, ?, ?, ?, ?)', [$name, $original_name, $fullType, $fileSize, $target_file, $userContent]);
echo shell_exec(escapeshellcmd('python /var/www/codeigniter/duplicates.py')); $this->db->cache_delete('admin', 'files');
echo shell_exec('python /var/www/codeigniter/duplicates.py');
return '/f/' . $name; return '/f/' . $name;
} }

View File

@ -8,6 +8,7 @@
{ {
parent::__construct(); parent::__construct();
$this->load->model('NotificationModel', '', TRUE); $this->load->model('NotificationModel', '', TRUE);
$this->load->model('UserModel', '', TRUE);
$this->load->model('EmailModel', '', TRUE); $this->load->model('EmailModel', '', TRUE);
$this->load->helper('cookie'); $this->load->helper('cookie');
} }
@ -22,19 +23,26 @@
} }
$logindata = $logindata[0]; $logindata = $logindata[0];
if($logindata['isDeleted']) {
$_SESSION['notice'] .= '<div class="alert alert-danger alert-dismissible"><button type="button" class="close" data-dismiss="alert" aria-label="Schließen"><span aria-hidden="true">&times;</span></button><strong>Der Account wurde deaktiviert!</strong> Dein Account wurde vom System deaktiviert, womöglich aufgrund von Fehlverhalten (beispielsweise in Form von anstößigen, unerwünschten, diskriminierenden oder volksverhetzenden Kommentaren, Posts oder Namen). Solltest du dies für ein Fehler halten, nutze bitte das Kontaktformular, um dich <b>höflich</b> zu beschweren.</div>';
return;
}
$encryptedPassword = $this->getPasswordHash($password, $logindata['original_name']); $encryptedPassword = $this->getPasswordHash($password, $logindata['original_name']);
if ($encryptedPassword == $logindata['password']) { if ($encryptedPassword == $logindata['password']) {
$this->startLoginSession($logindata, $rememberMe); $this->startLoginSession($logindata, $rememberMe);
} else { } else {
$_SESSION['notice'] .= '<div class="alert alert-danger alert-dismissible"><button type="button" class="close" data-dismiss="alert" aria-label="Schließen"><span aria-hidden="true">&times;</span></button><strong>Falsche Anmeldedaten!</strong> Benutzername und Passwort stimmen nicht überein!</div>'; $_SESSION['notice'] .= '<div class="alert alert-danger alert-dismissible"><button type="button" class="close" data-dismiss="alert" aria-label="Schließen"><span aria-hidden="true">&times;</span></button><strong>Falsche Anmeldedaten!</strong> Benutzername oder Passwort stimmen nicht mit unseren Akten überein.</div>';
} }
} }
public function getLoginData($username) public function getLoginData($username)
{ {
$this->db->cache_off();
$return = $this->db->query('SELECT * FROM users WHERE (username = lower(?) OR email = lower(?)) AND is_activated = TRUE LIMIT 1', $return = $this->db->query('SELECT * FROM users WHERE (username = lower(?) OR email = lower(?)) AND is_activated = TRUE LIMIT 1',
[htmlspecialchars($username, ENT_QUOTES), $username])->result_array(); [htmlspecialchars($username, ENT_QUOTES), $username])->result_array();
$this->db->cache_on();
return $return; return $return;
} }
@ -47,26 +55,26 @@
public function startLoginSession($logindata, $rememberMe) public function startLoginSession($logindata, $rememberMe)
{ {
$_SESSION['user']['displayname'] = $logindata['displayname']; $this->reloadLoginSession($logindata);
$_SESSION['user']['username'] = $logindata['username'];
$_SESSION['user']['rank'] = $logindata['rank'];
$_SESSION['user']['ID'] = $logindata['ID'];
$_SESSION['user']['ads'] = $logindata['showAds'];
$profilePic = $logindata['profile_picture'];
if (empty($profilePic)) {
$_SESSION['user']['profilePic'] = '/assets/images/steam.jpg';
} else {
$_SESSION['user']['profilePic'] = $profilePic;
}
$this->db->query('UPDATE users SET isCurrentlyOnline = 1, lastLogin = CURRENT_TIMESTAMP() WHERE ID = ?', [$logindata['ID']]); $this->db->query('UPDATE users SET isCurrentlyOnline = 1, lastLogin = CURRENT_TIMESTAMP() WHERE ID = ?', [$logindata['ID']]);
if ($rememberMe == 'on') { if ($rememberMe == 'on') {
$expire = time() + 3600 * 24 * 60; $expire = 3600 * 24 * 60;
$userHash = $this->LoginModel->getUserHash($logindata['username'], $logindata['password'], $logindata['email'], $logindata['ID']); $userHash = $this->LoginModel->getUserHash($logindata['username'], $logindata['password'], $logindata['email'], $logindata['ID']);
var_dump($expire); // $this->input->set_cookie('rememberMe', base64_encode($logindata['username']), $expire, base_url(), '/');
set_cookie('rememberMe', base64_encode($logindata['username']), $expire, base_url(), '/'); // $this->input->set_cookie('token', $userHash, $expire, base_url(), '/');
set_cookie('token', $userHash, $expire, base_url(), '/');
var_dump(get_cookie('rememberMe'));
echo 'fresh';
var_dump($_COOKIE);
$_COOKIE['rememberMe'] = base64_encode($logindata['username']);
$_COOKIE['token'] = $userHash;
echo 'tech';
// var_dump(get_cookie('rememberMe'));
// var_dump(get_cookie('token'));
var_dump($_COOKIE);
} }
} }
@ -83,6 +91,8 @@
} else { } else {
$_SESSION['user']['profilePic'] = $profilePic; $_SESSION['user']['profilePic'] = $profilePic;
} }
$_SESSION['user']['permissions'] = $this->UserModel->getPermissions($logindata['ID']);
} }
public function isTrashMail($email) public function isTrashMail($email)
@ -133,13 +143,16 @@
if (isset($_SESSION['loggedOut']) && $_SESSION['loggedOut']) { if (isset($_SESSION['loggedOut']) && $_SESSION['loggedOut']) {
return; return;
} }
var_dump('test');
if (!isset($_SESSION['user']) && isset($_COOKIE['rememberMe']) && isset($_COOKIE['token'])) { if (!isset($_SESSION['user']) && isset($_COOKIE['rememberMe']) && isset($_COOKIE['token'])) {
var_dump($_COOKIE);
$logindata = $this->getLoginData(base64_decode($_COOKIE['rememberMe'])); $logindata = $this->getLoginData(base64_decode($_COOKIE['rememberMe']));
if (!empty($logindata)) { if (!empty($logindata)) {
$logindata = $logindata[0]; $logindata = $logindata[0];
$token = $this->getUserHash($logindata['username'], $logindata['password'], $logindata['email'], $logindata['ID']); $token = $this->getUserHash($logindata['username'], $logindata['password'], $logindata['email'], $logindata['ID']);
if ($_COOKIE['token'] == $token) { if ($_COOKIE['token'] == $token) {
echo '<br> TEST! <br>';
$this->startLoginSession($logindata, 'on'); $this->startLoginSession($logindata, 'on');
} }
} }

View File

@ -82,7 +82,7 @@
$this->db->cache_delete('Main', 'getNotifications'); $this->db->cache_delete('Main', 'getNotifications');
// Send email // Send email
$email = $this->UserModel->getUserEmailByID($notification->sender->getId()); $email = $this->UserModel->getUserEmailByID($notification->recipient->getId());
$group = new NotificationGroup([$notification], 1); $group = new NotificationGroup([$notification], 1);
$messageData = $group->message(); $messageData = $group->message();
$message = sprintf(lang($messageData['line']), ...$messageData['attributes']); $message = sprintf(lang($messageData['line']), ...$messageData['attributes']);

View File

@ -13,7 +13,7 @@
function getUser($username) function getUser($username)
{ {
$result = $this->db->query('SELECT ID, username, displayname, email, rank, profile_picture, header_image, about, social_networks, showAds, date_created, gender, language, country, birthdate, birthyear, receiveEmails, receiveNewsletter FROM users WHERE username = ? AND is_activated = TRUE LIMIT 1', [$username])->result_array(); $result = $this->db->query('SELECT ID, username, displayname, email, rank, profile_picture, header_image, about, social_networks, showAds, date_created, gender, language, country, birthdate, birthyear, receiveEmails, receiveNewsletter FROM users WHERE username = ? AND is_activated = TRUE AND isDeleted = FALSE LIMIT 1', [$username])->result_array();
if (empty($result)) { if (empty($result)) {
return null; return null;
} }
@ -26,7 +26,7 @@
{ {
for ($i = 0; $i < sizeof($userList); $i++) { for ($i = 0; $i < sizeof($userList); $i++) {
if ((isset($userList[$i]['header_image']) && ($userList[$i]['header_image'] == '' || $userList[$i]['header_image'] == NULL)) || !isset($userList[$i]['header_image'])) { if ((isset($userList[$i]['header_image']) && ($userList[$i]['header_image'] == '' || $userList[$i]['header_image'] == NULL)) || !isset($userList[$i]['header_image'])) {
$userList[$i]['header_image'] = substr(base_url(), 0, base_url() - 1) . ':5000/' . $userList[$i]['displayname']; $userList[$i]['header_image'] = 'https://cdn.kinogofdog.eu' . '/' . $userList[$i]['displayname'];
} }
if (isset($userList[$i]['profile_picture']) && $userList[$i]['profile_picture'] == '') { if (isset($userList[$i]['profile_picture']) && $userList[$i]['profile_picture'] == '') {
$userList[$i]['profile_picture'] = base_url('/f/8d204712d8132b36d765640ce775ce15'); $userList[$i]['profile_picture'] = base_url('/f/8d204712d8132b36d765640ce775ce15');
@ -64,7 +64,7 @@
public function getFollowers($id) public function getFollowers($id)
{ {
$this->db->cache_off(); $this->db->cache_off();
$followers = $this->db->query('SELECT ID, followedSince, username, displayname, profile_picture, header_image FROM user_followers LEFT JOIN users ON ID = followerUserID WHERE followedUserID = ? ORDER BY followedSince DESC', [$id])->result_array(); $followers = $this->db->query('SELECT ID, followedSince, username, displayname, profile_picture, header_image FROM user_followers LEFT JOIN users ON ID = followerUserID WHERE followedUserID = ? AND is_activated = TRUE AND isDeleted = FALSE ORDER BY followedSince DESC', [$id])->result_array();
$this->db->cache_on(); $this->db->cache_on();
$followers = $this->setDefaultImages($followers); $followers = $this->setDefaultImages($followers);
$followers = $this->mergeFollowerCount($followers); $followers = $this->mergeFollowerCount($followers);
@ -73,7 +73,7 @@
function getUserByID($id) function getUserByID($id)
{ {
$result = $this->db->query('SELECT ID, original_name, username, displayname, email, rank, profile_picture, header_image, is_activated, about, lastLogin, social_networks, showAds, date_created, gender, language, country, birthdate, birthyear, receiveEmails, receiveNewsletter FROM users WHERE ID = ? AND is_activated = TRUE LIMIT 1', [$id])->result_array(); $result = $this->db->query('SELECT ID, original_name, username, displayname, email, rank, profile_picture, header_image, is_activated, about, lastLogin, social_networks, showAds, date_created, gender, language, country, birthdate, birthyear, receiveEmails, receiveNewsletter FROM users WHERE ID = ? AND is_activated = TRUE AND isDeleted = FALSE LIMIT 1', [$id])->result_array();
if (empty($result)) { if (empty($result)) {
return null; return null;
} }
@ -83,14 +83,14 @@
} }
function getUserEmailByID($id) { function getUserEmailByID($id) {
$result = $this->db->query('SELECT email FROM users WHERE ID = ? AND is_activated = TRUE', [$id])->result_array(); $result = $this->db->query('SELECT email FROM users WHERE ID = ? AND is_activated = TRUE AND isDeleted = TRUE', [$id])->result_array();
return !empty($result) ? $result[0]['email'] : ''; return !empty($result) ? $result[0]['email'] : '';
} }
public function getFollowing($id) public function getFollowing($id)
{ {
$this->db->cache_off(); $this->db->cache_off();
$following = $this->db->query('SELECT ID, followedSince, username, displayname, profile_picture, header_image FROM user_followers LEFT JOIN users ON ID = followedUserID WHERE followerUserID = ? ORDER BY followedSince DESC', [$id])->result_array(); $following = $this->db->query('SELECT ID, followedSince, username, displayname, profile_picture, header_image FROM user_followers LEFT JOIN users ON ID = followedUserID WHERE followerUserID = ? AND isDeleted = FALSE ORDER BY followedSince DESC', [$id])->result_array();
$this->db->cache_on(); $this->db->cache_on();
$following = $this->setDefaultImages($following); $following = $this->setDefaultImages($following);
$following = $this->mergeFollowerCount($following); $following = $this->mergeFollowerCount($following);
@ -187,14 +187,14 @@ WHERE user_id = ?', [$userID, $userID, $userID])->result_array()[0];
function getActiveUsers($count) function getActiveUsers($count)
{ {
$data = $this->db->query('SELECT username, displayname, profile_picture, lastLogin, (SELECT COUNT(*) FROM user_followers WHERE followedUserID = users.ID) follower_count FROM users WHERE isCurrentlyOnline = TRUE ORDER BY lastLogin DESC LIMIT ?', [$count])->result_array(); $data = $this->db->query('SELECT username, displayname, profile_picture, lastLogin, (SELECT COUNT(*) FROM user_followers WHERE followedUserID = users.ID) follower_count FROM users WHERE isCurrentlyOnline = TRUE AND is_activated = TRUE AND isDeleted = FALSE ORDER BY lastLogin DESC LIMIT ?', [$count])->result_array();
$data = $this->setDefaultImages($data); $data = $this->setDefaultImages($data);
return $data; return $data;
} }
public function getNewestUsers($count) public function getNewestUsers($count)
{ {
$data = $this->db->query('SELECT username, displayname, profile_picture, date_created, (SELECT COUNT(*) FROM user_followers WHERE followedUserID = users.ID) follower_count FROM users ORDER BY date_created DESC LIMIT ?', [$count])->result_array(); $data = $this->db->query('SELECT username, displayname, profile_picture, date_created, (SELECT COUNT(*) FROM user_followers WHERE followedUserID = users.ID) follower_count FROM users WHERE is_activated = TRUE AND isDeleted = FALSE ORDER BY date_created DESC LIMIT ?', [$count])->result_array();
$data = $this->setDefaultImages($data); $data = $this->setDefaultImages($data);
return $data; return $data;
} }
@ -222,7 +222,7 @@ WHERE user_id = ?', [$userID, $userID, $userID])->result_array()[0];
$dbClause = join(' AND ', $conditions); $dbClause = join(' AND ', $conditions);
$inputs[] = $amount; $inputs[] = $amount;
$inputs[] = $offset; $inputs[] = $offset;
$data = $this->db->query('SELECT username, displayname, profile_picture, header_image, about, rank FROM users WHERE ' . $dbClause . ' LIMIT ? OFFSET ?', $inputs)->result_array(); $data = $this->db->query('SELECT username, displayname, profile_picture, header_image, about, rank FROM users WHERE is_activated = TRUE AND isDeleted = FALSE AND ' . $dbClause . ' LIMIT ? OFFSET ?', $inputs)->result_array();
$data = $this->setDefaultImages($data); $data = $this->setDefaultImages($data);
$data = $this->setRankname($data); $data = $this->setRankname($data);
@ -238,4 +238,36 @@ WHERE user_id = ?', [$userID, $userID, $userID])->result_array()[0];
return $this->db->query('SELECT language, count(*) langUserCount FROM users GROUP BY language ORDER BY language')->result_array(); return $this->db->query('SELECT language, count(*) langUserCount FROM users GROUP BY language ORDER BY language')->result_array();
} }
public function deleteUser($id) {
$this->db->query('UPDATE users SET isDeleted = TRUE, isCurrentlyOnline = FALSE, lastOnlineUpdate = NULL WHERE ID = ?', [$id])->result_array();
}
public function getPermissions($userID) {
$this->db->cache_off();
$result = $this->db->query('SELECT * FROM user_permissions WHERE userID = ?', [$userID])->result_array();
$this->db->cache_on();
$perms = [];
foreach ($result as $item) {
$perms[] = $item['permissionType'] . '.' . $item['permissionName'];
}
return $perms;
}
public function hasPermission($userID, $permType, $permName) {
$this->db->cache_off();
$result = $this->db->query('SELECT ID FROM user_permissions WHERE userID = ? AND permissionType = ? AND permissionName = ?', [$userID, $permType, $permName])->result_array();
$this->db->cache_on();
return !empty($result);
}
public function addPermission($userID, $permissionGroup, $permissionName, $givenBy) {
$this->db->query('INSERT INTO user_permissions (userID, permissionType, permissionName, givenBy) VALUES (?, ?, ?, ?)', [$userID, $permissionGroup, $permissionName, $givenBy]);
}
public function revokePermission($userID, $permissionGroup, $permissionName) {
$this->db->query('DELETE FROM user_permissions WHERE userID = ? AND permissionType = ? AND permissionName = ?', [$userID, $permissionGroup, $permissionName]);
}
} }

View File

@ -10,7 +10,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
<div class="clearfix"></div> <div class="clearfix"></div>
</div> </div>
<div class="x_content"> <div class="x_content">
<iframe src="/piwik/index.php?module=CoreHome&action=index&idSite=1&period=day&date=today" <iframe src="https://stats.kingofdog.eu/"
style="height:100vh;width:100%" frameborder="0" async></iframe> style="height:100vh;width:100%" frameborder="0" async></iframe>
</div> </div>
</div> </div>

View File

@ -33,7 +33,7 @@
?> ?>
<link href="<?= $styleName ?>" rel="stylesheet"> <link href="<?= $styleName ?>" rel="stylesheet">
<link rel="stylesheet" href="<?= base_url('assets/css/lib/fontawesome-all.min.css') ?>"> <link rel="stylesheet" href="<?= base_url('assets/css/lib/fontawesome-all-5.2.0.min.css') ?>">
<link href="/assets/images/ico/favicon.ico" rel="icon"> <link href="/assets/images/ico/favicon.ico" rel="icon">
</head> </head>
@ -91,64 +91,78 @@
<?php endif; ?> <?php endif; ?>
</ul> </ul>
</div> </div>
<div class="menu_section"> <?php if (get_instance()->hasPermission('blog.view')): ?>
<h3>Blog</h3>
<ul class="nav side-menu">
<li>
<a href="/admin/blog">
<i class="fa fa-comments"></i>
Blog-Posts
</a>
</li>
<li>
<a href="/admin/blog/trashbin">
<i class="fa fa-trash"></i>
Gelöschte Blog-Posts
</a>
</li>
<li>
<a href="/admin/blog/edit">
<i class="fa fa-edit"></i>
Blog-Post erstellen
</a>
</li>
</ul>
</div>
<?php if ($_SESSION['user']['rank'] >= 9): ?>
<div class="menu_section"> <div class="menu_section">
<h3>Verwaltung</h3> <h3>Blog</h3>
<ul class="nav side-menu"> <ul class="nav side-menu">
<?php if (get_instance()->hasPermission('blog.view')): ?>
<li>
<a href="/admin/blog">
<i class="fa fa-comments"></i>
Blog-Posts
</a>
</li>
<?php endif; ?>
<?php if (get_instance()->hasPermission('blog.view')): ?>
<li>
<a href="/admin/blog/trashbin">
<i class="fa fa-trash"></i>
Gelöschte Blog-Posts
</a>
</li>
<?php endif; ?>
<?php if (get_instance()->hasPermission('blog.create')): ?>
<li>
<a href="/admin/blog/edit">
<i class="fa fa-edit"></i>
Blog-Post erstellen
</a>
</li>
<?php endif; ?>
</ul>
</div>
<?php endif; ?>
<div class="menu_section">
<h3>Verwaltung</h3>
<ul class="nav side-menu">
<?php if (get_instance()->hasPermission('projects.view')): ?>
<li> <li>
<a href="/admin/projects"> <a href="/admin/projects">
<i class="fa fa-camera"></i> <i class="fa fa-camera"></i>
Projekte Projekte
</a> </a>
</li> </li>
<?php endif; ?>
<?php if (get_instance()->hasPermission('projects.create')): ?>
<li> <li>
<a href="/admin/projects/edit"> <a href="/admin/projects/edit">
<i class="fa fa-plus"></i> <i class="fa fa-plus"></i>
Projekt erstellen Projekt erstellen
</a> </a>
</li> </li>
<?php endif; ?>
<?php if (get_instance()->hasPermission('file.view')): ?>
<li> <li>
<a href="/admin/files"> <a href="/admin/files">
<i class="fa fa-folder-open"></i> <i class="fa fa-folder-open"></i>
Dateien Dateien
</a> </a>
</li> </li>
<?php endif; ?>
<?php if (get_instance()->hasPermission('redirect.view')): ?>
<li> <li>
<a href="/admin/redirects"> <a href="/admin/redirects">
<i class="fa fa-arrow-right"></i> <i class="fa fa-arrow-right"></i>
Weiterleitungen Weiterleitungen
</a> </a>
</li> </li>
</ul> <?php endif; ?>
</div> </ul>
<?php endif; ?> </div>
<div class="menu_section"> <div class="menu_section">
<h3>Nutzer</h3> <h3>Nutzer</h3>
<ul class="nav side-menu"> <ul class="nav side-menu">
<?php if ($_SESSION['user']['rank'] >= 9): ?> <?php if (get_instance()->hasPermission('user.view')): ?>
<li> <li>
<a href="/admin/users"> <a href="/admin/users">
<i class="fa fa-users"></i> <i class="fa fa-users"></i>
@ -156,7 +170,7 @@
</a> </a>
</li> </li>
<?php endif; ?> <?php endif; ?>
<?php if ($_SESSION['user']['rank'] >= 9): ?> <?php if (get_instance()->hasPermission('feedback.receive')): ?>
<li> <li>
<a href="/admin/feedback"> <a href="/admin/feedback">
<i class="fa fa-comments"></i> <i class="fa fa-comments"></i>
@ -164,7 +178,7 @@
</a> </a>
</li> </li>
<?php endif; ?> <?php endif; ?>
<?php if ($_SESSION['user']['rank'] >= 8): ?> <?php if (get_instance()->hasPermission('contact.view')): ?>
<li> <li>
<a href="/admin/contact"> <a href="/admin/contact">
<i class="fa fa-envelope"></i> <i class="fa fa-envelope"></i>

View File

@ -1,5 +1,5 @@
<?php <?php
defined('BASEPATH') OR exit('No direct script access allowed'); defined('BASEPATH') OR exit('No direct script access allowed');
?> ?>
<div class="right_col" role="main"> <div class="right_col" role="main">
<div class="row"> <div class="row">
@ -77,5 +77,36 @@ defined('BASEPATH') OR exit('No direct script access allowed');
</div> </div>
</div> </div>
</div> </div>
<div class="col-md-6 col-sm-4 col-xs-4">
<div class="x_panel">
<div class="x_title">
<h2>Individuelle Rechte</h2>
<div class="clearfix"></div>
</div>
<div class="x_content">
<form method="POST" class="form">
<?php foreach ($availablePermissions as $group => $perms): ?>
<h4>
<?= $group ?>
<input type="checkbox" class="group-all">
</h4>
<ul>
<?php foreach ($perms as $perm):
$name = $group . '.' . $perm; ?>
<li>
<label data-toggle="tooltip" title="blablabla" for="<?= $group . $perm ?>"><?= $name ?></label>
<input type="checkbox" value="true" name="permissions[<?= $group . $perm ?>]" id="<?= $group . $perm ?>" <?= in_array($name, $permissions) ? 'checked' : '' ?>>
</li>
<?php endforeach; ?>
</ul>
<?php endforeach; ?>
<input type="submit" class="btn btn-primary" value="Speichern">
</form>
</div>
</div>
</div>
</div> </div>
</div> </div>

View File

@ -55,10 +55,11 @@
]; ];
$loginMethod = $loginMethods[$user['login_method']]; $loginMethod = $loginMethods[$user['login_method']];
$date_created = strtotime($user['date_created']); $dateCreated = strtotime($user['date_created']);
$last_login = strtotime($user['lastLogin']); $lastLogin = strtotime($user['lastLogin']);
$date_created_str = DateTimeHumanizer::difference(new \DateTime(), new \DateTime("@$date_created"), "de_DE"); $dateCreatedStr = DateTimeHumanizer::difference(new \DateTime(), new \DateTime("@$dateCreated"), "de_DE");
$last_login_str = DateTimeHumanizer::difference(new \DateTime(), new \DateTime("@$last_login"), "de_DE"); if($lastLogin)
$lastLoginStr = DateTimeHumanizer::difference(new \DateTime(), new \DateTime("@$lastLogin"), "de_DE");
?> ?>
<tr> <tr>
<td> <td>
@ -76,9 +77,9 @@
<?= $user['rankName'] ?> <?= $user['rankName'] ?>
</td> </td>
<td> <td>
<?= $date_created_str ?> <?= $dateCreatedStr ?>
<br> <br>
(<?= date("d.m.Y H:i", $date_created) ?>) (<?= date("d.m.Y H:i", $dateCreated) ?>)
</td> </td>
<td> <td>
<img src="<?= $user['profile_picture'] ?>?w=50" class="img-fluid rounded" <img src="<?= $user['profile_picture'] ?>?w=50" class="img-fluid rounded"
@ -104,9 +105,9 @@
<?= $loginMethod ?> <?= $loginMethod ?>
</td> </td>
<td> <td>
<?= $last_login_str ?> <?= $lastLoginStr ?>
<br> <br>
(<?= date("d.m.Y H:i", $last_login) ?>) (<?= date("d.m.Y H:i", $lastLogin) ?>)
</td> </td>
<td> <td>
<?= Locale::getDisplayLanguage($user['language'], "de") ?> <?= Locale::getDisplayLanguage($user['language'], "de") ?>
@ -114,14 +115,23 @@
<?= Locale::getDisplayRegion("-" . $user['country'], 'de') ?> <?= Locale::getDisplayRegion("-" . $user['country'], 'de') ?>
</td> </td>
<td> <td>
<?php if (isset($_SESSION['user']) && $_SESSION['user']['rank'] >= 8 && ($_SESSION['user']['rank'] > $user['rank'] || $_SESSION['user']['rank'] == 10)): ?> <?php if(get_instance()->hasPermission('user.viewDetails')): ?>
<a data-toggle="tooltip" data-placement="top" title="" data-original-title="Details" href="<?= base_url('admin/users/details/' . $user['ID']) ?>" target="_blank" class="btn btn-xs btn-default"> <a data-toggle="tooltip" data-placement="top" title="" data-original-title="Details" href="<?= base_url('admin/users/details/' . $user['ID']) ?>" target="_blank" class="btn btn-xs btn-default">
<i class="fa fa-info-circle"></i> <i class="fa fa-info-circle"></i>
</a> </a>
<?php endif; ?>
<?php if(get_instance()->hasPermission('user.viewDetails')): ?>
<a data-toggle="tooltip" data-placement="top" title="" data-original-title="Einstellungen" href="<?= base_url('admin/users/settings/' . $user['ID']) ?>" target="_blank" class="btn btn-xs btn-default"> <a data-toggle="tooltip" data-placement="top" title="" data-original-title="Einstellungen" href="<?= base_url('admin/users/settings/' . $user['ID']) ?>" target="_blank" class="btn btn-xs btn-default">
<i class="fa fa-cog"></i> <i class="fa fa-cog"></i>
</a> </a>
<?php endif; ?> <?php endif; ?>
<?php if(get_instance()->hasPermission('user.ban')): ?>
<a data-toggle="tooltip" data-placement="top" title="" data-original-title="Account löschen" onclick="showDeleteModal(<?= $user['ID'] ?>. <?= $user['username'] ?>)" target="_blank" class="btn btn-xs btn-red">
<i class="fas fa-user-slash"></i>
</a>
<?php endif; ?>
</td> </td>
</tr> </tr>
<?php endforeach; ?> <?php endforeach; ?>

View File

@ -127,6 +127,21 @@
}); });
})(jQuery); })(jQuery);
</script> </script>
<script type="text/javascript">
var _paq = _paq || [];
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u="//stats.kingofdog.eu/";
_paq.push(['setTrackerUrl', u+'piwik.php']);
_paq.push(['setSiteId', '1']);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s);
})();
</script>
<!--<script type="text/javascript"> <!--<script type="text/javascript">
var _paq = _paq || []; var _paq = _paq || [];
_paq.push(['trackPageView']); _paq.push(['trackPageView']);

View File

@ -1,12 +1,5 @@
<?php <?php
defined('BASEPATH') OR exit('No direct script access allowed'); defined('BASEPATH') OR exit('No direct script access allowed');
$this->LoginModel->autoLogin();
if (!isset($_SESSION['site_lang']) && isset($_COOKIE['language']) && in_array($_COOKIE['language'], ['de', 'en', 'fr'])) {
$this->session->set_userdata('site_lang', $_COOKIE['language']);
redirect(base_url(uri_string()));
}
?> ?>
<!DOCTYPE html> <!DOCTYPE html>
<html lang="<?= $_SESSION['site_lang'] ?>"> <html lang="<?= $_SESSION['site_lang'] ?>">
@ -138,7 +131,7 @@
<i class="fa fa-user-edit"></i> <i class="fa fa-user-edit"></i>
<?= lang('header_edit_profile') ?> <?= lang('header_edit_profile') ?>
</a> </a>
<?php if ($_SESSION['user']['rank'] >= 6): ?> <?php if (get_instance()->hasPermission('dashboard.view')): ?>
<a href="<?= base_url('admin') ?>" class="dropdown-item"> <a href="<?= base_url('admin') ?>" class="dropdown-item">
<i class="fa fa-tachometer-alt"></i> <i class="fa fa-tachometer-alt"></i>
<?= lang('header_admin_panel') ?> <?= lang('header_admin_panel') ?>

View File

@ -34,7 +34,7 @@
</p> </p>
<br> <br>
<a class="boxed btn btn-md animation animated-item-4" <a class="boxed btn btn-md animation animated-item-4"
href="<?= base_url('portfolio') ?>"> href="<?= base_url('projects') ?>">
<?= lang('home_slider_portfolio_btn') ?> <?= lang('home_slider_portfolio_btn') ?>
</a> </a>
</div> </div>
@ -140,70 +140,57 @@
</a> </a>
</section> </section>
<!--/#main-slider--> <!--/#main-slider-->
<section class="container">
<h1><?= lang('home_channels_title') ?></h1> <section class="container-fluid p-0">
<div class="row"> <div class="container">
<div class="row justify-content-center"> <div class="row my-2">
<div class="col-xs-12 col-md-6"> <div class="col">
<div class="row justify-content-center"> <h1><?= lang('home_channels_title') ?></h1>
<div class="col-xs-4 mx-4 m-sm-0">
<a href="https://www.youtube.de/KingOfDog" target="_blank">
<img src="/f/59768b61257e439b593ff2fb112d5079?w=200" class="img-fluid rounded">
</a>
</div>
<div class="col mr-4 m-sm-0">
<a href="https://www.youtube.de/KingOfDog" target="_blank">
<h2>KingOfDog</h2>
</a>
<p class="text-justify"><?= lang('home_kingofdog_des') ?></p>
</div>
</div>
</div> </div>
<div class="col-xs-12 col-md-6"> </div>
<div class="row justify-content-center"> </div>
<div class="col-xs-4 mx-4 m-sm-0">
<a href="https://www.youtube.com/channel/UCossYe6KMMhf9HJ9Uaqtu-g" target="_blank"> <div class="tilted-columns">
<img src="/f/fbee51f02df362fc8cca5a2a177e1852?w=200" class="img-fluid rounded"> <div class="tilted-column">
</a> <img class="column-image" src="/f/59768b61257e439b593ff2fb112d5079" alt="KingOfDog Logo">
</div> <div class="column-caption">
<div class="col mr-4 m-sm-0"> <h1 class="column-title">KingOfDog</h1>
<a href="https://www.youtube.com/channel/UCossYe6KMMhf9HJ9Uaqtu-g" target="_blank"> <h3 class="column-desc"><?= lang('home_kingofdog_des') ?></h3>
<h2>ZeybeFX</h2>
</a>
<p class="text-justify"><?= lang('home_zeybefx_des') ?></p>
</div>
</div>
</div> </div>
<div class="w-100"></div> </div>
<div class="col-xs-12 col-md-6"> <div class="tilted-column">
<div class="row justify-content-center"> <img class="column-image" src="/f/3c930821892961aba30c7f91df1e5d4e" alt="ZeybeFX Logo">
<div class="col-xs-4 mx-4 m-sm-0"> <div class="column-caption">
<a href="https://www.youtube.com/channel/UCJ1_Tj4SVkU5h9a8Q0VrB4A" target="_blank"> <h1 class="column-title">ZeybeFX</h1>
<img src="/f/b1771da2202f7fc83325520be61d961a?w=200" class="img-fluid rounded"> <h3 class="column-desc"><?= lang('home_zeybefx_des') ?></h3>
</a>
</div>
<div class="col mr-4 m-sm-0">
<a href="https://www.youtube.com/channel/UCJ1_Tj4SVkU5h9a8Q0VrB4A" target="_blank">
<h2>ZeybeOfficial</h2>
</a>
<p class="text-justify"><?= lang('home_zeybeofficial_des') ?></p>
</div>
</div>
</div> </div>
<div class="col-xs-12 col-md-6"> </div>
<div class="row justify-content-center"> <div class="tilted-column">
<div class="col-xs-4 mx-4 m-sm-0"> <img class="column-image" src="/f/54c5963da3587342cb34336fd15c87aa" alt="ZeybeOfficial Logo">
<a href="https://www.youtube.com/channel/UCthOkS9cpKgnBSj7AdR1rDg" target="_blank"> <div class="column-caption">
<img src="/f/972a648bc945712b44dd2b020150d3d5?w=200" class="img-fluid rounded"> <h1 class="column-title">ZeybeOfficial</h1>
</a> <h3 class="column-desc"><?= lang('home_zeybeofficial_des') ?></h3>
</div> </div>
<div class="col mr-4 m-sm-0"> </div>
<a href="https://www.youtube.com/channel/UCthOkS9cpKgnBSj7AdR1rDg" target="_blank"> <div class="tilted-column">
<h2>KingOfDog International</h2> <img class="column-image" src="/f/7b3fd0b5fb3ef9565f396a266db14a64" alt="KingOfDog International Logo">
</a> <div class="column-caption">
<p class="text-justify"><?= lang('home_kingofdogint_des') ?></p> <h1 class="column-title">KingOfDog International</h1>
</div> <h3 class="column-desc"><?= lang('home_kingofdogint_des') ?></h3>
</div> </div>
</div>
<div class="tilted-column">
<img class="column-image" src="/f/d904d757da59e2d514d9b12604b9c8b6" alt="KingOfDogTV Logo">
<div class="column-caption">
<h1 class="column-title">KingOfDogTV</h1>
<h3 class="column-desc"><?= lang('home_kingofdogtv_des') ?></h3>
</div>
</div>
<div class="tilted-column">
<img class="column-image" src="/f/1771967ab185e4d62ff5963977032fd8" alt="MinePoint Logo">
<div class="column-caption">
<h1 class="column-title">MinePoint</h1>
<h3 class="column-desc"><?= lang('home_minepoint_des') ?></h3>
</div> </div>
</div> </div>
</div> </div>
@ -228,8 +215,8 @@
</section> </section>
<section class="container"> <section class="container">
<div class="row"> <div class="grid grid-kod-network">
<div class="col-xs-12 col-sm-12 col-md-6 col-lg-4"> <div class="item-active">
<h2><?= lang('home_active_users') ?></h2> <h2><?= lang('home_active_users') ?></h2>
<?php foreach ($currentlyActiveUsers as $activeUser): <?php foreach ($currentlyActiveUsers as $activeUser):
$loginTime = strtotime($activeUser['lastLogin']); ?> $loginTime = strtotime($activeUser['lastLogin']); ?>
@ -245,7 +232,7 @@
</div> </div>
<?php endforeach; ?> <?php endforeach; ?>
</div> </div>
<div class="col-xs-12 col-sm-12 col-md-6 col-lg-4"> <div class="item-newest">
<h2><?= lang('home_newest_users') ?></h2> <h2><?= lang('home_newest_users') ?></h2>
<?php <?php
foreach ($newestUsers as $newestUser): foreach ($newestUsers as $newestUser):
@ -263,7 +250,7 @@
</div> </div>
<?php endforeach; ?> <?php endforeach; ?>
</div> </div>
<div class="col-xs-12 col-sm-12 col-md-6 col-lg-4"> <div class="item-posts">
<h2><?= lang('home_newest_posts') ?></h2> <h2><?= lang('home_newest_posts') ?></h2>
<ul class="comment-list"> <ul class="comment-list">
<?php foreach ($newestPosts as $newestPost): <?php foreach ($newestPosts as $newestPost):

View File

@ -1,14 +1,13 @@
<?php <?php
defined('BASEPATH') OR exit('No direct script access allowed'); defined('BASEPATH') OR exit('No direct script access allowed');
$this->load->view('network/user/profile_page_header'); $this->load->view('network/user/profile_page_header');
?> ?>
<section class="container" id="profile-content" data-type="foreground" data-speed="10"> <section class="container" id="profile-content" data-type="foreground" data-speed="10">
<div class="row"> <div class="row">
<!-- --><?php //$this->load->view('network/user/user_profile_card') ?> <!-- --><?php //$this->load->view('network/user/user_profile_card') ?>
<div class="col-xs-12 col-sm-12 col-md-4 col-lg-4"></div> <div class="col-xs-12 col-sm-12 col-md-8 col-lg-8 offset-md-2" id="profile-content-container">
<div class="col-xs-12 col-sm-12 col-md-8 col-lg-8" id="profile-content-container">
<?= $message ?> <?= $message ?>
<h1>Profil bearbeiten</h1> <h1 class="text-center">Profil bearbeiten</h1>
<div class="row"> <div class="row">
<div class="col-3"> <div class="col-3">
<div class="nav nav-pills flex-column" role="tablist" aria-orientation="vertical"> <div class="nav nav-pills flex-column" role="tablist" aria-orientation="vertical">
@ -24,6 +23,11 @@ $this->load->view('network/user/profile_page_header');
<br> <br>
E-Mail E-Mail
</a> </a>
<a href="#messages" class="nav-link text-center" role="tab" data-toggle="pill" id="messages-pill" aria-controls="messages" aria-selected="false">
<i class="fa fa-bell"></i>
<br>
Nachrichten
</a>
<a href="#password" class="nav-link text-center" role="tab" data-toggle="pill" <a href="#password" class="nav-link text-center" role="tab" data-toggle="pill"
id="password-pill" aria-controls="password" aria-selected="false"> id="password-pill" aria-controls="password" aria-selected="false">
<i class="fa fa-lock"></i> <i class="fa fa-lock"></i>
@ -1126,22 +1130,27 @@ $this->load->view('network/user/profile_page_header');
<form method="post"> <form method="post">
<div class="form-group"> <div class="form-group">
<label for="email">E-Mail-Adresse</label> <label for="email">E-Mail-Adresse</label>
<input type="email" class="form-control" name="email" <input type="email" class="form-control" name="email" id="email"
value="<?= isset($data['email']) ? $data['email'] : "" ?>"> value="<?= isset($data['email']) ? $data['email'] : "" ?>">
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="email-password">Passwort zur Bestätigung der E-Mail-Adresse</label> <label for="email-password">Passwort zur Bestätigung der E-Mail-Adresse</label>
<input type="password" class="form-control" name="email-password" <input type="password" class="form-control" name="email-password" id="email-password"
placeholder="Bitte gebe dein derzeitiges Passwort ein"> placeholder="Bitte gebe dein derzeitiges Passwort ein">
</div> </div>
<input type="submit" class="btn btn-primary" value="Speichern">
</form>
</div>
<div class="tab-pane fade" id="messages" role="tabpanel" aria-labelledby="messages-pill">
<form method="post">
<div class="form-group"> <div class="form-group">
<input type="checkbox" value="true" <input type="checkbox" value="true"
name="email-notifications" <?= isset($data['receiveEmails']) && $data['receiveEmails'] ? "checked" : "" ?>> rel="email-notifications" id="email-notifications" <?= isset($data['receiveEmails']) && $data['receiveEmails'] ? "checked" : "" ?>>
<label for="email-notifications">E-Mail Benachrichtigungen</label> <label for="email-notifications">E-Mail Benachrichtigungen</label>
</div> </div>
<div class="form-group"> <div class="form-group">
<input type="checkbox" value="true" <input type="checkbox" value="true"
name="newsletter" <?= isset($data['receiveNewsletter']) && $data['receiveNewsletter'] ? "checked" : "" ?>> rel="newsletter" id="newsletter" <?= isset($data['receiveNewsletter']) && $data['receiveNewsletter'] ? "checked" : "" ?>>
<label for="newsletter">Newsletter</label> <label for="newsletter">Newsletter</label>
</div> </div>
<input type="submit" class="btn btn-primary" value="Speichern"> <input type="submit" class="btn btn-primary" value="Speichern">
@ -1151,44 +1160,51 @@ $this->load->view('network/user/profile_page_header');
<form method="post"> <form method="post">
<div class="form-group"> <div class="form-group">
<label for="passwordOld">Altes Passwort</label> <label for="passwordOld">Altes Passwort</label>
<input type="password" class="form-control" name="passwordOld"> <input type="password" class="form-control" name="passwordOld" id="passwordOld">
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="passwordNew">Neues Passwort</label> <label for="passwordNew">Neues Passwort</label>
<input type="password" class="form-control" name="passwordNew"> <input type="password" class="form-control" name="passwordNew" id="passwordNew">
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="passwordNewRepeat">Neues Passwort wiederholen</label> <label for="passwordNewRepeat">Neues Passwort wiederholen</label>
<input type="password" class="form-control" name="passwordNewRepeat"> <input type="password" class="form-control" name="passwordNewRepeat" id="passwordNewRepeat">
</div> </div>
<input type="submit" class="btn btn-primary" value="Speichern"> <input type="submit" class="btn btn-primary" value="Speichern">
</form> </form>
</div> </div>
<div class="tab-pane fade" id="premium" role="tabpanel" aria-labelledby="premium-pill"> <div class="tab-pane fade" id="premium" role="tabpanel" aria-labelledby="premium-pill">
<form method="post"> <form method="post">
<?php if (isset($_SESSION['user']['rank']) && $_SESSION['user']['rank'] >= 2): ?> <?php if (get_instance()->hasPermission('user.disableAds')): ?>
<div class="form-group"> <div class="form-group">
<input type="checkbox" name="showAds" value="true" <input type="checkbox" name="showAds" id="showAds" value="true"
aria-describedby="adHelp" <?= isset($data['showAds']) && $data['showAds'] ? "checked" : "" ?>> aria-describedby="adsThankYou" <?= isset($data['showAds']) && $data['showAds'] ? "checked" : "" ?>>
<label for="showAds">Werbung anzeigen und uns unterstützen</label> <label for="showAds">Werbung anzeigen und uns unterstützen</label>
<span class="help-block" id="adsHelp">Danke für deine bisherige Unterstützung durch Spenden. Solltest du dennoch weiterhin uns unterstützen wollen, kannst du freiwilligerweise Werbeanzeigen aktivieren. Wie immer gilt unser Motto: höchstens eine Anzeige pro Seite!</span> <small class="form-text text-muted" id="adsThankYou">Danke für deine bisherige Unterstützung durch Spenden. Solltest du dennoch weiterhin uns unterstützen wollen, kannst du freiwilligerweise Werbeanzeigen aktivieren. Wie immer gilt unser Motto: höchstens eine Anzeige pro Seite!</small>
</div> </div>
<?php else: ?> <?php else: ?>
<p class="text-warning">Um diese Einstellungen zu sehen und zu verändern, musst du <p class="text-warning">Um diese Einstellungen zu sehen und zu verändern, musst du
entweder ein Team-Mitglied, ein Plus-Nutzer oder ein Premium-Nutzer sein.</p> entweder ein Team-Mitglied, ein Plus-Nutzer oder ein Premium-Nutzer sein.</p>
<p>Premium-Nutzer kannst du werden, indem du einen beliebigen Betrag auf der <a <p>Premium-Nutzer kannst du werden, indem du einen beliebigen Betrag auf der
href="<?= base_url('donate') ?>">Spenden-Seite</a> hinterlässt. So <a
unterstützt du zum einen diese Webseite und sorgst für ein Weiterleben dieses href="<?= base_url('donate') ?>">Spenden-Seite
Services und gleichzeitig erhälst du die Möglichkeit, den Dienst ohne Werbung zu </a>
erleben.</p> hinterlässt. So
unterstützt du zum einen diese Webseite und sorgst für ein Weiterleben dieses
Services und gleichzeitig erhälst du die Möglichkeit, den Dienst ohne Werbung zu
erleben.
</p>
<p>Plus-Nutzer oder Team-Mitglied kannst du nur auf persönliche Einladung eines <p>Plus-Nutzer oder Team-Mitglied kannst du nur auf persönliche Einladung eines
hochrangigen Team-Mitgliedes werden. Der Plus-Rang wird beispielsweise an hochrangigen Team-Mitgliedes werden. Der Plus-Rang wird beispielsweise an
YouTuber, YouTuber,
bekannte Persönlichkeiten, sehr aktive Nutzer, sehr großzügige Spender, aktive bekannte Persönlichkeiten, sehr aktive Nutzer, sehr großzügige Spender, aktive
Abonnenten des Kanals <a href="https://youtube.com/KingOfDog" target="_blank">KingOfDog</a> Abonnenten des Kanals
oder Freunde und Bekannte vergeben.</p> <a href="https://youtube.com/KingOfDog" target="_blank">KingOfDog</a>
oder Freunde und Bekannte vergeben.
</p>
<p>Es gilt jedoch eine Regel: <b>Bitte. Nicht. Nach. Einem. Rang. Betteln.</b> Durch <p>Es gilt jedoch eine Regel: <b>Bitte. Nicht. Nach. Einem. Rang. Betteln.</b> Durch
eine solche Aktivität verfliegt eure Chance auf einen Rang.</p> eine solche Aktivität verfliegt eure Chance auf einen Rang.</p>
<?php endif; ?> <?php endif; ?>
</form> </form>
</div> </div>

View File

@ -106,6 +106,158 @@
animation: fadeInUp 300ms linear 1200ms both; animation: fadeInUp 300ms linear 1200ms both;
} }
.tilted-column {
position: relative;
width: calc((100% / 3) + 6px + (32px / 3));
height: 33vw;
display: inline-block;
margin-left: -6px;
overflow: hidden;
border-right: 10px solid transparent;
transform: skewX(-6deg);
}
.tilted-column:nth-child(3n+1) {
margin-left: -24px;
margin-right: 0 !important;
}
.tilted-column:nth-child(3n+3) {
margin-right: -32px;
border-right: 0;
}
.tilted-column > .column-image {
width: 100%;
transform: skewX(6deg) scale(1.1);
transition: transform .8s;
}
.tilted-column > .column-caption {
position: absolute;
width: 75%;
top: 100%;
left: 56%;
opacity: 0;
transform: skewX(6deg) translate(-50%, 0);
transition: all .8s;
}
.tilted-column > .column-caption > .column-title,
.tilted-column > .column-caption > .column-desc {
color: #fff;
background-color: rgba(0, 0, 0, .8);
padding: 4px 16px;
border-radius: 10px;
font-size: 2.5vw;
}
.tilted-column > .column-caption > .column-desc {
font-size: 1.25vw;
font-weight: bolder;
width: 100%;
}
.tilted-column:hover > .column-image {
transform: skewX(6deg) scale(1.5);
}
.tilted-column:hover > .column-caption {
top: 50%;
left: 54%;
transform: skewX(6deg) translate(-50%, -50%);
opacity: 1;
}
@media (max-width: 767px) {
.tilted-column {
width: calc(50% + 6px + (32px / 2));
height: 50vw;
}
.tilted-column:nth-child(3n+1) {
margin-left: -6px;
}
.tilted-column:nth-child(3n+3) {
margin-right: 0;
border-right: 10px solid transparent;
}
.tilted-column:nth-child(2n+1) {
margin-left: -24px;
margin-right: 0 !important;
}
.tilted-column:nth-child(2n + 2) {
margin-right: -32px !important;
border-right: none;
}
.tilted-column > .column-caption > .column-title {
font-size: 4vw;
}
.tilted-column > .column-caption > .column-desc {
font-size: 2.5vw;
}
}
@media (max-width: 575px) {
.tilted-column {
width: 100%;
height: 100vw;
margin: 10px 0 !important;
transform: none;
}
.tilted-column > .column-image {
transform: none;
}
.tilted-column > .column-caption {
left: 50%;
transform: translate(0, -50%);
}
.tilted-column:hover > .column-image {
transform: scale(1.5);
}
.tilted-column:hover > .column-caption {
left: 50%;
transform: translate(-50%, -50%);
}
}
.grid-kod-network {
grid-template-areas: "posts" "active" "newest";
}
@media (min-width: 768px) {
.grid-kod-network {
grid-template-areas: "posts posts" "active newest";
}
}
@media (min-width: 992px) {
.grid-kod-network {
grid-template-areas: "active posts" "newest posts";
}
}
.grid-kod-network > .item-active {
grid-area: active;
}
.grid-kod-network > .item-newest {
grid-area: newest;
}
.grid-kod-network > .item-posts {
grid-area: posts;
}
/* Backgrounds for social media posts */ /* Backgrounds for social media posts */
.bg-twitter { .bg-twitter {
background-color: #4099FF; background-color: #4099FF;

View File

@ -18,6 +18,13 @@ body > section {
padding: 50px 0; padding: 50px 0;
} }
.grid {
display: grid;
grid-template-columns: auto;
grid-template-rows: auto;
grid-gap: 10px 20px;
}
.dark { .dark {
background: #222222; background: #222222;
color: #FAFAFA; color: #FAFAFA;
@ -1836,26 +1843,20 @@ ul#downloadSlider a.active .overlay {
} }
.user-item { .user-item {
display: grid;
grid-template-columns: 50px 1fr;
grid-gap: 10px;
width: 100%; width: 100%;
background-color: #fff; background-color: #fff;
border-radius: 10px; border-radius: 10px;
box-shadow: 0 2px 2px 0 rgba(0, 0, 0, .5); box-shadow: 0 2px 2px 0 rgba(0, 0, 0, .25);
padding: 10px; padding: 10px;
margin-bottom: 10px; margin-bottom: 10px;
} }
.user-item img { .user-item img {
height: 50px; height: 50px;
display: inline-block;
vertical-align: top; vertical-align: top;
margin-right: 10px;
}
.user-item .user-info {
display: inline-block;
width: calc(100% - 60px);
float: right;
margin: 2.5px 0;
} }
.user-item .user-info h2 { .user-item .user-info h2 {

27
assets/js/admin_users.js Normal file
View File

@ -0,0 +1,27 @@
function showDeleteModal(userID, username) {
const modal = $(`
<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Bestätigung</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<b>Bist du dir sicher, dass du den Account von ${username} löschen möchtest?</b>
Die Account-Daten werden für eine gewisse Zeit noch auf dem Server gespeichert, allerdings wird der Nutzer nicht mehr dazu in der Lage sein, sich in seinen Account einzuloggen, und somit auch keine Posts, Kommentare etc. verfassen können.
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary">Account löschen</button>
<button type="button" class="btn btn-primary" data-dismiss="modal">Abbruch</button>
</div>
</div>
</div>
</div>
`);
$('body').append(modal);
modal.modal('show');
}

View File

@ -219,6 +219,26 @@ $(function () {
}); });
}); });
Number.prototype.pad = function(size) {
let s = String(this);
while(s.length < (size || 2)) s = "0" + s;
return s;
};
function convertDate(dbDate) {
const date = new Date(dbDate);
console.log(date);
const day = date.getDate().pad();
const month = (date.getMonth() + 1).pad();
const year = date.getFullYear();
const hour = date.getHours().pad();
const minutes = date.getMinutes().pad();
return `${day}.${month}.${year} ${hour}:${minutes}`;
}
function getPostData() { function getPostData() {
const postID = $('#postID').val(); const postID = $('#postID').val();
$.ajax({ $.ajax({
@ -234,7 +254,9 @@ function getPostData() {
$('#postUrl').val(result.postData.postUrl); $('#postUrl').val(result.postData.postUrl);
$('#postCategory').val(result.postData.postCategoryID); $('#postCategory').val(result.postData.postCategoryID);
switchCategory(); switchCategory();
$('#postPublishDate').val(result.postData.postPublishDate);
$('#postPublishDate').data('DateTimePicker').setValue(convertDate(result.postData.postPublishDate));
// $('#postPublishDate').val(convertDate(result.postData.postPublishDate));
$('#uploadedImage').val(result.postData.postImage); $('#uploadedImage').val(result.postData.postImage);
$('.img-container').css('background-image', 'url(' + result.postData.postImage + ')'); $('.img-container').css('background-image', 'url(' + result.postData.postImage + ')');

View File

@ -91,3 +91,15 @@ $(function () {
`) `)
}); });
}); });
const chk = $('input[type="checkbox"]');
chk.each(function () {
const v = $(this).is(':checked');
$(this).after(`<input type="hidden" name="${$(this).attr('rel')}" value="${v.toString()}" />`);
});
chk.change(function () {
const v = $(this).is(':checked');
$(this).next('input[type="hidden"]').val(v.toString());
});

28
assets/js/user-edit.js Normal file
View File

@ -0,0 +1,28 @@
$('.group-all').change(function () {
const v = $(this).is(':checked');
const items = $(this).parent().next('ul').children();
items.each(function () {
$(this).find('input[type=checkbox]').prop('checked', v);
});
});
$('input[type=checkbox]:not(.group-all)').change(function () {
const groupAll = $(this).parent().parent().prev('h4').find('.group-all');
if(!$(this).is(':checked')) {
groupAll.prop('checked', false);
} else {
const siblings = $(this).parent().siblings().find('input[type=checkbox]:not(:checked)');
if(siblings.length === 0) {
groupAll.prop('checked', true);
}
}
});
function checkSiblings() {
}
$(function () {
});

43
unregistered_images.py Normal file
View File

@ -0,0 +1,43 @@
#!/usr/bin/python3
from os import listdir, remove
from os.path import isfile, join, getsize
import hashlib, pymysql
files = [f for f in listdir('files') if isfile(join('files', f))]
db = pymysql.connect('localhost',
'kingofdog',
'123456',
'kingofdog')
cur = db.cursor()
def pushToDatabase(fileName, originalName, fileType, size, path, uploadDate, isUserData):
try:
cur.execute('INSERT INTO files (name, original_name, type, size, path, isUserData) VALUES (%s, %s, %s, %s, %s, %s)', (fileName, originalName, fileType, size, path, isUserData))
db.commit()
except:
db.rollback()
def checkInDatabase(name):
cur.execute('SELECT * FROM files WHERE name = %s', (name))
result = cur.fetchone()
return result != None
def findUnregisteredImages():
for file in files:
with open('./files/' + file, 'rb') as imageFile:
imageName = file.split(".")[0]
if(not checkInDatabase(imageName)):
print('Adding "' + imageName + '" to the database.')
fileType = 'image/jpeg'
size = getsize(imageFile.name)
path = imageFile.name[2:]
pushToDatabase(imageName, file, fileType, size, path, None, False)
print('Searching for unregistered files...')
findUnregisteredImages()
print('Successfully finished registering all previously unregistered files.')
db.close()