Advertisement
Snoop-Dogg

PHPStatus - add_lang.php

Dec 15th, 2020
24
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.42 KB | None | 0 0
  1. <?php
  2. /****************************************************************/
  3. /* phpStatus */
  4. /* add_lang.php file */
  5. /* (c)copyright 2003 */
  6. /* By hinton design */
  7. /* http://www.hintondesign.org */
  8. /* support@hintondesign.org */
  9. /* */
  10. /* This program is free software. You can redistrabute it and/or*/
  11. /* modify it under the terms of the GNU General Public Licence */
  12. /* as published by the Free Software Foundation; either version */
  13. /* 2 of the license. */
  14. /* */
  15. /****************************************************************/
  16.  
  17. define("PHPSTATUS_REAL_PATH","./../");
  18. require PHPSTATUS_REAL_PATH . 'common.php';
  19.  
  20. $errors = []; // an array to hold user/validation error messages
  21. $post = []; // an array to hold a trimmed working copy of the form data
  22.  
  23. if(!isset($_COOKIE['loged']) || $_COOKIE['loged'] != 'yes')
  24. {
  25. // not logged in
  26. $errors['loged'] = 'error_mess6';
  27. } else {
  28. // check user level
  29. if(!isset($_COOKIE['user_level']) || $_COOKIE['user_level'] != '1')
  30. {
  31. $errors['user_level'] = 'error_mess5';
  32. }
  33. }
  34.  
  35. // if no user errors, process the post method form data
  36. if(empty($errors) && $_SERVER['REQUEST_METHOD'] == 'POST')
  37. {
  38. // inputs - name , ports (array)
  39. // trim, than validate all inputs
  40. $post = array_map('_trim',$_POST); // note: _trim is a recursive 'trim' user written function
  41.  
  42. if($post['name'] == '')
  43. {
  44. $errors['name'] = 'error_mess7';
  45. }
  46.  
  47. //if(!$HTTP_POST_VARS['name']) {
  48. require "header.php";
  49. $template->getFile(array(
  50. 'error' => 'admin/error.tpl')
  51. );
  52. $template->add_vars(array(
  53. 'L_ERROR' => $lang['error'],
  54. 'DISPLAY' => $lang['error_mess25'])
  55. );
  56. $template->parse "error";
  57. require("footer.php");
  58. exit();
  59. }
  60.  
  61. // as a 1st pass, store data exactly the same as currently being done
  62. //$sql = "INSERT INTO _groups (name, ports) VALUES (?,?)";
  63. //$stmt = $pdo->prepare($sql);
  64. $sql = "SELECT name FROM _lang WHERE name='$post['name']'";
  65. $stmt = $pdo->prepare($sql);
  66. //$sql = "SELECT name FROM _lang WHERE name='$HTTP_POST_VARS[name]'";
  67. //$result = $db->query($sql);
  68.  
  69. $num = $db->num($result);
  70.  
  71. if($num > 0) {
  72. require "header.php";
  73. unset($post['name']); //unset($HTTP_POST_VARS['name']);
  74. $template->getFile(array(
  75. error' => 'admin/error.tpl')
  76. );
  77. $template->add_vars(array(
  78. 'L_ERROR' => $lang['error'],
  79. 'DISPLAY' => $lang['error_mess26'])
  80. );
  81. $template->parse("error");
  82. require "footer.php";
  83. exit();
  84. }
  85.  
  86. $sql = "INSERT INTO _lang (name) VALUES ('$post['name']')";
  87. $stmt = $pdo->prepare($sql);
  88. //$sql = "INSERT INTO _lang (name) VALUES ('$HTTP_POST_VARS[name]')";
  89. //$result = $db->query($sql);
  90.  
  91. if(!$result) {
  92. require "header.php";
  93. $template->getFile(array(
  94. 'error' => 'admin/error.tpl')
  95. );
  96. $template->add_vars(array(
  97. 'L_ERROR' => $lang['error'],
  98. 'DISPLAY' => $lang['error_mess27'])
  99. );
  100. $template->parse("error");
  101. require "footer.php";
  102. exit();
  103. } else {
  104. require "header.php";
  105. $link = "lang.php";
  106. $template->getFile(array(
  107. 'success' => 'admin/success.tpl')
  108. );
  109. $template->add_vars(array(
  110. 'L_SUCCESS' => $lang['success'],
  111. 'DISPLAY' => $lang['success_mess11'],
  112. 'LINK' => $link)
  113. );
  114. $template->parse("success");
  115. require "footer.php";
  116. exit();
  117. }
  118. } else {
  119. require "header.php";
  120. $template->getFile(array(
  121. 'error' => 'admin/error.tpl')
  122. );
  123. $template->add_vars(array(
  124. 'L_ERROR' => $lang['error'],
  125. 'DISPLAY' => $lang['error_mess5'])
  126. );
  127. $template->parse("error");
  128. require("footer.php");
  129. exit();
  130. }
  131. } else {
  132. require "header.php";
  133. $template->getFile(array(
  134. 'error' => 'admin/error.tpl')
  135. );
  136. $template->add_vars(array(
  137. 'L_ERROR' => $lang['error'],
  138. 'DISPLAY' => $lang['error_mess6'])
  139. );
  140. $template->parse("error");
  141. require "footer.php";
  142. exit();
  143. }
  144. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement