<?php

/**
 * Created by PhpStorm.
 * User: Kavand
 * Date: 7/7/2018
 * Time: 5:19 AM
 */


$object = $request['object'];

if (isset($object['data'])) {
    if (($object['for'] === 'c1') OR ($object['for'] === 'c2')) {
        $array = explode('][', $object['data']);
        $array = str_replace("]", "", str_replace("[", "", $array));
        if ($DLA->DoCommand("DELETE FROM " . ($object['for'] === 'c1' ? "app_slide_show" : "app_advertising_list"))) {
            if (count($array) > 0) {
                for ($i = 0; $i < count($array); $i += 1) {
                    $item = explode(',', $array[$i]);
                    $query = "INSERT INTO " . ($object['for'] === 'c1' ? "app_slide_show" : "app_advertising_list") . " (URL, POST_ID) VALUES ('{$item[0]}','{$item[1]}')";
                    $DLA->DoCommand($query);
                }
                echo 1;
            }
        } else {
            echo 0;
        }
    } else {
        echo 0;
    }
} else {
    echo 0;
}
