Initial commit as of 2018-10-16
This commit is contained in:
22
application/controllers/About.php
Normal file
22
application/controllers/About.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class About extends MY_Controller {
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct('about');
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
$this->load->view('header', ['active' => 'about', 'title' => lang('about_sitetitle')]);
|
||||
$this->load->view('about');
|
||||
$this->load->view('footer');
|
||||
}
|
||||
|
||||
public function impressum() {
|
||||
$this->load->view('header', ['active' => '', 'title' => 'Impressum']);
|
||||
$this->load->view('impressum');
|
||||
$this->load->view('footer');
|
||||
}
|
||||
}
|
188
application/controllers/Blog.php
Normal file
188
application/controllers/Blog.php
Normal file
@@ -0,0 +1,188 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Blog extends MY_Controller {
|
||||
|
||||
function __construct() {
|
||||
parent::__construct('blog');
|
||||
$this->load->model('BlogModel', '', TRUE);
|
||||
$this->load->helper('url');
|
||||
}
|
||||
|
||||
function index() {
|
||||
$offset = isset($_GET['page']) ? intval($_GET['page']) - 1 : 0;
|
||||
$data = $this->BlogModel->getAllPosts('', 5, $offset);
|
||||
|
||||
$this->load->view('header', ['active' => 'blog', 'title' => 'Blog', 'additionalStyles' => ['blog.css']]);
|
||||
$this->load->view('blog/first', ['categories' => $this->BlogModel->getCategories()]);
|
||||
|
||||
if(!empty($data)) {
|
||||
$pageCount = $this->BlogModel->getPostPageCount('', 5);
|
||||
$this->load->view('blog/postList', ['pageContent' => $data]);
|
||||
} else {
|
||||
$pageCount = 1;
|
||||
$this->load->view('blog/postListError', ['search' => '']);
|
||||
}
|
||||
|
||||
$this->load->view('footer', ['additionalScripts' => ['lib/jquery.twbsPagination.min.js']]);
|
||||
$this->load->view('blog/pagination', ['pageCount' => $pageCount]);
|
||||
}
|
||||
|
||||
function search($query = null) {
|
||||
if(isset($_GET['q'])) {
|
||||
redirect(base_url('blog/search/' . urlencode($this->input->get('q'))));
|
||||
} elseif($query == null) {
|
||||
redirect(base_url('blog'));
|
||||
} else {
|
||||
$query = $this->security->xss_clean(urldecode($query));
|
||||
$offset = isset($_GET['page']) ? intval($_GET['page']) - 1 : 0;
|
||||
$data = $this->BlogModel->getAllPosts($query, 5, $offset);
|
||||
|
||||
$this->load->view('header', ['active' => 'blog', 'title' => 'Blog', 'additionalStyles' => ['blog.css']]);
|
||||
$this->load->view('blog/first', ['categories' => $this->BlogModel->getCategories()]);
|
||||
|
||||
if(!empty($data)) {
|
||||
$pageCount = $this->BlogModel->getPostPageCount($query, 5);
|
||||
$this->load->view('blog/postList', ['pageContent' => $data]);
|
||||
} else {
|
||||
$pageCount = 1;
|
||||
$this->load->view('blog/postListError', ['search' => $query]);
|
||||
}
|
||||
|
||||
$this->load->view('footer');
|
||||
$this->load->view('blog/pagination', ['pageCount' => $pageCount]);
|
||||
}
|
||||
}
|
||||
|
||||
function category($category = null) {
|
||||
if($category == null) {
|
||||
redirect(base_url('blog'));
|
||||
} else {
|
||||
$category = urldecode($category);
|
||||
$offset = isset($_GET['page']) ? intval($_GET['page']) - 1 : 0;
|
||||
$data = $this->BlogModel->getCategoryPosts($category, 5, $offset);
|
||||
|
||||
$this->load->view('header', ['active' => 'blog', 'title' => 'Blog', 'additionalStyles' => ['blog.css']]);
|
||||
$this->load->view('blog/first', ['categories' => $this->BlogModel->getCategories()]);
|
||||
|
||||
if(!empty($data)) {
|
||||
$pageCount = $this->BlogModel->getPostPageCount('', 5);
|
||||
$this->load->view('blog/postList', ['pageContent' => $data]);
|
||||
} else {
|
||||
$pageCount = 1;
|
||||
$this->load->view('blog/postListError', ['search' => $category]);
|
||||
}
|
||||
|
||||
$this->load->view('footer');
|
||||
$this->load->view('blog/pagination', ['pageCount' => $pageCount]);
|
||||
}
|
||||
}
|
||||
|
||||
public function tag($tag = null) {
|
||||
if($tag == null) {
|
||||
redirect(base_url('blog'));
|
||||
}
|
||||
$tag = urldecode($tag);
|
||||
$offset = isset($_GET['page']) ? intval($_GET['page']) -1 : 0;
|
||||
$data = $this->BlogModel->getTagPosts($tag, 5, $offset);
|
||||
|
||||
$this->load->view('header', ['active' => 'blog', 'title' => 'Blog', 'additionalStyles' => ['blog.css']]);
|
||||
$this->load->view('blog/first', ['categories' => $this->BlogModel->getCategories()]);
|
||||
|
||||
if(!empty($data)) {
|
||||
$pageCount = $this->BlogModel->getPostPageCount('', 5);
|
||||
$this->load->view('blog/postList', ['pageContent' => $data]);
|
||||
} else {
|
||||
$pageCount = 1;
|
||||
$this->load->view('blog/postListError', ['search' => $tag]);
|
||||
}
|
||||
|
||||
$this->load->view('footer');
|
||||
$this->load->view('blog/pagination', ['pageCount' => $pageCount]);
|
||||
}
|
||||
|
||||
function add() {
|
||||
if(isset($_SESSION['user']) && $_SESSION['user']['rank'] >= 6) {
|
||||
redirect('/admin/blog/add');
|
||||
} else {
|
||||
redirect('/blog');
|
||||
}
|
||||
}
|
||||
|
||||
function post($postTitle = null) {
|
||||
if($postTitle == null) {
|
||||
redirect("/blog");
|
||||
} elseif(isset($_GET['q'])) {
|
||||
redirect('/blog?q=' . $_GET['q']);
|
||||
} else {
|
||||
$post = $this->BlogModel->getPost($postTitle);
|
||||
if(empty($post)) {
|
||||
redirect('/blog');
|
||||
} else {
|
||||
$post['randomPosts'] = $this->BlogModel->getRandomPosts($post['postID']);
|
||||
$post['comments'] = $this->BlogModel->getComments($post['postID']);
|
||||
$post['tags'] = $this->BlogModel->getTags($post['postID']);
|
||||
$post['hasLiked'] = isset($_SESSION['user']) && !empty($_SESSION['user']) ? $this->BlogModel->hasAlreadyLiked($post['postID'], $_SESSION['user']['ID']) : false;
|
||||
$sameCategoryPosts = $this->BlogModel->getCategoryPostsByID($post['postCategoryID'], 3, $post['postID']);
|
||||
|
||||
$post['prevPost'] = $this->BlogModel->getPrevPost($post['postID']);
|
||||
$post['nextPost'] = $this->BlogModel->getNextPost($post['postID']);
|
||||
|
||||
$this->BlogModel->incrementViews($post['postID']);
|
||||
|
||||
$this->load->view('header', ['active' => 'blog', 'title' => $post['postTitle'], 'additionalStyles' => ['posts_list.css', 'blog.css']]);
|
||||
$this->load->view('blog/first', ['categoryPosts' => $sameCategoryPosts, 'categories' => $this->BlogModel->getCategories()]);
|
||||
$this->load->view('blog/post', $post);
|
||||
$this->load->view('footer', ['additionalScripts' => ['lib/prism.js', 'blog.js']]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function like() {
|
||||
if(!isset($_SESSION['user']) || $_SESSION['user']['username'] == NULL) {
|
||||
echo "no-user";
|
||||
} else {
|
||||
if(!$this->BlogModel->hasAlreadyLiked($_POST['postID'], $_SESSION['user']['ID'])) {
|
||||
echo 'true:';
|
||||
echo $this->BlogModel->addLike($_POST['postID'], $_SESSION['user']['ID'])['likeCount'];
|
||||
} else {
|
||||
echo 'false:';
|
||||
echo $this->BlogModel->removeLike($_POST['postID'], $_SESSION['user']['ID'])['likeCount'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function comment() {
|
||||
if(!isset($_SESSION['user']) || $_SESSION['user']['username'] == NULL) {
|
||||
$result = ['type' => 'error', 'message' => 'Nicht eingeloggt'];
|
||||
} else {
|
||||
$url = $this->input->post('url');
|
||||
|
||||
$url = str_replace('/blog/post/', '', $url);
|
||||
|
||||
$comment = $this->BlogModel->addCommentByUrl($url, $_SESSION['user']['ID'], $this->input->post('comment'), false, NULL);
|
||||
$result = ['type' => 'success', 'content' => [
|
||||
'username' => $_SESSION['user']['username'],
|
||||
'displayname' => $_SESSION['user']['displayname'],
|
||||
'profilePic' => $_SESSION['user']['profilePic'],
|
||||
'date' => date('d.m.Y H: i \\U\\h\\r', strtotime($comment['date_created']))
|
||||
]];
|
||||
}
|
||||
|
||||
header("Content-Type: application/json");
|
||||
echo json_encode($result);
|
||||
}
|
||||
|
||||
function getComments() {
|
||||
$url = $this->input->get('url');
|
||||
|
||||
$url = str_replace('/blog/post/', '', $url);
|
||||
|
||||
$comments = $this->BlogModel->getCommentsByUrl($url);
|
||||
foreach($comments as $comment) {
|
||||
$comment['author'] = $this->BlogModel->getAuthorData($comment['user_id']);
|
||||
$this->load->view('blog/comment', $comment);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
16
application/controllers/Donate.php
Normal file
16
application/controllers/Donate.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Donate extends MY_Controller {
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct('donate');
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
$this->load->view('header', ['active' => 'donate', 'title' => lang('donate_title')]);
|
||||
$this->load->view('donate');
|
||||
$this->load->view('footer', ['additionalScripts' => ['donate.js']]);
|
||||
}
|
||||
}
|
16
application/controllers/Error404.php
Normal file
16
application/controllers/Error404.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Error404 extends MY_Controller {
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
$this->load->view('header', ['active' => '', 'title' => '404 - Seite nicht gefunden!']);
|
||||
$this->load->view('404', ['random' => rand(1, 3)]);
|
||||
$this->load->view('footer');
|
||||
}
|
||||
}
|
17
application/controllers/Faq.php
Normal file
17
application/controllers/Faq.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Faq extends MY_Controller {
|
||||
|
||||
public function __construct() {
|
||||
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');
|
||||
}
|
||||
}
|
||||
|
90
application/controllers/File.php
Normal file
90
application/controllers/File.php
Normal file
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class File extends MY_Controller
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function open($title = null, $download = false)
|
||||
{
|
||||
if ($title == null) {
|
||||
redirect(base_url());
|
||||
} else {
|
||||
$file = $this->db->query('SELECT name, type, path FROM files WHERE name = ?', [urldecode($title)])->result_array();
|
||||
|
||||
if (!empty($file)) {
|
||||
$file = $file[0];
|
||||
// TODO: FIX!
|
||||
// header("Content-length: " . $file['size']);
|
||||
header("Content-type: " . $file['type']);
|
||||
if ($download) {
|
||||
header("Content-Disposition: attachment; filename=" . $file['name'] . '.' . explode('/', $file['type'])[1]);
|
||||
}
|
||||
|
||||
$imagePath = 'files/' . (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];
|
||||
|
||||
if (!file_exists($imagePath)) {
|
||||
$config['image_library'] = 'gd2';
|
||||
$config['source_image'] = $file['path'];
|
||||
if (isset($_GET['w'])) {
|
||||
$config['width'] = $_GET['w'];
|
||||
}
|
||||
if (isset($_GET['h'])) {
|
||||
$config['height'] = $_GET['h'];
|
||||
}
|
||||
$config['maintain_ratio'] = TRUE;
|
||||
$config['new_image'] = $imagePath;
|
||||
|
||||
$this->load->library('image_lib', $config);
|
||||
|
||||
if (!$this->image_lib->resize()) {
|
||||
echo $this->image_lib->display_errors();
|
||||
}
|
||||
}
|
||||
readfile(base_url($imagePath));
|
||||
exit;
|
||||
} else {
|
||||
redirect(base_url());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function thumbnail($videoID = null)
|
||||
{
|
||||
if ($videoID !== null && strlen($videoID) == 11) {
|
||||
$thumbnail_url = "http://img.youtube.com/vi/" . $videoID . "/maxresdefault.jpg";
|
||||
header("Content-Type: image/jpeg");
|
||||
readfile($thumbnail_url);
|
||||
} else {
|
||||
redirect(base_url());
|
||||
}
|
||||
}
|
||||
|
||||
public function csgo($category = null, $item = null)
|
||||
{
|
||||
if ($category == null || $item == null) {
|
||||
redirect(base_url());
|
||||
} else {
|
||||
if ($category == 'weapon') {
|
||||
header("Content-Type: image/png");
|
||||
readfile('http://csgo-stats.com/img/weapons/3d/' . $item . '.png');
|
||||
} elseif ($category == 'map') {
|
||||
header("Content-Type: image/jpeg");
|
||||
readfile('http://csgo-stats.com/img/maps/' . $item . '.jpg');
|
||||
} elseif ($category = 'mapicon') {
|
||||
header("Content-Type: image/png");
|
||||
readfile('http://csgo-stats.com/img/maps/icons/' . $item . '.png');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function weapon()
|
||||
{
|
||||
header("Content-Type: image/jpeg");
|
||||
readfile('http://csgo-stats.com/img/weapons/bg.jpg');
|
||||
}
|
||||
}
|
29
application/controllers/Lang.php
Normal file
29
application/controllers/Lang.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Lang extends MY_Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->load->helper('url');
|
||||
$this->load->helper('cookie');
|
||||
}
|
||||
|
||||
function change($lang = "en")
|
||||
{
|
||||
if (isset($_GET['r']) && !empty($_GET['r'])) {
|
||||
$url = urldecode(base64_decode($_GET['r']));
|
||||
} else {
|
||||
$url = base_url();
|
||||
}
|
||||
if (in_array($lang, ['de', 'en', 'fr'])) {
|
||||
$this->session->set_userdata('site_lang', $lang);
|
||||
setcookie('language', $lang, time() + 7776000, '/');
|
||||
} else {
|
||||
$this->session->set_userdata('site_lang', 'en');
|
||||
setcookie('language', 'en', time() + 7776000, '/');
|
||||
}
|
||||
redirect($url);
|
||||
}
|
||||
}
|
263
application/controllers/Login.php
Normal file
263
application/controllers/Login.php
Normal file
@@ -0,0 +1,263 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Login extends MY_Controller
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct('login');
|
||||
$this->load->model('LoginModel', '', TRUE);
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
if (isset($_POST['logout']) && $_POST['logout'] == 'Logout') {
|
||||
$_POST['logout'] = '';
|
||||
redirect("/logout");
|
||||
}
|
||||
|
||||
if (isset($_SESSION['user'])) {
|
||||
redirect(base_url('user/' . $_SESSION['user']['username']));
|
||||
}
|
||||
|
||||
if (isset($_POST['loginname']) && !empty($_POST['loginname']) && isset($_POST['loginPassword']) && !empty($_POST['loginPassword'])) {
|
||||
$_SESSION['loggedOut'] = false;
|
||||
$rememberMe = isset($_POST['rememberMe']) ? $_POST['rememberMe'] : 'off';
|
||||
$this->LoginModel->login($_POST['loginname'], $_POST['loginPassword'], $rememberMe);
|
||||
isset($_GET['r']) && !empty($_GET['r']) ? redirect(base64_decode($_GET['r'])) : redirect(base_url('login'));
|
||||
}
|
||||
|
||||
$notice = isset($_SESSION['notice']) ? $_SESSION['notice'] : '';
|
||||
$_SESSION['notice'] = '';
|
||||
|
||||
$this->load->view('header', ['active' => 'login', 'title' => 'Login', 'additionalStyles' => ['login.css']]);
|
||||
$this->load->view('login', ['notice' => $notice]);
|
||||
$this->load->view('footer', ['additionalScripts' => ['login.js']]);
|
||||
}
|
||||
|
||||
public function register()
|
||||
{
|
||||
$notice = ['state' => false,
|
||||
'errors' => ['username', 'email', 'password', 'passwordRepeat'],
|
||||
'messages' => [],
|
||||
'endMessage' => lang('register_error_occured')];
|
||||
$username = $this->input->post('username');
|
||||
$email = $this->input->post('email');
|
||||
$password = $this->input->post('password');
|
||||
$passwordRepeat = $this->input->post('passwordRepeat');
|
||||
|
||||
// Username
|
||||
if (isset($username)) {
|
||||
if (!preg_match('/[^A-Za-z0-9._]/', $username)) {
|
||||
if ($this->LoginModel->isAvailable($username) == "") {
|
||||
if (strlen($username) >= 4) {
|
||||
unset($notice['errors'][array_search('username', $notice['errors'])]);
|
||||
} else {
|
||||
$notice['messages'][] = ['type' => 'danger',
|
||||
'headline' => lang('register_error_username_short'),
|
||||
'body' => lang('register_error_username_short_body')];
|
||||
}
|
||||
} else {
|
||||
$notice['messages'][] = ['type' => 'danger',
|
||||
'headline' => lang('register_error_username_occupied'),
|
||||
'body' => lang('register_error_username_occupied_body')];
|
||||
}
|
||||
} else {
|
||||
$notice['messages'][] = ['type' => 'danger',
|
||||
'headline' => lang('register_error_username_characters'),
|
||||
'body' => lang('register_error_username_characters_body')];
|
||||
}
|
||||
} else {
|
||||
$notice['messages'][] = ['type' => 'danger',
|
||||
'headline' => lang('register_error_username_missing'),
|
||||
'body' => lang('register_error_username_missing_body')];
|
||||
}
|
||||
|
||||
// Email
|
||||
if (isset($email)) {
|
||||
$isRegistered = $this->LoginModel->isRegistered($email);
|
||||
if ($isRegistered == "") {
|
||||
$trashMail = $this->LoginModel->isTrashMail($email);
|
||||
if (!$trashMail) {
|
||||
unset($notice['errors'][array_search('email', $notice['errors'])]);
|
||||
} else {
|
||||
$notice['messages'][] = ['type' => 'danger',
|
||||
'headline' => lang('register_error_trashmail'),
|
||||
'body' => lang('register_error_trashmail')];
|
||||
}
|
||||
} else {
|
||||
$notice['messages'][] = ['type' => 'danger',
|
||||
'headline' => lang('register_error_email_occupied'),
|
||||
'body' => lang('register_error_email_occupied')];
|
||||
}
|
||||
} else {
|
||||
$notice['messages'][] = ['type' => 'danger',
|
||||
'headline' => lang('register_error_email_missing'),
|
||||
'body' => lang('register_error_email_missing')];
|
||||
}
|
||||
|
||||
// Password
|
||||
if (isset($password)) {
|
||||
if (isset($passwordRepeat)) {
|
||||
if ($password == $passwordRepeat) {
|
||||
if ($this->LoginModel->checkPassword($password)) {
|
||||
unset($notice['errors'][array_search('password', $notice['errors'])]);
|
||||
unset($notice['errors'][array_search('passwordRepeat', $notice['errors'])]);
|
||||
} else {
|
||||
$notice['messages'][] = ['type' => 'danger',
|
||||
'headline' => lang('register_error_pw_unsecure'),
|
||||
'body' => lang('register_error_unsecure_body')];
|
||||
}
|
||||
} else {
|
||||
$notice['messages'][] = ['type' => 'danger',
|
||||
'headline' => lang('register_error_pw_different'),
|
||||
'body' => lang('register_error_pw_different_body')];
|
||||
}
|
||||
} else {
|
||||
$notice['messages'][] = ['type' => 'danger',
|
||||
'headline' => lang('register_error_pw_second_missing'),
|
||||
'body' => lang('register_error_pw_second_missing_body')];
|
||||
}
|
||||
} else {
|
||||
$notice['messages'][] = ['type' => 'danger',
|
||||
'headline' => lang('register_error_pw_missing'),
|
||||
'body' => lang('register_error_pw_missing_body')];
|
||||
}
|
||||
|
||||
// Register
|
||||
if (empty($notice['errors'])) {
|
||||
$this->LoginModel->register($username, $email, $password, 0); // TODO: Implement login method
|
||||
$notice['messages'][] = ['type' => 'success',
|
||||
'headline' => sprintf(lang('register_welcome'), $username),
|
||||
'body' => lang('register_welcome_body')];
|
||||
$notice['state'] = true;
|
||||
$notice['endMessage'] = lang('register_end_message_success');
|
||||
}
|
||||
|
||||
header("Content-Type: application/json");
|
||||
echo json_encode($notice);
|
||||
}
|
||||
|
||||
public function logout()
|
||||
{
|
||||
unset($_SESSION['user']);
|
||||
$this->load->helper('cookie');
|
||||
delete_cookie('rememberMe');
|
||||
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">×</span></button><strong>Abgemeldet!</strong> Du wurdest erfolgreich abgemeldet! Ich hoffe wir sehen uns bald wieder.</div>';
|
||||
$_SESSION['notice'] = $notice;
|
||||
$_SESSION['loggedOut'] = true;
|
||||
$redirect = isset($_GET['redirect']) ? urldecode(base64_decode($_GET['redirect'])) : base_url("login");
|
||||
redirect($redirect);
|
||||
}
|
||||
|
||||
public function activate($emailHash = '', $activationKey = '')
|
||||
{
|
||||
if ($emailHash !== '' && $activationKey !== '' && strlen($activationKey) == 256 && strlen($emailHash) == 32) {
|
||||
$email_id = $this->LoginModel->hashMailExists($emailHash, $activationKey);
|
||||
if ($email_id !== NULL) {
|
||||
$this->LoginModel->activateMail($email_id);
|
||||
$_SESSION['notice'] = '<div class="alert alert-success alert-dismissible"><button type="button" class="close" data-dismiss="alert" aria-label="Schließen"><span aria-hidden="true">×</span></button><strong>Dein Account wurde erfolgreich bestätigt!</strong> Du kannst dich jetzt mit deinem Passwort einloggen und alle Funktionen dieser Seite ausreizen!</div>';
|
||||
} 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">×</span></button><strong>Dein Account konnte nicht aktiviert werden!</strong> Möglicherweise ist der Aktivierungs-Schlüssel falsch. Sollte dieser Fehler weiterhin auftreten, kontaktiere bitte das Website-Team!</div>';
|
||||
}
|
||||
} 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">×</span></button><strong>Ein Fehler ist aufgetreten!</strong> Der angegebene Aktivierungs-Schlüssel ist ungültig und entspricht nicht den Anforderungen. Der Account kann nicht aktiviert werden!</div>';
|
||||
}
|
||||
redirect(base_url('login'));
|
||||
}
|
||||
|
||||
public function forget()
|
||||
{
|
||||
if (isset($_SESSION['user']))
|
||||
redirect(base_url('login'));
|
||||
|
||||
$username = $this->input->post("username");
|
||||
$notice = ["state" => false, "message" => ""];
|
||||
if (!isset($username) || $username == "") {
|
||||
$notice["message"] = '<b>Bitte gib deinen Nutzernamen oder deine E-Mail-Adresse an!</b> Um dir Zugriff auf deinen Account zu gewähren, musst du entweder deinen Nutzernamen oder deine E-Mail-Adresse angeben.';
|
||||
echo json_encode($notice);
|
||||
header('Content-Type: application/json');
|
||||
exit;
|
||||
}
|
||||
|
||||
$loginData = $this->LoginModel->getLoginData($username);
|
||||
if (empty($loginData)) {
|
||||
$notice['message'] = '<b>Dieser Nutzer existiert nicht!</b> Es konnte kein Nutzer mit dieser E-Mail oder diesem Namen gefunden werden.';
|
||||
echo json_encode($notice);
|
||||
header('Content-Type: application/json');
|
||||
exit;
|
||||
}
|
||||
|
||||
$loginData = $loginData[0];
|
||||
$username = strtolower($username);
|
||||
if ($username == $loginData['username'] || $username == $loginData['email']) {
|
||||
$resetKey = $this->LoginModel->createForgetPasswordKey($loginData['username']);
|
||||
|
||||
// TODO: E-Mail send
|
||||
$this->load->library('email');
|
||||
$message = "<a href='" . base_url('reset/' . base64_encode($loginData['username']) . '/' . $resetKey) . "'></a>";
|
||||
|
||||
// $config['mailtype'] = "html";
|
||||
// $this->mail->initialize($config);
|
||||
|
||||
$this->email->from('noreply@kingofdog.de', 'KingOfDog.de');
|
||||
$this->email->to($loginData['email']);
|
||||
|
||||
$this->email->subject('Passwort zurücksetzen');
|
||||
$this->email->message($message);
|
||||
|
||||
// $this->email->send();
|
||||
$notice['state'] = true;
|
||||
$notice['message'] = "<b>Eine E-Mail wurde an dich gesendet!</b> Schau' in dein Postfach und klick auf den Link, um dein Passwort zu ändern!";
|
||||
}
|
||||
echo json_encode($notice);
|
||||
header('Content-Type: application/json');
|
||||
}
|
||||
|
||||
public function reset($userKey = NULL, $resetKey = NULL)
|
||||
{
|
||||
if ($resetKey == NULL || $userKey == NULL)
|
||||
redirect(base_url("login"));
|
||||
|
||||
$username = base64_decode($userKey);
|
||||
if (!$this->LoginModel->resetKeyIsValid($username, $resetKey))
|
||||
redirect(base_url('login'));
|
||||
|
||||
$password = $this->input->post('password');
|
||||
$passwordRepeat = $this->input->post('passwordConfirm');
|
||||
$notice = ["type" => false, "message" => ""];
|
||||
if (isset($password)) {
|
||||
if (isset($passwordRepeat)) {
|
||||
$loginData = $this->LoginModel->getLoginData($username);
|
||||
if (!empty($loginData)) {
|
||||
$loginData = $loginData[0];
|
||||
if ($this->LoginModel->checkPassword($password)) {
|
||||
if ($password == $passwordRepeat) {
|
||||
$this->LoginModel->changePassword($password, $loginData['original_name']);
|
||||
$this->LoginModel->unsetResetKey($loginData['ID']);
|
||||
$notice['message'] .= "<div class='alert alert-success' role='alert'><b>Dein Passwort wurde geändert!</b> Du kannst dich nun damit einloggen</div>";
|
||||
$notice['type'] = true;
|
||||
} else {
|
||||
$notice['message'] .= "<div class='alert alert-danger' role='alert'><b>Wiederholtes Passwort falsch!</b> Das Passwort, das du wiederholt hast, stimmt nicht mit dem eigentlichen überein.</div>";
|
||||
}
|
||||
} else {
|
||||
$notice['message'] .= "<div class='alert alert-danger' role='alert'><b>Zu unsicheres Passwort!</b> Dein Passwort sollte mindest 8 Zeichen lang sein und jeweils einen Groß-, einen Kleinbuchstaben, eine Zahl und ein Sonderzeichen enthalten.</div>";
|
||||
}
|
||||
} else {
|
||||
$notice['message'] .= "<div class='alert alert-danger' role='alert'><b>Ungültiger Account</b> Anscheinend versuchst du die E-Mail-Adresse eines nicht existierenden Accounts zu ändern. Sollte es sich um einen Fehler handeln, kontaktiere bitte das Website-Team!</div>";
|
||||
}
|
||||
} else {
|
||||
$notice['message'] .= "<div class='alert alert-danger' role='alert'><b>Wiederholtes Passwort fehlend!</b> Bitte gib dein Passwort zur Bestätigung ein zweites Mal ein!</div>";
|
||||
}
|
||||
echo json_encode($notice);
|
||||
header('Content-Type: application/json');
|
||||
exit;
|
||||
}
|
||||
|
||||
$this->load->view('header', ['active' => 'reset_password', 'title' => 'Neues Passwort festlegen', 'additionalStyles' => ['login.css']]);
|
||||
$this->load->view('network/password_reset', ['notice' => $notice['message']]);
|
||||
$this->load->view('footer', ['additionalScripts' => ['login.js']]);
|
||||
}
|
||||
}
|
154
application/controllers/Main.php
Normal file
154
application/controllers/Main.php
Normal file
@@ -0,0 +1,154 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
use Coduo\PHPHumanizer\DateTimeHumanizer;
|
||||
|
||||
class Main extends MY_Controller
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct('home');
|
||||
$this->load->model('YoutubePlayerModel', '', TRUE);
|
||||
$this->load->model('SocialMediaModel', '', TRUE);
|
||||
$this->load->model('UserModel', '', TRUE);
|
||||
$this->load->model('NotificationModel', '', TRUE);
|
||||
$this->load->model('PostsModel', '', TRUE);
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
// TODO: Add twitch, instagram and 500px as further services
|
||||
// TODO: Receive posts async
|
||||
// $this->SocialMediaModel->getTwitterPosts();
|
||||
// $this->SocialMediaModel->getYouTubeVideos();
|
||||
|
||||
// $this->load->library('email');
|
||||
// $config['protocol'] = 'sendmail';
|
||||
// $config['mailpath'] = '/sendmail';
|
||||
// $config['charset'] = 'iso-8859-1';
|
||||
// $config['wordwrap'] = TRUE;
|
||||
//
|
||||
// $this->email->initialize($config);
|
||||
//
|
||||
// $this->email->from('info@kingofdog.eu', 'KingOfDog.de');
|
||||
// $this->email->to('struckatmarcel@gmail.com');
|
||||
//
|
||||
// $this->email->subject('Email Test');
|
||||
// $this->email->message('Testing the email class.');
|
||||
//
|
||||
// $this->email->send();
|
||||
|
||||
// ini_set('SMTP', 'smtp.gmail.com');
|
||||
// ini_set('smtp_port', '465');
|
||||
//
|
||||
$video = $this->YoutubePlayerModel->newestVids(1)[0];
|
||||
|
||||
$currentlyActiveUsers = $this->UserModel->getActiveUsers(5);
|
||||
$newestUsers = $this->UserModel->getNewestUsers(5);
|
||||
$newestPosts = $this->PostsModel->getNewestPosts(3, 128);
|
||||
|
||||
$this->load->view('header', ['active' => 'home', 'title' => lang('home_sitetitle'), 'additionalStyles' => ['lib/social-media-font.css', 'sortlist.css', 'home.css']]);
|
||||
$this->load->view('home', ['video' => $video, 'currentlyActiveUsers' => $currentlyActiveUsers, 'newestUsers' => $newestUsers, 'newestPosts' => $newestPosts]);
|
||||
$this->load->view('footer', ['additionalScripts' => ['lib/isotope.pkgd.min.js', 'home.js']]);
|
||||
}
|
||||
|
||||
public function getPosts()
|
||||
{
|
||||
$amount = (int)$this->input->get('amount');
|
||||
$offset = $this->input->get('offset') * $amount;
|
||||
$category = $this->input->get('category');
|
||||
if ($category == "*") {
|
||||
$items = $this->SocialMediaModel->getPosts($amount, $offset);
|
||||
} else {
|
||||
$items = $this->SocialMediaModel->getPostsOfCategory($amount, $offset, explode(".", $category)[1]);
|
||||
}
|
||||
$font_sizes = [27, 27, 24, 24, 24, 20, 16, 16, 14, 14, 12, 11, 10];
|
||||
foreach ($items as $item) {
|
||||
$post_date = $item['post_date'];
|
||||
$item['post_date'] = DateTimeHumanizer::difference(new \DateTime(), new \DateTime("@$post_date"), $_SESSION['site_lang']);
|
||||
$item['font_sizes'] = $font_sizes;
|
||||
$this->load->view('post_list_entry', $item);
|
||||
}
|
||||
}
|
||||
|
||||
public function addFeedback()
|
||||
{
|
||||
$url = $this->input->post('url');
|
||||
$message = $this->input->post('message');
|
||||
$anonymous = filter_var($this->input->post('anonymous'), FILTER_VALIDATE_BOOLEAN);
|
||||
var_dump($anonymous);
|
||||
$email = NULL;
|
||||
$userID = NULL;
|
||||
|
||||
if (!$anonymous && !empty($_SESSION['user'])) {
|
||||
$userID = $_SESSION['user']['ID'];
|
||||
}
|
||||
|
||||
$this->GeneralModel->addFeedback($url, $message, $anonymous, $userID, $email);
|
||||
}
|
||||
|
||||
public function contactTeam()
|
||||
{
|
||||
$message = $this->input->post('message');
|
||||
$email = $this->input->post('email');
|
||||
$notice = ['type' => false, 'message' => ''];
|
||||
|
||||
if (isset($message) && $message != "") {
|
||||
if ($email != "" || isset($_SESSION['user'])) {
|
||||
if (isset($_SESSION['user']))
|
||||
$email = $this->UserModel->getUser($_SESSION['user']['username'])[0]['email'];
|
||||
if (preg_match("/[A-Za-z._]+@[A-Za-z._]+\.[A-Za-z._]+/", $email)) {
|
||||
// TODO: Send contact mail
|
||||
$notice['type'] = true;
|
||||
$notice['message'] = "Deine Nachricht wurde versendet!";
|
||||
} else {
|
||||
$notice['message'] = "Die eingebene E-Mail-Adresse ist ungültig!";
|
||||
}
|
||||
} else {
|
||||
$notice['message'] = "Bitte gib eine E-Mail-Adresse ein oder melde dich an.";
|
||||
}
|
||||
} else {
|
||||
$notice['message'] = "Bitte gib eine zu versendende Nachricht ein.";
|
||||
}
|
||||
|
||||
echo json_encode($notice);
|
||||
header('Content-Type: application/json');
|
||||
}
|
||||
|
||||
public function stillAlive()
|
||||
{
|
||||
if (isset($_SESSION['user']) && !empty($_SESSION['user'])) {
|
||||
$this->UserModel->updateOnline(intval($_SESSION['user']['ID']));
|
||||
}
|
||||
redirect(base_url());
|
||||
}
|
||||
|
||||
public function getNotifications()
|
||||
{
|
||||
header('Content-Type: application/json');
|
||||
if (!isset($_SESSION['user']) || empty($_SESSION['user'])) {
|
||||
echo json_encode(['status' => 'error', 'message' => 'Du musst eingeloggt sein, um Benachrichtigungen zu empfangen.']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$returnData = ['status' => 'success', 'notifications' => []];
|
||||
|
||||
$notifications = $this->NotificationModel->getUserNotifications($_SESSION['user']['ID']);
|
||||
$returnData['notifications'] = $notifications;
|
||||
|
||||
echo json_encode($returnData);
|
||||
}
|
||||
|
||||
public function notificationsRead() {
|
||||
header('Content-Type: application/json');
|
||||
if(!isset($_SESSION['user']) || empty($_SESSION['user'])) {
|
||||
echo json_encode(['success' => false, 'message' => 'Du musst eingeloggt sein, um Benachrichtigungen zu empfangen.']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$this->NotificationModel->markUserNotificationsAsRead($_SESSION['user']['ID']);
|
||||
|
||||
echo json_encode(['success' => true]);
|
||||
}
|
||||
}
|
216
application/controllers/Posts.php
Normal file
216
application/controllers/Posts.php
Normal file
@@ -0,0 +1,216 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Posts extends MY_Controller
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct('profile', 'language_names', 'country_names');
|
||||
$this->load->model('UserModel', '', TRUE);
|
||||
$this->load->model('PostsModel', '', TRUE);
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
if (isset($_SESSION['user']) && !empty($_SESSION['user']))
|
||||
redirect(base_url('posts/feed'));
|
||||
redirect(base_url('posts/popular'));
|
||||
}
|
||||
|
||||
public function feed()
|
||||
{
|
||||
if (!isset($_SESSION['user']) || empty($_SESSION['user']))
|
||||
redirect(base_url('posts'));
|
||||
|
||||
$this->load->view('header', ['active' => 'feed', 'title' => 'Dein Feed', 'additionalStyles' => ['posts_list.css']]);
|
||||
$this->load->view('network/posts/posts_list', ['active', 'feed']);
|
||||
$this->load->view('footer', ['additionalScripts' => ['post_feed.js', 'post_search.js']]);
|
||||
}
|
||||
|
||||
public function getFeedPosts()
|
||||
{
|
||||
if (!isset($_SESSION['user']) || empty($_SESSION['user']))
|
||||
redirect(base_url('posts'));
|
||||
|
||||
$amount = (int)$this->input->get('amount');
|
||||
$offset = (int)$this->input->get('offset') * $amount;
|
||||
$posts = $this->PostsModel->getFeedPosts($_SESSION['user']['ID'], $amount, $offset);
|
||||
|
||||
foreach ($posts as $post) {
|
||||
$this->load->view('network/posts/post_item', $post);
|
||||
}
|
||||
}
|
||||
|
||||
public function popular()
|
||||
{
|
||||
$this->load->view('header', ['active' => 'popular', 'title' => 'Beliebte Posts', 'additionalStyles' => ['posts_list.css']]);
|
||||
$this->load->view('network/posts/posts_list', ['active' => 'popular']);
|
||||
$this->load->view('footer', ['additionalScripts' => ['post_feed.js', 'post_search.js']]);
|
||||
}
|
||||
|
||||
public function getPopularPosts()
|
||||
{
|
||||
$amount = (int)$this->input->get('amount');
|
||||
$offset = (int)$this->input->get('offset') * $amount;
|
||||
$posts = $this->PostsModel->getPopularPosts($amount, $offset);
|
||||
|
||||
foreach ($posts as $post) {
|
||||
$this->load->view('network/posts/post_item', $post);
|
||||
}
|
||||
}
|
||||
|
||||
public function addPostLike()
|
||||
{
|
||||
header('Content-Type: application/json');
|
||||
if (!isset($_SESSION['user']) || empty($_SESSION['user'])) {
|
||||
echo json_encode([
|
||||
'success' => false,
|
||||
'message' => lang('post_like_account_missing')
|
||||
]);
|
||||
exit;
|
||||
}
|
||||
|
||||
$postUUID = $this->input->post('postUUID');
|
||||
|
||||
$isLiked = $this->PostsModel->addPostLikeByUUID($postUUID, $_SESSION['user']['ID']);
|
||||
$likeCount = $this->PostsModel->getPostLikeCountByUUID($postUUID);
|
||||
|
||||
echo json_encode([
|
||||
'success' => true,
|
||||
'message' => 'Du hast den Post erfolgreich bewertet.',
|
||||
'isLiked' => $isLiked,
|
||||
'likeCount' => $likeCount
|
||||
]);
|
||||
}
|
||||
|
||||
public function search()
|
||||
{
|
||||
$type = $this->input->get('type');
|
||||
$query = $this->input->get('q');
|
||||
$rank = $this->input->get('rank');
|
||||
|
||||
$this->load->view('header', ['active' => 'search', 'title' => 'Suche', 'additionalStyles' => ['posts_list.css']]);
|
||||
$this->load->view('network/posts/posts_list', ['active' => 'search', 'search' => ['query' => $query, 'type' => $type, 'rank' => $rank]]);
|
||||
$this->load->view('footer', ['additionalScripts' => ['post_search.js']]);
|
||||
}
|
||||
|
||||
public function getSearchPosts()
|
||||
{
|
||||
$type = $this->input->get('type');
|
||||
$query = $this->input->get('query');
|
||||
$rank = $type == 'type-users' ? $this->input->get('rank') : '';
|
||||
$lang = $type == 'type-users' ? $this->input->get('lang') : '';
|
||||
$country = $type == 'type-users' ? $this->input->get('country') : '';
|
||||
$amount = (int)$this->input->get('amount');
|
||||
$offset = (int)$this->input->get('offset') * $amount;
|
||||
|
||||
if ($type !== 'type-users' && $rank !== '' && $lang !== '' && strlen($query) < 4) {
|
||||
exit;
|
||||
}
|
||||
|
||||
if (($type == 'type-all' && $offset == 0) || $type == 'type-users') {
|
||||
$userAmount = $type == 'type-users' ? $amount : 3;
|
||||
$userOffset = $type == 'type-users' ? $offset : 0;
|
||||
$users = $this->UserModel->searchUsers($query, $rank, $country, $lang, $userAmount, $userOffset);
|
||||
|
||||
if (!empty($users)) {
|
||||
if($offset == 0) {
|
||||
echo '<h2>Nutzer (' . sizeof($users) . ')</h2>';
|
||||
}
|
||||
|
||||
echo '<div class="row">';
|
||||
foreach ($users as $user) {
|
||||
$user['about'] = strlen($user['about']) > 60 ? substr($user['about'], 0, 60) . '...' : $user['about'];
|
||||
|
||||
echo $this->load->view('network/user/user_overview_card', $user, true);
|
||||
}
|
||||
echo '</div>';
|
||||
}
|
||||
}
|
||||
|
||||
if ($type == 'type-all' || $type == 'type-posts') {
|
||||
$posts = $this->PostsModel->searchPosts($query, $amount, $offset);
|
||||
|
||||
if (!empty($posts) && $offset == 0) {
|
||||
echo '<h2>Posts</h2>';
|
||||
}
|
||||
|
||||
foreach ($posts as $post) {
|
||||
$this->load->view('network/posts/post_item', $post);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function getAvailableCountries() {
|
||||
$countries = $this->UserModel->getAvailableCountries();
|
||||
|
||||
foreach ($countries as $i => $country) {
|
||||
$countries[$i]['name'] = lang('country_' . $country['country']);
|
||||
}
|
||||
|
||||
header('Content-Type: application/json');
|
||||
echo json_encode(['countries' => $countries]);
|
||||
}
|
||||
|
||||
public function getAvailableLanguages() {
|
||||
$languages = $this->UserModel->getAvailableLanguages();
|
||||
|
||||
foreach ($languages as $i => $language) {
|
||||
$languages[$i]['name'] = lang('lang_' . strtolower($language['language']));
|
||||
}
|
||||
|
||||
header('Content-Type: application/json');
|
||||
echo json_encode(['languages' => $languages]);
|
||||
}
|
||||
|
||||
public function getReportModal() {
|
||||
$this->load->view('network/posts/report_modal');
|
||||
}
|
||||
|
||||
public function reportPost() {
|
||||
header('Content-Type: application/json');
|
||||
$uuid = $this->input->post('uuid');
|
||||
$reason = $this->input->post('reason');
|
||||
$reasonText = $this->input->post('explanation');
|
||||
|
||||
if($reason == '') {
|
||||
echo json_encode(['success' => false, 'message' => 'Bitte wähle einen Grund für deine Meldung aus.']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$allowedReasons = ['hatespeech', 'racism', 'terrorism', 'abuse', 'violence', 'copyright', 'spam', 'technical-issue'];
|
||||
|
||||
if(!array_search($reason, $allowedReasons)) {
|
||||
echo json_encode(['success' => false, 'message' => 'Bitte wähle einen standardmäßig vorhandenen und validen Grund für die Meldung aus.']);
|
||||
exit;
|
||||
}
|
||||
|
||||
if(!$this->PostsModel->isUUIDValid($uuid)) {
|
||||
echo json_encode(['success' => true, 'message' => 'Der ausgewählte Post ist nicht (mehr) vorhanden. Sollte es sich hierbei um ein Irrtum handeln, verfasse bitte über den Button unten rechts ein Feedback.']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$this->PostsModel->reportPost($uuid, $reason, $reasonText);
|
||||
|
||||
echo json_encode(['success' => true, 'message' => 'Vielen Dank für das Melden dieses Posts. Wir werden schnellstmöglich angemessene Aktionen unternehmen.']);
|
||||
}
|
||||
|
||||
public function getDeleteModal() {
|
||||
header('Content-Type: application/json');
|
||||
if(!isset($_SESSION['user'])) {
|
||||
echo json_encode(['success' => false, 'message' => 'Du musst eingeloggt sein, um die Posts deines Accounts zu löschen']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$uuid = $this->input->post('uuid');
|
||||
$post = $this->PostsModel->getPostByUUID($uuid);
|
||||
|
||||
if(empty($post)) {
|
||||
echo json_encode(['success' => false, 'message' => 'Der angegebene Post existiert nicht.']);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
91
application/controllers/Projects.php
Normal file
91
application/controllers/Projects.php
Normal file
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
use Coduo\PHPHumanizer\DateTimeHumanizer;
|
||||
|
||||
class Projects extends MY_Controller
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct('projects');
|
||||
$this->load->model('ProjectsModel', '', TRUE);
|
||||
}
|
||||
|
||||
public function index($album = 'all')
|
||||
{
|
||||
$collections = $this->ProjectsModel->getCategories($album);
|
||||
$content = $this->ProjectsModel->getEntries('all');
|
||||
|
||||
$this->load->view('header', ['active' => 'projects', 'title' => lang('projects_sitetitle'), 'additionalStyles' => ['sortlist.css', 'projects.css']]);
|
||||
$this->load->view('projects', ['content' => $content, 'album' => $album, 'collections' => $collections]);
|
||||
$this->load->view('footer', ['additionalScripts' => ['lib/isotope.pkgd.min.js', 'projects.js']]);
|
||||
}
|
||||
|
||||
public function entry($entry = null)
|
||||
{
|
||||
if ($entry == null) {
|
||||
redirect(base_url('projects'));
|
||||
} else {
|
||||
if ($this->ProjectsModel->checkIfNameExists($entry)) {
|
||||
$data = $this->ProjectsModel->getEntryByName($entry, $_SESSION['site_lang']);
|
||||
$timecreated = strtotime($data['datetime']);
|
||||
$data['time_existing'] = DateTimeHumanizer::difference(new \DateTime(), new \DateTime("@$timecreated"), $_SESSION['site_lang']);
|
||||
|
||||
$voteCount = $this->ProjectsModel->getVoteCount($data['ID']);
|
||||
$voteType = 0;
|
||||
if (isset($_SESSION['user']['ID']))
|
||||
$voteType = $this->ProjectsModel->getUserVoteType($data['ID'], $_SESSION['user']['ID']);
|
||||
$prevProject = $this->ProjectsModel->getPrevProject($data['ID']);
|
||||
$nextProject = $this->ProjectsModel->getNextProject($data['ID']);
|
||||
|
||||
$this->load->view('header', ['active' => 'projects', 'title' => $data['title'] . ' - ' . lang('projects_sitetitle'), 'additionalStyles' => ['project_entry.css']]);
|
||||
$this->load->view('projects_entry', ['data' => $data, 'voteCount' => $voteCount, 'voteType' => $voteType, 'prevProject' => $prevProject, 'nextProject' => $nextProject]);
|
||||
$this->load->view('footer', ['additionalScripts' => ['project-entry.js']]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function getEntries()
|
||||
{
|
||||
$items = $this->ProjectsModel->getEntries('all');
|
||||
var_dump($items);
|
||||
foreach ($items as $item) {
|
||||
var_dump($item);
|
||||
$this->load->view('projects_list_entry', $item);
|
||||
}
|
||||
}
|
||||
|
||||
public function addVote()
|
||||
{
|
||||
header('Content-Type: text/json');
|
||||
if (!isset($_SESSION['user']) || empty($_SESSION['user'])) {
|
||||
$result = ['type' => 'error', 'msg' => 'Du musst eingeloggt sein, um dieses Projekt zu bewerten.'];
|
||||
echo json_encode($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
$projectID = $this->input->post('id');
|
||||
$voteType = $this->input->post('type');
|
||||
|
||||
if (!isset($projectID) || !isset($voteType)) {
|
||||
$result = ['type' => 'error', 'msg' => 'Es ist ein unbekannter Fehler aufgetreten.'];
|
||||
echo json_encode($result);
|
||||
exit;
|
||||
}
|
||||
|
||||
$projectID = intval($projectID);
|
||||
$voteType = intval($voteType);
|
||||
|
||||
if ($voteType < 0)
|
||||
$voteType = -1;
|
||||
else
|
||||
$voteType = 1;
|
||||
|
||||
$this->ProjectsModel->addVote($projectID, $_SESSION['user']['ID'], $voteType);
|
||||
$voteCount = $this->ProjectsModel->getVoteCount($projectID);
|
||||
|
||||
$result = ['type' => 'success', 'msg' => 'Vielen Dank für deine Bewertung.', 'voteCount' => $voteCount];
|
||||
echo json_encode($result);
|
||||
}
|
||||
}
|
45
application/controllers/Redirect.php
Normal file
45
application/controllers/Redirect.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Redirect extends CI_Controller {
|
||||
|
||||
public function __construct() {
|
||||
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) {
|
||||
var_dump($redirect);
|
||||
if($redirect == null) {
|
||||
if(isset($_SESSION['user']) && $_SESSION['user']['rank'] >= 9) {
|
||||
$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 {
|
||||
header("Location: /");
|
||||
}
|
||||
} else {
|
||||
$url = $this->RedirectModel->getUrl($redirect);
|
||||
header("Location: " . $url);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
219
application/controllers/Tools/Csgo.php
Normal file
219
application/controllers/Tools/Csgo.php
Normal file
@@ -0,0 +1,219 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Csgo extends MY_Controller
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct('tools');
|
||||
}
|
||||
|
||||
public function index($user = 'kingofdog')
|
||||
{
|
||||
if (isset($_GET['q']) && !empty($_GET['q'])) redirect(base_url('tools/csgo/' . $_GET['q']));
|
||||
|
||||
$this->load->view('header', ['active' => 'csgo', 'title' => 'CS:GO Tools', 'additionalStyles' => ['csgo.css']]);
|
||||
$this->load->view('tools/csgo', ['user' => $user]);
|
||||
$this->load->view('footer', ['additionalScripts' => ['lib/nanobar.min.js', 'csgo.js']]);
|
||||
}
|
||||
|
||||
public function data($user)
|
||||
{
|
||||
$data = simplexml_load_string(file_get_contents('http://steamcommunity.com/id/' . $user . '/?xml=1'));
|
||||
$a['player_exists'] = true;
|
||||
$a['player_owns_game'] = true;
|
||||
$a['id64'] = (string)$data->steamID64;
|
||||
$a['id'] = (string)$data->steamID;
|
||||
$a['name'] = (string)$data->realname;
|
||||
$a['location'] = (string)$data->location;
|
||||
$a['onStat'] = (string)$data->onlineState;
|
||||
$a['statusMes'] = (string)$data->stateMessage;
|
||||
$a['avatar'] = (string)$data->avatarFull;
|
||||
$a['vacban'] = (string)$data->vacBanned;
|
||||
$a['tradeban'] = (string)$data->tradeBanState;
|
||||
if($a['id'] == "") {
|
||||
$a['player_exists'] = false;
|
||||
$a['player_owns_game'] = false;
|
||||
echo json_encode($a);
|
||||
exit;
|
||||
}
|
||||
$status = ['in-game' => 'In Game', 'online' => 'Online', 'offline' => 'Offline', 'busy' => 'Busy', 'away' => 'Away'];
|
||||
$a['status'] = $status[$a['onStat']];
|
||||
|
||||
$successful = file_get_contents('http://api.steampowered.com/ISteamUserStats/GetUserStatsForGame/v0002/?appid=730&key=79E0709F4D4157636A833312C91639FC&steamid=' . $a['id64'], true);
|
||||
if($successful == false) {
|
||||
goto go_on;
|
||||
}
|
||||
|
||||
$data = json_decode($successful, true)['playerstats'];
|
||||
|
||||
$stats = $data['stats'];
|
||||
$kills = [];
|
||||
foreach ($stats as $stat) {
|
||||
$a[$stat['name']] = $stat['value'];
|
||||
if (strpos($stat['name'], 'total_kills_') !== false && !in_array($stat['name'], ['total_kills_headshot', 'total_kills_enemy_weapon', 'total_kills_enemy_blinded', 'total_kills_knife_fight', 'total_kills_against_zoomed_sniper'])) {
|
||||
$kills[] = $stat['value'] . '_' . explode('_', $stat['name'])[2];
|
||||
}
|
||||
}
|
||||
natsort($kills);
|
||||
$a['kills'] = array_reverse($kills);
|
||||
if ($a['last_match_wins'] > $a['last_match_rounds'] / 2) {
|
||||
$a['last_match_end_status'] = 2;
|
||||
} elseif ($a['last_match_wins'] < $a['last_match_rounds'] / 2) {
|
||||
$a['last_match_end_status'] = 0;
|
||||
} else {
|
||||
$a['last_match_end_status'] = 1;
|
||||
}
|
||||
|
||||
if(isset($data['achievements'])) {
|
||||
$ach = $data['achievements'];
|
||||
foreach ($ach as $entry) {
|
||||
$a[$entry['name']] = $entry['achieved'];
|
||||
}
|
||||
$a['total_time_played'] = round($a['total_time_played'] / 60 / 60);
|
||||
} else {
|
||||
$a['player_owns_game'] = false;
|
||||
}
|
||||
|
||||
go_on:
|
||||
$data = json_decode(file_get_contents('http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=79E0709F4D4157636A833312C91639FC&steamids=' . $a['id64']), true)['response'];
|
||||
$data = $data['players'];
|
||||
$data = $data[0];
|
||||
$a['lastseen'] = $data['lastlogoff'];
|
||||
$a['url'] = $data['profileurl'];
|
||||
$a['created'] = $data['timecreated'];
|
||||
$a['country'] = $data['loccountrycode'];
|
||||
|
||||
$a['weapon_list'] = [
|
||||
1 => ["Desert Eagle", "deagle"],
|
||||
2 => ["Dual Berettas", "elite"],
|
||||
3 => ["Five-SeveN", "fiveseven"],
|
||||
4 => ["Glock-18", "glock"],
|
||||
7 => ["AK-47", "ak47"],
|
||||
8 => ["AUG", "aug"],
|
||||
9 => ["AWP", "awp"],
|
||||
10 => ["FAMAS", "famas"],
|
||||
11 => ["G3SG1", "g3sg1"],
|
||||
13 => ["Galil AR", "galilar"],
|
||||
14 => ["M249", "m249"],
|
||||
16 => ["M4A4", "m4a4"],
|
||||
17 => ["MAC-10", "mac10"],
|
||||
19 => ["P90", "p90"],
|
||||
24 => ["UMP-45", "ump45"],
|
||||
25 => ["XM1014", "xm1014"],
|
||||
26 => ["PP-Bizon", "bizon"],
|
||||
27 => ["MAG-7", "mag7"],
|
||||
28 => ["Negev", "negev"],
|
||||
29 => ["Sawed-Off", "sawedoff"],
|
||||
30 => ["Tec-9", "tec9"],
|
||||
31 => ["Zeus x27", "taser"],
|
||||
32 => ["P2000", "hkp2000"],
|
||||
33 => ["MP7", "m79"],
|
||||
34 => ["MP9", "mp9"],
|
||||
35 => ["Nova", "nova"],
|
||||
36 => ["P250", "p250"],
|
||||
38 => ["SCAR-20", "scar20"],
|
||||
39 => ["SG 553", "sg556"],
|
||||
40 => ["SSG 08", "ssg08"],
|
||||
42 => ["Knife", "knife_ct"],
|
||||
43 => ["Flashbang", "flashbang"],
|
||||
44 => ["High Explosive Grenade", "hegrenade"],
|
||||
45 => ["Smoke Grenade", "smokegrenade"],
|
||||
46 => ["Molotov", "molotov"],
|
||||
47 => ["Decoy Grenade", "decoy"],
|
||||
48 => ["Incendiary Grenade", "incgrenade"],
|
||||
59 => ["Knife", "knife"],
|
||||
60 => ["M4A1-S", "m4a1"],
|
||||
61 => ["USP-S", "usp"],
|
||||
63 => ["CZ75-Auto", "cz75"],
|
||||
64 => ["R8 Revolver", "deagle"],
|
||||
];
|
||||
|
||||
if(isset($a['total_kills_headshot'])) {
|
||||
$a['total_headshot_rate'] = number_format(
|
||||
$a['total_kills_headshot'] / $a['total_kills'] * 100,
|
||||
1,
|
||||
lang('csgo_comma'),
|
||||
lang('csgo_point')) . " %";
|
||||
$a['total_kills'] = number_format($a['total_kills'], 0, lang('csgo_comma'), lang('csgo_point'));
|
||||
$a['total_time_played'] = number_format($a['total_time_played'], 0, lang('csgo_comma'), lang('csgo_point')) . " h";
|
||||
$a['total_accuracy'] = number_format($a['total_shots_hit'] / $a['total_shots_fired'] * 100, 1, lang('csgo_comma'), lang('csgo_point')) . " %";
|
||||
$a['total_mvps'] = number_format($a['total_mvps'], 0, lang('csgo_comma'), lang('csgo_point'));
|
||||
$a['total_win_rate'] = number_format($a['total_wins'] / $a['total_rounds_played'] * 100, 1, lang('csgo_comma'), lang('csgo_point')) . " %";
|
||||
$a['total_planted_bombs'] = number_format($a['total_planted_bombs'], 0, lang('csgo_comma'), lang('csgo_point'));
|
||||
$a['total_rescued_hostages'] = number_format($a['total_rescued_hostages'], 0, lang('csgo_comma'), lang('csgo_point'));
|
||||
$a['last_match_result'] = $a['last_match_end_status'] == 2 ? 'win' : '';
|
||||
$a['last_match_outcome'] = lang('csgo_' . $a['last_match_end_status']);
|
||||
$a['last_match_favweapon_accuracy'] = number_format($a['last_match_favweapon_hits'] / $a['last_match_favweapon_shots'] * 100, 1, lang('csgo_comma'), lang('csgo_point'));
|
||||
|
||||
$a['last_match_kd'] = number_format($a['last_match_kills'] / $a['last_match_deaths'], 2, lang('csgo_comma'), lang('csgo_point'));
|
||||
$a['last_match_kills'] = number_format($a['last_match_kills'], 0, lang('csgo_comma'), lang('csgo_point'));
|
||||
$a['last_match_deaths'] = number_format($a['last_match_deaths'], 0, lang('csgo_comma'), lang('csgo_point'));
|
||||
$a['last_match_mvps'] = number_format($a['last_match_mvps'], 0, lang('csgo_comma'), lang('csgo_point'));
|
||||
$a['last_match_damage'] = number_format($a['last_match_damage'], 0, lang('csgo_comma'), lang('csgo_point'));
|
||||
$a['last_match_money_spent'] = number_format($a['last_match_money_spent'], 0, lang('csgo_comma'), lang('csgo_point'));
|
||||
$a['last_match_dominations'] = number_format($a['last_match_dominations'], 0, lang('csgo_comma'), lang('csgo_point'));
|
||||
$a['last_match_revenges'] = number_format($a['last_match_revenges'], 0, lang('csgo_comma'), lang('csgo_point'));
|
||||
$a['last_match_contribution_score'] = number_format($a['last_match_contribution_score'], 0, lang('csgo_comma'), lang('csgo_point'));
|
||||
|
||||
$a['favweapons'] = '';
|
||||
for ($i = 0;
|
||||
$i < 5;
|
||||
$i++) {
|
||||
$weapon = $a['kills'][$i];
|
||||
$killCount = explode('_', $weapon)[0];
|
||||
$weaponName = explode('_', $weapon)[1];
|
||||
|
||||
$a['favweapons'] .= '<li class="item ' . $weaponName . ' ';
|
||||
$a['favweapons'] .= $i == 0 ? 'card">' : 'line">';
|
||||
$a['favweapons'] .= '<h3 class="title"><span class="number">' . ($i + 1);
|
||||
if ($i > 0) {
|
||||
$a['favweapons'] .= '. ';
|
||||
}
|
||||
$a['favweapons'] .= '</span> ' . $weaponName . '</h3>';
|
||||
if ($i == 0) {
|
||||
$a['favweapons'] .= '<img src="' . base_url('file/csgo/weapon/' . $weaponName) . '" class="photo" alt="" />';
|
||||
} else {
|
||||
$a['favweapons'] .= ' <svg class="icon"><use xlink:href="#i-' . $weaponName . '"></use></svg>';
|
||||
}
|
||||
$a['favweapons'] .= '<p class="stat kills">' . $killCount . '<svg><use xlink:href="#i-kills"></use></svg></p></li>';
|
||||
}
|
||||
|
||||
$a['total_deaths'] = number_format($a['total_deaths'], 0, lang('csgo_comma'), lang('csgo_point'));
|
||||
$a['total_kd'] = number_format($a['total_kills'] / $a['total_deaths'], 2, lang('csgo_comma'), lang('csgo_point'));
|
||||
$a['total_contribution_score'] = number_format($a['total_contribution_score'], 0, lang('csgo_comma'), lang('csgo_point'));
|
||||
$a['total_damage_done'] = number_format($a['total_damage_done'], 0, lang('csgo_comma'), lang('csgo_point')) . ' HP';
|
||||
$a['total_shots_fired'] = number_format($a['total_shots_fired'], 0, lang('csgo_comma'), lang('csgo_point'));
|
||||
$a['total_shots_hit'] = number_format($a['total_shots_hit'], 0, lang('csgo_comma'), lang('csgo_point'));
|
||||
$a['total_kills_headshot'] = number_format($a['total_kills_headshot'], 0, lang('csgo_comma'), lang('csgo_point'));
|
||||
$a['total_dominations'] = number_format($a['total_dominations'], 0, lang('csgo_comma'), lang('csgo_point'));
|
||||
$a['total_revenges'] = number_format($a['total_revenges'], 0, lang('csgo_comma'), lang('csgo_point'));
|
||||
$a['total_matches_played'] = number_format($a['total_matches_played'], 0, lang('csgo_comma'), lang('csgo_point'));
|
||||
$a['total_matches_won'] = number_format($a['total_matches_won'], 0, lang('csgo_comma'), lang('csgo_point'));
|
||||
$a['total_matches_won_percent'] = number_format($a['total_matches_won'] / $a['total_matches_played'] * 100, 2, lang('csgo_comma'), lang('csgo_point')) . ' %';
|
||||
$a['total_rounds_played'] = number_format($a['total_rounds_played'], 0, lang('csgo_comma'), lang('csgo_point'));
|
||||
$a['total_wins'] = number_format($a['total_wins'], 0, lang('csgo_comma'), lang('csgo_point'));
|
||||
$a['total_wins_pistolround'] = number_format($a['total_wins_pistolround'], 0, lang('csgo_comma'), lang('csgo_point'));
|
||||
$a['total_defused_bombs'] = number_format($a['total_defused_bombs'], 0, lang('csgo_comma'), lang('csgo_point'));
|
||||
$a['total_rescued_hostages'] = number_format($a['total_rescued_hostages'], 0, lang('csgo_comma'), lang('csgo_point'));
|
||||
$a['total_kills_enemy_blinded'] = number_format($a['total_kills_enemy_blinded'], 0, lang('csgo_comma'), lang('csgo_point'));
|
||||
$a['total_kills_knife_fight'] = number_format($a['total_kills_knife_fight'], 0, lang('csgo_comma'), lang('csgo_point'));
|
||||
$a['total_kills_against_zoomed_sniper'] = number_format($a['total_kills_against_zoomed_sniper'], 0, lang('csgo_comma'), lang('csgo_point'));
|
||||
$a['total_kills_taser'] = number_format($a['total_kills_taser'], 0, lang('csgo_comma'), lang('csgo_point'));
|
||||
$a['total_kills_enemy_weapon'] = number_format($a['total_kills_enemy_weapon'], 0, lang('csgo_comma'), lang('csgo_point'));
|
||||
$a['total_money_earned'] = number_format($a['total_money_earned'], 0, lang('csgo_comma'), lang('csgo_point')) . ' $';
|
||||
$a['total_weapons_donated'] = number_format($a['total_weapons_donated'], 0, lang('csgo_comma'), lang('csgo_point'));
|
||||
$a['total_broken_windows'] = number_format($a['total_broken_windows'], 0, lang('csgo_comma'), lang('csgo_point'));
|
||||
} else {
|
||||
$a['player_owns_game'] = false;
|
||||
}
|
||||
|
||||
header('Content-Type: application/json');
|
||||
echo json_encode($a);
|
||||
}
|
||||
|
||||
public function getDefaultPage($user) {
|
||||
$this->load->view('csgo-tools', ['user' => $user]);
|
||||
}
|
||||
}
|
25
application/controllers/Tools/Encoder.php
Normal file
25
application/controllers/Tools/Encoder.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Encoder extends MY_Controller {
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct('tools');
|
||||
}
|
||||
|
||||
public function base64() {
|
||||
$this->load->view('header', ['active' => 'base64-encoder', 'title' => lang('base64_site_title')]);
|
||||
// $this->load->view('encoder', ['type' => 'base64']);
|
||||
$this->load->view('tools/encoders/base64');
|
||||
$this->load->view('footer');
|
||||
// $this->load->view('encoder_end', ['type' => 'base64']);
|
||||
}
|
||||
|
||||
public function url() {
|
||||
$this->load->view('header', ['active' => 'url-encoder', 'title' => lang('url_site_title')]);
|
||||
// $this->load->view('encoder', ['type' => 'url']);
|
||||
$this->load->view('tools/encoders/url');
|
||||
$this->load->view('footer');
|
||||
// $this->load->view('encoder_end', ['type' => 'url']);
|
||||
}
|
||||
}
|
15
application/controllers/Tools/Encrypter.php
Normal file
15
application/controllers/Tools/Encrypter.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Encrypter extends MY_Controller {
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct('tools');
|
||||
}
|
||||
|
||||
public function index($active = 'adfgvx') {
|
||||
$this->load->view('header', ['active' => 'encrypter', 'title' => lang('encrypter_site_title')]);
|
||||
$this->load->view('tools/encrypter/main', ['active' => $active]);
|
||||
$this->load->view('footer', ['additionalScripts' => ['encrypters.js']]);
|
||||
}
|
||||
}
|
30
application/controllers/Tools/Generators.php
Normal file
30
application/controllers/Tools/Generators.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Generators extends MY_Controller {
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct('tools');
|
||||
$this->load->model('NicknameModel', '', TRUE);
|
||||
}
|
||||
|
||||
public function nickname()
|
||||
{
|
||||
$this->load->view('header', ['active' => 'nickname-generator', 'title' => lang('nick_site_title')]);
|
||||
$this->load->view('tools/generators/nickname', ["counter" => "unendlich"]);
|
||||
$this->load->view('footer', ['additionalScripts' => ['nickname.js']]);
|
||||
}
|
||||
|
||||
public function nickname_functions()
|
||||
{
|
||||
$this->NicknameModel->generateName();
|
||||
}
|
||||
|
||||
public function password()
|
||||
{
|
||||
$this->load->view('header', ['active' => 'password-generator', 'title' => lang('pass_site_title'), 'additionalStyles' => ['tools.css']]);
|
||||
$this->load->view('tools/generators/password');
|
||||
$this->load->view('footer', ['additionalScripts' => ['password.js']]);
|
||||
}
|
||||
|
||||
}
|
92
application/controllers/Tools/Minecraft.php
Normal file
92
application/controllers/Tools/Minecraft.php
Normal file
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Minecraft extends MY_Controller {
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct('tools');
|
||||
$this->load->model('minecraftModel', '', TRUE);
|
||||
}
|
||||
|
||||
public function index() {
|
||||
$this->load->view('header', ['active' => '', 'title' => 'Error']);
|
||||
$this->load->view('under_construction');
|
||||
$this->load->view('footer');
|
||||
}
|
||||
public function servers() {
|
||||
$this->load->view('header', ['active' => '', 'title' => 'Error']);
|
||||
$this->load->view('under_construction');
|
||||
$this->load->view('footer');
|
||||
}
|
||||
public function players() {
|
||||
$this->load->view('header', ['active' => '', 'title' => 'Error']);
|
||||
$this->load->view('under_construction');
|
||||
$this->load->view('footer');
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*public function server() {
|
||||
$serverip = isset($_GET['serverip']) ? $_GET['serverip'] : 'gommehd.net';
|
||||
|
||||
$errorIP = $this->MinecraftModel->getServerName($serverip) == lang('servers_error_ip') ? true : false;
|
||||
|
||||
$this->load->view('header', ['active' => 'minecraft-servers', 'title' => lang('servers_site_title')]);
|
||||
$this->load->view('minecraft', ['type' => 'server', 'serverip' => $serverip, 'error' => $errorIP]);
|
||||
$this->load->view('footer');
|
||||
}
|
||||
|
||||
public function player()
|
||||
{
|
||||
$username = !empty($_GET['username']) ? $_GET['username'] : "KingOfDog";
|
||||
$username = $this->MinecraftModel->getUUID($username)[1];
|
||||
|
||||
$cracked = $this->MinecraftModel->getUUID($username)[2] == true ? '<small>Cracked</small>' : '<small style="color:#FFAA00;">Premium</small>';
|
||||
$crackedBool = $this->MinecraftModel->getUUID($username)[2];
|
||||
if ($crackedBool == false) {
|
||||
$uuid = $this->MinecraftModel->getUUID($username)[0];
|
||||
$uuid_formatted = $this->MinecraftModel->formatUUID($uuid);
|
||||
} else {
|
||||
$uuid = null;
|
||||
$uuid_formatted = null;
|
||||
}
|
||||
|
||||
if (isset($_GET['download']) && !empty($_GET['download'])) {
|
||||
if ($_GET['download'] == "skin") {
|
||||
header('Content-Type: image/png');
|
||||
header('Content-Disposition: attachment; filename="skin_' . $username . '.png"');
|
||||
readfile('https://crafatar.com/skins/' . $username);
|
||||
die();
|
||||
}
|
||||
if ($_GET['download'] == "render") {
|
||||
header('Content-Type: image/png');
|
||||
header('Content-Disposition: attachment; filename="render_' . $username . '.png"');
|
||||
readfile('https://crafatar.com/renders/body/' . $username . '?overlay&scale=7');
|
||||
die();
|
||||
}
|
||||
if ($_GET['download'] == "head") {
|
||||
header('Content-Type: image/png');
|
||||
header('Content-Disposition: attachment; filename="head_' . $username . '.png"');
|
||||
readfile('https://crafatar.com/renders/head/' . $username . '?overlay&scale=7');
|
||||
die();
|
||||
}
|
||||
if ($_GET['download'] == "avatar") {
|
||||
if (isset($_GET['size']) && !empty($_GET['size'])) {
|
||||
$size = $_GET['size'];
|
||||
} else {
|
||||
$size = "128";
|
||||
}
|
||||
|
||||
header('Content-Type: image/png');
|
||||
header('Content-Disposition: attachment; filename="avatar' . $size . '_' . $username . '.png"');
|
||||
|
||||
readfile('https://crafatar.com/avatar/' . $username . '?overlay&size=' . $size);
|
||||
die();
|
||||
}
|
||||
}
|
||||
|
||||
$this->load->view('header', ['active' => 'minecraft-players', 'title' => lang('players_site_title')]);
|
||||
$this->load->view('minecraft', ['type' => 'player', 'username' => $username, 'uuid' => $uuid, 'uuid_formatted' => $uuid_formatted, 'cracked' => $cracked, 'crackedBool' => $crackedBool]);
|
||||
$this->load->view('footer');
|
||||
}*/
|
||||
}
|
16
application/controllers/Tools/Tools.php
Normal file
16
application/controllers/Tools/Tools.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Tools extends MY_Controller {
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct('tools');
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
$this->load->view('header', ['active' => 'tools', 'title' => 'Tools']);
|
||||
$this->load->view('tools/index');
|
||||
$this->load->view('footer');
|
||||
}
|
||||
}
|
66
application/controllers/Tools/Twitch.php
Normal file
66
application/controllers/Tools/Twitch.php
Normal file
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Twitch extends MY_Controller {
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct('tools');
|
||||
}
|
||||
|
||||
public function index($channel = 'kingofdog') {
|
||||
if(isset($_GET['twitch-channel']) && !empty($_GET['twitch-channel'])) {
|
||||
header("Location: /tools/twitch/" . $_GET['twitch-channel']);
|
||||
}
|
||||
$this->load->view('header', ['active' => 'twitch-tools', 'title' => lang('twitch_site_title')]);
|
||||
$this->load->model('TwitchModel');
|
||||
|
||||
// $data =
|
||||
|
||||
$result = $this->load->view('twitch_result', ['json' => $this->TwitchModel->getTwitchInfos($channel), 'stream' => $this->TwitchModel->getTwitchStream($channel), 'videos' => $this->TwitchModel->getTwitchVideos($channel)], true);
|
||||
$this->load->view('twitch', ['result' => $result]);
|
||||
$this->load->view('footer');
|
||||
}
|
||||
|
||||
public function sudoku() {
|
||||
if(isset($_POST['sudoku'])) {
|
||||
$sudoku = [];
|
||||
$rows = [];
|
||||
$cols = [];
|
||||
$fields = [];
|
||||
for ($i=0; $i < 9; $i++) {
|
||||
for ($j=0; $j < 9; $j++) {
|
||||
if(isset($_POST['field-' . $i . '-' . $j])) {
|
||||
$sudoku[$i][$j] = $_POST['field-' . $i . '-' . $j];
|
||||
} else {
|
||||
$sudoku[$i][$j] = '_';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for ($i=0; $i < 9; $i++) {
|
||||
for ($j=0; $j < 9; $j++) {
|
||||
$rows[$i] .= $sudoku[$i][$j] . "|";
|
||||
$cols[$i] .= $sudoku[$j][$i] . "|";
|
||||
}
|
||||
}
|
||||
|
||||
for ($i=0; $i < 3; $i++) {
|
||||
for ($j=0; $j < 3; $j++) {
|
||||
for ($k=0; $k < 3; $k++) {
|
||||
for ($l=0; $l < 3; $l++) {
|
||||
$fields[$i][$j] .= $sudoku[$i * $k][$j * $l] . "|";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var_dump($fields);
|
||||
var_dump($rows);
|
||||
var_dump($cols);
|
||||
}
|
||||
|
||||
$this->load->view('header', ['active' => 'sudoku', 'title' => 'Sudoku-Löser']);
|
||||
$this->load->view('sudoku');
|
||||
$this->load->view('footer');
|
||||
}
|
||||
}
|
287
application/controllers/Tools/Youtube.php
Normal file
287
application/controllers/Tools/Youtube.php
Normal file
@@ -0,0 +1,287 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Youtube extends MY_Controller
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct('tools');
|
||||
$this->load->model('YoutubeDownloadModel', '', TRUE);
|
||||
$this->load->model('RedirectModel', '', TRUE);
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
$this->load->view('header', ['active' => 'youtube-downloader', 'title' => lang('ytdl_site_title')]);
|
||||
$this->load->view('youtube_downloader');
|
||||
$this->load->view('footer');
|
||||
}
|
||||
|
||||
public function download()
|
||||
{
|
||||
if (empty($_GET['mime']) OR empty($_GET['token'])) {
|
||||
header("Location: /youtube");
|
||||
}
|
||||
$mime = filter_var($_GET['mime']);
|
||||
$ext = str_replace(array('/', 'x-'), '', strstr($mime, '/'));
|
||||
$url = base64_decode(filter_var($_GET['token']));
|
||||
$name = urldecode($_GET['title']) . '.' . $ext;
|
||||
echo $url;
|
||||
if ($url) {
|
||||
$size = $this->YoutubeDownloadModel->get_size($url);
|
||||
// Generate the server headers
|
||||
if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== FALSE) {
|
||||
header('Content-Type: "' . $mime . '"');
|
||||
header('Content-Disposition: attachment; filename="' . $name . '"');
|
||||
header('Expires: 0');
|
||||
header('Content-Length: ' . $size);
|
||||
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
|
||||
header("Content-Transfer-Encoding: binary");
|
||||
header('Pragma: public');
|
||||
} else {
|
||||
header('Content-Type: "' . $mime . '"');
|
||||
header('Content-Disposition: attachment; filename="' . $name . '"');
|
||||
header("Content-Transfer-Encoding: binary");
|
||||
header('Expires: 0');
|
||||
header('Content-Length: ' . $size);
|
||||
header('Pragma: no-cache');
|
||||
}
|
||||
|
||||
readfile($url);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
public function video()
|
||||
{
|
||||
echo $this->load->view('header', ['title' => lang('ytdl_site_title'), 'active' => 'youtube-downloader'], true);
|
||||
if (isset($_REQUEST['videoid'])) {
|
||||
$my_id = $_REQUEST['videoid'];
|
||||
if (preg_match('/^https:\/\/w{3}?.youtube.com\//', $my_id)) {
|
||||
$url = parse_url($my_id);
|
||||
$my_id = NULL;
|
||||
if (is_array($url) && count($url) > 0 && isset($url['query']) && !empty($url['query'])) {
|
||||
$parts = explode('&', $url['query']);
|
||||
if (is_array($parts) && count($parts) > 0) {
|
||||
foreach ($parts as $p) {
|
||||
$pattern = '/^v\=/';
|
||||
if (preg_match($pattern, $p)) {
|
||||
$my_id = preg_replace($pattern, '', $p);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!$my_id) {
|
||||
header("Location: /tools/youtube?error=1");
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
header("Location: /tools/youtube?error=2");
|
||||
exit;
|
||||
}
|
||||
} elseif (preg_match('/^https?:\/\/youtu.be/', $my_id)) {
|
||||
$url = parse_url($my_id);
|
||||
$my_id = NULL;
|
||||
$my_id = preg_replace('/^\//', '', $url['path']);
|
||||
}
|
||||
} else {
|
||||
header("Location: /tools/youtube?error=1");
|
||||
exit;
|
||||
}
|
||||
|
||||
if (isset($_REQUEST['type'])) {
|
||||
$my_type = $_REQUEST['type'];
|
||||
} else {
|
||||
$my_type = 'redirect';
|
||||
}
|
||||
|
||||
if ($my_type == 'Download') {
|
||||
?>
|
||||
|
||||
<section class="container">
|
||||
<h1 class="center"><?= lang('ytdl_title'); ?></h1>
|
||||
<p class="lead center"><?= lang('ytdl_description'); ?></p>
|
||||
<div class="row center">
|
||||
|
||||
<?php
|
||||
} // end of if for type=Download
|
||||
|
||||
/* First get the video info page for this video id */
|
||||
//$my_video_info = 'http://www.youtube.com/get_video_info?&video_id='. $my_id;
|
||||
$my_video_info = 'http://www.youtube.com/get_video_info?&video_id=' . $my_id . '&asv=3&el=detailpage&hl=' . lang('ytdl_language'); //video details fix *1
|
||||
$my_video_info = $this->YoutubeDownloadModel->curlGet($my_video_info);
|
||||
|
||||
/* TODO: Check return from curl for status code */
|
||||
if (empty($my_video_info)) {
|
||||
header("Location: /tools/youtube?error=3");
|
||||
}
|
||||
|
||||
$thumbnail_url = $title = $view_count = $author = $length_seconds = $url_encoded_fmt_stream_map = $type = $url = '';
|
||||
|
||||
parse_str($my_video_info);
|
||||
$length_seconds = date("i:s", $length_seconds);
|
||||
$view_count = number_format($view_count, 0, ',', '.');
|
||||
if ($status == 'fail') {
|
||||
header("Location: /tools/youtube?error=3");
|
||||
exit();
|
||||
} ?>
|
||||
<div id="info">
|
||||
<div class="row">
|
||||
<div class="col-sm-4">
|
||||
<a href="/file/thumbnail/<?= $my_id; ?>" target="_blank">
|
||||
<img class="float-right" style="max-width:100%" src="/file/thumbnail/<?= $my_id; ?>">
|
||||
</a>
|
||||
</div>
|
||||
<div class="col-sm-8">
|
||||
<a href="https://youtu.be/<?= $my_id ?>" target="_blank">
|
||||
<h3 align="left"><?= $title; ?></h3>
|
||||
</a>
|
||||
<h4 align="left"><?= lang('ytdl_views'); ?>: <?= $view_count; ?></h4>
|
||||
<h4 align="left"><?= lang('ytdl_length') . ': ' . $length_seconds . ' ' . lang('ytdl_minutes'); ?></h4>
|
||||
<h4 align="left"><?= lang('ytdl_author') ?>:
|
||||
<a href="http://youtube.com/<?= $author; ?>"
|
||||
target="_blank"><?= $author; ?></a>
|
||||
</h4>
|
||||
<a align="left" href="https://youtu.be/<?= $my_id; ?>" target="_blank"
|
||||
class="btn btn-primary raised pull-left"><?= lang('ytdl_watch'); ?></a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<?php
|
||||
$my_title = $title;
|
||||
$cleanedtitle = $this->YoutubeDownloadModel->clean($title);
|
||||
|
||||
if (isset($url_encoded_fmt_stream_map)) {
|
||||
/* Now get the url_encoded_fmt_stream_map, and explode on comma */
|
||||
$my_formats_array = explode(',', $url_encoded_fmt_stream_map);
|
||||
} else {
|
||||
echo '<p>No encoded format stream found.</p>';
|
||||
echo '<p>Here is what we got from YouTube:</p>';
|
||||
echo $my_video_info;
|
||||
}
|
||||
if (count($my_formats_array) == 0) {
|
||||
echo '<p>' . lang('ytdl_error_no_downloads') . '</p>';
|
||||
exit;
|
||||
}
|
||||
|
||||
/* create an array of available download formats */
|
||||
$avail_formats[] = '';
|
||||
$i = 0;
|
||||
$ipbits = $ip = $itag = $sig = $quality = '';
|
||||
$expire = time();
|
||||
|
||||
foreach ($my_formats_array as $format) {
|
||||
parse_str($format);
|
||||
$avail_formats[$i]['itag'] = $itag;
|
||||
$avail_formats[$i]['quality'] = $quality;
|
||||
$type = explode(';', $type);
|
||||
$avail_formats[$i]['type'] = $type[0];
|
||||
$avail_formats[$i]['url'] = urldecode($url) . '&signature=' . $sig;
|
||||
parse_str(urldecode($url));
|
||||
$avail_formats[$i]['expires'] = date("d.m.Y G:i:s", $expire);
|
||||
$avail_formats[$i]['ipbits'] = $ipbits;
|
||||
$avail_formats[$i]['ip'] = $ip;
|
||||
$i++;
|
||||
}
|
||||
|
||||
if ($my_type == 'Download') {
|
||||
echo '<p align="left"><b>' . lang('ytdl_available_formats') . ':</b></p>
|
||||
<div class="table-responsive"><table class="table table-hover table-striped"><thead><tr><td>' . lang('ytdl_format') . '</td><td>' . lang('ytdl_quality') . '</td><td>' . lang('ytdl_size') . '</td><td>' . lang('ytdl_download_link') . '</td><td>' . lang('ytdl_available_until') . '</td></tr></thead><tbody>';
|
||||
|
||||
$formats = [
|
||||
'22' => '720p',
|
||||
'18' => '360p',
|
||||
'43' => '360p',
|
||||
'5' => '240p',
|
||||
'36' => '240p',
|
||||
'17' => '144p'
|
||||
];
|
||||
/* now that we have the array, print the options */
|
||||
for ($i = 0; $i < count($avail_formats); $i++) {
|
||||
$type = explode('/', $avail_formats[$i]['type'])[1];
|
||||
$thisurl = base_url('tools/youtube/download?mime=' . $avail_formats[$i]['type'] . '&title=' . urlencode(htmlspecialchars($my_title)) . '&token=' . base64_encode($avail_formats[$i]['url']));
|
||||
$url = base_url('r/' . $this->RedirectModel->addRandomItem($thisurl, true, 6));
|
||||
echo '<tr><td>';
|
||||
echo '<a href="' . base_url('r/' . $this->RedirectModel->addRandomItem($avail_formats[$i]['url'] . '&title=' . $cleanedtitle, true, 6)) . '" class="mime">' . $type . '</a> ';
|
||||
echo '</td> ' .
|
||||
'<td>' . $formats[$avail_formats[$i]['itag']] . '</td><td><span class="size">' . $this->YoutubeDownloadModel->formatBytes($this->YoutubeDownloadModel->get_size($avail_formats[$i]['url'])) . '</span></td>';
|
||||
echo '<td><a href="' . $url . '" class="dl btn btn-default btn-sm">' . lang('ytdl_download_link') . '</a></td><td>' . $avail_formats[$i]['expires'] . '</td>';
|
||||
echo '</tr>';
|
||||
}
|
||||
echo '</tbody></table></div><small>' . lang('ytdl_not_related_youtube') . '</small><br><small>' . lang('ytdl_no_haftung') . '</small><br><small>Der Betreiber nimmt Abstand von jeglichen urheberrechtsverletzenden Handlungen, die mit dem YouTube-Downloader durchgeführt werden könnten und unterstützt diese keinesfalls.</small>';
|
||||
?>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<?php
|
||||
|
||||
} else {
|
||||
|
||||
/* In this else, the request didn't come from a form but from something else
|
||||
* like an RSS feed.
|
||||
* As a result, we just want to return the best format, which depends on what
|
||||
* the user provided in the url.
|
||||
* If they provided "format=best" we just use the largest.
|
||||
* If they provided "format=free" we provide the best non-flash version
|
||||
* If they provided "format=ipad" we pull the best MP4 version
|
||||
*
|
||||
* Thanks to the python based youtube-dl for info on the formats
|
||||
* http://rg3.github.com/youtube-dl/
|
||||
*/
|
||||
|
||||
$format = $_REQUEST['format'];
|
||||
$target_formats = '';
|
||||
switch ($format) {
|
||||
case "best":
|
||||
/* largest formats first */
|
||||
$target_formats = array('38', '37', '46', '22', '45', '35', '44', '34', '18', '43', '6', '5', '17', '13');
|
||||
break;
|
||||
case "free":
|
||||
/* Here we include WebM but prefer it over FLV */
|
||||
$target_formats = array('38', '46', '37', '45', '22', '44', '35', '43', '34', '18', '6', '5', '17', '13');
|
||||
break;
|
||||
case "ipad":
|
||||
/* here we leave out WebM video and FLV - looking for MP4 */
|
||||
$target_formats = array('37', '22', '18', '17');
|
||||
break;
|
||||
default:
|
||||
/* If they passed in a number use it */
|
||||
if (is_numeric($format)) {
|
||||
$target_formats[] = $format;
|
||||
} else {
|
||||
$target_formats = array('38', '37', '46', '22', '45', '35', '44', '34', '18', '43', '6', '5', '17', '13');
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
/* Now we need to find our best format in the list of available formats */
|
||||
$best_format = '';
|
||||
for ($i = 0; $i < count($target_formats); $i++) {
|
||||
for ($j = 0; $j < count($avail_formats); $j++) {
|
||||
if ($target_formats[$i] == $avail_formats[$j]['itag']) {
|
||||
//echo '<p>Target format found, it is '. $avail_formats[$j]['itag'] .'</p>';
|
||||
$best_format = $j;
|
||||
break 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//echo '<p>Out of loop, best_format is '. $best_format .'</p>';
|
||||
if ((isset($best_format)) &&
|
||||
(isset($avail_formats[$best_format]['url'])) &&
|
||||
(isset($avail_formats[$best_format]['type']))
|
||||
) {
|
||||
$redirect_url = $avail_formats[$best_format]['url'] . '&title=' . $cleanedtitle;
|
||||
$content_type = $avail_formats[$best_format]['type'];
|
||||
}
|
||||
if (isset($redirect_url)) {
|
||||
header("Location: $redirect_url");
|
||||
}
|
||||
|
||||
}
|
||||
$this->load->view('footer');
|
||||
}
|
||||
}
|
134
application/controllers/Uploader.php
Normal file
134
application/controllers/Uploader.php
Normal file
@@ -0,0 +1,134 @@
|
||||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
class Uploader extends CI_Controller {
|
||||
|
||||
/* Constructor */
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->load->helper(array('jbimages','language'));
|
||||
|
||||
// is_allowed is a helper function which is supposed to return False if upload operation is forbidden
|
||||
// [See jbimages/is_alllowed.php]
|
||||
|
||||
if (is_allowed() === FALSE)
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
// User configured settings
|
||||
$this->config->load('uploader_settings', TRUE);
|
||||
}
|
||||
|
||||
/* Language set */
|
||||
|
||||
private function _lang_set($lang)
|
||||
{
|
||||
// We accept any language set as lang_id in **_dlg.js
|
||||
// Therefore an error will occur if language file doesn't exist
|
||||
|
||||
$this->config->set_item('language', $lang);
|
||||
$this->lang->load('jbstrings', $lang);
|
||||
}
|
||||
|
||||
/* Default upload routine */
|
||||
|
||||
public function upload ($lang='en')
|
||||
{
|
||||
// Set language
|
||||
$this->_lang_set($lang);
|
||||
|
||||
// Get configuartion data (we fill up 2 arrays - $config and $conf)
|
||||
|
||||
$conf['img_path'] = $this->config->item('img_path', 'uploader_settings');
|
||||
$conf['allow_resize'] = $this->config->item('allow_resize', 'uploader_settings');
|
||||
|
||||
$config['allowed_types'] = $this->config->item('allowed_types', 'uploader_settings');
|
||||
$config['max_size'] = $this->config->item('max_size', 'uploader_settings');
|
||||
$config['encrypt_name'] = $this->config->item('encrypt_name', 'uploader_settings');
|
||||
$config['overwrite'] = $this->config->item('overwrite', 'uploader_settings');
|
||||
$config['upload_path'] = $this->config->item('upload_path', 'uploader_settings');
|
||||
|
||||
if (!$conf['allow_resize'])
|
||||
{
|
||||
$config['max_width'] = $this->config->item('max_width', 'uploader_settings');
|
||||
$config['max_height'] = $this->config->item('max_height', 'uploader_settings');
|
||||
}
|
||||
else
|
||||
{
|
||||
$conf['max_width'] = $this->config->item('max_width', 'uploader_settings');
|
||||
$conf['max_height'] = $this->config->item('max_height', 'uploader_settings');
|
||||
|
||||
if ($conf['max_width'] == 0 and $conf['max_height'] == 0)
|
||||
{
|
||||
$conf['allow_resize'] = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
// Load uploader
|
||||
$this->load->library('upload', $config);
|
||||
|
||||
if ($this->upload->do_upload()) // Success
|
||||
{
|
||||
// General result data
|
||||
$result = $this->upload->data();
|
||||
|
||||
// Shall we resize an image?
|
||||
if ($conf['allow_resize'] and $conf['max_width'] > 0 and $conf['max_height'] > 0 and (($result['image_width'] > $conf['max_width']) or ($result['image_height'] > $conf['max_height'])))
|
||||
{
|
||||
// Resizing parameters
|
||||
$resizeParams = array
|
||||
(
|
||||
'source_image' => $result['full_path'],
|
||||
'new_image' => $result['full_path'],
|
||||
'width' => $conf['max_width'],
|
||||
'height' => $conf['max_height']
|
||||
);
|
||||
|
||||
// Load resize library
|
||||
$this->load->library('image_lib', $resizeParams);
|
||||
|
||||
// Do resize
|
||||
$this->image_lib->resize();
|
||||
}
|
||||
|
||||
// Add our stuff
|
||||
$result['result'] = "file_uploaded";
|
||||
$result['resultcode'] = 'ok';
|
||||
$result['file_name'] = $conf['img_path'] . '/' . $result['file_name'];
|
||||
|
||||
// $this->FileModel->addBlogImageToDatabase();
|
||||
var_dump($result);
|
||||
|
||||
|
||||
// Output to user
|
||||
$this->load->view('ajax_upload_result', $result);
|
||||
}
|
||||
else // Failure
|
||||
{
|
||||
// Compile data for output
|
||||
$result['result'] = $this->upload->display_errors(' ', ' ');
|
||||
$result['resultcode'] = 'failed';
|
||||
|
||||
// Output to user
|
||||
$this->load->view('ajax_upload_result', $result);
|
||||
}
|
||||
}
|
||||
|
||||
/* Blank Page (default source for iframe) */
|
||||
|
||||
public function blank($lang='en')
|
||||
{
|
||||
$this->_lang_set($lang);
|
||||
$this->load->view('blank');
|
||||
}
|
||||
|
||||
public function index($lang='en')
|
||||
{
|
||||
$this->blank($lang);
|
||||
}
|
||||
}
|
||||
|
||||
/* End of file uploader.php */
|
||||
/* Location: ./application/controllers/uploader.php */
|
615
application/controllers/User.php
Normal file
615
application/controllers/User.php
Normal file
@@ -0,0 +1,615 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
use Coduo\PHPHumanizer\DateTimeHumanizer;
|
||||
|
||||
class User extends MY_Controller
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct('profile', 'language_names', 'country_names');
|
||||
$this->load->model('UserModel', '', TRUE);
|
||||
$this->load->model('PostsModel', '', TRUE);
|
||||
$this->load->model('FileModel', '', TRUE);
|
||||
}
|
||||
|
||||
public function index($user = "")
|
||||
{
|
||||
if ($user == "") {
|
||||
$title = "Error - Profile";
|
||||
$message = ["type" => "danger", "message1" => "Dieser Nutzer existiert nicht!", "message2" => "Es wurde kein Nutzername angegeben."];
|
||||
} else {
|
||||
$user_data = $this->UserModel->getUser($user);
|
||||
$user_exists = !empty($user_data);
|
||||
if ($user_exists) {
|
||||
$user_data = $user_data[0];
|
||||
$user_stats = $this->UserModel->getUserStats($user_data['ID']);
|
||||
|
||||
$user_posts = $this->PostsModel->getUserPosts($user_data['ID'], 3, 0, 192);
|
||||
$user_comments = $this->UserModel->getUserComments($user_data['ID'], 3, 0);
|
||||
$user_blog_posts = $this->UserModel->getUserBlogPosts($user_data['ID'], 3, 0);
|
||||
|
||||
$date_created = strtotime($user_data['date_created']);
|
||||
$user_data['time_existing'] = DateTimeHumanizer::difference(new \DateTime(), new \DateTime("@$date_created"), $_SESSION['site_lang']);
|
||||
$title = $user_data['displayname'] . " - Profile";
|
||||
$isCurrentUserFollowing = false;
|
||||
if (isset($_SESSION['user']['ID']))
|
||||
$isCurrentUserFollowing = $this->UserModel->isFollowing($_SESSION['user']['ID'], $user_data['ID']);
|
||||
|
||||
$_SESSION['currentProfilePage'] = $user_data['ID'];
|
||||
} else {
|
||||
$message = ["type" => "danger", "message1" => "Dieser Nutzer existiert nicht!", "message2" => "Der angegebene Nutzername konnte nicht gefunden werden."];
|
||||
$title = "Error - Profile";
|
||||
}
|
||||
}
|
||||
|
||||
$this->load->view('header', ['active' => 'profile', 'title' => $title, 'additionalStyles' => ['profile_page.css']]);
|
||||
if (isset($message)) {
|
||||
$this->load->view('network/message', $message);
|
||||
}
|
||||
if (isset($user_data) && isset($user_stats) && isset($user_posts) && isset($user_comments) && isset($user_blog_posts)) {
|
||||
$this->load->view('network/user/profile_page', ['data' => $user_data, 'stats' => $user_stats, 'posts' => $user_posts, 'comments' => $user_comments, 'blog_posts' => $user_blog_posts, 'isCurrentUserFollowing' => $isCurrentUserFollowing]);
|
||||
}
|
||||
$this->load->view('footer', ['additionalScripts' => ['profile_page.js']]);
|
||||
}
|
||||
|
||||
public function comments($user = "")
|
||||
{
|
||||
if ($user == "") {
|
||||
$title = "Error - Profile";
|
||||
$message = ["type" => "danger", "message1" => "Dieser Nutzer existiert nicht!", "message2" => "Es wurde kein Nutzername angegeben."];
|
||||
}
|
||||
|
||||
$user_data = $this->UserModel->getUser($user);
|
||||
$user_exists = !empty($user_data);
|
||||
if ($user_exists) {
|
||||
$user_data = $user_data[0];
|
||||
$dateCreated = strtotime($user_data['date_created']);
|
||||
$user_data['time_existing'] = DateTimeHumanizer::difference(new \DateTime(), new \DateTime("@$dateCreated"), $_SESSION['site_lang']);
|
||||
$user_stats = $this->UserModel->getUserStats($user_data['ID']);
|
||||
$title = $user_data['displayname'] . " - Blog-Kommentare";
|
||||
$isCurrentUserFollowing = false;
|
||||
if (isset($_SESSION['user']['ID']))
|
||||
$isCurrentUserFollowing = $this->UserModel->isFollowing($_SESSION['user']['ID'], $user_data['ID']);
|
||||
|
||||
$_SESSION['currentProfilePage'] = $user_data['ID'];
|
||||
} else {
|
||||
$message = ["type" => "danger", "message1" => "Dieser Nutzer existiert nicht!", "message2" => "Der angegebene Nutzername konnte nicht gefunden werden."];
|
||||
$title = "Error - Profile";
|
||||
}
|
||||
|
||||
|
||||
$this->load->view('header', ['active' => 'profile', 'title' => $title, 'additionalStyles' => ['profile_page.css']]);
|
||||
if (isset($message)) {
|
||||
$this->load->view('network/message', $message);
|
||||
}
|
||||
if ($user_exists) {
|
||||
$this->load->view('network/blog/user_comments', ['data' => $user_data, 'stats' => $user_stats, 'isCurrentUserFollowing' => $isCurrentUserFollowing]);
|
||||
}
|
||||
$this->load->view('footer', ['additionalScripts' => ['profile_page.js']]);
|
||||
$this->load->view('network/blog/user_comments_end', ['data' => $user_data]);
|
||||
}
|
||||
|
||||
public function getComments()
|
||||
{
|
||||
$user = (int)$this->input->get('user');
|
||||
$amount = (int)$this->input->get('amount');
|
||||
$offset = (int)$this->input->get('offset') * $amount;
|
||||
$user_comments = $this->UserModel->getUserComments($user, $amount, $offset);
|
||||
$comment_user = $this->UserModel->getUserByID($user)[0];
|
||||
|
||||
foreach ($user_comments as $comment) {
|
||||
$this->load->view('network/blog/comment_item', ['data' => $comment_user, 'c' => $comment]);
|
||||
}
|
||||
}
|
||||
|
||||
public function posts($user = "")
|
||||
{
|
||||
if ($user == "") {
|
||||
redirect(base_url('user'));
|
||||
}
|
||||
|
||||
$user_data = $this->UserModel->getUser($user);
|
||||
$user_exists = !empty($user_data);
|
||||
if ($user_exists) {
|
||||
$user_data = $user_data[0];
|
||||
$dateCreated = strtotime($user_data['date_created']);
|
||||
$user_data['time_existing'] = DateTimeHumanizer::difference(new \DateTime(), new \DateTime("@$dateCreated"), $_SESSION['site_lang']);
|
||||
$user_stats = $this->UserModel->getUserStats($user_data['ID']);
|
||||
$title = $user_data['displayname'] . " - Posts";
|
||||
$isCurrentUserFollowing = false;
|
||||
if (isset($_SESSION['user']['ID']))
|
||||
$isCurrentUserFollowing = $this->UserModel->isFollowing($_SESSION['user']['ID'], $user_data['ID']);
|
||||
|
||||
$_SESSION['currentProfilePage'] = $user_data['ID'];
|
||||
} else {
|
||||
$message = ["type" => "danger", "message1" => "Dieser Nutzer existiert nicht!", "message2" => "Der angegebene Nutzername konnte nicht gefunden werden."];
|
||||
$title = "Error - Profile";
|
||||
}
|
||||
|
||||
$this->load->view('header', ['active' => 'profile', 'title' => $title, 'additionalStyles' => ['profile_page.css']]);
|
||||
if (isset($message)) {
|
||||
$this->load->view('network/message', $message);
|
||||
}
|
||||
if ($user_exists) {
|
||||
$this->load->view('network/user/user_posts', ['data' => $user_data, 'stats' => $user_stats, 'isCurrentUserFollowing' => $isCurrentUserFollowing]);
|
||||
}
|
||||
$this->load->view('footer', ['additionalScripts' => ['profile_page.js']]);
|
||||
$this->load->view('network/user/user_posts_end', ['data' => $user_data]);
|
||||
}
|
||||
|
||||
public function getPosts()
|
||||
{
|
||||
$user = (int)$this->input->get('user');
|
||||
$amount = (int)$this->input->get('amount');
|
||||
$offset = (int)$this->input->get('offset') * $amount;
|
||||
$user_posts = $this->PostsModel->getUserPosts($user, $amount, $offset);
|
||||
|
||||
foreach ($user_posts as $post) {
|
||||
$this->load->view('network/posts/post_item', $post);
|
||||
}
|
||||
}
|
||||
|
||||
public function blogposts($user = "")
|
||||
{
|
||||
if ($user == "") {
|
||||
redirect(base_url('user'));
|
||||
}
|
||||
|
||||
$user_data = $this->UserModel->getUser($user);
|
||||
$user_exists = !empty($user_data);
|
||||
if ($user_exists) {
|
||||
$user_data = $user_data[0];
|
||||
$dateCreated = strtotime($user_data['date_created']);
|
||||
$user_data['time_existing'] = DateTimeHumanizer::difference(new \DateTime(), new \DateTime("@$dateCreated"), $_SESSION['site_lang']);
|
||||
$user_stats = $this->UserModel->getUserStats($user_data['ID']);
|
||||
$title = $user_data['displayname'] . " - Posts";
|
||||
$isCurrentUserFollowing = false;
|
||||
if (isset($_SESSION['user']['ID']))
|
||||
$isCurrentUserFollowing = $this->UserModel->isFollowing($_SESSION['user']['ID'], $user_data['ID']);
|
||||
|
||||
$_SESSION['currentProfilePage'] = $user_data['ID'];
|
||||
} else {
|
||||
$message = ["type" => "danger", "message1" => "Dieser Nutzer existiert nicht!", "message2" => "Der angegebene Nutzername konnte nicht gefunden werden."];
|
||||
$title = "Error - Profile";
|
||||
}
|
||||
|
||||
$this->load->view('header', ['active' => 'profile', 'title' => $title, 'additionalStyles' => ['profile_page.css']]);
|
||||
if (isset($message)) {
|
||||
$this->load->view('network/message', $message);
|
||||
}
|
||||
if ($user_exists) {
|
||||
$this->load->view('network/blog/user_blog_posts', ['data' => $user_data, 'stats' => $user_stats, 'isCurrentUserFollowing' => $isCurrentUserFollowing]);
|
||||
}
|
||||
$this->load->view('footer', ['additionalScripts' => ['profile_page.js']]);
|
||||
$this->load->view('network/blog/user_blog_posts_end', ['data' => $user_data]);
|
||||
}
|
||||
|
||||
public function getBlogPosts()
|
||||
{
|
||||
$user = (int)$this->input->get('user');
|
||||
$amount = (int)$this->input->get('amount');
|
||||
$offset = (int)$this->input->get('offset') * $amount;
|
||||
$user_posts = $this->UserModel->getUserBlogPosts($user, $amount, $offset);
|
||||
$post_user = $this->UserModel->getUserByID($user)[0];
|
||||
|
||||
foreach ($user_posts as $post) {
|
||||
$this->load->view('network/blog/blog_post_item', ['data' => $post_user, 'post' => $post]);
|
||||
}
|
||||
}
|
||||
|
||||
public function publishPost()
|
||||
{
|
||||
if (!isset($_SESSION['user']) || empty($_SESSION['user'])) {
|
||||
?>
|
||||
<div class="alert alert-danger" role="alert">
|
||||
<b>Veröffentlichen des Posts fehlgeschlagen!</b>
|
||||
Du musst in deinen Account eingeloggt sein, um Posts erstellen zu können.<br>
|
||||
|
||||
Bitte erstelle dir entweder
|
||||
<a href="<?= base_url('login') ?>">kostenlos einen neuen Account</a>
|
||||
oder
|
||||
<a href="<?= base_url('login') ?>">melde dich an</a>.
|
||||
</div>
|
||||
<?php
|
||||
exit;
|
||||
}
|
||||
|
||||
var_dump($this->input->post('postMedia'));
|
||||
|
||||
$content = $this->input->post('content');
|
||||
if (strlen($content) >= 10000) {
|
||||
?>
|
||||
<div class="alert alert-warning" role="alert">
|
||||
<b>Veröffentlichung des Posts fehlgeschlagen!</b> Dein Post ist leider zu lang. Er darf maximal 10.000 Zeichen umfassen.
|
||||
</div>
|
||||
<?php
|
||||
exit;
|
||||
}
|
||||
|
||||
$replyTo = $this->input->post('replyTo');
|
||||
if ($replyTo !== "-1" && !$this->PostsModel->isUUIDValid($replyTo)) {
|
||||
?>
|
||||
<div class="alert alert-warning" role="alert">
|
||||
<b>Veröffentlichung des Posts fehlgeschlagen!</b> Der Post, an den du deine Antwort richten willst, existiert nicht (mehr).<br>
|
||||
Solltest du dies für einen Fehler halten, versuche es später erneut oder kontaktiere uns.
|
||||
</div>
|
||||
<?php
|
||||
exit;
|
||||
}
|
||||
|
||||
$postID = -1;
|
||||
if ($replyTo !== "-1") {
|
||||
$postID = $this->PostsModel->addReply($_SESSION['user']['ID'], $content, $replyTo);
|
||||
} else {
|
||||
$postID = $this->PostsModel->addPost($_SESSION['user']['ID'], $content);
|
||||
}
|
||||
|
||||
$media = $this->input->post('postMedia');
|
||||
foreach ($media as $entry) {
|
||||
$image = str_replace(' ', '+', $entry['image']);
|
||||
$image = substr($image, strpos($image, ',') + 1);
|
||||
$image = base64_decode($image);
|
||||
|
||||
$fileUrl = $this->FileModel->uploadFileByContent($image, $entry['name'], $entry['type'], $entry['size']);
|
||||
|
||||
$this->PostsModel->addImageToPost($postID, $fileUrl);
|
||||
}
|
||||
|
||||
?>
|
||||
<div class="alert alert-success" role="alert">
|
||||
<b>Dein Post wurde erfolgreich veröffentlicht!</b> Möchtest du nun deine Posts ansehen? <br>
|
||||
<button type="button" class="btn btn-sm btn-default" data-dismiss="modal">Nein</button>
|
||||
<a href='<?= base_url('user/' . $_SESSION['user']['username'] . '/posts') ?>' class='btn btn-sm btn-primary'>Ja</a>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
public function followers($user = "")
|
||||
{
|
||||
if ($user == "") {
|
||||
$title = "Error - Profile";
|
||||
$message = ["type" => "danger", "message1" => "Dieser Nutzer existiert nicht!", "message2" => "Es wurde kein Nutzername angegeben."];
|
||||
}
|
||||
|
||||
$user_data = $this->UserModel->getUser($user);
|
||||
$user_exists = !empty($user_data);
|
||||
if ($user_exists) {
|
||||
$user_data = $user_data[0];
|
||||
$dateCreated = strtotime($user_data['date_created']);
|
||||
$user_data['time_existing'] = DateTimeHumanizer::difference(new \DateTime(), new \DateTime("@$dateCreated"), $_SESSION['site_lang']);
|
||||
$user_stats = $this->UserModel->getUserStats($user_data['ID']);
|
||||
$followers = $this->UserModel->getFollowers($user_data['ID']);
|
||||
$title = $user_data['displayname'] . " - Follower";
|
||||
$isCurrentUserFollowing = false;
|
||||
if (isset($_SESSION['user']['ID']))
|
||||
$isCurrentUserFollowing = $this->UserModel->isFollowing($_SESSION['user']['ID'], $user_data['ID']);
|
||||
|
||||
$_SESSION['currentProfilePage'] = $user_data['ID'];
|
||||
} else {
|
||||
$message = ["type" => "danger", "message1" => "Dieser Nutzer existiert nicht!", "message2" => "Der angegebene Nutzername konnte nicht gefunden werden."];
|
||||
$title = "Error - Profile";
|
||||
}
|
||||
|
||||
$this->load->view('header', ['active' => 'profile', 'title' => $title, 'additionalStyles' => ['profile_page.css']]);
|
||||
if (isset($message)) {
|
||||
$this->load->view('network/message', $message);
|
||||
}
|
||||
if ($user_exists) {
|
||||
$this->load->view('network/user/user_followers', ['data' => $user_data, 'active' => 'followers', 'stats' => $user_stats, 'isCurrentUserFollowing' => $isCurrentUserFollowing, 'followers' => $followers]);
|
||||
}
|
||||
$this->load->view('footer', ['additionalScripts' => ['profile_page.js']]);
|
||||
}
|
||||
|
||||
public function following($user = "")
|
||||
{
|
||||
if ($user == "") {
|
||||
$title = "Error - Profile";
|
||||
$message = ["type" => "danger", "message1" => "Dieser Nutzer existiert nicht!", "message2" => "Es wurde kein Nutzername angegeben."];
|
||||
}
|
||||
|
||||
$user_data = $this->UserModel->getUser($user);
|
||||
$user_exists = !empty($user_data);
|
||||
if ($user_exists) {
|
||||
$user_data = $user_data[0];
|
||||
$dateCreated = strtotime($user_data['date_created']);
|
||||
$user_data['time_existing'] = DateTimeHumanizer::difference(new \DateTime(), new \DateTime("@$dateCreated"), $_SESSION['site_lang']);
|
||||
$user_stats = $this->UserModel->getUserStats($user_data['ID']);
|
||||
$following = $this->UserModel->getFollowing($user_data['ID']);
|
||||
$title = $user_data['displayname'] . " - Follower";
|
||||
$isCurrentUserFollowing = false;
|
||||
if (isset($_SESSION['user']['ID']))
|
||||
$isCurrentUserFollowing = $this->UserModel->isFollowing($_SESSION['user']['ID'], $user_data['ID']);
|
||||
|
||||
$_SESSION['currentProfilePage'] = $user_data['ID'];
|
||||
} else {
|
||||
$message = ["type" => "danger", "message1" => "Dieser Nutzer existiert nicht!", "message2" => "Der angegebene Nutzername konnte nicht gefunden werden."];
|
||||
$title = "Error - Profile";
|
||||
}
|
||||
|
||||
$this->load->view('header', ['active' => 'profile', 'title' => $title, 'additionalStyles' => ['profile_page.css']]);
|
||||
if (isset($message)) {
|
||||
$this->load->view('network/message', $message);
|
||||
}
|
||||
if ($user_exists) {
|
||||
$this->load->view('network/user/user_followers', ['data' => $user_data, 'active' => 'following', 'stats' => $user_stats, 'isCurrentUserFollowing' => $isCurrentUserFollowing, 'followers' => $following]);
|
||||
}
|
||||
$this->load->view('footer', ['additionalScripts' => ['profile_page.js']]);
|
||||
}
|
||||
|
||||
public function switchFollowing()
|
||||
{
|
||||
header('Content-Type: application/json');
|
||||
if(!isset($_SESSION['currentProfilePage'])) {
|
||||
$response = ['type' => 'error', 'code' => -1];
|
||||
echo json_encode($response);
|
||||
exit;
|
||||
}
|
||||
|
||||
$followedUser = $_SESSION['currentProfilePage'];
|
||||
|
||||
// code 0: not logged in
|
||||
// code 1: same user
|
||||
// code 10: unfollowed
|
||||
// code 11: now following
|
||||
|
||||
if (!isset($_SESSION['user']['username'])) {
|
||||
$response = ['type' => 'error', 'code' => 0];
|
||||
echo json_encode($response);
|
||||
exit;
|
||||
}
|
||||
|
||||
$follower = $_SESSION['user']['ID'];
|
||||
|
||||
if ($follower == $followedUser) {
|
||||
$response = ['type' => 'error', 'code' => 1];
|
||||
echo json_encode($response);
|
||||
exit;
|
||||
}
|
||||
|
||||
if ($this->UserModel->isFollowing($follower, $followedUser)) {
|
||||
$this->UserModel->unfollow($follower, $followedUser);
|
||||
$response = ['type' => 'success', 'code' => 10];
|
||||
echo json_encode($response);
|
||||
exit;
|
||||
}
|
||||
|
||||
$this->UserModel->follow($follower, $followedUser);
|
||||
$response = ['type' => 'success', 'code' => 11];
|
||||
echo json_encode($response);
|
||||
exit;
|
||||
}
|
||||
|
||||
public function edit($user = "")
|
||||
{
|
||||
if ($user == "") {
|
||||
redirect(base_url('user'));
|
||||
}
|
||||
|
||||
$user_data = $this->UserModel->getUser($user);
|
||||
$user_exists = !empty($user_data);
|
||||
if ($user_exists) {
|
||||
$user_data = $user_data[0];
|
||||
// Update Settings
|
||||
$newData = [];
|
||||
// TODO: Error messages
|
||||
// Username
|
||||
if (isset($_POST['username'])) {
|
||||
if (!preg_match('/[^A-Za-z0-9._]/', $_POST['username'])) {
|
||||
if ($this->LoginModel->isAvailable($_POST['username'])) {
|
||||
if (strlen($_POST['username']) >= 4) {
|
||||
$newData['username'] = strtolower($_POST['username']);
|
||||
$newData['displayname'] = $_POST['username'];
|
||||
} else {
|
||||
$_SESSION['profileEditNotification'] .= "<div class='alert alert-danger' role='alert'><b>Zu kurzer Nutzername!</b> Dein Name muss 4 Zeichen oder mehr enthalten.</div>";
|
||||
}
|
||||
} else {
|
||||
$_SESSION['profileEditNotification'] .= "<div class='alert alert-danger' role='alert'><b>Nutzername bereits vergeben!</b> Ein anderer Nutzer hat anscheinend diesen Namen bereits gewählt.</div>";
|
||||
}
|
||||
} else {
|
||||
$_SESSION['profileEditNotification'] .= "<div class='alert alert-danger' role='alert'><b>Ungültiger Nutzername!</b> Dein Name darf nur Groß- (A-Z) und Kleinbuchstaben (a-z), Zahlen (0-9) und Punkte (.) sowie Unterstriche (_).</div>";
|
||||
}
|
||||
}
|
||||
// Gender
|
||||
if (isset($_POST['gender'])) {
|
||||
if ($_POST['gender'] == "male" || $_POST['gender'] == "female" || $_POST['gender'] == 'other') {
|
||||
$newData['gender'] = $_POST['gender'];
|
||||
}
|
||||
}
|
||||
// Birth date
|
||||
if (isset($_POST['birthdate-day']) && isset($_POST['birthdate-month'])) {
|
||||
$day = intval($_POST['birthdate-day']);
|
||||
$month = intval($_POST['birthdate-month']);
|
||||
if ($month > 0 && $month <= 12) {
|
||||
$monthDayCount = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
||||
if ($day <= $monthDayCount[$month - 1]) {
|
||||
$newData['birthdate'] = $day . '.' . $month . '.';
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isset($_POST['birthdate-year'])) {
|
||||
|
||||
}
|
||||
// Language
|
||||
if (isset($_POST['language'])) {
|
||||
$newData['language'] = $_POST['language'];
|
||||
}
|
||||
// Country
|
||||
if (isset($_POST['country'])) {
|
||||
$newData['country'] = $_POST['country'];
|
||||
}
|
||||
// Biography/About
|
||||
if (isset($_POST['biography'])) {
|
||||
$newData['about'] = $_POST['biography'];
|
||||
}
|
||||
// Avatar
|
||||
if (isset($_FILES['avatar'])) {
|
||||
$image = $this->FileModel->uploadImage('avatar', 4096, $_FILES['avatar']['name'], 200);
|
||||
if ($image != null)
|
||||
$newData['profile_picture'] = $image;
|
||||
unset($_FILES['avatar']);
|
||||
}
|
||||
// Header
|
||||
if (isset($_FILES['header'])) {
|
||||
// var_dump($_FILES['header']);
|
||||
$image = $this->FileModel->uploadImage('header', 4096, $_FILES['header']['name'], 1920);
|
||||
// var_dump($image);
|
||||
if ($image != null)
|
||||
$newData['header_image'] = $image;
|
||||
unset($_FILES['header']);
|
||||
}
|
||||
// Social Networks
|
||||
if (isset($_POST['social-networks'])) {
|
||||
|
||||
}
|
||||
// Profile color
|
||||
if (isset($_POST['color'])) {
|
||||
|
||||
}
|
||||
// E-Mail-Address
|
||||
if (isset($_POST['email'])) {
|
||||
if (isset($_POST['email-password']) && !empty($_POST['email-password'])) {
|
||||
$loginData = $this->LoginModel->getLoginData($_SESSION['user']['username']);
|
||||
if (empty($loginData)) {
|
||||
$_SESSION['profileEditNotification'] .= "<div class='alert alert-danger' role='alert'><b>Ungültiger Account</b> Anscheinend versuchst du die E-Mail-Adresse eines nicht existierenden Accounts zu ändern. Sollte es sich um einen Fehler handeln, kontaktiere bitte das Website-Team!</div>";
|
||||
} else {
|
||||
$loginData = $loginData[0];
|
||||
$encryptedPassword = $this->LoginModel->getPasswordHash($_POST['email-password'], $loginData['original_name']);
|
||||
if ($loginData['password'] == $encryptedPassword) {
|
||||
$isRegistered = $this->LoginModel->isRegistered($_POST['email']);
|
||||
if ($isRegistered == "") {
|
||||
$trashMail = $this->LoginModel->isTrashMail($_POST['email']);
|
||||
if ($trashMail == '') {
|
||||
$this->LoginModel->changeMailAddress($_POST['email'], $loginData['username']);
|
||||
$_SESSION['profileEditNotification'] .= "<div class='alert alert-warning' role='alert'><b>Deine E-Mail-Adresse wurde geändert!</b> Nun musst du nur noch in deinem Postfach vorbeischauen und die neue Adresse aktivieren.</div>";
|
||||
} else {
|
||||
$_SESSION['profileEditNotification'] .= $trashMail;
|
||||
}
|
||||
} else {
|
||||
$_SESSION['profileEditNotification'] .= $isRegistered;
|
||||
}
|
||||
} else {
|
||||
$_SESSION['profileEditNotification'] .= "<div class='alert alert-danger' role='alert'><b>Ungültiges Passwort!</b> Es scheint als wäre das eingegebene Passwort nicht mit dem richtigen übereinstimmend.</div>";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$_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
|
||||
if (isset($_POST['email-notifications'])) {
|
||||
$newData['receiveEmails'] = filter_var($_POST['email-notifications'], FILTER_VALIDATE_BOOLEAN);
|
||||
}
|
||||
// Newsletter
|
||||
if (isset($_POST['newsletter'])) {
|
||||
$newData['receiveNewsletter'] = filter_var($_POST['newsletter'], FILTER_VALIDATE_BOOLEAN);
|
||||
}
|
||||
// Password
|
||||
if (isset($_POST['passwordNew'])) {
|
||||
if (isset($_POST['passwordOld'])) {
|
||||
$loginData = $this->LoginModel->getLoginData($_SESSION['user']['username']);
|
||||
if (!empty($loginData)) {
|
||||
$loginData = $loginData[0];
|
||||
$encryptedPassword = $this->LoginModel->getPasswordHash($_POST['passwordOld'], $loginData['original_name']);
|
||||
if ($encryptedPassword == $loginData['password']) {
|
||||
if ($this->LoginModel->checkPassword($_POST['passwordNew'])) {
|
||||
if (isset($_POST['passwordNewRepeat']) && $_POST['passwordNew'] == $_POST['passwordNewRepeat']) {
|
||||
$this->LoginModel->changePassword($_POST['passwordNew'], $loginData['original_name']);
|
||||
$_SESSION['profileEditNotification'] .= "<div class='alert alert-success' role='alert'><b>Dein Passwort wurde geändert!</b> Du kannst dich nun damit einloggen</div>";
|
||||
} else {
|
||||
$_SESSION['profileEditNotification'] .= "<div class='alert alert-danger' role='alert'><b>Wiederholtes Passwort falsch!</b> Das Passwort, das du wiederholt hast, stimmt nicht mit dem eigentlichen überein.</div>";
|
||||
}
|
||||
} else {
|
||||
$_SESSION['profileEditNotification'] .= "<div class='alert alert-danger' role='alert'><b>Zu unsicheres Passwort!</b> Dein Passwort sollte mindest 8 Zeichen lang sein und jeweils einen Groß-, einen Kleinbuchstaben, eine Zahl und ein Sonderzeichen enthalten.</div>";
|
||||
}
|
||||
} else {
|
||||
$_SESSION['profileEditNotification'] .= "<div class='alert alert-danger' role='alert'><b>Altes Passwort falsch!</b> Dein altes eingegebenes Passwort ist falsch!</div>";
|
||||
}
|
||||
} else {
|
||||
$_SESSION['profileEditNotification'] .= "<div class='alert alert-danger' role='alert'><b>Ungültiger Account</b> Anscheinend versuchst du die E-Mail-Adresse eines nicht existierenden Accounts zu ändern. Sollte es sich um einen Fehler handeln, kontaktiere bitte das Website-Team!</div>";
|
||||
}
|
||||
} else {
|
||||
$_SESSION['profileEditNotification'] .= "<div class='alert alert-danger' role='alert'><b>Altes Passwort fehlend!</b> Bitte gib dein altes Passwort ebenfalls ein!</div>";
|
||||
}
|
||||
}
|
||||
if (isset($_POST['showAds'])) {
|
||||
if (isset($_SESSION['user']) && $_SESSION['user']['rank'] >= 2) {
|
||||
$newData['showAds'] = filter_var($_POST['email-notifications'], FILTER_VALIDATE_BOOLEAN);
|
||||
} 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>";
|
||||
}
|
||||
}
|
||||
if (!empty($newData)) {
|
||||
// Add entry to history
|
||||
$this->UserModel->insertIntoHistory($user_data);
|
||||
// Update profile
|
||||
$this->UserModel->updateProfile($newData, $user_data['ID']);
|
||||
// redirect(base_url(uri_string()));
|
||||
}
|
||||
|
||||
$user_stats = $this->UserModel->getUserStats($user_data['ID']);
|
||||
$title = $user_data['displayname'] . ' - Profil bearbeiten';
|
||||
}
|
||||
|
||||
$this->load->view('header', ['active' => 'profile', 'title' => $title, 'additionalStyles' => ['lib/selectize.css', 'lib/selectize.bootstrap3.css', 'profile_page.css']]);
|
||||
$editMessage = isset($_SESSION['profileEditNotification']) ? $_SESSION['profileEditNotification'] : "";
|
||||
$_SESSION['profileEditNotification'] = "";
|
||||
if (isset($message)) {
|
||||
$this->load->view('network/message', $message);
|
||||
}
|
||||
if ($user_exists) {
|
||||
$this->load->view('network/user/profile_edit', ['message' => $editMessage, 'data' => $user_data, 'stats' => $user_stats]);
|
||||
}
|
||||
$this->load->view('footer', ['additionalScripts' => ['lib/selectize.js', 'profile_page.js', 'profile_edit.js']]);
|
||||
}
|
||||
|
||||
public function single_post($username = null, $uuid = null, $origin = null)
|
||||
{
|
||||
$origin = isset($_GET['o']) ? $_GET['o'] : null;
|
||||
if ($origin == null) {
|
||||
$origin = base_url('user/' . $username);
|
||||
} else {
|
||||
$origin = base64_decode(urldecode($origin));
|
||||
}
|
||||
|
||||
$this->load->view('header', ['active' => 'profile', 'title' => 'Test']);
|
||||
$this->load->view('network/posts/user_post_page', ['origin' => $origin, 'username' => $username, 'uuid' => $uuid]);
|
||||
$this->load->view('footer', ['additionalScripts' => ['single-post-page.js']]);
|
||||
}
|
||||
|
||||
public function single_post_data($username = null, $uuid = null)
|
||||
{
|
||||
$message = "";
|
||||
$post = [];
|
||||
$replies = [];
|
||||
if ($username == null) {
|
||||
$message .= '<div class="alert alert-danger" role="alert"><b>Es wurde kein Nutzer angegeben!</b> Es können keine Posts von einem undefinierten Nutzer gefunden werden.</div>';
|
||||
goto display;
|
||||
}
|
||||
if ($uuid == null) {
|
||||
$message .= '<div class="alert alert-danger" role="alert"><b>Es wurde keine Post-ID angegeben!</b> Es können keine undefinierten Posts gefunden werden.</div>';
|
||||
goto display;
|
||||
}
|
||||
|
||||
$user = $this->UserModel->getUser($username);
|
||||
if (empty($user)) {
|
||||
$message .= '<div class="alert alert-warning" role="alert"><b>Es wurde kein Nutzer mit dem angegebenen Namen gefunden!</b> Vielleicht kannst du ja diese Lücke füllen?</div>';
|
||||
goto display;
|
||||
}
|
||||
$user = $user[0];
|
||||
|
||||
$post = $this->PostsModel->getPostDetails($user['ID'], $uuid);
|
||||
if (empty($post)) {
|
||||
$message .= '<div class="alert alert-warning" role="alert"><b>Es wurde kein Post mit der angegebenen ID gefunden!</b> Vielleicht kannst du ja diesen neuen Content erschaffen?</div>';
|
||||
goto display;
|
||||
}
|
||||
$post = $post[0];
|
||||
|
||||
$replies = $this->PostsModel->getPostReplies($post['ID']);
|
||||
|
||||
display:
|
||||
$this->load->view('network/posts/user_post_content', ['message' => $message, 'post' => $post, 'replies' => $replies]);
|
||||
|
||||
}
|
||||
}
|
369
application/controllers/admin/Blog.php
Normal file
369
application/controllers/admin/Blog.php
Normal file
@@ -0,0 +1,369 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Blog extends CI_Controller
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->load->model('BlogModel', '', TRUE);
|
||||
$this->load->model('FileModel', '', TRUE);
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 6) redirect(base_url('login'));
|
||||
$posts = $this->BlogModel->getPostList(false);
|
||||
$this->load->view('admin/sidebar', ['title' => 'Alle Blog-Posts']);
|
||||
$this->load->view('admin/blog_posts', ['posts' => $posts]);
|
||||
$this->load->view('admin/footer');
|
||||
}
|
||||
|
||||
public function tags() {
|
||||
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 6) {
|
||||
redirect(base_url('login'));
|
||||
}
|
||||
|
||||
$tags = $this->BlogModel->getAllTags();
|
||||
$tags = $this->BlogModel->mergeTagInfo($tags);
|
||||
|
||||
$this->load->view('admin/sidebar', ['title' => 'Alle Blog-Tags']);
|
||||
$this->load->view('admin/blog_tags', ['tags' => $tags]);
|
||||
$this->load->view('admin/footer', ['additionalScripts' => 'all-blog-tags.js']);
|
||||
}
|
||||
|
||||
public function sendEdit()
|
||||
{
|
||||
header('Content-Type: application/json');
|
||||
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 6) {
|
||||
echo json_encode(['success' => false, 'message' => 'Du musst eingeloggt sein, um Blog-Posts zu verfassen']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$postID = $this->input->post('postID');
|
||||
$postID = is_numeric($postID) && is_int(intval($postID)) ? intval($postID) : -2;
|
||||
|
||||
if ($postID == -2) {
|
||||
echo json_encode(['success' => false, 'message' => 'Ungültige Post-ID angegeben. Bitte versuche es später erneut']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$contentID = $this->input->post('contentID');
|
||||
$contentID = is_numeric($contentID) && is_int(intval($contentID)) ? intval($contentID) : -2;
|
||||
|
||||
$translationID = $this->input->post('translationID');
|
||||
$translationID = is_numeric($translationID) && is_int(intval($translationID)) ? intval($translationID) : -2;
|
||||
|
||||
$postImage = $this->input->post('postImage');
|
||||
$postTitle = $this->input->post('postTitle');
|
||||
$postDescription = $this->input->post('postDescription');
|
||||
$postContent = $this->input->post('postContent');
|
||||
|
||||
$postPublishDate = $this->input->post('postPublishDate');
|
||||
$postPublishDate = date("Y-m-d H:i:s", strtotime($postPublishDate));
|
||||
|
||||
$postUrl = $this->input->post('postUrl');
|
||||
$postCategory = $this->input->post('postCategory');
|
||||
$postTags = $this->input->post('postTags');
|
||||
|
||||
$postLang = $this->input->post('postLanguage');
|
||||
$postLang = $postLang !== NULL ? $postLang : 'de';
|
||||
|
||||
if(strlen($postUrl) == 0) {
|
||||
echo json_encode(['success' => false, 'message' => 'Es wurde keine Post-URL angegeben.']);
|
||||
exit;
|
||||
}
|
||||
if(strlen($postUrl) < 4) {
|
||||
echo json_encode(['success' => false, 'message' => 'Die angegebene Post-URL ist zu kurz. Sie muss mindestens 4 Zeichen umfassen, um eine eindeutige Zuordnung zu ermöglichen.']);
|
||||
exit;
|
||||
}
|
||||
|
||||
if ($postID == -1 || $translationID == -1) { // Create new blog post
|
||||
if ($postID == -1) {
|
||||
$postID = $this->BlogModel->createNewPostDraft($_SESSION['user']['ID']);
|
||||
|
||||
if($this->BlogModel->postUrlExisting($postUrl)) {
|
||||
echo json_encode(['success' => false, 'message' => 'Die angegebene Post-URL bereits vorhanden.']);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
$translationID = $this->BlogModel->createNewTranslation($postID, $postLang);
|
||||
}
|
||||
|
||||
if ($contentID < 0) {
|
||||
$contentID = $this->BlogModel->createNewContentDraft($postID);
|
||||
}
|
||||
|
||||
$this->BlogModel->updatePostDraft($postID, $postUrl, $postCategory, $postPublishDate, $postImage);
|
||||
$this->BlogModel->updateContentDraft($contentID, $postContent, $postLang);
|
||||
$this->BlogModel->updateTranslation($translationID, $postTitle, $postDescription);
|
||||
|
||||
if(!empty($postTags)) {
|
||||
$this->BlogModel->deleteAllPostTags($postID);
|
||||
foreach ($postTags as $postTag) {
|
||||
$tagID = $this->BlogModel->createTagIfNotExists($postTag);
|
||||
$this->BlogModel->addPostTagByID($postID, $tagID);
|
||||
}
|
||||
}
|
||||
|
||||
echo json_encode(['success' => true, 'message' => 'Der Entwurf wurde erfolgreich gespeichert.', 'postID' => $postID, 'contentID' => $contentID, 'translationID' => $translationID]);
|
||||
}
|
||||
|
||||
public function publishPost()
|
||||
{
|
||||
header('Content-Type: application/json');
|
||||
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 6) {
|
||||
echo json_encode(['success' => false, 'message' => 'Du musst eingeloggt sein, um Blog-Posts zu verfassen']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$postID = $this->input->post('postID');
|
||||
$postID = is_numeric($postID) && is_int(intval($postID)) ? intval($postID) : -2;
|
||||
|
||||
if ($postID < 0) {
|
||||
echo json_encode(['success' => false, 'message' => 'Ungültige Post-ID angegeben. Bitte versuche es später erneut']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$contentIDs = $this->input->post('contentIDs');
|
||||
$contentPublished = FALSE;
|
||||
foreach ($contentIDs as $lang => $contentID) {
|
||||
$contentID = is_numeric($contentID) && is_int(intval($contentID)) ? intval($contentID) : -2;
|
||||
|
||||
if($contentID < 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->BlogModel->publishContentDraft($_SESSION['user']['ID'], $contentID, $postID, $lang);
|
||||
$contentPublished = TRUE;
|
||||
}
|
||||
|
||||
if (!$contentPublished) {
|
||||
echo json_encode(['success' => false, 'message' => 'Ungültige Content-ID angegeben. Bitte versuche es später erneut']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$this->BlogModel->publishPostDraft($postID);
|
||||
|
||||
echo json_encode(['success' => true, 'message' => 'Der Post wurde erfolgreich veröffentlicht.']);
|
||||
}
|
||||
|
||||
public function getTranslations()
|
||||
{
|
||||
header('Content-Type: application/json');
|
||||
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 6) {
|
||||
echo json_encode(['status' => 'error', 'message' => 'Du musst eingeloggt sein, um Blog-Posts zu verfassen']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$postID = $this->input->post('postID');
|
||||
$postID = is_numeric($postID) && is_int(intval($postID)) ? intval($postID) : -2;
|
||||
|
||||
if ($postID < 0) {
|
||||
echo json_encode(['status' => 'error', 'message' => 'Ungültige Post-ID angegeben. Bitte versuche es später erneut']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$translations = $this->BlogModel->getPostTranslations($postID);
|
||||
echo json_encode(['status' => 'success', 'translations' => $translations]);
|
||||
}
|
||||
|
||||
public function getPost() {
|
||||
header('Content-Type: application/json');
|
||||
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 6) {
|
||||
echo json_encode(['status' => 'error', 'message' => 'Du musst eingeloggt sein, um Blog-Posts zu verfassen.']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$postID = intval($this->input->post('postID'));
|
||||
|
||||
if(!is_numeric($postID)) {
|
||||
echo json_encode(['status' => 'error', 'message' => 'Es wurde eine ungültige Post-ID angegeben.']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$postData = $this->BlogModel->getPostDataByID($postID);
|
||||
|
||||
if(empty($postData)) {
|
||||
echo json_encode(['status' => 'error', 'message' => 'Es wurde kein Post mit der angegebenen Post-ID gefunden.']);
|
||||
exit;
|
||||
}
|
||||
|
||||
echo json_encode(['status' => 'success', 'postData' => $postData[0]]);
|
||||
}
|
||||
|
||||
public function getContent() {
|
||||
header('Content-Type: application/json');
|
||||
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 6) {
|
||||
echo json_encode(['status' => 'error', 'message' => 'Du musst eingeloggt sein, um Blog-Posts zu verfassen.']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$postID = intval($this->input->post('postID'));
|
||||
$contentID = intval($this->input->post('contentID'));
|
||||
$language = $this->input->post('lang');
|
||||
|
||||
if(!is_numeric($postID)) {
|
||||
echo json_encode(['status' => 'error', 'message' => 'Es wurde eine ungültige Post-ID angegeben.']);
|
||||
exit;
|
||||
}
|
||||
|
||||
if(!is_numeric($contentID)) {
|
||||
echo json_encode(['status' => 'error', 'message' => 'Es wurde kein Content mit der angegebenen Content-ID gefunden.']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$contentData = $this->BlogModel->getContentDataByID($postID, $contentID, $language);
|
||||
|
||||
if(empty($contentData)) {
|
||||
echo json_encode(['status' => 'error', 'message' => 'Es wurde kein Content mit der angegebenen Content-ID gefunden.']);
|
||||
exit;
|
||||
}
|
||||
|
||||
echo json_encode(['status' => 'success', 'contentData' => $contentData[0]]);
|
||||
}
|
||||
|
||||
public function getTranslationData() {
|
||||
header('Content-Type: application/json');
|
||||
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 6) {
|
||||
echo json_encode(['status' => 'error', 'message' => 'Du musst eingeloggt sein, um Blog-Posts zu verfassen.']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$postID = intval($this->input->post('postID'));
|
||||
$translationID = intval($this->input->post('translationID'));
|
||||
$language = $this->input->post('lang');
|
||||
|
||||
if(!is_numeric($postID)) {
|
||||
echo json_encode(['status' => 'error', 'message' => 'Es wurde eine ungültige Post-ID angegeben.']);
|
||||
exit;
|
||||
}
|
||||
|
||||
if(!is_numeric($translationID)) {
|
||||
echo json_encode(['status' => 'error', 'message' => 'Es wurde kein Übersetzung mit der angegebenen ID gefunden.']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$translationData = $this->BlogModel->getTranslationDataByID($postID, $translationID, $language);
|
||||
|
||||
if(empty($translationData)) {
|
||||
echo json_encode(['status' => 'error', 'message' => 'Es wurde kein Übersetzung mit der angegebenen ID gefunden.']);
|
||||
exit;
|
||||
}
|
||||
|
||||
echo json_encode(['status' => 'success', 'translationData' => $translationData[0]]);
|
||||
}
|
||||
|
||||
public function getPostTags() {
|
||||
header('Content-Type: application/json');
|
||||
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 6) {
|
||||
echo json_encode(['success' => false, 'message' => 'Du musst eingeloggt sein, um Blog-Posts zu verfassen.']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$postID = intval($this->input->post('postID'));
|
||||
|
||||
if(!is_numeric($postID)) {
|
||||
echo json_encode(['success' => false, 'message' => 'Es wurde eine ungültige Post-ID angegeben.']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$postTags = $this->BlogModel->getTags($postID);
|
||||
|
||||
echo json_encode(['success' => true, 'tags' => $postTags]);
|
||||
}
|
||||
|
||||
public function edit($postID = -1, $lang = "de")
|
||||
{
|
||||
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 6) redirect(base_url('login'));
|
||||
|
||||
$translations = ['de' => -1];
|
||||
$contents = ['de' => -1];
|
||||
|
||||
if(!$postID != -1) {
|
||||
if($this->BlogModel->postIDExisting($postID)) {
|
||||
$postTranslations = $this->BlogModel->getPostTranslationIDs($postID);
|
||||
foreach ($postTranslations as $postTranslation) {
|
||||
$translations[$postTranslation['language']] = $postTranslation['postTranslationID'];
|
||||
}
|
||||
|
||||
$postContents = $this->BlogModel->getPostContentIDs($postID);
|
||||
foreach ($postContents as $postContent) {
|
||||
$contents[$postContent['language']] = $postContent['contentID'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$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/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']);
|
||||
}
|
||||
|
||||
public function history($postID = NULL)
|
||||
{
|
||||
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 6) redirect(base_url('login'));
|
||||
if ($postID === NULL) redirect(base_url('admin/blog'));
|
||||
|
||||
$content['de'] = $this->BlogModel->getAllContentVersions($postID, 'de');
|
||||
$content['en'] = $this->BlogModel->getAllContentVersions($postID, 'en');
|
||||
$content['fr'] = $this->BlogModel->getAllContentVersions($postID, 'fr');
|
||||
|
||||
$this->load->view('admin/sidebar', ['title' => 'Geschichte']);
|
||||
$this->load->view('admin/blog_history', ['content' => $content]);
|
||||
$this->load->view('admin/footer');
|
||||
}
|
||||
|
||||
public function new_category()
|
||||
{
|
||||
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] !== 'admin') redirect(base_url('login'));
|
||||
$name = filter_input(INPUT_POST, "name");
|
||||
$display_name = filter_input(INPUT_POST, "display_name");
|
||||
if ($name !== NULL && $display_name !== NULL) {
|
||||
$category = $this->BlogModel->getCategoryIDAfterInsert($name, $display_name);
|
||||
echo $category;
|
||||
}
|
||||
}
|
||||
|
||||
public function delete()
|
||||
{
|
||||
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 6) redirect(base_url('login'));
|
||||
$id = filter_input(INPUT_POST, "id");
|
||||
echo $this->BlogModel->deletePost($id);
|
||||
}
|
||||
|
||||
public function deleteFinally()
|
||||
{
|
||||
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 6) redirect(base_url('login'));
|
||||
$id = filter_input(INPUT_POST, "id");
|
||||
$this->BlogModel->deletePostFinally($id);
|
||||
}
|
||||
|
||||
public function restore()
|
||||
{
|
||||
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 6) redirect(base_url('login'));
|
||||
$id = filter_input(INPUT_POST, "id");
|
||||
echo $this->BlogModel->restorePost($id);
|
||||
}
|
||||
|
||||
public function trashbin()
|
||||
{
|
||||
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 6) redirect(base_url('login'));
|
||||
$posts = $this->BlogModel->getPostList(true);
|
||||
$this->load->view('admin/sidebar', ['title' => 'Alle Blog-Posts']);
|
||||
$this->load->view('admin/blog_posts', ['posts' => $posts, 'trashbin' => true]);
|
||||
$this->load->view('admin/footer');
|
||||
}
|
||||
|
||||
public function tagsList()
|
||||
{
|
||||
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 6) {
|
||||
echo '{"type":"error", "message":"<b>Fehler beim Upload!</b> Aufgrund von zu geringen Zugriffsrechten konnte das Bild leider nicht hochgeladen werden <i>Sollte es sich dabei um ein Irrtum handeln, kontaktiere bitte einen Admin über das Kontakformular.</i>"}';
|
||||
header("Content-Type: application/json");
|
||||
exit;
|
||||
}
|
||||
echo json_encode($this->BlogModel->getAllTags());
|
||||
header("Content-Type: application/json");
|
||||
}
|
||||
}
|
24
application/controllers/admin/Calendar.php
Normal file
24
application/controllers/admin/Calendar.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Calendar extends CI_Controller {
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
$this->load->model('adminModel', '', TRUE);
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 9) redirect(base_url('login'));
|
||||
$this->load->view('admin/sidebar', ['title' => 'Dashboard']);
|
||||
$this->load->view('admin/calendar');
|
||||
$this->load->view('admin/footer');
|
||||
}
|
||||
|
||||
public function getAllEvents() {
|
||||
$events = $this->adminModel->getCalendarEvents();
|
||||
|
||||
echo json_encode($events);
|
||||
}
|
||||
}
|
18
application/controllers/admin/Contact.php
Normal file
18
application/controllers/admin/Contact.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Contact extends CI_Controller
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->load->model('UserModel', '', TRUE);
|
||||
}
|
||||
|
||||
public function index() {
|
||||
|
||||
$this->load->view('admin/sidebar', ['title' => 'Kontakt-Nachrichten']);
|
||||
$this->load->view('admin/footer');
|
||||
}
|
||||
}
|
17
application/controllers/admin/Dashboard.php
Normal file
17
application/controllers/admin/Dashboard.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Dashboard extends CI_Controller {
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 6) redirect(base_url('login'));
|
||||
$this->load->view('admin/sidebar', ['title' => 'Dashboard']);
|
||||
$this->load->view('admin/dashboard');
|
||||
$this->load->view('admin/footer');
|
||||
}
|
||||
}
|
74
application/controllers/admin/Downloads.php
Normal file
74
application/controllers/admin/Downloads.php
Normal file
@@ -0,0 +1,74 @@
|
||||
<?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');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
67
application/controllers/admin/Feedback.php
Normal file
67
application/controllers/admin/Feedback.php
Normal file
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Feedback extends CI_Controller
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->load->model('MessageModel', '', TRUE);
|
||||
}
|
||||
|
||||
public function index() {
|
||||
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 9) redirect(base_url('login'));
|
||||
|
||||
$feedback = $this->MessageModel->getFeedbackMessages();
|
||||
|
||||
$this->load->view('admin/sidebar', ['title' => 'Feedback-Nachrichten']);
|
||||
$this->load->view('admin/feedback', ['feedback' => $feedback]);
|
||||
$this->load->view('admin/footer', ['additionalScripts' => 'feedback.js']);
|
||||
}
|
||||
|
||||
public function takeover($id = null, $state = 1) {
|
||||
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 9) redirect(base_url('login'));
|
||||
|
||||
if($id != null) {
|
||||
$this->MessageModel->setFeedbackSupporter($id, $_SESSION['user']['ID'], $state);
|
||||
}
|
||||
|
||||
redirect(base_url('admin/feedback'));
|
||||
}
|
||||
|
||||
public function change($id) {
|
||||
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 9) redirect(base_url('login'));
|
||||
|
||||
if($id != null) {
|
||||
$newStatus = $this->input->post('feedbackState');
|
||||
|
||||
$this->MessageModel->updateState($id, $_SESSION['user']['ID'], $newStatus);
|
||||
}
|
||||
|
||||
redirect(base_url('admin/feedback'));
|
||||
}
|
||||
|
||||
public function archive() {
|
||||
// header('Content-Type: application/json');
|
||||
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 9) {
|
||||
echo json_encode(['type' => 'error', 'message' => 'Du musst eingeloggt sein, um Feedbacks zu beantworten.']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$feedbackID = intval($this->input->post('id'));
|
||||
|
||||
if(!is_numeric($feedbackID)) {
|
||||
echo json_encode(['type' => 'error', 'message' => 'Die angegebene Feedback-ID ist ungültig.']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$successful = $this->MessageModel->archiveFeedback($feedbackID);
|
||||
|
||||
if($successful) {
|
||||
echo json_encode(['type' => 'success', 'message' => 'Das Feedback wurde erfolgreich gelöscht.']);
|
||||
} else {
|
||||
echo json_encode(['type' => 'error', 'message' => 'Das Feedback muss vor dem Löschen zuerst bearbeitet und geschlossen werden.']);
|
||||
}
|
||||
}
|
||||
}
|
74
application/controllers/admin/Files.php
Normal file
74
application/controllers/admin/Files.php
Normal file
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Files extends CI_Controller
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->load->model('FileModel', '', TRUE);
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 9) redirect(base_url('login'));
|
||||
|
||||
if(isset($_FILES['fileUpload'])) {
|
||||
$fileName = $_FILES['fileUpload']['name'];
|
||||
$tmpName = $_FILES['fileUpload']['tmp_name'];
|
||||
$fileSize = $_FILES['fileUpload']['size'];
|
||||
$fileType = $_FILES['fileUpload']['type'];
|
||||
|
||||
$this->FileModel->uploadFile($fileName, $tmpName, $fileSize, $fileType);
|
||||
|
||||
unset($_FILES['fileUpload']);
|
||||
|
||||
redirect(base_url('admin/files'));
|
||||
}
|
||||
|
||||
|
||||
$files = $this->FileModel->getFileList();
|
||||
|
||||
$this->load->view('admin/sidebar', ['title' => 'Alle Dateien', 'additionalStyles' => ['lib/jquery.fileupload.css', 'lib/jquery.fileupload-ui.css']]);
|
||||
$this->load->view('admin/files', ['files' => $files]);
|
||||
$this->load->view('admin/footer', ['additionalScripts' => ['lib/jquery.ui.widget.js', 'lib/jquery.iframe-transport.js', 'lib/jquery.fileupload.js', 'lib/jquery.fileupload-process.js', 'lib/jquery.fileupload-image.js', 'lib/jquery.fileupload-audio.js', 'lib/jquery.fileupload-video.js', 'lib/jquery.fileupload-validate.js', 'lib/jquery.fileupload-ui.js']]);
|
||||
}
|
||||
|
||||
public function delete() {
|
||||
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 9) redirect(base_url('login'));
|
||||
$id = filter_input(INPUT_POST, "id");
|
||||
$this->FileModel->delete($id);
|
||||
}
|
||||
|
||||
public function uploadImage()
|
||||
{
|
||||
header("Content-Type: application/json");
|
||||
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 6) {
|
||||
echo json_encode([
|
||||
'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.'
|
||||
]);
|
||||
exit;
|
||||
}
|
||||
|
||||
if(!isset($_POST['image']) || !isset($_POST['name']) || !isset($_POST['type']) || !isset($_POST['size'])) {
|
||||
echo json_encode([
|
||||
'success' => false,
|
||||
'message' => '<b>Fehler beim Upload!</b> Das hochgeladene Bild enthält fehlerhafte Informationen.'
|
||||
]);
|
||||
exit;
|
||||
}
|
||||
$image = str_replace(' ', '+', $_POST['image']);
|
||||
$image = substr($image, strpos($image, ',') + 1);
|
||||
$image = base64_decode($image);
|
||||
|
||||
$fileUrl = $this->FileModel->uploadFileByContent($image, $_POST['name'], $_POST['type'], $_POST['size']);
|
||||
|
||||
echo json_encode([
|
||||
'success' => true,
|
||||
'message' => '<b>Bild erfolgreich hochgeladen!</b>',
|
||||
'url' => $fileUrl
|
||||
]);
|
||||
}
|
||||
}
|
109
application/controllers/admin/Projects.php
Normal file
109
application/controllers/admin/Projects.php
Normal file
@@ -0,0 +1,109 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Projects extends CI_Controller
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->load->model('ProjectsModel', '', TRUE);
|
||||
$this->load->model('FileModel', '', TRUE);
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 9) redirect(base_url('login'));
|
||||
|
||||
$entries = $this->ProjectsModel->getEntries('all');
|
||||
$categories = $this->ProjectsModel->getCategories('all');
|
||||
|
||||
$this->load->view('admin/sidebar', ['title' => 'Projekte verwalten']);
|
||||
$this->load->view('admin/projects', ['entries' => $entries, 'categories' => $categories]);
|
||||
$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;
|
||||
$content = null;
|
||||
$projectCategories = [];
|
||||
|
||||
if ($edit) {
|
||||
if ($this->ProjectsModel->checkIfExists($id)) {
|
||||
$content = $this->ProjectsModel->getEntry($id)[0];
|
||||
$projectCategories = $this->ProjectsModel->getEntryCategories($id);
|
||||
} else {
|
||||
redirect(base_url('admin/projects/edit'));
|
||||
}
|
||||
}
|
||||
|
||||
$categories = $this->ProjectsModel->getCategories();
|
||||
|
||||
$this->load->view('admin/sidebar', ['title' => 'Projekt erstellen', 'additionalStyles' => ['lib/content-tools/content-tools.min.css', 'project-edit.css']]);
|
||||
$this->load->view('admin/project_edit', ['edit' => -1, 'categories' => $categories, 'content' => $content, 'pCategories' => $projectCategories]);
|
||||
$this->load->view('admin/footer', ['additionalScripts' => ['lib/content-tools/content-tools.min.js', 'project-edit.js']]);
|
||||
}
|
||||
|
||||
public function sendEdit()
|
||||
{
|
||||
header('Content-Type: application/json');
|
||||
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 9) {
|
||||
echo json_encode(['success' => false, 'message' => 'Du hast nicht genügend Rechte, um Projekte zu erstellen bzw. bearbeiten.']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$translations = [];
|
||||
$translations['de']['title'] = $this->input->post('titleDE');
|
||||
$translations['de']['description'] = $this->input->post('headlineDE');
|
||||
$translations['de']['content'] = $this->input->post('contentDE');
|
||||
|
||||
$url = $this->input->post('url');
|
||||
|
||||
$download['available'] = $this->input->post('isDownloadable') == 'on' ? true : false;
|
||||
$download['link'] = $this->input->post('downloadLink');
|
||||
$download['name'] = $this->input->post('downloadLinkName');
|
||||
|
||||
$openSource['available'] = $this->input->post('isOpenSource') == 'on' ? true : false;
|
||||
$openSource['link'] = $this->input->post('openSourceLink');
|
||||
$openSource['name'] = $this->input->post('openSourceLinkName');
|
||||
|
||||
$customLink['link'] = $this->input->post('customLink');
|
||||
$customLink['name'] = $this->input->post('customLinkName');
|
||||
|
||||
$categories = $this->input->post('categories');
|
||||
$date = date('Y-m-d H:i:s', strtotime($this->input->post('date')));
|
||||
$image = $this->input->post('image');
|
||||
|
||||
$editingID = $this->input->post('editingID');
|
||||
|
||||
if($editingID == '-1' && $this->ProjectsModel->checkIfNameExists($url)) {
|
||||
echo json_encode(['success' => false, 'message' => 'Die angegebene URL ist bereits vergeben.']);
|
||||
exit;
|
||||
}
|
||||
|
||||
if ($editingID == '-1' || !$this->ProjectsModel->checkIfExists($editingID)) {
|
||||
$editingID = $this->ProjectsModel->createNewProjectDraft();
|
||||
}
|
||||
|
||||
$this->ProjectsModel->updateProject($editingID, $translations, $url, $download, $openSource, $customLink, $date, $image);
|
||||
$this->ProjectsModel->updateCategories($editingID, $categories);
|
||||
|
||||
echo json_encode(['success' => true, 'message' => 'Das Projekt wurde erfolgreich gespeichert.', 'id' => $editingID]);
|
||||
}
|
||||
|
||||
public function delete()
|
||||
{
|
||||
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 9) redirect(base_url('login'));
|
||||
$id = filter_input(INPUT_POST, "id");
|
||||
$this->ProjectsModel->delete($id);
|
||||
}
|
||||
|
||||
public function delete_category()
|
||||
{
|
||||
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 9) redirect(base_url('login'));
|
||||
$id = filter_input(INPUT_POST, "id");
|
||||
$this->ProjectsModel->deleteCategory($id);
|
||||
}
|
||||
}
|
49
application/controllers/admin/Redirects.php
Normal file
49
application/controllers/admin/Redirects.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Redirects extends CI_Controller
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->load->model('RedirectModel', '', TRUE);
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 9) redirect(base_url('login'));
|
||||
$redirects = $this->RedirectModel->getItems();
|
||||
$this->load->view('admin/sidebar', ['title' => 'Alle Weiterleitungen']);
|
||||
$this->load->view('admin/redirects', ['redirects' => $redirects]);
|
||||
$this->load->view('admin/footer', ['additionalScripts' => ['redirects.js']]);
|
||||
}
|
||||
|
||||
public function addRedirect() {
|
||||
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 9) redirect(base_url('login'));
|
||||
|
||||
$id = $this->input->post('redirectID');
|
||||
$name = $this->input->post('redirectName');
|
||||
$url = $this->input->post('redirectUrl');
|
||||
|
||||
if(isset($name) && isset($url)) {
|
||||
if(isset($id)) {
|
||||
$this->RedirectModel->editRedirect($id, $url, $name);
|
||||
} else {
|
||||
$this->RedirectModel->insertRedirect($url, $name);
|
||||
}
|
||||
}
|
||||
|
||||
redirect(base_url('admin/redirects'));
|
||||
}
|
||||
|
||||
public function removeRedirect($id = null) {
|
||||
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 9) redirect(base_url('login'));
|
||||
|
||||
if($id != null) {
|
||||
$this->RedirectModel->removeRedirect($id);
|
||||
}
|
||||
|
||||
redirect(base_url('admin/redirects'));
|
||||
}
|
||||
}
|
84
application/controllers/admin/Users.php
Normal file
84
application/controllers/admin/Users.php
Normal file
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Users extends MY_Controller
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->load->model('UserModel', '', TRUE);
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 9) redirect(base_url('login'));
|
||||
|
||||
$usersData = $this->UserModel->getUserList(50, 0);
|
||||
|
||||
$this->load->view('admin/sidebar', ['title' => 'Alle Nutzer']);
|
||||
$this->load->view('admin/users', ['users' => $usersData]);
|
||||
$this->load->view('admin/footer');
|
||||
}
|
||||
|
||||
public function details($userID = NULL)
|
||||
{
|
||||
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 9) redirect(base_url('login'));
|
||||
|
||||
if ($userID == NULL) redirect(base_url('admin/users'));
|
||||
|
||||
$userData = $this->UserModel->getUserByID($userID);
|
||||
|
||||
if ($userData == null) redirect(base_url('admin/users'));
|
||||
$userData = $userData[0];
|
||||
|
||||
$this->load->view('admin/sidebar', ['title' => 'Details - ' . $userData['displayname']]);
|
||||
$this->load->view('admin/user_details', ['user' => $userData]);
|
||||
$this->load->view('admin/footer');
|
||||
}
|
||||
|
||||
public function settings($userID = NULL)
|
||||
{
|
||||
if (!isset($_SESSION['user']) || empty($_SESSION['user']) || $_SESSION['user']['rank'] < 9) redirect(base_url('login'));
|
||||
|
||||
if ($userID == NULL) redirect(base_url('admin/users'));
|
||||
|
||||
$userData = $this->UserModel->getUserByID($userID);
|
||||
|
||||
if ($userData == null) redirect(base_url('admin/users'));
|
||||
$userData = $userData[0];
|
||||
|
||||
if (isset($_POST['rank'])) {
|
||||
$rank = intval($_POST['rank']);
|
||||
if (($rank < 1) || ($rank > 3 && $rank < 6) || $rank > 10) {
|
||||
redirect(base_url(uri_string()));
|
||||
}
|
||||
// Add entry to history
|
||||
$historyData = [
|
||||
'ID' => $userID,
|
||||
'username' => $userData['username'],
|
||||
'displayname' => $userData['displayname'],
|
||||
'email' => $userData['email'],
|
||||
'rank' => $userData['rank'],
|
||||
'profile_picture' => $userData['profile_picture'],
|
||||
'header_image' => $userData['header_image'],
|
||||
'social_networks' => $userData['social_networks'],
|
||||
'showAds' => $userData['showAds'],
|
||||
'about' => $userData['about'],
|
||||
'language' => $userData['language'],
|
||||
'country' => $userData['country'],
|
||||
'gender' => $userData['gender'],
|
||||
'receiveEmails' => $userData['receiveEmails'],
|
||||
'receiveNewsletter' => $userData['receiveNewsletter']
|
||||
];
|
||||
$this->UserModel->insertIntoHistory($historyData);
|
||||
// Update profile
|
||||
$this->UserModel->updateProfile(['rank' => $rank], $userID);
|
||||
redirect(base_url(uri_string()));
|
||||
}
|
||||
|
||||
$this->load->view('admin/sidebar', ['title' => 'Nutzer-Einstellungen - ' . $userData['displayname']]);
|
||||
$this->load->view('admin/user_settings', ['user' => $userData]);
|
||||
$this->load->view('admin/footer');
|
||||
}
|
||||
}
|
11
application/controllers/index.html
Normal file
11
application/controllers/index.html
Normal file
@@ -0,0 +1,11 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>403 Forbidden</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p>Directory access is forbidden.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
Reference in New Issue
Block a user