public function store(Request $request) { $this->validate($request, ['key' => 'required|unique:configs,key', 'value' => 'required']); $config = new \App\Config(); $config->key = strtolower($request->input('key')); $config->value = $request->input('value'); $config->save(); return redirect('backend/configs' . $config->id); }
/** * Run the database seeds. * * @return void */ public function run() { $config = ['aero' => ['lat' => '44.7785709', 'lng' => '17.1361267', 'zoom_level' => '7', 'default_marker' => '1'], 'aerometrics' => ['properties' => ['temperature' => ['min' => 1, 'max' => 99, 'color' => '#09476d'], 'pressure' => ['min' => 1, 'max' => 99, 'color' => '#afffed'], 'altitude' => ['min' => 1, 'max' => 99, 'color' => '#89c43c'], 'insolation' => ['min' => 1, 'max' => 99, 'color' => '#9d8fe0'], 'humidity' => ['min' => 1, 'max' => 99, 'color' => '#16e5a7'], 'co' => ['min' => 1, 'max' => 99, 'color' => '#fff699'], 'co2' => ['min' => 1, 'max' => 99, 'color' => '#a1d0f4'], 'methane' => ['min' => 1, 'max' => 99, 'color' => '#dfe524'], 'butane' => ['min' => 1, 'max' => 99, 'color' => '#1f58dd'], 'propane' => ['min' => 1, 'max' => 99, 'color' => '#e0971a'], 'benzene' => ['min' => 1, 'max' => 99, 'color' => '#fce25f'], 'ethanol' => ['min' => 1, 'max' => 99, 'color' => '#de30e8'], 'alcohol' => ['min' => 1, 'max' => 99, 'color' => '#559cdb'], 'hydrogen' => ['min' => 1, 'max' => 99, 'color' => '#7ae8f9'], 'ozone' => ['min' => 1, 'max' => 99, 'color' => '#2028c9'], 'cng' => ['min' => 1, 'max' => 99, 'color' => '#84f992'], 'lpg' => ['min' => 1, 'max' => 99, 'color' => '#db5e75'], 'coal_gas' => ['min' => 1, 'max' => 99, 'color' => '#fcc2c4'], 'smoke' => ['min' => 1, 'max' => 99, 'color' => '#d68b22']]]]; foreach (array_dot($config) as $key => $value) { $c = new App\Config(); $c->key = $key; $c->value = $value; $c->save(); } }
/** * @author: lmkhang - skype * @date: 2016-01-11 * Profile */ public function index() { //set Title for PAGE $this->_page_title = 'Setting'; //get list $setting_get = new \App\Config(); $setting = $setting_get->getAll(['show' => 1, 'del_flg' => 1]); //DATA $home_get = new \App\Home(); $stats_show = $home_get->getAll(['prefix' => 'stats_show', 'del_flg' => 1]); return view('admin.setting.index', ['admin' => $this->_admin, 'name' => $this->getName(), 'page_title' => $this->_page_title, 'active' => $this->_active, 'setting' => $setting, 'stats_show' => $stats_show]); }
function handle_exception($e) { $template = App\Config::get('debug') ? 'debug' : '5xx'; $view = new App\Template($template, compact('e')); $response = new Symfony\Component\HttpFoundation\Response($view->fetch(), Symfony\Component\HttpFoundation\Response::HTTP_INTERNAL_SERVER_ERROR); $response->send(); }
<?php session_start(); require '../app/Autoloader.class.php'; App\Autoloader::register(); $config = App\Config::getInstance(); $bdd = App\database\Database::getInstance_bdd($config->get("db_name"), $config->get("db_user"), $config->get("db_pass"), $config->get("db_host")); require '../functions/functions.php'; if (isset($_POST['login']) && isset($_POST['email']) && isset($_POST['password1']) && isset($_POST['password2']) && $_POST['password1'] == $_POST['password2']) { if (create_user($bdd, $_POST['login'], $_POST['email'], $_POST['password1'])) { $_SESSION['alert'] = "Success"; header("Location: ../index.php"); die; } else { $_SESSION['alert'] = "ERROR"; header("Location: ../index.php"); die; } } else { $_SESSION['alert'] = "ERROR"; header("Location: ../index.php"); die; }
<?php error_reporting(E_ALL); if (file_exists('./vendor/autoload.php')) { require './vendor/autoload.php'; } else { echo "<h1>Install via Composer. Type 'composer install' in Terminal.</h1>"; exit; } if (!is_readable("./app/Config.php")) { echo "<h1>No Config found. (config.php in /app)</h1>"; exit; } define('SITE_ROOT', realpath(dirname(__FILE__))); App\Config::init(); Helpers\Session::init(); require "./app/routes.php"; System\Router::dispatch();
// Move jQuery to the footer, include it by default, remove the "jquery-migrate" dependency. // NB: jQuery will be automatically moved in the header if a plugin requires it. add_action('wp_enqueue_scripts', function () { wp_deregister_script('jquery'); wp_enqueue_script('jquery', '/wp-includes/js/jquery/jquery.js', array(), false, true); }); // Add a stylesheet to the admin add_action('admin_enqueue_scripts', function () use($assetsDir) { wp_enqueue_style('wp-boilerplate-admin', $assetsDir . '/admin.css'); }); // Add a stylesheet for TinyMCE add_action('after_setup_theme', function () use($assetsDir) { add_editor_style($assetsDir . '/editor.css'); }); // Register an "asset" filter to easily manage asset versions (see the "theme.php" file). add_action('twig_apply_filters', function ($twig) use($assetsDir) { $assetsVersions = App\Config::get('assets'); // Register the filter $twig->addFilter('asset', new Twig_Filter_Function(function ($filepath, $assetName) use($assetsDir, $assetsVersions) { if (strtolower(substr($filepath, 0, 4)) != 'http') { $filepath = $assetsDir . '/' . $filepath; } $hasQueryParams = strstr($filepath, '?') !== false; return $filepath . (!$hasQueryParams ? '?ver=' : '&ver=') . $assetsVersions[$assetName]; })); return $twig; }); // Avoid emojis errors, see: https://core.trac.wordpress.org/ticket/32305 remove_action('wp_head', 'print_emoji_detection_script', 7); remove_action('wp_print_styles', 'print_emoji_styles'); });
<?php // Load Composer if (file_exists(__DIR__ . '/vendor/autoload.php')) { include_once __DIR__ . '/vendor/autoload.php'; } // Load the configuration foreach (glob(__DIR__ . '/config{/,/*/}*.php', GLOB_BRACE) as $filename) { require_once $filename; } App\Config::processConfigFile();
<?php session_start(); define('ROOT', dirname(dirname(__DIR__))); define('SRC', ROOT . '/src'); define('PHP', SRC . '/php'); define('VIEWS', SRC . '/views'); define('CONFIG', SRC . '/config'); spl_autoload_register(function ($class) { $file = PHP . '/classes/' . str_replace('\\', '/', $class) . '.php'; if (is_file($file)) { include $file; } else { throw new \Exception("Класс {$class} не найден"); } }); define('DOCS', ROOT . '/' . App\Config::get('docsDir')); if (App\Config::get('debug')) { ini_set('display_errors', 1); error_reporting(E_ALL); } else { ini_set('display_errors', 0); error_reporting(0); } ini_set('xdebug.max_nesting_level', 200);