function Changeblacklist($phones, $reason) { $user_id = $_SESSION['USERID']; foreach ($phones as $phone) { $asterisk = new asterisk("213.131.56.86", "5038", "admin", "amp111", 300); $result = $asterisk->blackListAdd($phone); if ($result == 1) { $req = mysql_query("SELECT incomming_call.id \r\n FROM incomming_call\r\n WHERE incomming_call.actived=1 \r\n AND incomming_call.call_status_id = 3 \r\n AND incomming_call.phone = '{$phone}'"); while ($aRow = mysql_fetch_assoc($req)) { mysql_query("UPDATE `incomming_call` \r\n \tSET \r\n `fan_status` = '2'\r\n WHERE `id` = '{$aRow['id']}'"); } mysql_query("INSERT INTO `blacklis`\r\n (`user_id`, `date`, `phone`, `reason`)\r\n VALUES\r\n ('{$user_id}', NOW(), '{$phone}', '{$reason}');"); } else { global $error; $error = 'დაბლოკვა არ მოხდა'; } } }
function Addblacklist($user_id, $phone, $reason) { $check_phone = mysql_fetch_assoc(mysql_query("SELECT 1 AS check_phone\r\n FROM blacklis\r\n WHERE phone='{$phone}' \r\n AND actived=1 \r\n LIMIT 1")); if ($check_phone[check_phone] != 1) { $asterisk = new asterisk("213.131.56.86", "5038", "admin", "amp111", 300); $result = $asterisk->blackListAdd($phone); if ($result == 1) { mysql_query("INSERT INTO `blacklis`\r\n (`user_id`, `date`, `phone`, `reason`)\r\n VALUES\r\n ('{$user_id}', NOW(), '{$phone}', '{$reason}');"); } else { global $error; $error = 'ნომერი არ დაიბლოკა'; } } else { global $error; $error = 'ნომერი უკვე დაბლოკილია'; } }
<?php require_once '../../includes/classes/asterisk.class.php'; $asterisk = new asterisk("212.72.155.176", "5038", "admin", "sudobash", 300); $data = ''; $action = $_REQUEST['act']; switch ($action) { case 'black_list_add': $phone = $_REQUEST['phone']; $data['error'] = "ნომერი დაემატა შავ სიას"; echo json_encode($data); $asterisk->blackListAdd($phone); break; case 'black_list_remove': $phone = $_REQUEST['phone']; $data['error'] = "ნომერი ამოიშალა შავი სიიდან"; echo json_encode($data); $asterisk->blackListRemove($phone); break; default: break; }