46 lines
1.8 KiB
PHP
46 lines
1.8 KiB
PHP
<?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);
|
|
}
|
|
}
|
|
|
|
}
|