Xom9ik

SetValue.php

May 10th, 2018
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.49 KB | None | 0 0
  1. <?php
  2. require 'db.php';
  3.  
  4. $arrayData  = json_decode($_POST['arrayData'], true);
  5. //echo "\n" . displayRecursiveResults($arrayData) . "\n";
  6.  
  7. $playerID = $arrayData['uid'];
  8. $username = $arrayData['username'];
  9. $email = $arrayData['email'];
  10.  
  11. $game_data_json0 = $arrayData['game_data_json0'];
  12. $game_data_json1 = $arrayData['game_data_json1'];
  13. $game_data_json2 = $arrayData['game_data_json2'];
  14. $game_data_json3 = $arrayData['game_data_json3'];
  15.  
  16. if(!isset($playerID)){
  17.     echo "Fail data UID";
  18.     exit;
  19. }
  20. else {
  21.     SetValue($playerID, $game_data_json0, $game_data_json1, $game_data_json2, $game_data_json3);
  22. }
  23.  
  24. function displayRecursiveResults($arrayObject) {
  25.     foreach($arrayObject as $key=>$data) {
  26.         if(is_array($data)) {
  27.             displayRecursiveResults($data);
  28.         } elseif(is_object($data)) {
  29.             displayRecursiveResults($data);
  30.         } else {
  31.             echo $key." => ".$data."\n";
  32.         }
  33.     }
  34. }
  35.  
  36. function SetValue($playerID, $game_data_json0, $game_data_json1, $game_data_json2, $game_data_json3) {
  37.     $user_data = R::findOne('users', 'uid = ?', [$playerID]);
  38.     if ($user_data) {
  39.         $user_data->game_data_json0 = $game_data_json0;
  40.         $user_data->game_data_json1 = $game_data_json1;
  41.         $user_data->game_data_json2 = $game_data_json2;
  42.         $user_data->game_data_json3 = $game_data_json3;
  43.         R::store($user_data);
  44.         echo "Set successfull";
  45.     }
  46.     else {
  47.         echo "Not find this user set" . $playerID;
  48.     }
  49. }
  50. ?>
Advertisement
Add Comment
Please, Sign In to add comment