*
 * http://ifsoft.com.ua, http://ifsoft.co.uk
 * qascript@ifsoft.co.uk
 *
 * Copyright 2012-2016 Demyanchuk Dmitry (https://vk.com/dmitry.demyanchuk)
 */
include_once $_SERVER['DOCUMENT_ROOT'] . "/core/init.inc.php";
include_once $_SERVER['DOCUMENT_ROOT'] . "/config/api.inc.php";
if (!empty($_POST)) {
    $accountId = isset($_POST['accountId']) ? $_POST['accountId'] : 0;
    $accessToken = isset($_POST['accessToken']) ? $_POST['accessToken'] : '';
    $profileId = isset($_POST['profileId']) ? $_POST['profileId'] : 0;
    $reason = isset($_POST['reason']) ? $_POST['reason'] : '';
    $accountId = helper::clearInt($accountId);
    $profileId = helper::clearInt($profileId);
    $reason = preg_replace("/[\r\n]+/", " ", $reason);
    //replace all new lines to one new line
    $reason = preg_replace('/\\s+/', ' ', $reason);
    //replace all white spaces to one space
    $reason = helper::escapeText($reason);
    $result = array("error" => true, "error_code" => ERROR_UNKNOWN);
    $auth = new auth($dbo);
    if (!$auth->authorize($accountId, $accessToken)) {
        api::printError(ERROR_ACCESS_TOKEN, "Error authorization.");
    }
    $blacklist = new blacklist($dbo);
    $blacklist->setRequestFrom($accountId);
    $result = $blacklist->add($profileId, $reason);
    echo json_encode($result);
    exit;
}
Example #2
0
                 } else {
                     $message = $ui[$status];
                 }
             } else {
                 $message = $ui['insufficientData'];
             }
         } else {
             $message = $ui['wrongPassword'];
         }
         break;
     case 'blacklist':
         if (isset($_GET['blacklistAction'], $_POST['type'], $_POST['value'])) {
             if ($_SESSION[$shortTitle . 'User']['password'] == sha1($_POST['password'])) {
                 switch ($_GET['blacklistAction']) {
                     case 'add':
                         $message = $ui[blacklist::add($_POST['type'], $_POST['value'])];
                         break;
                     case 'remove':
                         foreach ($_POST['value'] as $value) {
                             $message = $ui[blacklist::remove($_POST['type'], $value)];
                         }
                         break;
                 }
             } else {
                 $message = $ui['wrongPassword'];
             }
         } else {
             $message = $ui['insufficientData'];
         }
         break;
 }