當前位置: 首頁>>代碼示例>>PHP>>正文


PHP parse_xml_config_pkg函數代碼示例

本文整理匯總了PHP中parse_xml_config_pkg函數的典型用法代碼示例。如果您正苦於以下問題:PHP parse_xml_config_pkg函數的具體用法?PHP parse_xml_config_pkg怎麽用?PHP parse_xml_config_pkg使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了parse_xml_config_pkg函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: add_base_packages_menu_items

function add_base_packages_menu_items()
{
    global $g, $config;
    $base_packages = split($g['base_packages'], ",");
    $modified_config = false;
    foreach ($base_packages as $bp) {
        $basepkg_path = "/usr/local/pkg/";
        if (file_exists($basepkg_path . $configfile)) {
            $pkg_config = parse_xml_config_pkg($basepkg_path . $bp, "packagegui");
            if ($pkg_config['menu'] != "") {
                if (is_array($pkg_config['menu'])) {
                    foreach ($pkg_config['menu'] as $menu) {
                        if (is_array($config['installedpackages']['menu'])) {
                            foreach ($config['installedpackages']['menu'] as $amenu) {
                                if ($amenu['name'] == $menu['name']) {
                                    continue;
                                }
                            }
                        }
                        $config['installedpackages']['menu'][] = $menu;
                        $modified_config = true;
                    }
                }
                $static_output .= "done.\n";
                update_output_window($static_output);
            }
        }
    }
    if ($modified_config) {
        write_confg("Restored base_package menus after configuration restore.");
        $config = parse_config(true);
    }
}
開發者ID:rootsghost,項目名稱:5651-pfsense,代碼行數:33,代碼來源:diag_backup.php

示例2: add_base_packages_menu_items

function add_base_packages_menu_items()
{
    global $g, $config;
    $base_packages = explode(",", $g['base_packages']);
    $modified_config = false;
    foreach ($base_packages as $bp) {
        $basepkg_path = "/usr/local/pkg/{$bp}";
        $tmpinfo = pathinfo($basepkg_path, PATHINFO_EXTENSION);
        if ($tmpinfo['extension'] == "xml" && file_exists($basepkg_path)) {
            $pkg_config = parse_xml_config_pkg($basepkg_path, "packagegui");
            if ($pkg_config['menu'] != "") {
                if (is_array($pkg_config['menu'])) {
                    foreach ($pkg_config['menu'] as $menu) {
                        if (is_array($config['installedpackages']['menu'])) {
                            foreach ($config['installedpackages']['menu'] as $amenu) {
                                if ($amenu['name'] == $menu['name']) {
                                    continue;
                                }
                            }
                        }
                        $config['installedpackages']['menu'][] = $menu;
                        $modified_config = true;
                    }
                }
                $static_output .= "done.\n";
                update_output_window($static_output);
            }
        }
    }
    if ($modified_config) {
        write_config(gettext("Restored base_package menus after configuration restore."));
        $config = parse_config(true);
    }
}
開發者ID:jdillard,項目名稱:pfsense,代碼行數:34,代碼來源:diag_backup.php

示例3: htmlspecialchars

    $stepid = htmlspecialchars($_POST['stepid']);
}
if (!$stepid) {
    $stepid = "0";
}
$xml = htmlspecialchars($_GET['xml']);
if ($_POST['xml']) {
    $xml = htmlspecialchars($_POST['xml']);
}
if (empty($xml)) {
    $xml = "not_defined";
    print_info_box_np(sprintf(gettext("ERROR:  Could not open %s."), $xml));
    die;
} else {
    if (file_exists("{$g['www_path']}/wizards/{$xml}")) {
        $pkg = parse_xml_config_pkg("{$g['www_path']}/wizards/" . $xml, "pfsensewizard");
    } else {
        print_info_box_np(sprintf(gettext("ERROR:  Could not open %s."), $xml));
        die;
    }
}
if (!is_array($pkg)) {
    print_info_box_np(sprintf(gettext("ERROR: Could not parse %s/wizards/%s file."), $g['www_path'], $xml));
    die;
}
$title = preg_replace("/pfSense/i", $g['product_name'], $pkg['step'][$stepid]['title']);
$description = preg_replace("/pfSense/i", $g['product_name'], $pkg['step'][$stepid]['description']);
$totalsteps = $pkg['totalsteps'];
if ($pkg['includefile']) {
    require_once $pkg['includefile'];
}
開發者ID:rdmenezes,項目名稱:pfsense,代碼行數:31,代碼來源:wizard.php

示例4: pfSenseHeader

function pfSenseHeader($location)
{
    header("Location: " . $location);
}
$xml = htmlspecialchars($_GET['xml']);
if ($_POST['xml']) {
    $xml = htmlspecialchars($_POST['xml']);
}
$xml_fullpath = realpath('/usr/local/pkg/' . $xml);
if ($xml == "" || $xml_fullpath === false || substr($xml_fullpath, 0, strlen('/usr/local/pkg/')) != '/usr/local/pkg/') {
    include "head.inc";
    print_info_box(gettext("ERROR: No valid package defined."));
    include "foot.inc";
    die;
} else {
    $pkg = parse_xml_config_pkg($xml_fullpath, "packagegui");
}
if ($pkg['include_file'] != "") {
    require_once $pkg['include_file'];
}
if (!isset($pkg['adddeleteeditpagefields'])) {
    $only_edit = true;
} else {
    $only_edit = false;
}
$id = $_GET['id'];
if (isset($_POST['id'])) {
    $id = htmlspecialchars($_POST['id']);
}
// Not posting?	 Then user is editing a record. There must be a valid id
// when editing a record.
開發者ID:nwholloway,項目名稱:pfsense,代碼行數:31,代碼來源:pkg_edit.php

示例5: create_port

function create_port($pkg)
{
    global $ports_dir, $tools_dir, $packages_dir, $product_name;
    if (isset($pkg['internal_name'])) {
        $pkg_name = $pkg['internal_name'];
    } else {
        $pkg_name = $pkg['name'];
    }
    if (empty($pkg_name)) {
        echo "!!! Error: Package name cannot be empty\n";
        exit(1);
    }
    if (!preg_match('/^[a-zA-Z0-9\\.\\-_]+$/', $pkg_name)) {
        echo "!!! Error: Package name '{$pkg_name}' is invalid\n";
        exit(1);
    }
    if (isset($pkg['port_category']) && !empty($pkg['port_category'])) {
        $category = $pkg['port_category'];
    } else {
        $category = 'sysutils';
    }
    $port_name_prefix = $product_name . '-pkg-';
    $port_name = $port_name_prefix . $pkg_name;
    $port_path = $ports_dir . '/' . $category . '/' . $port_name;
    if (is_dir($port_path)) {
        $_gb = exec("rm -rf {$port_path}");
    }
    mkdir($port_path . "/files", 0755, true);
    if (isset($pkg['descr']) && !empty($pkg['descr'])) {
        $pkg_descr = $pkg['descr'];
    } else {
        /* provide a generic description when it's not available */
        $pkg_descr = "{$pkg_name} {$product_name} package";
    }
    if (isset($pkg['pkginfolink']) && !empty($pkg['pkginfolink'])) {
        $pkg_descr .= "\n\nWWW: {$pkg['pkginfolink']}";
    }
    $pkg_descr .= "\n";
    file_put_contents($port_path . "/pkg-descr.tmp", $pkg_descr);
    unset($pkg_descr);
    $_gb = exec("/usr/bin/fmt -w 80 {$port_path}/pkg-descr.tmp > {$port_path}/pkg-descr 2>/dev/null");
    @unlink("{$port_path}/pkg-descr.tmp");
    if (isset($pkg['after_install_info']) && !empty($pkg['after_install_info'])) {
        file_put_contents($port_path . "/pkg-message", $pkg['after_install_info'] . "\n");
    }
    $pkg_install = file_get_contents($tools_dir . "/templates/pkg-install.in");
    file_put_contents($port_path . "/files/pkg-install.in", $pkg_install);
    unset($pkg_install);
    $pkg_deinstall = file_get_contents($tools_dir . "/templates/pkg-deinstall.in");
    file_put_contents($port_path . "/files/pkg-deinstall.in", $pkg_deinstall);
    unset($pkg_deinstall);
    $config_file = preg_replace('/^https*:\\/\\/[^\\/]+\\/packages\\//', '', $pkg['config_file']);
    if (!file_exists($packages_dir . '/' . $config_file)) {
        echo "!!! Error, config file {$config_file} not found\n";
        exit(1);
    }
    $pkg_config = parse_xml_config_pkg($packages_dir . '/' . $config_file, "packagegui");
    if (empty($pkg_config)) {
        echo "!!! Error, config file {$config_file} is invalid\n";
        exit(1);
    }
    if (!is_dir($port_path . '/files/usr/local/pkg')) {
        mkdir($port_path . '/files/usr/local/pkg', 0755, true);
    }
    copy($packages_dir . '/' . $config_file, $port_path . '/files/usr/local/pkg/' . basename($config_file));
    $plist_files = array('pkg/' . basename($config_file));
    $plist_dirs = array();
    $mkdirs = array('${MKDIR} ${STAGEDIR}${PREFIX}/pkg');
    $install = array('${INSTALL_DATA} -m 0644 ${FILESDIR}${PREFIX}/pkg/' . basename($config_file) . " \\\n\t\t" . '${STAGEDIR}${PREFIX}/pkg');
    if (!empty($pkg_config['additional_files_needed'])) {
        foreach ($pkg_config['additional_files_needed'] as $item) {
            if (is_array($item['item'])) {
                $item['item'] = $item['item'][0];
            }
            if (isset($item['do_not_add_to_port'])) {
                continue;
            }
            $file_relpath = preg_replace('/^https*:\\/\\/[^\\/]+\\/packages\\//', '', $item['item']);
            if (!file_exists($packages_dir . '/' . $file_relpath)) {
                echo "!!! Error: Additional file needed {$file_relpath} not found\n";
                exit(1);
            }
            if (!is_dir($port_path . '/files' . $item['prefix'])) {
                mkdir($port_path . '/files' . $item['prefix'], 0755, true);
            }
            copy($packages_dir . '/' . $file_relpath, $port_path . '/files' . $item['prefix'] . '/' . basename($file_relpath));
            fix_php_calls($port_path . '/files' . $item['prefix'] . '/' . basename($file_relpath));
            /* Remove /usr/local/ from prefix */
            $plist_entry = preg_replace('/^\\/usr\\/local\\//', '', $item['prefix']);
            $plist_entry = preg_replace('/\\/*$/', '', $plist_entry);
            if (substr($plist_entry, 0, 1) == '/' && !in_array("@dir {$plist_entry}", $plist_dirs)) {
                $plist_dirs[] = "@dir {$plist_entry}";
            }
            $plist_entry .= '/' . basename($item['item']);
            if (!in_array($plist_entry, $plist_files)) {
                $plist_files[] = $plist_entry;
            }
            unset($plist_entry);
            if (preg_match('/^\\/usr\\/local\\//', $item['prefix'])) {
                $mkdirs_entry = preg_replace('/^\\/usr\\/local\\//', '${PREFIX}/', $item['prefix']);
//.........這裏部分代碼省略.........
開發者ID:rstevens011,項目名稱:pfsense,代碼行數:101,代碼來源:update_package_pfPorts.php

示例6: system

        system("/usr/bin/csup -h {$csup_host} {$supfile} {$quiet_mode}");
    }
}
function chroot_command($chroot_location, $command_to_run)
{
    file_put_contents("{$chroot_location}/cmd.sh", $command_to_run);
    exec("/bin/chmod a+rx {$chroot_location}/cmd.sh");
    `/usr/sbin/chroot {$chroot_location} /cmd.sh`;
}
$options = getopt("x:p:d:jl:c:rqs:");
if (!isset($options['x'])) {
    usage();
}
// Set the XML filename that we are processing
$xml_filename = $options['x'];
$pkg = parse_xml_config_pkg($xml_filename, "pfsensepkgs");
if (!$pkg) {
    echo "!!! An error occurred while trying to process {$xml_filename}.  Exiting.\n";
    exit;
}
// Set csup hostname
if ($options['c'] != "") {
    echo ">>> Setting csup hostname to {$options['c']} \n";
    $csup_host = $options['c'];
} else {
    echo ">>> Setting csup hostname to cvsup.livebsd.com \n";
    $csup_host = "cvsup.livebsd.com";
}
if (isset($options['q'])) {
    $quiet_mode = "</dev/null 2>&1";
}
開發者ID:rootsghost,項目名稱:pfsense-tools,代碼行數:31,代碼來源:rebuild_package_binaries.php

示例7: DAMAGES

    AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
    OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
    SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
    INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
    CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
    ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    POSSIBILITY OF SUCH DAMAGE.
*/
require_once "guiconfig.inc";
$xml = $_REQUEST['xml'];
if ($xml == "") {
    print_info_box_np("HATA: Böyle bir sayfa yok.");
    exit;
} else {
    if (file_exists("/usr/local/pkg/" . $xml)) {
        $pkg = parse_xml_config_pkg("/usr/local/pkg/" . $xml, "packagegui");
    } else {
        echo "Dosya bulunamadı " . htmlspecialchars($xml);
        exit;
    }
}
if ($pkg['donotsave'] != "") {
    Header("Location: pkg_edit.php?xml=" . $xml);
    exit;
}
if ($pkg['include_file'] != "") {
    require_once $pkg['include_file'];
}
$package_name = $pkg['menu'][0]['name'];
$section = $pkg['menu'][0]['section'];
$config_path = $pkg['configpath'];
開發者ID:nuclewall,項目名稱:nuclewall,代碼行數:31,代碼來源:pkg.php

示例8: htmlspecialchars

if ($_POST['xml']) {
    $xml = htmlspecialchars($_POST['xml']);
}
if (empty($xml)) {
    $xml = "not_defined";
    print_info_box(sprintf(gettext("Could not open %s."), $xml), 'danger');
    die;
} else {
    $wizard_xml_prefix = "{$g['www_path']}/wizards";
    $wizard_full_path = "{$wizard_xml_prefix}/{$xml}";
    if (substr_compare(realpath($wizard_full_path), $wizard_xml_prefix, 0, strlen($wizard_xml_prefix))) {
        print_info_box(gettext("Invalid path specified."), 'danger');
        die;
    }
    if (file_exists($wizard_full_path)) {
        $pkg = parse_xml_config_pkg($wizard_full_path, "pfsensewizard");
    } else {
        print_info_box(sprintf(gettext("Could not open %s."), $xml), 'danger');
        die;
    }
}
if (!is_array($pkg)) {
    print_info_box(sprintf(gettext("Could not parse %s/wizards/%s file."), $g['www_path'], $xml), 'danger');
    die;
}
$title = preg_replace("/pfSense/i", $g['product_name'], $pkg['step'][$stepid]['title']);
$description = preg_replace("/pfSense/i", $g['product_name'], $pkg['step'][$stepid]['description']);
$totalsteps = $pkg['totalsteps'];
if ($pkg['includefile']) {
    require_once $pkg['includefile'];
}
開發者ID:NewEraCracker,項目名稱:pfsense,代碼行數:31,代碼來源:wizard.php

示例9: get_pkgs

function get_pkgs($raw_params)
{
    $path_to_files = '../packages/';
    $pkg_rootobj = 'pfsensepkgs';
    $apkgs = array();
    $toreturn = array();
    $params = array_shift(xmlrpc_params_to_php($raw_params));
    if ($params['freebsd_version']) {
        $freebsd_version = "." . $params['freebsd_version'];
    } else {
        $freebsd_version = "";
    }
    if (!empty($params['freebsd_machine'])) {
        $freebsd_machine = $params['freebsd_machine'];
    } else {
        $freebsd_machine = "i386";
    }
    $xml_config_file = $path_to_files . 'pkg_config' . $freebsd_version . '.xml';
    if (file_exists($xml_config_file . '.' . $freebsd_machine)) {
        $xml_config_file .= '.' . $freebsd_machine;
    }
    $pkg_config = parse_xml_config_pkg($xml_config_file, $pkg_rootobj);
    foreach ($pkg_config['packages']['package'] as $pkg) {
        if ($params['pkg'] != 'all' and !in_array($pkg['name'], $params['pkg'])) {
            continue;
        }
        if (!empty($pkg['only_for_archs'])) {
            $allowed_archs = explode(' ', preg_replace('/\\s+/', ' ', trim($pkg['only_for_archs'])));
            if (!in_array($freebsd_machine, $allowed_archs)) {
                continue;
            }
        }
        if (isset($pkg['depends_on_package_pbi']) && preg_match('/##ARCH##/', $pkg['depends_on_package_pbi'])) {
            $pkg['depends_on_package_pbi'] = preg_replace('/##ARCH##/', $freebsd_machine, $pkg['depends_on_package_pbi']);
        }
        // On pkg_config.10.xml and later, depends_on_package_base_url is global
        if (!empty($pkg_config['depends_on_package_base_url'])) {
            $pkg['depends_on_package_base_url'] = $pkg_config['depends_on_package_base_url'];
        }
        if ($params['info'] == 'all') {
            $apkgs[$pkg['name']] = $pkg;
        } else {
            $apkgs[$pkg['name']] = array_intersect_key($pkg, array_flip($params['info']));
        }
    }
    $response = XML_RPC_encode($apkgs);
    return new XML_RPC_Response($response);
}
開發者ID:hynnet,項目名稱:xmlrpc-server,代碼行數:48,代碼來源:xmlrpc.php

示例10: getAdminPageList

function getAdminPageList()
{
    global $g;
    $tmp = array();
    if ($dir = opendir($g['www_path'])) {
        while ($file = readdir($dir)) {
            // Make sure the file exists and is not a directory
            if ($file == "." or $file == ".." or $file[0] == '.') {
                continue;
            }
            // Is this a .inc.php file? pfSense!
            if (fnmatch('guiconfig.inc', $file)) {
                continue;
            }
            if (fnmatch('*.inc', $file)) {
                continue;
            }
            if (fnmatch('*.inc.php', $file)) {
                continue;
            }
            if (fnmatch('*.php', $file)) {
                // Read the description out of the file
                $contents = file_get_contents($file);
                $contents_split = split("\n", $contents);
                $mlinestr = "";
                foreach ($contents_split as $contents) {
                    $pgtitle = "";
                    // Looking for a line like:
                    // $pgtitle = array(gettext("System"), gettext("Group manager")); // - DO NOT REMOVE.
                    if ($mlinestr == "" && stristr($contents, "\$pgtitle") == false) {
                        continue;
                    }
                    if ($mlinestr == "" && stristr($contents, "=") == false) {
                        continue;
                    }
                    if (stristr($contents, "<")) {
                        continue;
                    }
                    if (stristr($contents, ">")) {
                        continue;
                    }
                    /* at this point its evalable */
                    $contents = trim($contents);
                    $lastchar = substr($contents, strlen($contents) - 1, strlen($contents));
                    $firstchar = substr($contents, 0, 1);
                    /* check whether pgtitle is on one or multible lines */
                    if ($firstchar != "/" && $firstchar != "#" && $lastchar != ";") {
                        /* remember the partitial pgtitle string for the next loop iteration */
                        $mlinestr .= $contents;
                        continue;
                    } else {
                        if ($mlinestr != "" && $lastchar == ";") {
                            /* this is the final pgtitle part including the semicolon */
                            $mlinestr .= $contents;
                        } else {
                            if ($mlinestr == "" && $lastchar == ";") {
                                /* this is a single line pgtitle, hence just
                                 * copy its contents into mlinestr
                                 */
                                $mlinestr = $contents;
                            } else {
                                if ($firstchar == "/" || $firstchar == "#") {
                                    /* same applies for comment lines */
                                    $mlinestr = $contents;
                                }
                            }
                        }
                    }
                    eval($mlinestr);
                    /* after eval, if not an array, continue */
                    if (!is_array($pgtitle)) {
                        /* reset mlinestr for the next loop iteration */
                        $mlinestr = "";
                        continue;
                    }
                    $tmp[$file] = convert_array_to_pgtitle($pgtitle);
                    /* break out of the for loop, on to next file */
                    break;
                }
            }
        }
        /* loop through and read in wizard information */
        if ($dir = opendir("{$g['www_path']}/wizards")) {
            while ($file = readdir($dir)) {
                // Make sure the file exists and is not directory
                if ($file == "." or $file == ".." or $file[0] == '.') {
                    continue;
                }
                // Is this a .xml file? pfSense!
                if (fnmatch('*.xml', $file)) {
                    /* parse package and retrieve the package title */
                    $pkg = parse_xml_config_pkg("{$g['www_path']}/wizards/{$file}", "pfsensewizard");
                    $title = $pkg['title'];
                    if ($title) {
                        $tmp[$file] = trim($title);
                    }
                }
            }
        }
        /* loop through and read in package information */
//.........這裏部分代碼省略.........
開發者ID:nagyrobi,項目名稱:pfsense-packages,代碼行數:101,代碼來源:system_groupmanager.php


注:本文中的parse_xml_config_pkg函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。