Archived
1
0
This repository has been archived on 2020-12-10. You can view files and clone it, but cannot push or open issues or pull requests.
old/application/controllers/Redirect.php

46 lines
1.8 KiB
PHP
Raw Normal View History

2018-10-16 16:28:42 +00:00
<?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);
}
}
}