<?php

/*  Alternate WebKit
(C) 2012 by Alternate Tools
-----------------------------------------------------

File:         display_phpinfo.php
Description:  Administrative module to display phpinfo

*/

    include "../modules/mod_admin.php";


    // Check privileges
    check_login();
    if (user_is_admin() == false)
    {
        log_out();
        return;
    }

    // Cancel log?
    if (isset($_POST['phpi_Cancel']))
    {
        header('location: ' . $ADMIN_MAIN_SITE);
        return;
    }

    // Display
    print_admin_header(get_translation('admin_phpinfo_head'), true, get_translation('admin_login_logout'), $ADMIN_HELP_FILE . '#n1-15', true, get_translation('admin_backtomain'));
    echo_r ('<form method="post" action="">');

    echo_r ('<hr>');
    echo_r ('<table border="0" width="100%">');
    echo_r ('  <tr>');
    echo_r ('    <td>');

    ob_start();
    phpinfo();
    preg_match ('%<style type="text/css">(.*?)</style>.*?<body>(.*?)</body>%s', ob_get_clean(), $matches);
    # $matches [1]; # Style information
    # $matches [2]; # Body information
    echo_r ("<div class='phpinfodisplay'><style type='text/css'>\n" .
    join( "\n",
        array_map(
            create_function(
                '$i',
                'return ".phpinfodisplay " . preg_replace( "/,/", ",.phpinfodisplay ", $i );'
                ),
            preg_split( '/\n/', trim(preg_replace( "/\nbody/", "\n", $matches[1])) )
            )
        ) . "</style>\n" . $matches[2] . "\n</div>\n");

    echo_r ('    </td>');
    echo_r ('  </tr>');
    echo_r ('</table>');

    print_bottom_links("phpi_Cancel", get_translation('admin_ok'));

    print_admin_footer();
?>