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

49 lines
1.8 KiB
PHP

<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Redirect extends MY_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)
{
if ($redirect != null) {
$url = $this->RedirectModel->getUrl($redirect);
redirect($url);
}
if (!$this->hasPermission('redirect.view')) {
redirect(base_url());
}
$returnMessage = '';
if (isset($_POST['redirectInput']) && !empty($_POST['redirectInput']) && isset($_POST['redirectUrl']) && !empty($_POST['redirectUrl'])) {
$feedback = $this->redirect->insertRedirect($_POST['redirectUrl'], $_POST['redirectInput']);
if ($feedback['feedback'] == 'success') {
$returnMessage = '<div class="alert alert-success" role="alert"><strong>Umleitung hinzugefügt!</strong> Code: "' . $_POST['redirectInput'] . '" Ziel-Url: "' . $_POST['redirectUrl'] . '"</div>';
} else {
$returnMessage = '<div class="alert alert-danger" role="alert"><strong>Error!</strong> ' . $feedback['message'] . '</div>';
}
}
$this->load->view('header', ['title' => 'Redirect-Manager', 'active' => '']);
$this->load->view('redirect', ['message' => $returnMessage, 'allItems' => $this->RedirectModel->getItems()]);
$this->load->view('footer');
}
}