Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /****************************************************************/
- /* phpStatus */
- /* add_lang.php file */
- /* (c)copyright 2003 */
- /* By hinton design */
- /* http://www.hintondesign.org */
- /* support@hintondesign.org */
- /* */
- /* This program is free software. You can redistrabute it and/or*/
- /* modify it under the terms of the GNU General Public Licence */
- /* as published by the Free Software Foundation; either version */
- /* 2 of the license. */
- /* */
- /****************************************************************/
- define("PHPSTATUS_REAL_PATH","./../");
- require PHPSTATUS_REAL_PATH . 'common.php';
- $errors = []; // an array to hold user/validation error messages
- $post = []; // an array to hold a trimmed working copy of the form data
- if(!isset($_COOKIE['loged']) || $_COOKIE['loged'] != 'yes')
- {
- // not logged in
- $errors['loged'] = 'error_mess6';
- } else {
- // check user level
- if(!isset($_COOKIE['user_level']) || $_COOKIE['user_level'] != '1')
- {
- $errors['user_level'] = 'error_mess5';
- }
- }
- // if no user errors, process the post method form data
- if(empty($errors) && $_SERVER['REQUEST_METHOD'] == 'POST')
- {
- // inputs - name , ports (array)
- // trim, than validate all inputs
- $post = array_map('_trim',$_POST); // note: _trim is a recursive 'trim' user written function
- if($post['name'] == '')
- {
- $errors['name'] = 'error_mess7';
- }
- //if(!$HTTP_POST_VARS['name']) {
- require "header.php";
- $template->getFile(array(
- 'error' => 'admin/error.tpl')
- );
- $template->add_vars(array(
- 'L_ERROR' => $lang['error'],
- 'DISPLAY' => $lang['error_mess25'])
- );
- $template->parse "error";
- require("footer.php");
- exit();
- }
- // as a 1st pass, store data exactly the same as currently being done
- //$sql = "INSERT INTO _groups (name, ports) VALUES (?,?)";
- //$stmt = $pdo->prepare($sql);
- $sql = "SELECT name FROM _lang WHERE name='$post['name']'";
- $stmt = $pdo->prepare($sql);
- //$sql = "SELECT name FROM _lang WHERE name='$HTTP_POST_VARS[name]'";
- //$result = $db->query($sql);
- $num = $db->num($result);
- if($num > 0) {
- require "header.php";
- unset($post['name']); //unset($HTTP_POST_VARS['name']);
- $template->getFile(array(
- error' => 'admin/error.tpl')
- );
- $template->add_vars(array(
- 'L_ERROR' => $lang['error'],
- 'DISPLAY' => $lang['error_mess26'])
- );
- $template->parse("error");
- require "footer.php";
- exit();
- }
- $sql = "INSERT INTO _lang (name) VALUES ('$post['name']')";
- $stmt = $pdo->prepare($sql);
- //$sql = "INSERT INTO _lang (name) VALUES ('$HTTP_POST_VARS[name]')";
- //$result = $db->query($sql);
- if(!$result) {
- require "header.php";
- $template->getFile(array(
- 'error' => 'admin/error.tpl')
- );
- $template->add_vars(array(
- 'L_ERROR' => $lang['error'],
- 'DISPLAY' => $lang['error_mess27'])
- );
- $template->parse("error");
- require "footer.php";
- exit();
- } else {
- require "header.php";
- $link = "lang.php";
- $template->getFile(array(
- 'success' => 'admin/success.tpl')
- );
- $template->add_vars(array(
- 'L_SUCCESS' => $lang['success'],
- 'DISPLAY' => $lang['success_mess11'],
- 'LINK' => $link)
- );
- $template->parse("success");
- require "footer.php";
- exit();
- }
- } else {
- require "header.php";
- $template->getFile(array(
- 'error' => 'admin/error.tpl')
- );
- $template->add_vars(array(
- 'L_ERROR' => $lang['error'],
- 'DISPLAY' => $lang['error_mess5'])
- );
- $template->parse("error");
- require("footer.php");
- exit();
- }
- } else {
- require "header.php";
- $template->getFile(array(
- 'error' => 'admin/error.tpl')
- );
- $template->add_vars(array(
- 'L_ERROR' => $lang['error'],
- 'DISPLAY' => $lang['error_mess6'])
- );
- $template->parse("error");
- require "footer.php";
- exit();
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement