properties.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. <?php
  2. require "settings.php";
  3. $properties = json_decode( '{
  4. "level": 95,
  5. "gender": "Female",
  6. "player_id": 123123123,
  7. "name": "onetwothree",
  8. "personalstats": {
  9. "useractivity": 26835837,
  10. "logins": 4361,
  11. "weaponsbought": 11148,
  12. "attackmisses": 23164,
  13. "attackdamage": 59351490,
  14. "attackhits": 52858,
  15. "axehits": 1067,
  16. "attackswon": 14060,
  17. "highestbeaten": 100,
  18. "bestkillstreak": 504,
  19. "jailed": 306,
  20. "mailssent": 1725,
  21. "attackcriticalhits": 10820,
  22. "slahits": 426,
  23. "moneymugged": 19552822850,
  24. "largestmug": 1000026663,
  25. "friendmailssent": 375,
  26. "roundsfired": 271197,
  27. "pishits": 347,
  28. "defendswon": 2765,
  29. "hospital": 8416,
  30. "defendslost": 3737,
  31. "rifhits": 6620,
  32. "attackslost": 797,
  33. "attacksassisted": 336,
  34. "attacksstealthed": 8336,
  35. "onehitkills": 6547,
  36. "dumpsearches": 1026,
  37. "dumpfinds": 1026,
  38. "itemsdumped": 5050,
  39. "itemssent": 3568,
  40. "drugsused": 5358,
  41. "cantaken": 77,
  42. "auctionswon": 16,
  43. "daysbeendonator": 1883,
  44. "spousemailssent": 104,
  45. "medicalitemsused": 21768,
  46. "companymailssent": 185,
  47. "trainsreceived": 1071,
  48. "cityfinds": 522,
  49. "theyrunaway": 1022,
  50. "failedbusts": 249,
  51. "peoplebusted": 3002,
  52. "pointsbought": 44095,
  53. "itemsbought": 3426,
  54. "xantaken": 4818,
  55. "traveltimes": 3488,
  56. "mextravel": 483,
  57. "itemsboughtabroad": 93119,
  58. "cantravel": 462,
  59. "lontravel": 390,
  60. "caytravel": 418,
  61. "argtravel": 350,
  62. "hawtravel": 165,
  63. "japtravel": 132,
  64. "switravel": 587,
  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": 109,
  79. "revivesreceived": 806,
  80. "auctionsells": 15,
  81. "exttaken": 246,
  82. "kettaken": 50,
  83. "respectforfaction": 76343,
  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": 30999395805,
  93. "grehits": 276,
  94. "missioncreditsearned": 40991,
  95. "contractscompleted": 1024,
  96. "dukecontractscompleted": 1024,
  97. "revives": 663,
  98. "missionscompleted": 1,
  99. "bountiesplaced": 487,
  100. "totalbountyspent": 194943585,
  101. "bloodwithdrawn": 5140,
  102. "lsdtaken": 11,
  103. "defendsstalemated": 28,
  104. "meritsbought": 45,
  105. "opitaken": 14,
  106. "nerverefills": 1412,
  107. "consumablesused": 24815,
  108. "candyused": 1838,
  109. "alcoholused": 13924,
  110. "energydrinkused": 9053,
  111. "tokenrefills": 202,
  112. "organisedcrimes": 158,
  113. "booksread": 10,
  114. "h2hhits": 147,
  115. "classifiedadsplaced": 6,
  116. "traveltime": 38079060,
  117. "unarmoredwon": 261,
  118. "stockpayouts": 489,
  119. "boostersused": 1189,
  120. "territorytime": 2655360,
  121. "rehabs": 6695,
  122. "rehabcost": 1410430000,
  123. "awards": 462,
  124. "statenhancersused": 5,
  125. "bestdamage": 11472,
  126. "racingpointsearned": 2139,
  127. "raceswon": 701,
  128. "racesentered": 2402,
  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": 1614
  139. },
  140. "status": {
  141. "description": "Okay",
  142. "details": "",
  143. "state": "Okay",
  144. "color": "green",
  145. "until": 0
  146. },
  147. "criminalrecord": {
  148. "selling_illegal_products": 5003,
  149. "theft": 25055,
  150. "auto_theft": 3003,
  151. "drug_deals": 697,
  152. "computer_crimes": 7172,
  153. "murder": 10019,
  154. "fraud_crimes": 10340,
  155. "other": 5007,
  156. "total": 66296
  157. }
  158. }');
  159. print( "<pre>" );
  160. print_r( $properties );
  161. print( "</pre>");
  162. $list = [];
  163. foreach ( $properties as $key => $val ) {
  164. if ( is_object( $val ) ) {
  165. foreach( $val as $subkey => $subval) {
  166. $list[] = [$subkey, $key];
  167. }
  168. } else {
  169. $list[] = [$key, ''];
  170. }
  171. }
  172. print("<pre>");
  173. print_r( $list );
  174. print("</pre>");
  175. $pdo = null;
  176. try {
  177. $pdo = new PDO("sqlite:" . "${db_path}/slork.sqlite");
  178. } catch (PDOException $e) {
  179. // handle the exception here
  180. }
  181. if ( !$pdo ) {
  182. exit( "Cannot connect to database" );
  183. }
  184. $query = "DROP TABLE IF EXISTS properties;";
  185. $pdo->exec( $query );
  186. $query = <<<QUERY
  187. CREATE TABLE IF NOT EXISTS properties (
  188. id INTEGER PRIMARY KEY, property TEXT, parent TEXT, UNIQUE(property));
  189. QUERY;
  190. $pdo->exec( $query );
  191. $query = "INSERT INTO properties (property, parent) VALUES (?, ?) ON CONFLICT (property) DO NOTHING;";
  192. $stmt = $pdo->prepare( $query );
  193. foreach ( $list as $item ) {
  194. $stmt->execute( $item );
  195. }
  196. /**
  197. $query = "SELECT property FROM properties;";
  198. $stmt = $pdo->query( $query );
  199. foreach( $stmt as $row ) {
  200. print( $row['property'] . ', ');
  201. }
  202. */