コード例 #1
0
/**
 * function generate_module_repo_url
 * short create array of full URLs to get a file from repo
 * use this function to generate an array of URLs for all configured REPOs
 * @author Philippe Lindheimer
 *
 * @pram string
 * @returns string
 */
function generate_module_repo_url($path, $add_options = false)
{
    global $db;
    global $amp_conf;
    $urls = array();
    if ($add_options) {
        $firstinstall = false;
        $type = null;
        $sql = "SELECT * FROM module_xml WHERE id = 'installid'";
        $result = sql($sql, 'getRow', DB_FETCHMODE_ASSOC);
        // if not set so this is a first time install
        // get a new hash to account for first time install
        //
        if (!isset($result['data']) || trim($result['data']) == "") {
            $firstinstall = true;
            $install_hash = _module_generate_unique_id();
            $installid = $install_hash['uniqueid'];
            $type = $install_hash['type'];
            // save the hash so we remeber this is a first time install
            //
            $data4sql = $db->escapeSimple($installid);
            sql("INSERT INTO module_xml (id,time,data) VALUES ('installid'," . time() . ",'" . $data4sql . "')");
            $data4sql = $db->escapeSimple($type);
            sql("INSERT INTO module_xml (id,time,data) VALUES ('type'," . time() . ",'" . $data4sql . "')");
            // Not a first time so save the queried hash and check if there is a type set
            //
        } else {
            $installid = $result['data'];
            $sql = "SELECT * FROM module_xml WHERE id = 'type'";
            $result = sql($sql, 'getRow', DB_FETCHMODE_ASSOC);
            if (isset($result['data']) && trim($result['data']) != "") {
                $type = $result['data'];
            }
        }
        // Now we have the id and know if this is a firstime install so we can get the announcement
        //
        $options = "?installid=" . urlencode($installid);
        if (trim($type) != "") {
            $options .= "&type=" . urlencode($type);
        }
        if ($firstinstall) {
            $options .= "&firstinstall=yes";
        }
        // We check specifically for false because evenif blank it means the file
        // was there so we want module.xml to do appropriate actions
        $brandid = _module_brandid();
        if ($brandid !== false) {
            $options .= "&brandid=" . urlencode($brandid);
        }
        $deploymentid = _module_deploymentid();
        if ($deploymentid !== false) {
            $options .= "&depolymentid=" . urlencode($deploymentid);
        }
        $engver = engine_getinfo();
        if ($engver['engine'] == 'asterisk' && trim($engver['engine']) != "") {
            $options .= "&astver=" . urlencode($engver['version']);
        } else {
            $options .= "&astver=" . urlencode($engver['raw']);
        }
        $options .= "&phpver=" . urlencode(phpversion());
        $distro_info = _module_distro_id();
        $options .= "&distro=" . urlencode($distro_info['pbx_type']);
        $options .= "&distrover=" . urlencode($distro_info['pbx_version']);
        $options .= "&fpbxver=" . urlencode(getversion());
        if (function_exists('core_users_list')) {
            $options .= "&ucount=" . urlencode(count(core_users_list()));
        }
        $path .= $options;
        // Other modules may need to add 'get' paramters to the call to the repo. Check and add them
        // here if we are adding paramters. The module should return an array of key/value pairs each of which
        // is to be appended to the GET parameters. The variable name will be prepended with the module name
        // when sent.
        //
        $repo_params = array();
        foreach (mod_func_iterator('module_repo_parameters_callback', $path) as $mod => $res) {
            if (is_array($res)) {
                foreach ($res as $p => $v) {
                    $path .= '&' . urlencode($mod) . '_' . urlencode($p) . '=' . urlencode($v);
                }
            }
        }
    }
    $repos = explode(',', $amp_conf['MODULE_REPO']);
    foreach ($repos as $repo) {
        $urls[] = $repo . $path;
    }
    return $urls;
}
コード例 #2
0
ファイル: functions.inc.php プロジェクト: hardikk/HNH
function module_get_annoucements()
{
    global $db;
    global $amp_conf;
    $firstinstall = false;
    $type = null;
    $sql = "SELECT * FROM module_xml WHERE id = 'installid'";
    $result = sql($sql, 'getRow', DB_FETCHMODE_ASSOC);
    // if not set so this is a first time install
    // get a new hash to account for first time install
    //
    if (!isset($result['data']) || trim($result['data']) == "") {
        $firstinstall = true;
        $install_hash = _module_generate_unique_id();
        $installid = $install_hash['uniqueid'];
        $type = $install_hash['type'];
        // save the hash so we remeber this is a first time install
        //
        $data4sql = $db->escapeSimple($installid);
        sql("INSERT INTO module_xml (id,time,data) VALUES ('installid'," . time() . ",'" . $data4sql . "')");
        $data4sql = $db->escapeSimple($type);
        sql("INSERT INTO module_xml (id,time,data) VALUES ('type'," . time() . ",'" . $data4sql . "')");
        // Not a first time so save the queried hash and check if there is a type set
        //
    } else {
        $installid = $result['data'];
        $sql = "SELECT * FROM module_xml WHERE id = 'type'";
        $result = sql($sql, 'getRow', DB_FETCHMODE_ASSOC);
        if (isset($result['data']) && trim($result['data']) != "") {
            $type = $result['data'];
        }
    }
    // Now we have the id and know if this is a firstime install so we can get the announcement
    //
    $options = "?installid=" . urlencode($installid);
    if (trim($type) != "") {
        $options .= "&type=" . urlencode($type);
    }
    if ($firstinstall) {
        $options .= "&firstinstall=yes";
    }
    $engver = engine_getinfo();
    if ($engver['engine'] == 'asterisk' && trim($engver['engine']) != "") {
        $options .= "&astver=" . urlencode($engver['version']);
    } else {
        $options .= "&astver=" . urlencode($engver['raw']);
    }
    $options .= "&phpver=" . urlencode(phpversion());
    $distro_info = _module_distro_id();
    $options .= "&distro=" . urlencode($distro_info['pbx_type']);
    $options .= "&distrover=" . urlencode($distro_info['pbx_version']);
    $fn = "http://mirror.freepbx.org/version-" . getversion() . ".html" . $options;
    if (!$amp_conf['MODULEADMINWGET']) {
        ini_set('user_agent', 'Wget/1.10.2 (Red Hat modified)');
        $announcement = @file_get_contents($fn);
    } else {
        $announcement = '';
    }
    if (empty($announcement)) {
        $fn2 = str_replace('&', '\\&', $fn);
        exec("wget -O - {$fn2} 2>> /dev/null", $data_arr, $retcode);
        $announcement = implode("\n", $data_arr);
    }
    return $announcement;
}
コード例 #3
0
ファイル: footer.php プロジェクト: jfinstrom/framework
//footer
$html .= '</div>';
//page
//add javascript
//localized strings and other javascript values that need to be set dynamically
//TODO: this should be done via callbacks so that all modules can hook in to it
$fpbx['conf'] = $amp_conf;
$clean = array('AMPASTERISKUSER', 'AMPASTERISKGROUP', 'AMPASTERISKWEBGROUP', 'AMPASTERISKWEBUSER', 'AMPDBENGINE', 'AMPDBHOST', 'AMPDBNAME', 'AMPDBPASS', 'AMPDBUSER', 'AMPDEVGROUP', 'AMPDEVUSER', 'AMPMGRPASS', 'AMPMGRUSER', 'AMPVMUMASK', 'ARI_ADMIN_PASSWORD', 'ARI_ADMIN_USERNAME', 'ASTMANAGERHOST', 'ASTMANAGERPORT', 'ASTMANAGERPROXYPORT', 'CDRDBHOST', 'CDRDBNAME', 'CDRDBPASS', 'CDRDBPORT', 'CDRDBTABLENAME', 'CDRDBTYPE', 'CDRDBUSER', 'FOPPASSWORD', 'FOPSORT');
foreach ($clean as $var) {
    if (isset($fpbx['conf'][$var])) {
        unset($fpbx['conf'][$var]);
    }
}
$fpbx['conf']['text_dir'] = isset($_COOKIE['lang']) && in_array($_COOKIE['lang'], array('he_IL')) ? 'rtl' : 'ltr';
$fpbx['conf']['uniqueid'] = sql('SELECT data FROM module_xml WHERE id = "installid"', 'getOne');
$fpbx['conf']['dist'] = _module_distro_id();
$fpbx['conf']['ver'] = get_framework_version();
$fpbx['conf']['reload_needed'] = $reload_needed;
$fpbx['msg']['framework']['reload_unidentified_error'] = _(" error(s) occurred, you should view the notification log on the dashboard or main screen to check for more details.");
$fpbx['msg']['framework']['close'] = _("Close");
$fpbx['msg']['framework']['continuemsg'] = _("Continue");
//continue is a resorved word!
$fpbx['msg']['framework']['cancel'] = _("Cancel");
$fpbx['msg']['framework']['retry'] = _("Retry");
$fpbx['msg']['framework']['update'] = _("Update");
$fpbx['msg']['framework']['save'] = _("Save");
$fpbx['msg']['framework']['bademail'] = _("Invalid email address");
$fpbx['msg']['framework']['updatenotifications'] = _("Update Notifications");
$fpbx['msg']['framework']['securityissue'] = _("Security Issue");
$fpbx['msg']['framework']['validation']['duplicate'] = _(" extension number already in use by: ");
$fpbx['msg']['framework']['noupdates'] = _("Are you sure you want to disable automatic update notifications? This could leave your system at risk to serious security vulnerabilities. Enabling update notifications will NOT automatically install them but will make sure you are informed as soon as they are available.");