Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $get_host = getenv('HTTP_HOST');
- preg_match("/[^\.\/]+\.[^\.\/]+$/", $get_host, $get_domain);
- $set_hosts = array(
- 'asqim.az'
- );
- if (!in_array($get_domain[0], $set_hosts)) {
- header($_SERVER['SERVER_PROTOCOL'] . ' 400 Bad Request');
- exit();
- }
- require "inc.php";
- try {
- $db = new PDO("mysql:host=" . hostname . ";dbname=" . dbname, username, password);
- $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- }
- catch (PDOException $e) {
- die($e->getMessage());
- }
- $id = $_GET['id'];
- $ps = $_GET['ps'];
- $who = isset($_GET['who']) ? $_GET['who'] : $_POST['who'];
- $whom = isset($_GET['whom']) ? $_GET['whom'] : $_POST['whom'];
- $time = time();
- $vfile = "file/dat_folder/vcalling.dat";
- $vfile = file($vfile);
- $price = floatval($vfile[0]);
- function getuser($id)
- {
- global $db;
- $query = $db->prepare("select * from `users` where `id`=?;");
- $query->execute(array(
- $id
- ));
- $inf = $query->fetch(PDO::FETCH_ASSOC);
- return $inf;
- }
- $inf = getuser($whom);
- $json = array();
- $json['error'] = 'ok';
- $json['whom_user'] = ($inf['user']) ? $inf['user'] : '';
- $query = $db->prepare("select * from `users` where `id`=? and `pass`=?;");
- $query->execute(array(
- $id,
- $ps
- ));
- $cnt = $query->rowCount();
- if (!$cnt) {
- die('login or password is wrong');
- }
- $row = $query->fetch(PDO::FETCH_ASSOC);
- $azn = $row['azn'];
- $go = strip_tags($_POST['go']);
- switch ($go) {
- case 'connecting':
- $json['connMsg'] = "<div class='spinner'></div>
- <break></break>
- <p>Zəngə qoşulur...</p>
- <break></break>
- <p>Zəhmət olmasa qarşı tərəfin zəngə cavab vermesini gözləyin</p>";
- break;
- case 'openModal':
- $query = $db->prepare("select * from `vcalling` where `who`=? and `whom`=? and `sts`=?;");
- $query->execute(array(
- $who,
- $whom,
- 2
- ));
- $cnt = $query->rowCount();
- if ($cnt) {
- $list = $query->fetch(PDO::FETCH_ASSOC);
- $who_i = getuser($list['who']);
- $whom_i = getuser($list['whom']);
- $status = '';
- $status .= ($who_i['id'] == $id) ? '' : 'Zəng edən: <b>' . $who_i['user'] . '</b>';
- $status .= ($whom_i['id'] == $id) ? '' : 'Zəng edilən: <b>' . $whom_i['user'] . '</b>';
- $str = "<p>{$status}</p>
- <break></break>
- <p id='chrontime'>Danışıq vaxtı: <span>00:00:00</span></p>
- <break></break>
- <button type=\"button\" class=\"btn btn-xs btn-labeled btn-danger f-right\" onClick=\"leaveRoom();\">
- <span class=\"btn-label\"><i class=\"fas fa-phone-slash\"></i></span> Zəngi bitir
- </button>";
- if ($who_i['azn'] >= $price && $who_i['id'] == $id) {
- $price = $who_i['azn'] - $price;
- $query = $db->prepare("update `users` set `azn`=? where `id`=?;");
- $query->execute(array(
- $price,
- $who_i['id']
- ));
- }
- $json['txt'] = $str;
- $json['sender'] = $list['who'];
- $json['acceptable'] = $list['whom'];
- } else {
- $json['msg'] = 'Qarşı tərəf zəngdən imtina etdi';
- $json['title'] = 'Zəng imtina';
- $json['button'] = 'Ok';
- $json['error'] = 'busy';
- break;
- }
- break;
- case 'starttwoCall':
- $query = $db->prepare("update `vcalling` set `sts`=? where `who`=? and `whom`=?;");
- $query->execute(array(
- 2,
- $whom,
- $id
- ));
- break;
- case 'checktwoCall':
- $query = $db->prepare("select * from `vcalling` where `who`=? and `whom`=?;");
- $query->execute(array(
- $whom,
- $id
- ));
- $callCode = $query->fetch(PDO::FETCH_ASSOC);
- $inf = getuser($whom);
- if ($inf['calltime'] <= $time) {
- $query = $db->prepare("update `vcalling` set `sts`=? where `who`=? and `whom`=?;");
- $query->execute(array(
- 0,
- $whom,
- $id
- ));
- $json['msg'] = 'Qarşı tərəf saytdan çıxış etdi';
- $json['title'] = 'Offline';
- $json['button'] = 'Ok';
- $json['error'] = 'offline';
- break;
- }
- if ($callCode['sts'] != 2) {
- $json['msg'] = 'Qarşı tərəf zəngdən imtina etdi';
- $json['title'] = 'Zəng imtina';
- $json['button'] = 'Ok';
- $json['error'] = 'busy';
- break;
- }
- break;
- case 'startCall':
- if ($whom == $id) {
- $json['msg'] = 'Öz-özünüzə zəng etmək istəyirsiniz?';
- $json['title'] = 'Öz-özünə zəng';
- $json['error'] = 'self';
- break;
- }
- if (!isset($inf['id'])) {
- ......................................................................................
- .................................................
- ................
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement