From 513704ecad1b6d5aeee35c13a851389f99c95e9d Mon Sep 17 00:00:00 2001 From: Enrique Alcaraz <32360461+enriquealcaraz@users.noreply.github.com> Date: Mon, 9 Oct 2017 11:03:01 +0200 Subject: [PATCH] Add files via upload --- plugin/redirection/index.php | 8 ++-- plugin/redirection/lib/PluginRedirection.php | 40 ++++++++++++++++++++ 2 files changed, 44 insertions(+), 4 deletions(-) create mode 100644 plugin/redirection/lib/PluginRedirection.php diff --git a/plugin/redirection/index.php b/plugin/redirection/index.php index 4348252d9a..c6e4a4d4e0 100644 --- a/plugin/redirection/index.php +++ b/plugin/redirection/index.php @@ -7,15 +7,15 @@ */ require_once __DIR__.'/config.php'; -$redirecciones = Redirection::get(); +$redirecciones = PluginRedirection::get(); if (isset($_REQUEST["id"])) { - Redirection::delete($_REQUEST["id"]); + PluginRedirection::delete($_REQUEST["id"]); header ("Location: index.php"); exit(); } else if (isset($_POST["submit_button"])) { - Redirection::insert($_POST["user_id"], $_POST["url"]); + PluginRedirection::insert($_POST["user_id"], $_POST["url"]); header ("Location: index.php"); exit(); } @@ -54,4 +54,4 @@ else if (isset($_POST["submit_button"])) { } ?> - + \ No newline at end of file diff --git a/plugin/redirection/lib/PluginRedirection.php b/plugin/redirection/lib/PluginRedirection.php new file mode 100644 index 0000000000..72771c117a --- /dev/null +++ b/plugin/redirection/lib/PluginRedirection.php @@ -0,0 +1,40 @@ + $user_id, + 'url' => $url + ] + ); + } + + # Borramos al redirección + public static function delete($id) + { + $table = Database::get_main_table('plugin_redirection'); + Database::delete( + $table, + array('id = ?' => array($id)) + ); + } + + # Devolemos las redirecciones + public static function get() + { + $table = Database::get_main_table('plugin_redirection'); + return Database::select('*', $table); + } +} +