properties.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. <?php
  2. require "settings.php";
  3. $properties = json_decode( '{
  4. "level": 95,
  5. "gender": "Female",
  6. "player_id": 12345,
  7. "name": "Unknown",
  8. "personalstats": {
  9. "useractivity": 26817266,
  10. "logins": 4361,
  11. "weaponsbought": 11148,
  12. "attackmisses": 23141,
  13. "attackdamage": 59342703,
  14. "attackhits": 52840,
  15. "axehits": 1067,
  16. "attackswon": 14058,
  17. "highestbeaten": 100,
  18. "bestkillstreak": 504,
  19. "jailed": 306,
  20. "mailssent": 1724,
  21. "attackcriticalhits": 10817,
  22. "slahits": 425,
  23. "moneymugged": 19552798251,
  24. "largestmug": 1000026663,
  25. "friendmailssent": 375,
  26. "roundsfired": 271152,
  27. "pishits": 346,
  28. "defendswon": 2765,
  29. "hospital": 8385,
  30. "defendslost": 3707,
  31. "rifhits": 6620,
  32. "attackslost": 797,
  33. "attacksassisted": 336,
  34. "attacksstealthed": 8335,
  35. "onehitkills": 6547,
  36. "dumpsearches": 1026,
  37. "dumpfinds": 1026,
  38. "itemsdumped": 5050,
  39. "itemssent": 3567,
  40. "drugsused": 5352,
  41. "cantaken": 77,
  42. "auctionswon": 16,
  43. "daysbeendonator": 1881,
  44. "spousemailssent": 104,
  45. "medicalitemsused": 21720,
  46. "companymailssent": 185,
  47. "trainsreceived": 1071,
  48. "cityfinds": 522,
  49. "theyrunaway": 1022,
  50. "failedbusts": 249,
  51. "peoplebusted": 3000,
  52. "pointsbought": 44095,
  53. "itemsbought": 3426,
  54. "xantaken": 4812,
  55. "traveltimes": 3475,
  56. "mextravel": 481,
  57. "itemsboughtabroad": 92754,
  58. "cantravel": 462,
  59. "lontravel": 387,
  60. "caytravel": 411,
  61. "argtravel": 350,
  62. "hawtravel": 165,
  63. "japtravel": 132,
  64. "switravel": 586,
  65. "soutravel": 133,
  66. "dubtravel": 172,
  67. "chitravel": 196,
  68. "shrtaken": 50,
  69. "shohits": 157,
  70. "piehits": 4646,
  71. "bountiescollected": 798,
  72. "totalbountyreward": 210769630,
  73. "medstolen": 8,
  74. "attacksdraw": 218,
  75. "virusescoded": 125,
  76. "yourunaway": 157,
  77. "victaken": 84,
  78. "overdosed": 108,
  79. "revivesreceived": 805,
  80. "auctionsells": 15,
  81. "exttaken": 246,
  82. "kettaken": 50,
  83. "respectforfaction": 76338,
  84. "smghits": 1663,
  85. "bountiesreceived": 206,
  86. "factionmailssent": 173,
  87. "peoplebought": 502,
  88. "peopleboughtspent": 54974080,
  89. "chahits": 234,
  90. "machits": 119,
  91. "heahits": 697,
  92. "networth": 30897667775,
  93. "grehits": 276,
  94. "missioncreditsearned": 40942,
  95. "contractscompleted": 1022,
  96. "dukecontractscompleted": 1022,
  97. "revives": 663,
  98. "missionscompleted": 1,
  99. "bountiesplaced": 486,
  100. "totalbountyspent": 194793585,
  101. "bloodwithdrawn": 5140,
  102. "lsdtaken": 11,
  103. "defendsstalemated": 28,
  104. "meritsbought": 45,
  105. "opitaken": 14,
  106. "nerverefills": 1409,
  107. "consumablesused": 24693,
  108. "candyused": 1838,
  109. "alcoholused": 13823,
  110. "energydrinkused": 9032,
  111. "tokenrefills": 201,
  112. "organisedcrimes": 158,
  113. "booksread": 10,
  114. "h2hhits": 147,
  115. "classifiedadsplaced": 6,
  116. "traveltime": 37998600,
  117. "unarmoredwon": 259,
  118. "stockpayouts": 487,
  119. "boostersused": 1189,
  120. "territorytime": 2631552,
  121. "rehabs": 6667,
  122. "rehabcost": 1404830000,
  123. "awards": 462,
  124. "statenhancersused": 5,
  125. "bestdamage": 11472,
  126. "racingpointsearned": 2126,
  127. "raceswon": 699,
  128. "racesentered": 2395,
  129. "receivedbountyvalue": 88109384,
  130. "pcptaken": 1,
  131. "cityitemsbought": 85276,
  132. "specialammoused": 10977,
  133. "spetaken": 1,
  134. "hollowammoused": 4000,
  135. "tracerammoused": 2498,
  136. "incendiaryammoused": 2493,
  137. "piercingammoused": 1986,
  138. "refills": 1612
  139. },
  140. "status": {
  141. "description": "Okay",
  142. "details": "",
  143. "state": "Okay",
  144. "color": "green",
  145. "until": 0
  146. }
  147. }');
  148. print( "<pre>" );
  149. print_r( $properties );
  150. print( "</pre>");
  151. $list = [];
  152. foreach ( $properties as $key => $val ) {
  153. if ( is_object( $val ) ) {
  154. foreach( $val as $subkey => $subval) {
  155. $list[] = [$subkey, $key];
  156. }
  157. } else {
  158. $list[] = [$key, ''];
  159. }
  160. }
  161. print("<pre>");
  162. print_r( $list );
  163. print("</pre>");
  164. $pdo = null;
  165. try {
  166. $pdo = new PDO("sqlite:" . "${db_path}/slork.sqlite");
  167. } catch (PDOException $e) {
  168. // handle the exception here
  169. }
  170. if ( !$pdo ) {
  171. exit( "Cannot connect to database" );
  172. }
  173. $query = "DROP TABLE IF EXISTS properties;";
  174. $pdo->exec( $query );
  175. $query = <<<QUERY
  176. CREATE TABLE IF NOT EXISTS properties (
  177. id INTEGER PRIMARY KEY, property TEXT, parent TEXT, UNIQUE(property));
  178. QUERY;
  179. $pdo->exec( $query );
  180. $query = "INSERT INTO properties (property, parent) VALUES (?, ?) ON CONFLICT (property) DO NOTHING;";
  181. $stmt = $pdo->prepare( $query );
  182. foreach ( $list as $item ) {
  183. $stmt->execute( $item );
  184. }
  185. /**
  186. $query = "SELECT property FROM properties;";
  187. $stmt = $pdo->query( $query );
  188. foreach( $stmt as $row ) {
  189. print( $row['property'] . ', ');
  190. }
  191. */