PHP Classes

File: uploady/admin/languages/actions/edit.php

Recommend this page to a friend!
  Classes of Faris AL-Otabi   Uploady PHP Upload File to MySQL   uploady/admin/languages/actions/edit.php   Download  
File: uploady/admin/languages/actions/edit.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Uploady PHP Upload File to MySQL
Store file upload details in a MySQL database
Author: By
Last change: refactor
Code refactor
1. Starting to add CSRF on the new features
2. fixed missing alerts
3. added update direction
4. fixed a bug in admin session
update permission to 755
Date: 11 months ago
Size: 1,556 bytes
 

Contents

Class file image Download
<?php

include_once '../../session.php';

$language = new Uploady\Localization($db);

if (
$_SERVER['REQUEST_METHOD'] == 'POST') {
    if (!
$auth->checkToken($_POST['csrf'], $_SESSION['csrf'])) {
       
$utils->redirect(SITE_URL . "/admin/languages/view.php?msg=csrf");
    }

   
$lang = $_POST['lang'];

    if (isset(
$_POST['update_direction'])) {
       
$language->updateLanguageDirection($lang, $_POST['direction']);
    }

    if (isset(
$_POST['update_general'])) {
       
$data = [];

        foreach (
$_POST as $key => $value) {
            if (
strpos($key, "general_") !== false) {
               
$key = str_replace("general_", "", $key);
               
$data[$key] = $value;
            }
        }

       
$language->updateLanguage("general", $data, $lang);
    }

    if (isset(
$_POST['update_navbar'])) {
       
$data = [];

        foreach (
$_POST as $key => $value) {
            if (
strpos($key, "navbar_") !== false) {
               
$key = str_replace("navbar_", "", $key);
               
$data[$key] = $value;
            }
        }

       
$language->updateLanguage("navbar", $data, $lang);
    }

    if (isset(
$_POST['update_theme'])) {
       
$data = [];

        foreach (
$_POST as $key => $value) {
            if (
strpos($key, "theme_") !== false) {
               
$key = str_replace("theme_", "", $key);
               
$data[$key] = $value;
            }
        }

       
$language->updateLanguage("theme", $data, $lang);
    }

   
$utils->redirect(SITE_URL . "/admin/languages/view.php?msg=language_updated");
}