Advertisement
Guest User

Untitled

a guest
Nov 10th, 2019
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.42 KB | None | 0 0
  1. <?php
  2.  
  3. $get_host = getenv('HTTP_HOST');
  4. preg_match("/[^\.\/]+\.[^\.\/]+$/", $get_host, $get_domain);
  5. $set_hosts = array(
  6. 'asqim.az'
  7. );
  8. if (!in_array($get_domain[0], $set_hosts)) {
  9. header($_SERVER['SERVER_PROTOCOL'] . ' 400 Bad Request');
  10. exit();
  11. }
  12. require "inc.php";
  13. try {
  14. $db = new PDO("mysql:host=" . hostname . ";dbname=" . dbname, username, password);
  15. $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  16. }
  17. catch (PDOException $e) {
  18. die($e->getMessage());
  19. }
  20. $id = $_GET['id'];
  21. $ps = $_GET['ps'];
  22. $who = isset($_GET['who']) ? $_GET['who'] : $_POST['who'];
  23. $whom = isset($_GET['whom']) ? $_GET['whom'] : $_POST['whom'];
  24. $time = time();
  25. $vfile = "file/dat_folder/vcalling.dat";
  26. $vfile = file($vfile);
  27. $price = floatval($vfile[0]);
  28. function getuser($id)
  29. {
  30. global $db;
  31. $query = $db->prepare("select * from `users` where `id`=?;");
  32. $query->execute(array(
  33. $id
  34. ));
  35. $inf = $query->fetch(PDO::FETCH_ASSOC);
  36. return $inf;
  37. }
  38. $inf = getuser($whom);
  39. $json = array();
  40. $json['error'] = 'ok';
  41. $json['whom_user'] = ($inf['user']) ? $inf['user'] : '';
  42. $query = $db->prepare("select * from `users` where `id`=? and `pass`=?;");
  43. $query->execute(array(
  44. $id,
  45. $ps
  46. ));
  47. $cnt = $query->rowCount();
  48. if (!$cnt) {
  49. die('login or password is wrong');
  50. }
  51. $row = $query->fetch(PDO::FETCH_ASSOC);
  52. $azn = $row['azn'];
  53. $go = strip_tags($_POST['go']);
  54. switch ($go) {
  55. case 'connecting':
  56. $json['connMsg'] = "<div class='spinner'></div>
  57. <break></break>
  58. <p>Zəngə qoşulur...</p>
  59. <break></break>
  60. <p>Zəhmət olmasa qarşı tərəfin zəngə cavab vermesini gözləyin</p>";
  61. break;
  62. case 'openModal':
  63. $query = $db->prepare("select * from `vcalling` where `who`=? and `whom`=? and `sts`=?;");
  64. $query->execute(array(
  65. $who,
  66. $whom,
  67. 2
  68. ));
  69. $cnt = $query->rowCount();
  70. if ($cnt) {
  71. $list = $query->fetch(PDO::FETCH_ASSOC);
  72. $who_i = getuser($list['who']);
  73. $whom_i = getuser($list['whom']);
  74. $status = '';
  75. $status .= ($who_i['id'] == $id) ? '' : 'Zəng edən: <b>' . $who_i['user'] . '</b>';
  76. $status .= ($whom_i['id'] == $id) ? '' : 'Zəng edilən: <b>' . $whom_i['user'] . '</b>';
  77. $str = "<p>{$status}</p>
  78.  
  79. <break></break>
  80.  
  81. <p id='chrontime'>Danışıq vaxtı: <span>00:00:00</span></p>
  82.  
  83. <break></break>
  84.  
  85. <button type=\"button\" class=\"btn btn-xs btn-labeled btn-danger f-right\" onClick=\"leaveRoom();\">
  86. <span class=\"btn-label\"><i class=\"fas fa-phone-slash\"></i></span> Zəngi bitir
  87. </button>";
  88. if ($who_i['azn'] >= $price && $who_i['id'] == $id) {
  89. $price = $who_i['azn'] - $price;
  90. $query = $db->prepare("update `users` set `azn`=? where `id`=?;");
  91. $query->execute(array(
  92. $price,
  93. $who_i['id']
  94. ));
  95. }
  96. $json['txt'] = $str;
  97. $json['sender'] = $list['who'];
  98. $json['acceptable'] = $list['whom'];
  99. } else {
  100. $json['msg'] = 'Qarşı tərəf zəngdən imtina etdi';
  101. $json['title'] = 'Zəng imtina';
  102. $json['button'] = 'Ok';
  103. $json['error'] = 'busy';
  104. break;
  105. }
  106. break;
  107. case 'starttwoCall':
  108. $query = $db->prepare("update `vcalling` set `sts`=? where `who`=? and `whom`=?;");
  109. $query->execute(array(
  110. 2,
  111. $whom,
  112. $id
  113. ));
  114. break;
  115. case 'checktwoCall':
  116. $query = $db->prepare("select * from `vcalling` where `who`=? and `whom`=?;");
  117. $query->execute(array(
  118. $whom,
  119. $id
  120. ));
  121. $callCode = $query->fetch(PDO::FETCH_ASSOC);
  122. $inf = getuser($whom);
  123. if ($inf['calltime'] <= $time) {
  124. $query = $db->prepare("update `vcalling` set `sts`=? where `who`=? and `whom`=?;");
  125. $query->execute(array(
  126. 0,
  127. $whom,
  128. $id
  129. ));
  130. $json['msg'] = 'Qarşı tərəf saytdan çıxış etdi';
  131. $json['title'] = 'Offline';
  132. $json['button'] = 'Ok';
  133. $json['error'] = 'offline';
  134. break;
  135. }
  136. if ($callCode['sts'] != 2) {
  137. $json['msg'] = 'Qarşı tərəf zəngdən imtina etdi';
  138. $json['title'] = 'Zəng imtina';
  139. $json['button'] = 'Ok';
  140. $json['error'] = 'busy';
  141. break;
  142. }
  143. break;
  144. case 'startCall':
  145. if ($whom == $id) {
  146. $json['msg'] = 'Öz-özünüzə zəng etmək istəyirsiniz?';
  147. $json['title'] = 'Öz-özünə zəng';
  148. $json['error'] = 'self';
  149. break;
  150. }
  151. if (!isset($inf['id'])) {
  152. ......................................................................................
  153. .................................................
  154. ................
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement