#!/usr/bin/env php
<?php
/*************************************
 * SPDX-FileCopyrightText: 2009-present Vtenext S.r.l. Società Benefit 
 * SPDX-License-Identifier: LicenseRef-vtenext-business-license 
 ************************************/

/**
 * Simple script to change the debug.disable_outbound property
 * When set to 1, all outbound communication from vte is stopped (emails, webservices, pbx, ...)
 *
 * Call this script from command line and pass 1 or 0 to set/unset the property
 */
 
/*  crmv@210965  */
function error($msg) {
    echo "\e[31m[ERROR] ".$msg."\e[0m\n";
    exit(1);
}

// check cli invocation
if (php_sapi_name() != 'cli') error("Please execute from CLI");

require(__DIR__ . '/../config.inc.php');
if (empty($root_directory)) return error("Vtenext not installed");

chdir($root_directory);
require_once('include/utils/utils.php');

$VTEP = VTEProperties::getInstance();

switch($argv[1]){
    case '0':
        $VTEP->setProperty('debug.disable_outbound', 0);
        break;
    case '1':
        $VTEP->setProperty('debug.disable_outbound', 1);
        break;
    default:
        error("Use: php toggleOutbound.php 0/1");
        break;
}
