Example #1
0
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);
    }
}
Example #2
0
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);
    }
}
Example #3
0
    $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'];
}
Example #4
0
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.
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']);
            } else {
                $mkdirs_entry = $item['prefix'];
            }
            $mkdirs_entry = preg_replace('/\\/*$/', '', $mkdirs_entry);
            $install_entry = '${INSTALL_DATA} ';
            if (isset($item['chmod']) && !empty($item['chmod'])) {
                $install_entry .= "-m {$item['chmod']} ";
            }
            $install_entry .= '${FILESDIR}' . $mkdirs_entry . '/' . basename($item['item']) . " \\\n\t\t";
            $install_entry .= '${STAGEDIR}' . $mkdirs_entry;
            $mkdirs_entry = '${MKDIR} ${STAGEDIR}' . $mkdirs_entry;
            if (!in_array($mkdirs_entry, $mkdirs)) {
                $mkdirs[] = $mkdirs_entry;
            }
            if (!in_array($install_entry, $install)) {
                $install[] = $install_entry;
            }
            unset($install_entry, $mkdirs_entry);
        }
    }
    if (!is_dir($port_path . '/files/usr/local/share/' . $port_name)) {
        mkdir($port_path . '/files/usr/local/share/' . $port_name, 0755, true);
    }
    $info['package'][] = $pkg;
    $info_xml = dump_xml_config($info, 'pfsensepkgs');
    file_put_contents($port_path . '/files/usr/local/share/' . $port_name . '/info.xml', $info_xml);
    unset($info, $info_xml);
    $plist_files[] = '%%DATADIR%%/info.xml';
    $mkdirs[] = '${MKDIR} ${STAGEDIR}${DATADIR}';
    $install[] = '${INSTALL_DATA} ${FILESDIR}${DATADIR}/info.xml ' . "\\\n\t\t" . '${STAGEDIR}${DATADIR}';
    $version = $pkg['version'];
    /* Detect PORTEPOCH */
    if (($pos = strpos($version, ',')) != FALSE) {
        $epoch = substr($version, $pos + 1);
        $version = substr($version, 0, $pos);
    }
    /* Detect PORTREVISION */
    if (($pos = strpos($version, '_')) != FALSE) {
        $revision = substr($version, $pos + 1);
        $version = substr($version, 0, $pos);
    }
    $makefile = array();
    $makefile[] = '# $FreeBSD$';
    $makefile[] = '';
    $makefile[] = "PORTNAME=\t{$port_name}";
    $makefile[] = "PORTVERSION=\t{$version}";
    if (isset($revision)) {
        $makefile[] = "PORTREVISION=\t{$revision}";
    }
    if (isset($epoch)) {
        $makefile[] = "PORTEPOCH=\t{$epoch}";
    }
    // XXX: use categories from xml */
    $makefile[] = "CATEGORIES=\t{$category}";
    $makefile[] = "MASTER_SITES=\t# empty";
    $makefile[] = "DISTFILES=\t# empty";
    $makefile[] = "EXTRACT_ONLY=\t# empty";
    $makefile[] = "";
    $makefile[] = "MAINTAINER=\tcoreteam@pfsense.org";
    // XXX: Provide comment on xml */
    $makefile[] = "COMMENT=\t{$product_name} package {$pkg_name}";
    if (isset($pkg['run_depends']) && !empty($pkg['run_depends'])) {
        $run_depends = array();
        foreach (preg_split('/\\s+/', trim($pkg['run_depends'])) as $depend) {
            list($file_depend, $port_depend) = explode(':', $depend);
            $file_depend = '${LOCALBASE}/' . $file_depend;
            $port_depend = '${PORTSDIR}/' . $port_depend;
            $run_depends[] = $file_depend . ':' . $port_depend;
        }
        if (!empty($run_depends)) {
            $makefile[] = "";
            $first = true;
            foreach ($run_depends as $run_depend) {
                if ($first) {
                    $makefile_entry = "RUN_DEPENDS=\t" . $run_depend;
                    $first = false;
                } else {
                    $makefile_entry .= " \\\n\t\t" . $run_depend;
                }
            }
            $makefile[] = $makefile_entry;
            unset($makefile_entry);
        }
        unset($run_depends);
    }
    if (isset($pkg['lib_depends']) && !empty($pkg['lib_depends'])) {
        $lib_depends = array();
        foreach (preg_split('/\\s+/', trim($pkg['lib_depends'])) as $depend) {
            list($lib_depend, $port_depend) = explode(':', $depend);
            $port_depend = '${PORTSDIR}/' . $port_depend;
            $lib_depends[] = $lib_depend . ':' . $port_depend;
        }
        if (!empty($lib_depends)) {
            $makefile[] = "";
            $first = true;
            foreach ($lib_depends as $lib_depend) {
                if ($first) {
                    $makefile_entry = "LIB_DEPENDS=\t" . $lib_depend;
                    $first = false;
                } else {
                    $makefile_entry .= " \\\n\t\t" . $lib_depend;
                }
            }
            $makefile[] = $makefile_entry;
            unset($makefile_entry);
        }
        unset($run_depends);
    }
    if (isset($pkg['port_uses']) && !empty($pkg['port_uses'])) {
        $makefile[] = "";
        foreach (preg_split('/\\s+/', trim($pkg['port_uses'])) as $port_use) {
            $port_use = preg_replace('/=/', "=\t", $port_use);
            $makefile[] = $port_use;
        }
    }
    $conflicts = '';
    if (isset($pkg['noembedded'])) {
        $conflicts = $product_name . '-base-nanobsd-[0-9]*';
    }
    if (isset($pkg['conflicts']) && !empty($pkg['conflicts'])) {
        $conflicts = trim($conflicts . ' ' . $port_name_prefix . $pkg['conflicts'] . '-[0-9]*');
    }
    if (!empty($conflicts)) {
        $makefile[] = "";
        $makefile[] = "CONFLICTS=\t" . $conflicts;
    }
    $makefile[] = "";
    $makefile[] = "NO_BUILD=\tyes";
    $makefile[] = "NO_MTREE=\tyes";
    $makefile[] = "";
    $makefile[] = "SUB_FILES=\tpkg-install pkg-deinstall";
    $makefile[] = "SUB_LIST=\tPORTNAME=\${PORTNAME}";
    $makefile[] = "";
    $makefile[] = "do-extract:";
    $makefile[] = "\t\${MKDIR} \${WRKSRC}";
    $makefile[] = "";
    $makefile[] = "do-install:";
    foreach ($mkdirs as $item) {
        $makefile[] = "\t" . $item;
    }
    foreach ($install as $item) {
        $makefile[] = "\t" . $item;
    }
    $makefile[] = "";
    $makefile[] = ".include <bsd.port.mk>";
    file_put_contents($port_path . '/Makefile', implode("\n", $makefile) . "\n");
    unset($makefile);
    file_put_contents($port_path . '/pkg-plist', implode("\n", $plist_files) . "\n");
    if (!empty($plist_dirs)) {
        file_put_contents($port_path . '/pkg-plist', implode("\n", $plist_dirs) . "\n", FILE_APPEND);
    }
    unset($plist_files, $plist_dirs);
}
        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";
}
Example #7
0
    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'];
Example #8
0
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'];
}
Example #9
0
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);
}
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 */
        if ($dir = opendir("{$g['pkg_path']}")) {
            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['pkg_path']}/{$file}", "packagegui");
                    $title = $pkg['title'];
                    if ($title) {
                        $tmp[$file] = trim($title);
                    }
                }
            }
        }
        closedir($dir);
        // Sets Interfaces:Optional page that didn't read in properly with the above method,
        // and pages that don't have descriptions.
        $tmp['interfaces_opt.php'] = "Interfaces: Optional";
        $tmp['graph.php'] = "Status: Traffic Graph";
        $tmp['graph_cpu.php'] = "Diagnostics: CPU Utilization";
        $tmp['exec_raw.php'] = "Hidden: Exec Raw";
        $tmp['uploadconfig.php'] = "Hidden: Upload Configuration";
        $tmp['index.php'] = "Status: System";
        $tmp['system_usermanager.php'] = "System: User Password";
        $tmp['diag_logs_settings.php'] = "Diagnostics: Logs: Settings";
        $tmp['diag_logs_vpn.php'] = "Diagnostics: Logs: PPTP VPN";
        $tmp['diag_logs_filter.php'] = "Diagnostics: Logs: Firewall";
        $tmp['diag_logs_portal.php'] = "Diagnostics: Logs: Captive Portal";
        $tmp['diag_logs_dhcp.php'] = "Diagnostics: Logs: DHCP";
        $tmp['diag_logs.php'] = "Diagnostics: Logs: System";
        $tmp['ifstats.php'] = "Hidden: *XMLRPC Interface Stats";
        $tmp['license.php'] = "System: License";
        $tmp['progress.php'] = "Hidden: *No longer included";
        $tmp['diag_logs_filter_dynamic.php'] = "Hidden: *No longer included";
        $tmp['preload.php'] = "Hidden: *XMLRPC Preloader";
        $tmp['xmlrpc.php'] = "Hidden: *XMLRPC Library";
        $tmp['pkg.php'] = "System: *Renderer for XML based package GUIs (Part I)";
        $tmp['pkg_edit.php'] = "System: *Renderer for XML based package GUIs (Part II)";
        $tmp['functions.inc.php'] = "Hidden: Ajax Helper 1";
        $tmp['javascript.inc.php'] = "Hidden: Ajax Helper 2 ";
        $tmp['sajax.class.php'] = "Hidden: Ajax Helper 3";
        asort($tmp);
        return $tmp;
    }
}