Advertisement
Guest User

ripple_db.php

a guest
Sep 10th, 2018
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 21.00 KB | None | 0 0
  1. <?php
  2. define('DATABASE_NAME', 'ripple');
  3. define('DATABASE_USER', 'DB_USR');
  4. define('DATABASE_PASS', 'DB_PSW');
  5. define('DATABASE_HOST', 'localhost');
  6. define('DATABASE_WHAT', 'host');
  7.  
  8. $db = new DBPDO();
  9.  
  10. $q = <<<'ENDOFMYSQLQUERY'
  11. SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
  12. CREATE DATABASE IF NOT EXISTS `ripple` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci;
  13. USE `ripple`;
  14.  
  15. CREATE TABLE IF NOT EXISTS `2fa` (
  16. `userid` int(11) NOT NULL,
  17. `ip` int(11) NOT NULL,
  18. PRIMARY KEY (`userid`)
  19. ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  20.  
  21. CREATE TABLE IF NOT EXISTS `2fa_telegram` (
  22. `id` int(11) NOT NULL AUTO_INCREMENT,
  23. `userid` int(11) NOT NULL,
  24. PRIMARY KEY (`id`)
  25. ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  26.  
  27. CREATE TABLE IF NOT EXISTS `2fa_totp` (
  28. `enabled` tinyint(1) NOT NULL DEFAULT '0',
  29. `userid` int(11) NOT NULL,
  30. PRIMARY KEY (`userid`)
  31. ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  32.  
  33. CREATE TABLE IF NOT EXISTS `achievements` (
  34. `id` int(11) NOT NULL AUTO_INCREMENT,
  35. `name` varchar(64) NOT NULL,
  36. `description` varchar(128) NOT NULL,
  37. `icon` varchar(32) NOT NULL,
  38. `version` int(11) NOT NULL DEFAULT '0',
  39. PRIMARY KEY (`id`)
  40. ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;
  41.  
  42. CREATE TABLE IF NOT EXISTS `badges` (
  43. `id` int(11) NOT NULL AUTO_INCREMENT,
  44. `name` varchar(32) NOT NULL,
  45. `icon` varchar(32) NOT NULL,
  46. PRIMARY KEY (`id`)
  47. ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;
  48.  
  49. CREATE TABLE IF NOT EXISTS `bancho_channels` (
  50. `id` int(11) NOT NULL AUTO_INCREMENT,
  51. `name` varchar(32) NOT NULL,
  52. `description` varchar(127) NOT NULL,
  53. `public_read` tinyint(4) NOT NULL,
  54. `public_write` tinyint(4) NOT NULL,
  55. `status` tinyint(4) NOT NULL,
  56. `temp` tinyint(1) NOT NULL DEFAULT '0',
  57. `hidden` tinyint(1) NOT NULL DEFAULT '0',
  58. PRIMARY KEY (`id`)
  59. ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;
  60.  
  61. CREATE TABLE IF NOT EXISTS `bancho_messages` (
  62. `id` int(11) NOT NULL AUTO_INCREMENT,
  63. `msg_from_userid` int(11) NOT NULL,
  64. `msg_from_username` varchar(30) NOT NULL,
  65. `msg_to` varchar(32) NOT NULL,
  66. `msg` varchar(127) NOT NULL,
  67. `time` int(11) NOT NULL,
  68. PRIMARY KEY (`id`)
  69. ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  70.  
  71. CREATE TABLE IF NOT EXISTS `bancho_private_messages` (
  72. `id` int(11) NOT NULL AUTO_INCREMENT,
  73. `msg_from_userid` int(11) NOT NULL,
  74. `msg_from_username` varchar(30) NOT NULL,
  75. `msg_to` varchar(32) NOT NULL,
  76. `msg` varchar(127) NOT NULL,
  77. `time` int(11) NOT NULL,
  78. PRIMARY KEY (`id`)
  79. ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  80.  
  81. CREATE TABLE IF NOT EXISTS `bancho_settings` (
  82. `id` int(11) NOT NULL AUTO_INCREMENT,
  83. `name` varchar(32) NOT NULL,
  84. `value_int` int(11) NOT NULL DEFAULT '0',
  85. `value_string` varchar(512) NOT NULL,
  86. PRIMARY KEY (`id`)
  87. ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;
  88.  
  89. CREATE TABLE IF NOT EXISTS `bancho_tokens` (
  90. `id` int(11) NOT NULL AUTO_INCREMENT,
  91. `token` varchar(16) NOT NULL,
  92. `osu_id` int(11) NOT NULL,
  93. `latest_message_id` int(11) NOT NULL,
  94. `latest_private_message_id` int(11) NOT NULL,
  95. `latest_packet_time` int(11) NOT NULL,
  96. `latest_heavy_packet_time` int(11) NOT NULL,
  97. `joined_channels` varchar(512) NOT NULL,
  98. `game_mode` tinyint(4) NOT NULL,
  99. `action` int(11) NOT NULL,
  100. `action_text` varchar(128) NOT NULL,
  101. `kicked` tinyint(4) NOT NULL,
  102. PRIMARY KEY (`id`)
  103. ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  104.  
  105. CREATE TABLE IF NOT EXISTS `beatmaps` (
  106. `id` int(11) NOT NULL AUTO_INCREMENT,
  107. `beatmap_id` int(11) NOT NULL DEFAULT '0',
  108. `beatmapset_id` int(11) NOT NULL DEFAULT '0',
  109. `beatmap_md5` varchar(32) NOT NULL DEFAULT '',
  110. `song_name` varchar(128) NOT NULL DEFAULT '',
  111. `ar` float NOT NULL DEFAULT '0',
  112. `od` float NOT NULL DEFAULT '0',
  113. `difficulty_std` float NOT NULL DEFAULT '0',
  114. `difficulty_taiko` float NOT NULL DEFAULT '0',
  115. `difficulty_ctb` float NOT NULL DEFAULT '0',
  116. `difficulty_mania` float NOT NULL DEFAULT '0',
  117. `max_combo` int(11) NOT NULL DEFAULT '0',
  118. `hit_length` int(11) NOT NULL DEFAULT '0',
  119. `bpm` int(11) NOT NULL DEFAULT '0',
  120. `ranked` tinyint(4) NOT NULL DEFAULT '0',
  121. `latest_update` int(11) NOT NULL DEFAULT '0',
  122. `ranked_status_freezed` tinyint(1) NOT NULL DEFAULT '0',
  123. `playcount` int(11) NOT NULL DEFAULT '0',
  124. `passcount` int(11) NOT NULL DEFAULT '0',
  125. `pp_100` int(11) NOT NULL DEFAULT '0',
  126. `pp_99` int(11) NOT NULL DEFAULT '0',
  127. `pp_98` int(11) NOT NULL DEFAULT '0',
  128. `pp_95` int(11) NOT NULL DEFAULT '0',
  129. PRIMARY KEY (`id`)
  130. ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;
  131.  
  132. CREATE TABLE IF NOT EXISTS `beatmaps_names` (
  133. `id` int(11) NOT NULL AUTO_INCREMENT,
  134. `beatmap_md5` varchar(32) NOT NULL DEFAULT '',
  135. `beatmap_name` varchar(256) NOT NULL DEFAULT '',
  136. PRIMARY KEY (`id`)
  137. ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  138.  
  139. CREATE TABLE IF NOT EXISTS `beta_keys` (
  140. `id` int(11) NOT NULL AUTO_INCREMENT,
  141. `key_md5` varchar(32) NOT NULL DEFAULT '',
  142. `description` varchar(128) NOT NULL DEFAULT '',
  143. `allowed` tinyint(4) NOT NULL DEFAULT '0',
  144. `public` tinyint(4) NOT NULL DEFAULT '0',
  145. PRIMARY KEY (`id`)
  146. ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;
  147.  
  148. CREATE TABLE IF NOT EXISTS `cakes` (
  149. `id` int(11) NOT NULL AUTO_INCREMENT,
  150. `userid` int(11) NOT NULL,
  151. `score_id` int(11) NOT NULL,
  152. `processes` blob NOT NULL,
  153. `detected` json NOT NULL,
  154. `flags` int(11) NOT NULL DEFAULT '0',
  155. PRIMARY KEY (`id`)
  156. ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;
  157.  
  158. CREATE TABLE IF NOT EXISTS `discord_roles` (
  159. `id` int(11) NOT NULL AUTO_INCREMENT,
  160. `userid` int(11) NOT NULL,
  161. `discordid` int(11) NOT NULL,
  162. `roleid` int(11) NOT NULL,
  163. PRIMARY KEY (`id`)
  164. ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  165.  
  166. CREATE TABLE IF NOT EXISTS `docs` (
  167. `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
  168. `doc_name` varchar(255) NOT NULL DEFAULT 'New Documentation File',
  169. `doc_contents` mediumtext NOT NULL,
  170. `public` tinyint(1) UNSIGNED NOT NULL DEFAULT '0',
  171. `old_name` varchar(200) DEFAULT NULL,
  172. PRIMARY KEY (`id`)
  173. ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
  174.  
  175. CREATE TABLE IF NOT EXISTS `eggs` (
  176. `id` int(11) NOT NULL AUTO_INCREMENT,
  177. `type` enum('hash','path','file','title') NOT NULL DEFAULT 'hash',
  178. `value` varchar(128) NOT NULL,
  179. `tag` varchar(128) NOT NULL,
  180. `ban` tinyint(1) NOT NULL DEFAULT '0',
  181. `is_regex` tinyint(1) NOT NULL DEFAULT '0',
  182. PRIMARY KEY (`id`)
  183. ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  184.  
  185. CREATE TABLE IF NOT EXISTS `hw_user` (
  186. `id` int(11) NOT NULL AUTO_INCREMENT,
  187. `userid` int(11) NOT NULL,
  188. `mac` varchar(32) NOT NULL,
  189. `unique_id` varchar(32) NOT NULL,
  190. `disk_id` varchar(32) NOT NULL,
  191. `occurencies` int(11) NOT NULL DEFAULT '0',
  192. `activated` tinyint(1) NOT NULL DEFAULT '0',
  193. PRIMARY KEY (`id`),
  194. UNIQUE KEY `userid` (`userid`)
  195. ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;
  196.  
  197. CREATE TABLE IF NOT EXISTS `identity_tokens` (
  198. `userid` int(11) NOT NULL,
  199. `token` varchar(64) NOT NULL,
  200. UNIQUE KEY `userid` (`userid`)
  201. ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  202.  
  203. CREATE TABLE IF NOT EXISTS `ip_user` (
  204. `userid` int(11) NOT NULL,
  205. `ip` text NOT NULL,
  206. `occurencies` int(11) NOT NULL,
  207. UNIQUE KEY `userid` (`userid`)
  208. ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  209.  
  210. CREATE TABLE IF NOT EXISTS `irc_tokens` (
  211. `userid` int(11) NOT NULL DEFAULT '0',
  212. `token` varchar(32) NOT NULL DEFAULT '',
  213. UNIQUE KEY `userid` (`userid`)
  214. ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  215.  
  216. CREATE TABLE IF NOT EXISTS `leaderboard_ctb` (
  217. `position` int(10) UNSIGNED NOT NULL,
  218. `user` int(11) NOT NULL,
  219. `v` bigint(20) NOT NULL,
  220. PRIMARY KEY (`position`)
  221. ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  222.  
  223. CREATE TABLE IF NOT EXISTS `leaderboard_mania` (
  224. `position` int(10) UNSIGNED NOT NULL,
  225. `user` int(11) NOT NULL,
  226. `v` bigint(20) NOT NULL,
  227. PRIMARY KEY (`position`)
  228. ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  229.  
  230. CREATE TABLE IF NOT EXISTS `leaderboard_std` (
  231. `position` int(10) UNSIGNED NOT NULL,
  232. `user` int(11) NOT NULL,
  233. `v` bigint(20) NOT NULL,
  234. PRIMARY KEY (`position`)
  235. ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  236.  
  237. CREATE TABLE IF NOT EXISTS `leaderboard_taiko` (
  238. `position` int(10) UNSIGNED NOT NULL,
  239. `user` int(11) NOT NULL,
  240. `v` bigint(20) NOT NULL,
  241. PRIMARY KEY (`position`)
  242. ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  243.  
  244. CREATE TABLE IF NOT EXISTS `main_menu_icons` (
  245. `file_id` int(11) NOT NULL AUTO_INCREMENT,
  246. `url` varchar(128) NOT NULL,
  247. `is_current` tinyint(1) NOT NULL,
  248. PRIMARY KEY (`file_id`)
  249. ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  250.  
  251. CREATE TABLE IF NOT EXISTS `osin_access` (
  252. `scope` int(11) NOT NULL DEFAULT '0',
  253. `created_at` int(11) NOT NULL DEFAULT '0',
  254. `client` int(11) NOT NULL DEFAULT '0',
  255. `extra` int(11) NOT NULL DEFAULT '0'
  256. ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  257.  
  258. CREATE TABLE IF NOT EXISTS `osin_client` (
  259. `id` int(11) NOT NULL AUTO_INCREMENT,
  260. `secret` varchar(64) NOT NULL DEFAULT '',
  261. `extra` varchar(127) NOT NULL DEFAULT '',
  262. `redirect_uri` varchar(127) NOT NULL DEFAULT '',
  263. PRIMARY KEY (`id`)
  264. ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  265.  
  266. CREATE TABLE IF NOT EXISTS `osin_client_user` (
  267. `client_id` int(11) NOT NULL DEFAULT '0',
  268. `user` int(11) NOT NULL DEFAULT '0'
  269. ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  270.  
  271. CREATE TABLE IF NOT EXISTS `password_recovery` (
  272. `id` int(11) NOT NULL AUTO_INCREMENT,
  273. `k` varchar(80) NOT NULL,
  274. `u` varchar(30) NOT NULL,
  275. `t` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  276. PRIMARY KEY (`id`)
  277. ) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;
  278.  
  279. CREATE TABLE IF NOT EXISTS `privileges_groups` (
  280. `id` int(11) NOT NULL AUTO_INCREMENT,
  281. `name` varchar(32) NOT NULL,
  282. `privileges` int(11) NOT NULL,
  283. `color` varchar(32) NOT NULL,
  284. PRIMARY KEY (`id`),
  285. UNIQUE KEY `name` (`name`)
  286. ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;
  287.  
  288. CREATE TABLE IF NOT EXISTS `profile_backgrounds` (
  289. `uid` int(11) NOT NULL,
  290. `time` int(11) NOT NULL,
  291. `type` int(11) NOT NULL,
  292. `value` text NOT NULL,
  293. PRIMARY KEY (`uid`)
  294. ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  295.  
  296. CREATE TABLE IF NOT EXISTS `rank_requests` (
  297. `id` int(11) NOT NULL AUTO_INCREMENT,
  298. `userid` int(11) NOT NULL,
  299. `bid` int(11) NOT NULL,
  300. `type` varchar(8) NOT NULL,
  301. `time` int(11) NOT NULL,
  302. `blacklisted` tinyint(1) NOT NULL,
  303. PRIMARY KEY (`id`),
  304. UNIQUE KEY `bid` (`bid`)
  305. ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;
  306.  
  307. CREATE TABLE IF NOT EXISTS `remember` (
  308. `id` int(11) NOT NULL AUTO_INCREMENT,
  309. `userid` int(11) NOT NULL,
  310. `series_identifier` int(11) DEFAULT NULL,
  311. `token_sha` varchar(255) DEFAULT NULL,
  312. PRIMARY KEY (`id`)
  313. ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;
  314.  
  315. CREATE TABLE IF NOT EXISTS `reports` (
  316. `id` int(11) NOT NULL AUTO_INCREMENT,
  317. `name` varchar(128) NOT NULL,
  318. `from_username` varchar(32) NOT NULL,
  319. `content` varchar(1024) NOT NULL,
  320. `type` tinyint(4) NOT NULL,
  321. `open_time` varchar(18) NOT NULL,
  322. `update_time` varchar(18) NOT NULL,
  323. `status` tinyint(4) NOT NULL,
  324. `response` varchar(1024) NOT NULL,
  325. PRIMARY KEY (`id`)
  326. ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  327.  
  328. CREATE TABLE IF NOT EXISTS `scores` (
  329. `id` int(11) NOT NULL AUTO_INCREMENT,
  330. `beatmap_md5` varchar(32) NOT NULL DEFAULT '',
  331. `userid` int(11) NOT NULL,
  332. `score` bigint(20) DEFAULT NULL,
  333. `max_combo` int(11) NOT NULL DEFAULT '0',
  334. `full_combo` tinyint(1) NOT NULL DEFAULT '0',
  335. `mods` int(11) NOT NULL DEFAULT '0',
  336. `300_count` int(11) NOT NULL DEFAULT '0',
  337. `100_count` int(11) NOT NULL DEFAULT '0',
  338. `50_count` int(11) NOT NULL DEFAULT '0',
  339. `katus_count` int(11) NOT NULL DEFAULT '0',
  340. `gekis_count` int(11) NOT NULL DEFAULT '0',
  341. `misses_count` int(11) NOT NULL DEFAULT '0',
  342. `time` varchar(18) NOT NULL DEFAULT '',
  343. `play_mode` tinyint(4) NOT NULL DEFAULT '0',
  344. `completed` tinyint(11) NOT NULL DEFAULT '0',
  345. `accuracy` float(15,12) DEFAULT NULL,
  346. `pp` float DEFAULT '0',
  347. PRIMARY KEY (`id`)
  348. ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;
  349.  
  350. CREATE TABLE IF NOT EXISTS `system_settings` (
  351. `id` int(11) NOT NULL AUTO_INCREMENT,
  352. `name` varchar(32) NOT NULL,
  353. `value_int` int(11) NOT NULL DEFAULT '0',
  354. `value_string` varchar(512) NOT NULL,
  355. PRIMARY KEY (`id`)
  356. ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;
  357.  
  358. CREATE TABLE IF NOT EXISTS `tokens` (
  359. `id` int(11) NOT NULL AUTO_INCREMENT,
  360. `user` varchar(31) NOT NULL,
  361. `privileges` int(11) NOT NULL,
  362. `description` varchar(255) NOT NULL,
  363. `token` varchar(127) NOT NULL,
  364. `private` tinyint(4) NOT NULL,
  365. `last_updated` int(11) NOT NULL DEFAULT '0',
  366. PRIMARY KEY (`id`)
  367. ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;
  368.  
  369. CREATE TABLE IF NOT EXISTS `users` (
  370. `id` int(11) NOT NULL AUTO_INCREMENT,
  371. `username` varchar(30) NOT NULL,
  372. `username_safe` varchar(30) NOT NULL,
  373. `password_md5` varchar(127) NOT NULL,
  374. `salt` varchar(32) NOT NULL,
  375. `email` varchar(254) NOT NULL,
  376. `register_datetime` int(10) NOT NULL,
  377. `rank` tinyint(1) NOT NULL DEFAULT '1',
  378. `achievements_version` int(11) NOT NULL DEFAULT '0',
  379. `allowed` tinyint(1) NOT NULL DEFAULT '1',
  380. `latest_activity` int(10) NOT NULL DEFAULT '0',
  381. `silence_end` int(11) NOT NULL DEFAULT '0',
  382. `silence_reason` varchar(127) NOT NULL DEFAULT '',
  383. `notes` varchar(127) NOT NULL DEFAULT '',
  384. `ban_datetime` int(11) NOT NULL DEFAULT '0',
  385. `password_version` tinyint(4) NOT NULL DEFAULT '1',
  386. `privileges` int(11) NOT NULL,
  387. `donor_expire` int(11) NOT NULL DEFAULT '0',
  388. `flags` int(11) NOT NULL DEFAULT '0',
  389. PRIMARY KEY (`id`)
  390. ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;
  391.  
  392. CREATE TABLE IF NOT EXISTS `users_achievements` (
  393. `user_id` int(11) NOT NULL,
  394. `achievement_id` int(11) NOT NULL,
  395. `time` int(11) NOT NULL
  396. ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  397.  
  398. CREATE TABLE IF NOT EXISTS `users_relationships` (
  399. `id` int(11) NOT NULL AUTO_INCREMENT,
  400. `user1` int(11) NOT NULL,
  401. `user2` int(11) NOT NULL,
  402. PRIMARY KEY (`id`)
  403. ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;
  404.  
  405. CREATE TABLE IF NOT EXISTS `users_stats` (
  406. `id` int(11) NOT NULL AUTO_INCREMENT,
  407. `username` varchar(30) NOT NULL,
  408. `username_aka` varchar(32) NOT NULL DEFAULT '',
  409. `user_color` varchar(16) NOT NULL DEFAULT 'black',
  410. `user_style` varchar(128) NOT NULL DEFAULT '',
  411. `ranked_score_std` bigint(20) DEFAULT NULL,
  412. `playcount_std` int(11) NOT NULL DEFAULT '0',
  413. `total_score_std` bigint(20) DEFAULT NULL,
  414. `replays_watched_std` int(11) UNSIGNED NOT NULL DEFAULT '0',
  415. `ranked_score_taiko` bigint(20) DEFAULT NULL,
  416. `playcount_taiko` int(11) NOT NULL DEFAULT '0',
  417. `total_score_taiko` bigint(20) DEFAULT NULL,
  418. `replays_watched_taiko` int(11) NOT NULL DEFAULT '0',
  419. `ranked_score_ctb` bigint(20) DEFAULT NULL,
  420. `playcount_ctb` int(11) NOT NULL DEFAULT '0',
  421. `total_score_ctb` bigint(20) DEFAULT NULL,
  422. `replays_watched_ctb` int(11) NOT NULL DEFAULT '0',
  423. `ranked_score_mania` bigint(20) DEFAULT NULL,
  424. `playcount_mania` int(11) NOT NULL DEFAULT '0',
  425. `total_score_mania` bigint(20) DEFAULT NULL,
  426. `replays_watched_mania` int(10) UNSIGNED NOT NULL DEFAULT '0',
  427. `total_hits_std` int(11) NOT NULL DEFAULT '0',
  428. `total_hits_taiko` int(11) NOT NULL DEFAULT '0',
  429. `total_hits_ctb` int(11) NOT NULL DEFAULT '0',
  430. `total_hits_mania` int(11) NOT NULL DEFAULT '0',
  431. `country` char(2) NOT NULL DEFAULT 'XX',
  432. `show_country` tinyint(4) NOT NULL DEFAULT '1',
  433. `level_std` int(11) NOT NULL DEFAULT '1',
  434. `level_taiko` int(11) NOT NULL DEFAULT '1',
  435. `level_ctb` int(11) NOT NULL DEFAULT '1',
  436. `level_mania` int(11) NOT NULL DEFAULT '1',
  437. `avg_accuracy_std` float(15,12) NOT NULL DEFAULT '0.000000000000',
  438. `avg_accuracy_taiko` float(15,12) NOT NULL DEFAULT '0.000000000000',
  439. `avg_accuracy_ctb` float(15,12) NOT NULL DEFAULT '0.000000000000',
  440. `avg_accuracy_mania` float(15,12) NOT NULL DEFAULT '0.000000000000',
  441. `pp_std` int(11) NOT NULL DEFAULT '0',
  442. `pp_taiko` int(11) NOT NULL DEFAULT '0',
  443. `pp_ctb` int(11) NOT NULL DEFAULT '0',
  444. `pp_mania` int(11) NOT NULL DEFAULT '0',
  445. `badges_shown` varchar(24) NOT NULL DEFAULT '1,0,0,0,0,0',
  446. `safe_title` tinyint(4) NOT NULL DEFAULT '0',
  447. `userpage_content` mediumtext,
  448. `play_style` smallint(6) NOT NULL DEFAULT '0',
  449. `favourite_mode` tinyint(4) NOT NULL DEFAULT '0',
  450. `custom_badge_icon` varchar(32) NOT NULL DEFAULT '',
  451. `custom_badge_name` varchar(32) NOT NULL DEFAULT '',
  452. `can_custom_badge` tinyint(1) NOT NULL DEFAULT '0',
  453. `show_custom_badge` tinyint(1) NOT NULL DEFAULT '0',
  454. PRIMARY KEY (`id`)
  455. ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;
  456.  
  457. CREATE TABLE IF NOT EXISTS `user_badges` (
  458. `user` int(11) NOT NULL,
  459. `badge` int(11) NOT NULL,
  460. PRIMARY KEY (`user`)
  461. ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
  462.  
  463. /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
  464. /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
  465. /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
  466. ENDOFMYSQLQUERY;
  467.  
  468. $db->execute($q);
  469.  
  470. function randomString($l) {
  471. $c = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
  472. $res = '';
  473. srand((float) microtime() * 1000000);
  474. for ($i = 0; $i < $l; $i++) {
  475. $res .= $c[rand() % strlen($c)];
  476. }
  477.  
  478. return $res;
  479. }
  480.  
  481. echo "Fokabot doesn't exist. Creating account...\n";
  482. $plainPassword = randomString(8);
  483. $options = ['cost' => 9, 'salt' => base64_decode(base64_encode(mcrypt_create_iv(22, MCRYPT_DEV_URANDOM)))];
  484. $md5Password = crypt(md5($plainPassword), '$2y$'.$options['salt']);
  485. $db->execute("INSERT INTO `users`(`id`, `username`, `username_safe`, `password_md5`, `salt`, `email`, `register_datetime`, `rank`, `allowed`, `latest_activity`, `silence_end`, `silence_reason`, `password_version`, `privileges`, `flags`) VALUES ('999', 'FokaBot', 'fokabot', ?, ?, 'fo@kab.ot', '1452544880', '4', '1', '0', '0', '', 1, 978427, 0);", [$md5Password, base64_encode($options['salt'])]);
  486. $db->execute("INSERT INTO `users_stats`(`id`, `username`, `username_aka`, `user_color`, `user_style`, `ranked_score_std`, `playcount_std`, `total_score_std`, `replays_watched_std`, `ranked_score_taiko`, `playcount_taiko`, `total_score_taiko`, `replays_watched_taiko`, `ranked_score_ctb`, `playcount_ctb`, `total_score_ctb`, `replays_watched_ctb`, `ranked_score_mania`, `playcount_mania`, `total_score_mania`, `replays_watched_mania`, `total_hits_std`, `total_hits_taiko`, `total_hits_ctb`, `total_hits_mania`, `country`, `show_country`, `level_std`, `level_taiko`, `level_ctb`, `level_mania`, `avg_accuracy_std`, `avg_accuracy_taiko`, `avg_accuracy_ctb`, `avg_accuracy_mania`, `pp_std`, `pp_taiko`, `pp_ctb`, `pp_mania`, `badges_shown`, `safe_title`, `userpage_content`, `play_style`, `favourite_mode`) VALUES ('999', 'FokaBot', '', 'black', '', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', 'XX', '1', '0', '0', '0', '0', '0.000000000000', '0.000000000000', '0.000000000000', '0.000000000000', '0', '0', '0', '0', '3,4,11,0,0,0', '0', '', 0, 0);");
  487. echo 'Fokabot account created! Password is: '.$plainPassword."\n";
  488. echo 'Yepp... thats all we got for now. Some stuff might be missing as not everything is tested and set up correctly.';
  489.  
  490. class DBPDO {
  491. public $pdo;
  492. private $error;
  493.  
  494. public function __construct() {
  495. $this->connect();
  496. }
  497.  
  498. public function prep_query($query) {
  499. return $this->pdo->prepare($query);
  500. }
  501.  
  502. public function connect() {
  503. if (!$this->pdo) {
  504. $dsn = 'mysql:dbname='.DATABASE_NAME.';'.DATABASE_WHAT.'='.DATABASE_HOST;
  505. $user = DATABASE_USER;
  506. $password = DATABASE_PASS;
  507. try {
  508. $this->pdo = new PDO($dsn, $user, $password, [PDO::ATTR_PERSISTENT => true]);
  509.  
  510. return true;
  511. }
  512. catch(PDOException $e) {
  513. $this->error = $e->getMessage();
  514. die($this->error);
  515.  
  516. return false;
  517. }
  518. } else {
  519. $this->pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
  520.  
  521. return true;
  522. }
  523. }
  524.  
  525. public function table_exists($table_name) {
  526. $stmt = $this->prep_query('SHOW TABLES LIKE ?');
  527. $stmt->execute([$this->add_table_prefix($table_name)]);
  528.  
  529. return $stmt->rowCount() > 0;
  530. }
  531.  
  532. public function execute($query, $values = null) {
  533. if ($values === null) {
  534. $values = [];
  535. } elseif (!is_array($values)) {
  536. $values = [$values];
  537. }
  538. $stmt = $this->prep_query($query);
  539. $stmt->execute($values);
  540.  
  541. return $stmt;
  542. }
  543.  
  544. public function fetch($query, $values = null) {
  545. if ($values === null) {
  546. $values = [];
  547. } elseif (!is_array($values)) {
  548. $values = [$values];
  549. }
  550. $stmt = $this->execute($query, $values);
  551.  
  552. return $stmt->fetch(PDO::FETCH_ASSOC);
  553. }
  554.  
  555. public function fetchAll($query, $values = null, $key = null) {
  556. if ($values === null) {
  557. $values = [];
  558. } elseif (!is_array($values)) {
  559. $values = [$values];
  560. }
  561. $stmt = $this->execute($query, $values);
  562. $results = $stmt->fetchAll(PDO::FETCH_ASSOC);
  563. // Allows the user to retrieve results using a
  564. // column from the results as a key for the array
  565. if ($key != null && $results[0][$key]) {
  566. $keyed_results = [];
  567. foreach ($results as $result) {
  568. $keyed_results[$result[$key]] = $result;
  569. }
  570. $results = $keyed_results;
  571. }
  572.  
  573. return $results;
  574. }
  575.  
  576. public function lastInsertId() {
  577. return $this->pdo->lastInsertId();
  578. }
  579. }
  580. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement