Anonymous 3D Imageboard http://cyberia.digital/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

311 lines
6.6KB

  1. <?php
  2. /*
  3. ____ __ __ _ _______
  4. / __ \____ _/ /_____ _/ /_ ____ _________ | | / / ___/
  5. / / / / __ `/ __/ __ `/ __ \/ __ `/ ___/ _ \ | | /| / /\__ \
  6. / /_/ / /_/ / /_/ /_/ / /_/ / /_/ (__ ) __/ | |/ |/ /___/ /
  7. /_____/\__,_/\__/\__,_/_.___/\__,_/____/\___/ |__/|__//____/
  8. Database WS
  9. */
  10. ini_set('display_errors', 1);
  11. require_once "Utils/Constants.php";
  12. require_once "Imports/LazerImports.php";
  13. require_once 'MapController.php';
  14. require_once 'AdminController.php';
  15. use Lazer\Classes\Database as Lazer;
  16. defined('LAZER_DATA_PATH') or define('LAZER_DATA_PATH', realpath(dirname(__FILE__)).'/'.Constants::CONST_DB_FOLDER.'/');
  17. //Admin password
  18. $password = "";
  19. if(isset($_POST["password"])) $password = $_POST["password"];
  20. $adminController = new AdminController();
  21. if(!$adminController ->validPassword($password)){
  22. echo "bad password!!";
  23. exit;
  24. }
  25. //Create an autoloader
  26. $action = "";
  27. if(isset($_POST["action"]))
  28. $action = $_POST["action"];
  29. switch($action){
  30. case "initDB":
  31. //**************************************
  32. // * DB MAIN
  33. // *************************************
  34. try{
  35. $banExtist = false;
  36. try{
  37. $banExtist = \Lazer\Classes\Helpers\Validate::table(Constants::CONST_TABLE_BANS)->exists();
  38. } catch(\Lazer\Classes\LazerException $e){
  39. //Database doesn't exist
  40. }
  41. if(!$banExtist){
  42. Lazer::create(Constants::CONST_TABLE_BANS, array(
  43. 'id' => 'integer',
  44. 'reason' => 'string',
  45. 'id_post' => 'integer',
  46. //'thread_key' => 'string',
  47. 'map_key' => 'string',
  48. 'date' => 'integer',
  49. 'duration' => 'integer',
  50. 'player_ip' => 'string'
  51. ));
  52. echo 'Ban created';
  53. }
  54. Lazer::create(Constants::CONST_TABLE_FILES, array(
  55. 'id' => 'integer',
  56. 'id_post' => 'integer',
  57. 'map_key' => 'string',
  58. 'fake_path' => 'string',
  59. 'fake_name' => 'string',
  60. 'file_name' => 'string'
  61. ));
  62. echo 'Forum creation succed';
  63. } catch(\Lazer\Classes\LazerException $e){
  64. echo 'exception'.$e;
  65. }
  66. try{
  67. Lazer::create(Constants::CONST_TABLE_PLAYERS, array(
  68. 'id' => 'integer',
  69. 'name' => 'string',
  70. 'talk' => 'string',
  71. 'is_admin' => 'boolean',
  72. 'player_key' => 'string',
  73. 'hp' => 'integer',
  74. 'money' => 'integer',
  75. 'map_key' => 'string',
  76. 'last_action' => 'integer',
  77. 'position_x' => 'double',
  78. 'position_y' => 'double',
  79. 'position_z' => 'double'
  80. ));
  81. Lazer::create(Constants::CONST_TABLE_ITEMS, array(
  82. 'id' => 'integer',
  83. 'key' => 'string',
  84. 'player_id' => 'integer',
  85. 'action' => 'string',
  86. 'type' => 'string',
  87. 'name' => 'string',
  88. 'description' => 'string',
  89. 'map_key' => 'string',
  90. 'x' => 'double',
  91. 'y' => 'double',
  92. 'is_expendable' => 'boolean',
  93. 'value' => 'integer'
  94. ));
  95. Lazer::create(Constants::CONST_TABLE_LOGS, array(
  96. 'id' => 'integer',
  97. 'map_key' => 'string',
  98. 'last_action'=> 'integer',
  99. 'ip' => 'string',
  100. 'to' => 'integer',
  101. 'name' => 'string',
  102. 'player_id' => 'integer',
  103. 'value' => 'string',
  104. 'action' => 'string'
  105. ));
  106. echo 'PLAYER creation succed';
  107. } catch(\Lazer\Classes\LazerException $e){
  108. echo 'exception'.$e;
  109. }
  110. break;
  111. //**************************************
  112. // * DB MAPS AND POST
  113. // *************************************
  114. //init the data base
  115. case "initMapsAndPosts":
  116. try{
  117. Lazer::create(Constants::CONST_TABLE_POSTS, array(
  118. 'id' => 'integer',
  119. 'show' => 'boolean',
  120. 'key' => 'string',
  121. 'scale' => 'integer',
  122. 'date' => 'integer',
  123. 'reply' => 'integer',
  124. 'player_ip' => 'string',
  125. 'player_id' => 'integer',
  126. 'is_canon' => 'boolean',
  127. 'is_admin' => 'boolean',
  128. 'nsfw' => 'boolean',
  129. 'graffiti' => 'boolean',
  130. 'preview' => 'string',
  131. 'player_name' => 'string',
  132. //'thread_key' => 'string',
  133. 'map_key' => 'string',
  134. 'canvas_key' => 'string',
  135. 'message' => 'string',
  136. 'url' => 'string',
  137. 'magnet' => 'string',
  138. 'torrent' => 'string',
  139. 'hash' => 'string'
  140. ));
  141. //Map creation
  142. Lazer::create(Constants::CONST_TABLE_MAP, array(
  143. 'id' => 'integer',
  144. 'key' => 'string',
  145. 'name' => 'string',
  146. 'description' => 'string',
  147. 'theme' => 'string',
  148. 'width' => 'integer',
  149. 'height' => 'integer',
  150. 'x' => 'integer',
  151. 'y' => 'integer',
  152. 'door_key_n' => 'string',
  153. 'door_key_e' => 'string',
  154. 'door_key_s' => 'string',
  155. 'door_key_w' => 'string',
  156. 'level_data' => 'string',
  157. 'num_post_max' => 'integer',
  158. 'fast_travel' => 'boolean',
  159. 'is_safe' => 'boolean',
  160. 'is_chan' => 'boolean',
  161. 'is_secret' => 'boolean'
  162. ));
  163. $mapController = new MapController();
  164. $mapController -> generateWorld();
  165. echo 'MAP creation succed';
  166. } catch(\Lazer\Classes\LazerException $e){
  167. echo 'exception'.$e;
  168. }
  169. break;
  170. //init the data base
  171. case "initBans":
  172. $banExtist = false;
  173. try{
  174. $banExtist = \Lazer\Classes\Helpers\Validate::table(Constants::CONST_TABLE_BANS)->exists();
  175. } catch(\Lazer\Classes\LazerException $e){
  176. //Database doesn't exist
  177. }
  178. if(!$banExtist){
  179. Lazer::create(Constants::CONST_TABLE_BANS, array(
  180. 'id' => 'integer',
  181. 'reason' => 'string',
  182. 'id_post' => 'integer',
  183. //'thread_key' => 'string',
  184. 'map_key' => 'string',
  185. 'date' => 'integer',
  186. 'duration' => 'integer',
  187. 'player_ip' => 'string'
  188. ));
  189. echo 'Ban created';
  190. }
  191. break;
  192. case "destroyBans":
  193. Lazer::remove(Constants::CONST_TABLE_BANS);
  194. echo 'ban destroyed';
  195. break;
  196. //init the data base
  197. case "destroyDB":
  198. try{
  199. //Lazer::remove(Constants::CONST_TABLE_BANS);
  200. Lazer::remove(Constants::CONST_TABLE_FILES);
  201. Lazer::remove(Constants::CONST_TABLE_PLAYERS);
  202. Lazer::remove(Constants::CONST_TABLE_ITEMS);
  203. Lazer::remove(Constants::CONST_TABLE_LOGS);
  204. echo 'DB erase succed';
  205. } catch(\Lazer\Classes\LazerException $e){
  206. echo 'exception'.$e;
  207. }
  208. break;
  209. //init the data base
  210. case "destroyMapsAndPosts":
  211. try{
  212. Lazer::remove(Constants::CONST_TABLE_POSTS);
  213. Lazer::remove(Constants::CONST_TABLE_MAP);
  214. echo 'Maps and Posts erase succed';
  215. } catch(\Lazer\Classes\LazerException $e){
  216. echo 'exception'.$e;
  217. }
  218. break;
  219. //init the data base
  220. /*
  221. case "cleanDB":
  222. try{
  223. Lazer::table(Constants::CONST_TABLE_POSTS)->delete();
  224. Lazer::table(Constants::CONST_TABLE_BANS)->delete();
  225. Lazer::table(Constants::CONST_TABLE_PLAYERS)->delete();
  226. Lazer::table(Constants::CONST_TABLE_FILES)->delete();
  227. Lazer::table(Constants::CONST_TABLE_ITEMS)->delete();
  228. //Lazer::table(Constants::CONST_TABLE_LOOT)->delete();
  229. Lazer::table(Constants::CONST_TABLE_MAP)->delete();
  230. echo 'DB erase succed';
  231. } catch(\Lazer\Classes\LazerException $e){
  232. echo 'exception'.$e;
  233. }
  234. break;*/
  235. }