Example #1
0
function userman_configpageinit($pagename)
{
    global $currentcomponent;
    global $amp_conf;
    $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : null;
    $extdisplay = isset($_REQUEST['extdisplay']) ? $_REQUEST['extdisplay'] : null;
    $extension = isset($_REQUEST['extension']) ? $_REQUEST['extension'] : null;
    $tech_hardware = isset($_REQUEST['tech_hardware']) ? $_REQUEST['tech_hardware'] : null;
    if (version_compare_freepbx(getVersion(), '12.0', '<') && $pagename == 'userman') {
        $userman = setup_userman();
        $userman->doConfigPageInit($_REQUEST['display']);
    }
    // We only want to hook 'users' or 'extensions' pages.
    if ($pagename != 'users' && $pagename != 'extensions') {
        return true;
    }
    //$currentcomponent->addprocessfunc('userman_configprocess', 1);
    if ($tech_hardware != null || $extdisplay != '' || $pagename == 'users' || $action == 'add') {
        // On a 'new' user, 'tech_hardware' is set, and there's no extension. Hook into the page.
        if ($tech_hardware != null) {
            userman_applyhooks();
        } elseif ($action == 'add') {
            $currentcomponent->addprocessfunc('userman_configprocess', 1);
        } elseif ($extdisplay != '' || $pagename == 'users') {
            // We're now viewing an extension, so we need to display _and_ process.
            userman_applyhooks();
            $currentcomponent->addprocessfunc('userman_configprocess', 1);
        }
    }
}
Example #2
0
function upgrade_all($version)
{
    // **** Read upgrades/ directory
    outn("Checking for upgrades..");
    // read versions list from ugprades/
    $versions = array();
    $dir = opendir(UPGRADE_DIR);
    while ($file = readdir($dir)) {
        if ($file[0] != "." && is_dir(UPGRADE_DIR . "/" . $file)) {
            $versions[] = $file;
        }
    }
    closedir($dir);
    // callback to use php's version_compare() to sort
    usort($versions, "version_compare_freepbx");
    // find versions that are higher than the current version
    $starting_version = false;
    foreach ($versions as $check_version) {
        if (version_compare_freepbx($check_version, $version) > 0) {
            // if check_version < version
            $starting_version = $check_version;
            break;
        }
    }
    // run all upgrades from the list of higher versions
    if ($starting_version) {
        $pos = array_search($starting_version, $versions);
        $upgrades = array_slice($versions, $pos);
        // grab the list of versions, starting at $starting_version
        out(count($upgrades) . " found");
        run_upgrade($upgrades);
        /* Set the base version of key modules, currently core and framework, to the
         * Version packaged with this tarball, if any. The expectation is that the
         * packaging scripts will make these module version numbers the same as the
         * release plus a '.0' which can be incremented for bug fixes delivered through
         * the online system between main releases.
         *
         * added if function_exists because if this is being run from framework there is no
         * need to reset the base version.
         */
        if (function_exists('set_base_version')) {
            set_base_version();
        }
    } else {
        out("No upgrades found");
    }
}
 /** Check if a module meets dependencies.
  * @param  mixed  The name of the module, or the modulexml Array
  * @return mixed  Returns true if dependencies are met, or an array
  *                containing a list of human-readable errors if not.
  *                NOTE: you must use strict type checking (===) to test
  *                for true, because  array() == true !
  */
 function checkdepends($modulename)
 {
     $this->modDepends = array();
     // check if we were passed a modulexml array, or a string (name)
     // ensure $modulexml is the modules array, and $modulename is the name (as a string)
     if (is_array($modulename)) {
         $modulexml = $modulename;
         $modulename = $modulename['rawname'];
     } else {
         $modulexml = $this->getinfo($modulename);
         $modulexml = $modulexml[$modulename];
     }
     $errors = array();
     // special handling for engine
     $engine_dependency = false;
     // if we've found ANY engine dependencies to check
     $engine_matched = false;
     // if an engine dependency has matched
     $engine_errors = array();
     // the error strings for engines
     if (isset($modulexml['depends'])) {
         foreach ($modulexml['depends'] as $type => $requirements) {
             // if only a single item, make it an array so we can use the same code as for multiple items
             // this is because if there is  <module>a</module><module>b</module>  we will get array('module' => array('a','b'))
             if (!is_array($requirements)) {
                 $requirements = array($requirements);
             }
             foreach ($requirements as $value) {
                 switch ($type) {
                     case 'version':
                         if (preg_match('/^(lt|le|gt|ge|==|=|eq|!=|ne)?\\s*(\\d*[beta|alpha|rc|RC]?\\d+(\\.[^\\.]+)*)$/i', $value, $matches)) {
                             // matches[1] = operator, [2] = version
                             $installed_ver = getversion();
                             $operator = !empty($matches[1]) ? $matches[1] : 'ge';
                             // default to >=
                             $compare_ver = $matches[2];
                             if (version_compare_freepbx($installed_ver, $compare_ver, $operator)) {
                                 // version is good
                             } else {
                                 $errors[] = $this->_comparison_error_message('FreePBX', $compare_ver, $installed_ver, $operator);
                             }
                         }
                         break;
                     case 'phpversion':
                         /* accepted formats
                         			<depends>
                         			<phpversion>5.1.0<phpversion>       TRUE: if php is >= 5.1.0
                         			<phpversion>gt 5.1.0<phpversion>    TRUE: if php is > 5.1.0
                         			</depends>
                         			*/
                         if (preg_match('/^(lt|le|gt|ge|==|=|eq|!=|ne)?\\s*(\\d*[beta|alpha|rc|RC]?\\d+(\\.[^\\.]+)*)$/i', $value, $matches)) {
                             // matches[1] = operator, [2] = version
                             $installed_ver = phpversion();
                             $operator = !empty($matches[1]) ? $matches[1] : 'ge';
                             // default to >=
                             $compare_ver = $matches[2];
                             if (version_compare($installed_ver, $compare_ver, $operator)) {
                                 // php version is good
                             } else {
                                 $errors[] = $this->_comparison_error_message('PHP', $compare_ver, $installed_ver, $operator);
                             }
                         }
                         break;
                     case 'phpcomponent':
                         /* accepted formats
                         			<depends>
                         			<phpcomponent>zlib<phpversion>        TRUE: if extension zlib is loaded
                         			<phpcomponent>zlib 1.2<phpversion>    TRUE: if extension zlib is loaded and >= 1.2
                         			<phpcomponent>zlib gt 1.2<phpversion> TRUE: if extension zlib is loaded and > 1.2
                         			</depends>
                         			*/
                         $phpcomponents = explode('||', $value);
                         $newerrors = array();
                         foreach ($phpcomponents as $value) {
                             if (preg_match('/^([a-z0-9_]+|Zend (Optimizer|Guard Loader))(\\s+(lt|le|gt|ge|==|=|eq|!=|ne)?\\s*(\\d+(\\.\\d*[beta|alpha|rc|RC]*\\d+)+))?$/i', $value, $matches)) {
                                 // matches[1] = extension name, [3]=comparison operator, [4] = version
                                 $compare_ver = isset($matches[4]) ? $matches[4] : '';
                                 if (extension_loaded($matches[1])) {
                                     if (empty($compare_ver)) {
                                         // extension is loaded and no version specified
                                     } else {
                                         if (($installed_ver = phpversion($matches[1])) != '') {
                                             $operator = !empty($matches[3]) ? $matches[3] : 'ge';
                                             // default to >=
                                             if (version_compare($installed_ver, $compare_ver, $operator)) {
                                                 // version is good
                                             } else {
                                                 $newerrors[] = $this->_comparison_error_message("PHP Component " . $matches[1], $compare_ver, $installed_ver, $operator);
                                             }
                                         } else {
                                             $newerrors[] = $this->_comparison_error_message("PHP Component " . $matches[1], $compare_ver, "<no version info>", $operator);
                                         }
                                     }
                                 } else {
                                     if ($compare_version == '') {
                                         $newerrors[] = sprintf(_('PHP Component %s is required but missing from you PHP installation.'), $matches[1]);
                                     } else {
                                         $newerrors[] = sprintf(_('PHP Component %s version %s is required but missing from you PHP installation.'), $matches[1], $compare_version);
                                     }
                                 }
                             }
                         }
                         if (count($newerrors) == count($phpcomponents)) {
                             $errors = array_merge($errors, $newerrors);
                         }
                         break;
                     case 'module':
                         // Modify to allow versions such as 2.3.0beta1.2
                         if (preg_match('/^([a-z0-9_]+)(\\s+(lt|le|gt|ge|==|=|eq|!=|ne)?\\s*(\\d+(\\.\\d*[beta|alpha|rc|RC]*\\d+)+))?$/i', $value, $matches)) {
                             // matches[1] = modulename, [3]=comparison operator, [4] = version
                             $modules = $this->getinfo($matches[1]);
                             if (isset($modules[$matches[1]])) {
                                 $mod = isset($modules[$matches[1]]['rawname']) ? $modules[$matches[1]]['rawname'] : $matches[1];
                                 $needed_module = "<strong>" . (isset($modules[$matches[1]]['name']) ? $modules[$matches[1]]['name'] : $matches[1]) . "</strong>";
                                 $compare_ver = !empty($matches[4]) ? $matches[4] : null;
                                 switch ($modules[$matches[1]]['status']) {
                                     case MODULE_STATUS_ENABLED:
                                         if (!empty($compare_ver)) {
                                             // also doing version checking
                                             $installed_ver = $modules[$matches[1]]['dbversion'];
                                             $operator = !empty($matches[3]) ? $matches[3] : 'ge';
                                             // default to >=
                                             if (version_compare_freepbx($installed_ver, $compare_ver, $operator)) {
                                                 // version is good
                                             } else {
                                                 $errors[$mod] = $this->_comparison_error_message($needed_module . ' module', $compare_ver, $installed_ver, $operator);
                                                 $this->modDepends[] = array("module" => $mod, "version" => $compare_ver);
                                             }
                                         }
                                         break;
                                     case MODULE_STATUS_BROKEN:
                                         $errors[$mod] = sprintf(_('The Module Named "%s" is required, but yours is broken. You should reinstall it and try again.'), $needed_module);
                                         $this->modDepends[] = array("module" => $mod, "version" => $compare_ver);
                                         break;
                                     case MODULE_STATUS_DISABLED:
                                         $errors[$mod] = sprintf(_('The Module Named "%s" is required, but yours is disabled.'), $needed_module);
                                         $this->modDepends[] = array("module" => $mod, "version" => $compare_ver);
                                         break;
                                     case MODULE_STATUS_NEEDUPGRADE:
                                         $errors[$mod] = sprintf(_('The Module Named "%s" is required, but yours is disabled because it needs to be upgraded. Please upgrade %s first, and then try again.'), $needed_module, $needed_module);
                                         $this->modDepends[] = array("module" => $mod, "version" => $compare_ver);
                                         break;
                                     default:
                                     case MODULE_STATUS_NOTINSTALLED:
                                         $errors[$mod] = sprintf(_('The Module Named "%s" is required, yours is not installed.'), $needed_module);
                                         $this->modDepends[] = array("module" => $mod, "version" => $compare_ver);
                                         break;
                                 }
                             } else {
                                 $mod = $matches[1];
                                 $errors[$mod] = sprintf(_('The Module Named "%s" is required.'), $mod);
                                 $this->modDepends[] = array("module" => $mod, "version" => $compare_ver);
                             }
                         }
                         break;
                     case 'file':
                         // file exists
                         // replace embedded amp_conf %VARIABLES% in string
                         $file = $this->_ampconf_string_replace($value);
                         if (!file_exists($file)) {
                             $errors[] = sprintf(_('The File "%s" must exist.'), $file);
                         }
                         break;
                     case 'engine':
                         /****************************
                          *  NOTE: there is special handling for this check. We want to "OR" conditions, instead of
                          *        "AND"ing like the rest of them.
                          */
                         // we found at least one engine, so mark that we're matching this
                         $engine_dependency = true;
                         if (preg_match('/^([a-z0-9_]+)(\\s+(lt|le|gt|ge|==|=|eq|!=|ne)?\\s*(\\d+(\\.[^\\.]+)*))?$/i', $value, $matches)) {
                             // matches[1] = engine, [3]=comparison operator, [4] = version
                             $operator = !empty($matches[3]) ? $matches[3] : 'ge';
                             // default to >=
                             $engine = engine_getinfo();
                             if ($engine['engine'] == $matches[1] && (empty($matches[4]) || version_compare($engine['version'], $matches[4], $operator))) {
                                 $engine_matched = true;
                             } else {
                                 // add it to the error messages
                                 if ($matches[4]) {
                                     // version specified
                                     $operator_friendly = str_replace(array('gt', 'ge', 'lt', 'le', 'eq', 'ne'), array('>', '>=', '<', '<=', '=', 'not ='), $operator);
                                     $engine_errors[] = $matches[1] . ' (' . $operator_friendly . ' ' . $matches[4] . ')';
                                 } else {
                                     // no version
                                     $engine_errors[] = $matches[1];
                                 }
                             }
                         }
                         break;
                 }
             }
         }
         // special handling for engine
         // if we've had at least one engine dependency check, and no engine dependencies matched, we have an error
         if ($engine_dependency && !$engine_matched) {
             $engineinfo = engine_getinfo();
             $yourengine = $engineinfo['engine'] . ' ' . $engineinfo['version'];
             // print it nicely
             if (count($engine_errors) == 1) {
                 $errors[] = sprintf(_('Requires engine %s, you have: %s'), $engine_errors[0], $yourengine);
             } else {
                 $errors[] = sprintf(_('Requires one of the following engines: %s; you have: %s'), implode(', ', $engine_errors), $yourengine);
             }
         }
     }
     if (count($errors) > 0) {
         return $errors;
     } else {
         return true;
     }
 }
Example #4
0
 case MODULE_STATUS_NEEDUPGRADE:
     if (!EXTERNAL_PACKAGE_MANAGEMENT) {
         echo '<input type="radio" id="install_' . prep_id($name) . '" name="moduleaction[' . prep_id($name) . ']" value="install" /> ' . '<label for="install_' . prep_id($name) . '">' . sprintf(_('Upgrade to %s and Enable'), $modules_local[$name]['version']) . '</label> <br />';
         echo '<input type="radio" id="uninstall_' . prep_id($name) . '" name="moduleaction[' . prep_id($name) . ']" value="uninstall" /> ' . '<label for="uninstall_' . prep_id($name) . '">' . _('Uninstall') . '</label> <br />';
     }
     break;
 case MODULE_STATUS_BROKEN:
     if (!EXTERNAL_PACKAGE_MANAGEMENT) {
         echo '<input type="radio" id="install_' . prep_id($name) . '" name="moduleaction[' . prep_id($name) . ']" value="install" /> ' . '<label for="install_' . prep_id($name) . '">' . _('Install') . '</label> <br />';
         echo '<input type="radio" id="uninstall_' . prep_id($name) . '" name="moduleaction[' . prep_id($name) . ']" value="uninstall" /> ' . '<label for="uninstall_' . prep_id($name) . '">' . _('Uninstall') . '</label> <br />';
     }
     break;
 default:
     // check for online upgrade
     if (isset($modules_online[$name]['version'])) {
         $vercomp = version_compare_freepbx($modules_local[$name]['version'], $modules_online[$name]['version']);
         if (!EXTERNAL_PACKAGE_MANAGEMENT) {
             if ($vercomp < 0) {
                 echo '<input type="radio" id="upgrade_' . prep_id($name) . '" name="moduleaction[' . prep_id($name) . ']" value="upgrade" /> ' . '<label for="upgrade_' . prep_id($name) . '">' . sprintf(_('Download and Upgrade to %s'), $modules_online[$name]['version']) . '</label> <br />';
             } else {
                 $force_msg = $vercomp == 0 ? sprintf(_('Force Download and Install %s'), $modules_online[$name]['version']) : sprintf(_('Force Download and Downgrade to %s'), $modules_online[$name]['version']);
                 echo '<input type="radio" id="force_upgrade_' . prep_id($name) . '" name="moduleaction[' . prep_id($name) . ']" value="force_upgrade" /> ' . '<label for="force_upgrade_' . prep_id($name) . '">' . $force_msg . '</label> <br />';
             }
         }
     }
     if (enable_option($name, 'candisable')) {
         echo '<input type="radio" id="disable_' . prep_id($name) . '" name="moduleaction[' . prep_id($name) . ']" value="disable" /> ' . '<label for="disable_' . prep_id($name) . '">' . _('Disable') . '</label> <br />';
     }
     if (!EXTERNAL_PACKAGE_MANAGEMENT && enable_option($name, 'canuninstall')) {
         echo '<input type="radio" id="uninstall_' . prep_id($name) . '" name="moduleaction[' . prep_id($name) . ']" value="uninstall" /> ' . '<label for="uninstall_' . prep_id($name) . '">' . _('Uninstall') . '</label> <br />';
     }
Example #5
0
 function install_upgrades($version)
 {
     // **** Read upgrades/ directory
     $this->log("Checking for upgrades..");
     // read versions list from upgrades/
     $versions = array();
     $dir = opendir(UPGRADE_DIR);
     while ($file = readdir($dir)) {
         if ($file[0] != "." && is_dir(UPGRADE_DIR . "/" . $file)) {
             $versions[] = $file;
         }
     }
     closedir($dir);
     // callback to use php's version_compare() to sort
     usort($versions, "version_compare_freepbx");
     // find versions that are higher than the current version
     $starting_version = false;
     foreach ($versions as $check_version) {
         if (version_compare_freepbx($check_version, $version) > 0) {
             // if check_version < version
             $starting_version = $check_version;
             break;
         }
     }
     // run all upgrades from the list of higher versions
     if ($starting_version) {
         $pos = array_search($starting_version, $versions);
         $upgrades = array_slice($versions, $pos);
         // grab the list of versions, starting at $starting_version
         $this->log(count($upgrades) . " found");
         foreach ($upgrades as $version) {
             $this->log("Upgrading to " . $version . "..");
             $this->install_upgrade($version);
             $this->set_version($version);
             $this->log("Upgrading to " . $version . "..OK");
         }
     } else {
         $this->log("No further upgrades necessary");
     }
 }
Example #6
0
                     case '-1':
                         $actionstext[] = sprintf(_("%s %s will be upgraded to online version %s and switched to the %s track"), "<strong>" . $modules[$module]['name'] . "</strong>", "<strong>" . $modules[$module]['dbversion'] . "</strong>", "<strong>" . $trackinfo['version'] . "</strong>", "<strong>" . $track . "</strong>");
                         break;
                     case '0':
                         $force_actionstext[] = sprintf(_("%s %s will be re-installed to online version %s and switched to the %s track"), "<strong>" . $modules[$module]['name'] . "</strong>", "<strong>" . $modules[$module]['dbversion'] . "</strong>", "<strong>" . $trackinfo['version'] . "</strong>", "<strong>" . $track . "</strong>");
                         break;
                     default:
                         $force_actionstext[] = sprintf(_("%s %s will be downgraded to online version %s and switched to the %s track"), "<strong>" . $modules[$module]['name'] . "</strong>", "<strong>" . $modules[$module]['dbversion'] . "</strong>", "<strong>" . $trackinfo['version'] . "</strong>", "<strong>" . $track . "</strong>");
                 }
             }
         } else {
             if (is_array($errors = $modulef->checkdepends($trackinfo))) {
                 $skipaction = true;
                 $errorstext[] = sprintf(_("%s cannot be upgraded: %s Please try again after the dependencies have been installed."), "<strong>" . $modules[$module]['name'] . "</strong>", '<strong><ul><li>' . implode('</li><li>', $errors) . '</li></ul></strong>');
             } else {
                 switch (version_compare_freepbx($modules[$module]['dbversion'], $trackinfo['version'])) {
                     case '-1':
                         $actionstext[] = sprintf(_("%s %s will be upgraded to online version %s"), "<strong>" . $modules[$module]['name'] . "</strong>", "<strong>" . $modules[$module]['dbversion'] . "</strong>", "<strong>" . $trackinfo['version'] . "</strong>");
                         break;
                     case '0':
                         $force_actionstext[] = sprintf(_("%s %s will be re-installed to online version %s"), "<strong>" . $modules[$module]['name'] . "</strong>", "<strong>" . $modules[$module]['dbversion'] . "</strong>", "<strong>" . $trackinfo['version'] . "</strong>");
                         break;
                     default:
                         $force_actionstext[] = sprintf(_("%s %s will be downgraded to online version %s"), "<strong>" . $modules[$module]['name'] . "</strong>", "<strong>" . $modules[$module]['dbversion'] . "</strong>", "<strong>" . $trackinfo['version'] . "</strong>");
                 }
             }
         }
     }
     break;
 case 'downloadinstall':
     if (!EXTERNAL_PACKAGE_MANAGEMENT) {
Example #7
0
 private function showList($online = false)
 {
     global $amp_conf;
     $modules_local = $this->mf->getinfo(false, false, true);
     $modules = $modules_local;
     $this->check_active_repos();
     if ($online) {
         $modules_online = $this->mf->getonlinexml();
         if (isset($modules_online)) {
             $modules += $modules_online;
         }
     }
     ksort($modules);
     $this->mf->getAllSignatures(!$online, $online);
     $rows = array();
     foreach (array_keys($modules) as $name) {
         $status_index = isset($modules[$name]['status']) ? $modules[$name]['status'] : '';
         // Don't include modules not in our repo unless they are locally installed already
         if ((!isset($this->activeRepos[$modules[$name]['repo']]) || !$this->activeRepos[$modules[$name]['repo']]) && $status_index != MODULE_STATUS_BROKEN && !isset($modules_local[$name])) {
             continue;
         }
         switch ($status_index) {
             case MODULE_STATUS_NOTINSTALLED:
                 if (isset($modules_local[$name])) {
                     $status = _('Not Installed (Locally available)');
                 } else {
                     $status = _('Not Installed (Available online: ') . $modules_online[$name]['version'] . ')';
                 }
                 break;
             case MODULE_STATUS_DISABLED:
                 $status = _('Disabled');
                 break;
             case MODULE_STATUS_NEEDUPGRADE:
                 $status = _('Disabled; Pending upgrade to ') . $modules[$name]['version'];
                 break;
             case MODULE_STATUS_BROKEN:
                 $status = _('Broken');
                 break;
             default:
                 // check for online upgrade
                 if (isset($modules_online[$name]['version'])) {
                     $vercomp = version_compare_freepbx($modules[$name]['version'], $modules_online[$name]['version']);
                     if ($vercomp < 0) {
                         $status = sprintf(_('Online upgrade available (%s)'), $modules_online[$name]['version']);
                     } else {
                         if ($vercomp > 0) {
                             $status = sprintf(_('Newer than online version (%s)'), $modules_online[$name]['version']);
                         } else {
                             $status = _('Enabled and up to date');
                         }
                     }
                 } else {
                     if (isset($modules_online)) {
                         // we're connected to online, but didn't find this module
                         $status = _('Enabled; Not available online');
                     } else {
                         $status = _('Enabled');
                     }
                 }
                 break;
         }
         $module_version = isset($modules[$name]['dbversion']) ? $modules[$name]['dbversion'] : '';
         array_push($rows, array($name, $module_version, $status));
     }
     if ($this->format == 'json') {
         $this->writeln($rows);
     } else {
         $table = new Table($this->out);
         $table->setHeaders(array(_('Module'), _('Version'), _('Status')))->setRows($rows);
         $table->render();
     }
 }
Example #8
0
 private function createIntermediaries()
 {
     //generate intermediary file
     $ts = time() . rand(0, 1000);
     $soxClass = "Media\\Driver\\Drivers\\SoxShell";
     if (!$soxClass::installed()) {
         throw new \Exception("Sox needs to be installed");
     }
     //Convert everything to 48k, so we upscale and downscale
     //This is on purpose.
     //Transform into a wav file
     foreach ($this->getDrivers() as $driver) {
         if ($this->extension == "wav" && $driver == "AsteriskShell") {
             continue;
             //just dont allow it
         }
         $class = "Media\\Driver\\Drivers\\" . $driver;
         if ($class::installed() && $class::isCodecSupported($this->extension, "in")) {
             $d = new $class($this->track, $this->extension, $this->mime, 48000, 1, 16);
             $d->convert($this->tempDir . "/temp." . $ts . ".wav", "wav", "audio/x-wav");
             $intermediary['wav']['path'] = $this->tempDir . "/temp." . $ts . ".wav";
             $intermediary['wav']['extension'] = "wav";
             $intermediary['wav']['mime'] = "audio/x-wav";
             break;
         }
     }
     if (!isset($intermediary['wav']['path']) || !file_exists($intermediary['wav']['path'])) {
         throw new \Exception(sprintf(_("Unable to find an intermediary converter for %s"), $this->track));
     }
     //Asterisk 11 should support sln48 but it doesnt, it says it does but then complains
     //It might be a bug, regardless this is fixed in 13 people should just use it
     $ver = \FreePBX::Config()->get("ASTVERSION");
     if (version_compare_freepbx($ver, "13.0", "ge") && \Media\Driver\Drivers\AsteriskShell::isCodecSupported("sln48", "in")) {
         $type = "sln48";
         $samplerate = 48000;
     } elseif (\Media\Driver\Drivers\AsteriskShell::isCodecSupported("sln16", "in")) {
         $type = "sln16";
         $samplerate = 16000;
     } else {
         $type = "wav16";
         $samplerate = 16000;
     }
     $nt = \notifications::create();
     if (version_compare_freepbx($ver, "13.0", "ge") && !\Media\Driver\Drivers\AsteriskShell::isCodecSupported("sln48", "in")) {
         //something is wacky here
         $nt->add_warning("FRAMEWORK", "UNSUPPORTED_SLN48", _("The file format sln48 is not supported on your system"), _("The file format sln48 is not supported by Asterisk when it should be. Audio conversion quality will be limited to 16k instead of 48k"));
     } else {
         $nt->delete("FRAMEWORK", "UNSUPPORTED_SLN48");
     }
     //Now transform into a raw audio file
     $d = new $soxClass($intermediary['wav']['path'], $intermediary['wav']['extension'], $intermediary['wav']['mime'], $samplerate, 1, 16);
     $d->convert($this->tempDir . "/temp." . $ts . "." . $type, $type, "audio/x-raw");
     $intermediary['sln']['path'] = $this->tempDir . "/temp." . $ts . "." . $type;
     $intermediary['sln']['extension'] = $type;
     $intermediary['sln']['mime'] = "audio/x-raw";
     if (empty($intermediary)) {
         throw new \Exception("No Driver found for " . $this->extension);
     }
     if (!file_exists($intermediary['wav']['path']) || !file_exists($intermediary['sln']['path'])) {
         throw new \Exception("Intermediary files could not be created");
     }
     return $intermediary;
 }
Example #9
0
function timeconditions_updatedb()
{
    $ver = modules_getversion('timeconditions');
    if ($ver !== null && version_compare_freepbx($ver, '2.5', 'lt')) {
        outn(_("Checking for old timeconditions to upgrade.."));
        $upgradelist = timeconditions_list_forupgrade();
        if (isset($upgradelist)) {
            // we have old conditions to upgrade
            //
            out(_("starting migration"));
            foreach ($upgradelist as $upgrade) {
                $times[] = $upgrade['time'];
                $newid = _timeconditions_timegroups_add_group_timestrings('migrated-' . $upgrade['displayname'], $times);
                timeconditions_set_timegroupid($upgrade['timeconditions_id'], $newid);
                $newtimes = _timeconditions_timegroups_get_times($newid);
                out(sprintf(_("Upgraded %s and created group %s"), $upgrade['displayname'], 'migrated-' . $upgrade['displayname']));
                if (!is_array($newtimes)) {
                    out(sprintf(_("%sWARNING:%s No time defined for this condition, please review"), "<font color='red'>", "</font>"));
                }
                unset($times);
            }
        } else {
            out(_("no upgrade needed"));
        }
    }
}
Example #10
0
    // RHEL / CentOS
    $data = @parse_ini_file('/etc/sysconfig/clock');
    if (!empty($data['ZONE'])) {
        $timezone = trim($data['ZONE']);
    }
}
$set['category'] = 'System Setup';
$set['value'] = !empty($timezone) ? $timezone : "UTC";
$set['defaultval'] = 'UTC';
$set['name'] = 'PHP Timezone';
$set['description'] = "Timezone that should be used by PHP. Empty value will use PHP defaults. List of value Timezones: <a href='http://php.net/manual/en/timezones.php'>http://php.net/manual/en/timezones.php</a>";
$set['hidden'] = 0;
$set['emptyok'] = 1;
$set['readonly'] = 0;
$set['level'] = 0;
$set['options'] = \DateTimeZone::listIdentifiers();
$set['module'] = '';
$set['type'] = CONF_TYPE_CSELECT;
$freepbx_conf->define_conf_setting('PHPTIMEZONE', $set);
$freepbx_conf->commit_conf_settings();
$mf = \module_functions::create();
$info = $mf->getinfo("core");
if (!empty($info['core']['dbversion']) && version_compare_freepbx($info['core']['dbversion'], "13.0.45", "<=")) {
    outn(_("Migrating force_rport to the right default value..."));
    $res = $db->query("UPDATE sip SET data = 'yes' WHERE keyword = 'force_rport'");
    if (!DB::IsError($res)) {
        out(_("done"));
    } else {
        out(_("error occured"));
    }
}
Example #11
0
            out("Creating temp folder");
        }
    }
    if (version_compare_freepbx($epmdbversion, '2.10.3.1', '<=')) {
        out("Adding tftp server check and nmap search save values");
        $sql = 'INSERT INTO `endpointman_global_vars` (`idnum`, `var_name`, `value`) VALUES (NULL, \'tftp_check\', \'0\');';
        $db->query($sql);
        $sql = 'INSERT INTO `endpointman_global_vars` (`idnum`, `var_name`, `value`) VALUES (NULL, \'nmap_search\', \'\');';
        $db->query($sql);
    }
    if (version_compare_freepbx($epmdbversion, '2.10.3.7', '<=')) {
        out("Adding Config File Backups");
        $sql = 'INSERT INTO `endpointman_global_vars` (`idnum`, `var_name`, `value`) VALUES (NULL, \'backup_check\', \'1\');';
        $db->query($sql);
    }
    if (version_compare_freepbx($epmdbversion, '2.10.3.8', '<=')) {
        out("Adding Use Repo Option");
        $sql = 'INSERT INTO `endpointman_global_vars` (`idnum`, `var_name`, `value`) VALUES (NULL, \'use_repo\', \'0\');';
        $db->query($sql);
    }
}
if (empty($epmdbversion)) {
    out("Creating Brand List Table");
    $sql = "CREATE TABLE IF NOT EXISTS `endpointman_brand_list` (\n                  `id` varchar(11) NOT NULL,\n                  `name` varchar(255) NOT NULL,\n                  `directory` varchar(255) NOT NULL,\n                  `cfg_ver` varchar(255) NOT NULL,\n                  `installed` int(1) NOT NULL DEFAULT '0',\n                    `local` int(1) NOT NULL DEFAULT '0',\n                  `hidden` int(1) NOT NULL DEFAULT '0',\n                  PRIMARY KEY (`id`)\n                ) ENGINE=MyISAM";
    $db->query($sql);
    out("Creating Line List Table");
    $sql = "CREATE TABLE IF NOT EXISTS `endpointman_line_list` (\n  `luid` int(11) NOT NULL AUTO_INCREMENT,\n  `mac_id` int(11) NOT NULL,\n  `line` smallint(2) NOT NULL,\n  `ext` varchar(15) NOT NULL,\n  `description` varchar(20) NOT NULL,\n  `custom_cfg_data` longblob NOT NULL,\n  `user_cfg_data` longblob NOT NULL,\n  PRIMARY KEY (`luid`)\n) ENGINE=MyISAM";
    $db->query($sql);
    out("Creating Global Variables Table");
    $sql = "CREATE TABLE IF NOT EXISTS `endpointman_global_vars` (\n                  `idnum` int(11) NOT NULL AUTO_INCREMENT COMMENT 'Index',\n                  `var_name` varchar(25) NOT NULL COMMENT 'Variable Name',\n                  `value` text NOT NULL COMMENT 'Data',\n                  PRIMARY KEY (`idnum`),\n                  UNIQUE KEY `var_name` (`var_name`)\n                ) ENGINE=MyISAM";
    $db->query($sql);
Example #12
0
																		<label for="uninstall_<?php 
                        echo prep_id($module['name']);
                        ?>
"><?php 
                        echo _('Uninstall');
                        ?>
</label>
																	<?php 
                    }
                    break;
                default:
                    // check for online upgrade
                    $track = $module['track'];
                    $trackinfo = $track == 'stable' ? $module['raw']['online'] : (!empty($module['raw']['online']['releasetracks'][$track]) ? $module['raw']['online']['releasetracks'][$track] : array());
                    if (isset($trackinfo['version'])) {
                        $vercomp = version_compare_freepbx($module['raw']['local']['version'], $trackinfo['version']);
                        if (!EXTERNAL_PACKAGE_MANAGEMENT) {
                            if ($vercomp < 0) {
                                ?>
																				<input type="radio" id="upgrade_<?php 
                                echo prep_id($module['name']);
                                ?>
" name="moduleaction[<?php 
                                echo prep_id($module['name']);
                                ?>
]" value="upgrade" />
																				<label class="installabel" for="upgrade_<?php 
                                echo prep_id($module['name']);
                                ?>
"><?php 
                                echo sprintf(_('Download and Upgrade to %s'), $trackinfo['version']);
 $processors_list = FreePBX::Superfecta()->getProcessors();
 $conf['processor'] = (!isset($conf['processor']) or empty($conf['processor'])) ? 'superfecta_single.php' : $conf['processor'];
 define("ROOT_PATH", dirname(__FILE__) . '/');
 //get a list of the files that are on this local server
 $sources = array();
 $i = 0;
 foreach (glob(ROOT_PATH . "sources/source-*.module") as $filename) {
     if (file_exists($filename)) {
         $source_desc = '';
         $source_param = array();
         include $filename;
         preg_match('/source-(.*)\\.module/i', $filename, $matches);
         $this_source_name = $matches[1];
         if (class_exists($this_source_name)) {
             $this_source_class = new $this_source_name();
             if (version_compare_freepbx($module_info['version'], $this_source_class->version_requirement, ">=")) {
                 $j = !in_array($this_source_name, $conf['sources']) ? $j = $i + 200 : ($j = $i);
                 if (in_array($this_source_name, $conf['sources'])) {
                     $j = array_search($this_source_name, $conf['sources']);
                 } else {
                     $j = $i + 200;
                 }
                 $sources[$j]['showup'] = FALSE;
                 $sources[$j]['showdown'] = FALSE;
                 $sources[$j]['pretty_source_name'] = str_replace("_", " ", $this_source_name);
                 $sources[$j]['source_name'] = $this_source_name;
                 $sources[$j]['enabled'] = in_array($this_source_name, $conf['sources']) ? TRUE : FALSE;
                 $sources[$j]['status'] = in_array($this_source_name, $conf['sources']) ? 'enabled' : 'disabled';
                 $sources[$j]['description'] = isset($this_source_class->description) ? preg_replace('/(<a>|<\\/a>)/i', '', $this_source_class->description) : 'N/A';
                 $sources[$j]['configure'] = isset($this_source_class->source_param) ? TRUE : FALSE;
                 //Simplify please
Example #14
0
    $set['value'] = $value;
    $set['defaultval'] = false;
    $set['readonly'] = 0;
    $set['hidden'] = 0;
    $set['level'] = 3;
    $set['module'] = 'cdr';
    $set['category'] = 'CDR Report Module';
    $set['emptyok'] = 0;
    $set['sortorder'] = 10;
    $set['name'] = 'Enable CEL Reporting';
    $set['description'] = 'Setting this true will enable the CDR module to drill down on CEL data for each CDR. Although the CDR module will assure there is a CEL table available, the reporting functionality in Asterisk and associated ODBC database and CEL configuration must be done outside of FreePBX either by the user or at the Distro level.';
    $set['type'] = CONF_TYPE_BOOL;
    $freepbx_conf->define_conf_setting('CEL_ENABLED', $set, true);
}
$info = FreePBX::Modules()->getInfo("cdr");
if (version_compare_freepbx($info['cdr']['dbversion'], "12.0.13", "<=")) {
    if (FreePBX::Modules()->checkStatus('ucp') && FreePBX::Modules()->checkStatus('userman')) {
        $users = FreePBX::Userman()->getAllUsers();
        foreach ($users as $user) {
            $exts = FreePBX::Ucp()->getSetting($user['username'], 'Settings', 'assigned');
            if (!empty($exts)) {
                FreePBX::Ucp()->setSetting($user['username'], 'Cdr', 'assigned', $exts);
            }
        }
    } elseif (FreePBX::Modules()->checkStatus('ucp', MODULE_STATUS_NEEDUPGRADE)) {
        out(_("Please upgrade UCP before this module so that settings can be properly migrated"));
        return false;
    } elseif (FreePBX::Modules()->checkStatus('userman', MODULE_STATUS_NEEDUPGRADE)) {
        out(_("Please upgrade Usermanager before this module so that settings can be properly migrated"));
        return false;
    }