* * This program is free software, distributed under the terms of * the GNU General Public License Version 2. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . * */ include ('modules/digiumaddoninstaller/libdregister/digium_register.php'); global $db; /** * Digium Addon Installer Conf * * The conf class used by FreePBX to configure /etc/asterisk/ config files. */ class digiumaddoninstaller_conf { /** * Get Filename * * No current files to be configured */ public function get_filename() { return ''; } /** * Generate Conf * * No current files to be generated */ public function generateConf($file) { return ''; } } /** * Digium Addons * * This class is used to manage addon information, (un)install addons, and register * addons. */ class digium_addons { private $addons = array(); // The main addons array private $ast_version = ''; // The version of Asterisk private $bit = ''; // The server's bit private $downloads_addons_url = 'http://downloads.digium.com/pub/telephony/addons.json'; private $hasinited = false; // Has the module been initialized private $hasyum = true; // Do we have yum installed? private $hasyumaccess = true; // Do we have access to yum? private $module_version = '0.1'; // Version of the Digium Addons Module private $register = null; // The digiumaddons_register object /** * Constructor * * Load all needed information to use this class */ public function digium_addons() { $this->register = new digiumaddons_register(); $this->get_ast_version(); $this->load_addons(); $this->check_for_updates(); } /** * Add Addon * * Add an addon to the database */ public function add_addon($name, $data) { global $db; $sql = array(); $sql[] = sprintf("INSERT INTO digiumaddoninstaller_addons (id, name, description, documentation, link, product_index, category_index, register_limit, supported_version, is_installed, is_registered) VALUES (\"%s\", \"%s\", \"%s\", \"%s\", \"%s\", %d, %d, %d, \"%s\", false, false)", mysql_real_escape_string($name), mysql_real_escape_string($data->name), mysql_real_escape_string($data->description), mysql_real_escape_string($data->documentation), mysql_real_escape_string($data->link), mysql_real_escape_string($data->product_index), mysql_real_escape_string($data->category_index), mysql_real_escape_string($data->register_limit), mysql_real_escape_string($data->supported_version) ); foreach ($data->downloads as $dl) { $testsql = sprintf("SELECT id FROM digiumaddoninstaller_downloads WHERE id=\"%s\";", mysql_real_escape_string($dl->name)); $result = $db->getAll($testsql); if (DB::IsError($result)) { die_freepbx($result->getDebugInfo()); } if (sizeof($result) < 1) { $sql[] = sprintf("INSERT INTO digiumaddoninstaller_downloads (id, name, package, tarball, path, available_version) VALUES (\"%s\", \"%s\", \"%s\", \"%s\", \"%s\", \"%s\")", mysql_real_escape_string($dl->name), mysql_real_escape_string($dl->name), mysql_real_escape_string($dl->package), mysql_real_escape_string($dl->tarball), mysql_real_escape_string($dl->path), mysql_real_escape_string($dl->version) ); } $sql[] = sprintf("INSERT INTO digiumaddoninstaller_addons_downloads (addon_id, download_id) VALUES (\"%s\", \"%s\")", mysql_real_escape_string($name), mysql_real_escape_string($dl->name) ); foreach ($dl->bits as $bit) { $sql[] = sprintf("INSERT INTO digiumaddoninstaller_downloads_bits (download_id, bit) VALUES (\"%s\", \"%s\")", mysql_real_escape_string($dl->name), mysql_real_escape_string($bit) ); } foreach ($dl->ast_versions as $ast_ver) { $sql[] = sprintf("INSERT INTO digiumaddoninstaller_downloads_ast_versions (download_id, ast_version) VALUES (\"%s\", \"%s\")", mysql_real_escape_string($dl->name), mysql_real_escape_string($ast_ver) ); } } foreach ($sql as $s) { $result = $db->query($s); if (DB::IsError($result)) { die_freepbx($result->getDebugInfo()); } unset($result); } $add = array( 'id' => $name, 'name' => $data->name, 'description' => $data->description, 'downloads' => $data->downloads, 'link' => $data->link, 'status' => 'not_installed', 'product_index' => $data->product_index, 'category_index' => $data->category_index, 'register_limit' =>