Advertisement
Snoop-Dogg

PHPStatus - add_lang.php

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