Advertisement
Guest User

Untitled

a guest
Aug 18th, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.12 KB | None | 0 0
  1. private void dailyCheckin(final ProgressDialog pDialog) {
  2. //first getting the values
  3. final String reg_user_id=String.valueOf(SharedPref.getInstance(getApplicationContext()).getUserID());
  4. //Call our volley library
  5. StringRequest stringRequest = new StringRequest(Request.Method.POST, Constant.DAILYCHECKIN,
  6. new Response.Listener<String>() {
  7. @Override
  8. public void onResponse(String response) {
  9. try {
  10. JSONObject obj = new JSONObject(response);
  11. if (obj.getBoolean("error")) {
  12. pDialog.hide();
  13. Toast.makeText(getApplicationContext(),
  14. getString(R.string.newdailyreward)
  15. +" "+obj.getString("hours")+" "+
  16. getString(R.string.hours)
  17. +" "+obj.getString("minutes")+" "+
  18. getString(R.string.minutes), Toast.LENGTH_SHORT).show();
  19. } else {
  20. pDialog.hide();
  21. Toast.makeText(getApplicationContext(),
  22. getString(R.string.rewardsuccess)
  23. +" "+obj.getString("message")+" "+
  24. getString(R.string.rewardpoints)
  25. , Toast.LENGTH_SHORT).show();
  26.  
  27. }
  28. } catch (JSONException e) {
  29. pDialog.hide();
  30. e.printStackTrace();
  31. }
  32. }
  33. },
  34. new Response.ErrorListener() {
  35. @Override
  36. public void onErrorResponse(VolleyError error) {
  37. pDialog.hide();
  38. error.printStackTrace();
  39. }
  40. }) {
  41. @Override
  42. protected Map<String, String> getParams() throws AuthFailureError {
  43. Map<String, String> params = new HashMap<>();
  44. params.put("user_id", reg_user_id);
  45.  
  46. return params;
  47. }
  48. };
  49. VolleySingleton.getInstance(FreePointsActivity.this).addToRequestQueue(stringRequest);
  50. }//dailyCheckin
  51.  
  52. elseif (isset($_GET['dailycheckin'])) {
  53. $id=intval($_POST['user_id']);
  54.  
  55.  
  56. $daily="Daily Checkin";
  57.  
  58.  
  59.  
  60.  
  61.  
  62. $sql='select * from rewardpoints_points where user_id='.$id.' AND app_name="'.$daily.'" ORDER BY date_operation DESC;';
  63. $res=$cnx->query($sql);
  64. $data=$res->fetchAll(PDO::FETCH_OBJ)[0];
  65.  
  66.  
  67. if (empty($data)) {
  68.  
  69. $s='select daily_chekin_points from rewardpoints_settings';
  70. $r=$cnx->query($s);
  71. $d=$r->fetchAll(PDO::FETCH_OBJ)[0];
  72. $points=$d->daily_chekin_points;
  73. $sql="insert into rewardpoints_points values(NULL,'".$id."',0,'".$daily."','".$points."',NOW(),0)";
  74. if($cnx->exec($sql)){
  75. $response['error'] = false;
  76. $response['message'] = $points;
  77. }
  78.  
  79.  
  80. }
  81. else{
  82.  
  83. $newreward= strtotime( $data->date_operation ) + 24 * 3600;
  84. if ($newreward<=time()) {
  85. //echo "you can get";
  86. $s='select daily_chekin_points from rewardpoints_settings';
  87. $r=$cnx->query($s);
  88. $d=$r->fetchAll(PDO::FETCH_OBJ)[0];
  89. $points=$d->daily_chekin_points;
  90. $sql="insert into rewardpoints_points values(NULL,'".$id."',0,'".$daily."','".$points."',NOW(),0)";
  91. if($cnx->exec($sql)){
  92. $response['error'] = false;
  93. $response['message'] = $points;
  94. }
  95.  
  96. }//$newreward<=time()
  97. else{
  98. //echo "you can not";
  99. $response['error'] = true;
  100. $time=time()-$newreward;
  101. $m = floor($time / 60)*-1;
  102. $hours = floor($m / 60);
  103. $minutes = ($m % 60);
  104. $response['hours'] = $hours;
  105. $response['minutes'] = $minutes;
  106. }
  107.  
  108. }
  109. }//dailycheckin
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement