#!/usr/bin/php
<?php

namespace {

require_once('/usr/share/ombutel/www/includes/cli.php');

} //namespace

namespace update_mexican_numbering_plan {

use ombutel\db;
use ombutel\settings;
use ombutel\utils;
use ombutel\mexican_numbering_plan as mnp;

$url = settings::get('mexican_numbering_plan', 'url');

if ($url != '') {
	$content = @file_get_contents($url);
	if ($content != '' && is_resource($file = tmpfile())) {
		fwrite($file, $content);
		rewind($file);
		$filename = stream_get_meta_data($file)['uri'];
		db::begin_transaction();
		mnp::import($filename);
		db::commit();
	}
}

} //namespace

?>
