Welcome Guest, Not a member yet? Register   Sign In
Profiler Extension to show SESSION & SERVER data
#1

[eluser]redwiz[/eluser]
the library:
Code:
<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
* An open source application development framework for PHP 4.3.2 or newer
*
* @package        CodeIgniter
* @author        ExpressionEngine Dev Team
* @copyright    Copyright (c) 2008 - 2009, EllisLab, Inc.
* @license        http://ellislab.com/codeigniter/user-guide/license.html
* @link        http://codeigniter.com
* @since        Version 1.0
* @filesource
*/

// ------------------------------------------------------------------------

/**
* CodeIgniter Profiler Class
*
* This class enables you to display benchmark, query, and other data
* in order to help with debugging and optimization.
*
* Note: At some point it would be good to move all the HTML in this class
* into a set of template files in order to allow customization.
*
* @package        CodeIgniter
* @subpackage    Libraries
* @category    Libraries
* @author        ExpressionEngine Dev Team
* @link        http://ellislab.com/codeigniter/user-guide/general/profiling.html
*/
class MY_Profiler extends CI_Profiler {

    var $CI;
    
     function MY_Profiler()
     {
         parent::CI_Profiler();
         $this->CI =& get_instance();
         $this->CI->load->language('profiler');

     }
    

    /**
     * Compile $_SESSION Data
     *
     * @access    private
     * @return    string
     */    
    function _compile_session()
    {    
        $output  = "\n\n";
        $output .= '<fieldset style="border:1px solid #999000;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">';
        $output .= "\n";
        $output .= '<legend style="color:#999000;">&nbsp;&nbsp;'.$this->CI->lang->line('profiler_session_data').'&nbsp;&nbsp;</legend>';
        $output .= "\n";
                
        if (count($_SESSION) == 0)
        {
            $output .= "<div style='color:#999000;font-weight:normal;padding:4px 0 4px 0'>".$this->CI->lang->line('profiler_no_session')."</div>";
        }
        else
        {
            $output .= "\n\n<table cellpadding='4' cellspacing='1' border='0' width='100%'>\n";
        
            foreach ($_SESSION as $key => $val)
            {
                if ( ! is_numeric($key))
                {
                    $key = "'".$key."'";
                }
            
                $output .= "<tr><td width='50%' style='color:#000;background-color:#ddd;'>$_SESSION[".$key."]&nbsp;&nbsp; </td><td width='50%' style='color:#999000;font-weight:normal;background-color:#ddd;'>";
                if (is_array($val))
                {
                    $output .= "<pre>" . htmlspecialchars(stripslashes(print_r($val, true))) . "</pre>";
                }
                else
                {
                    $output .= htmlspecialchars(stripslashes($val));
                }
                $output .= "</td></tr>\n";
            }
            
            $output .= "</table>\n";
        }
        $output .= "</fieldset>";

        return $output;    
    }
    /**
     * Compile $_SESSION Data
     *
     * @access    private
     * @return    string
     */    
    function _compile_server()
    {    
        $output  = "\n\n";
        $output .= '<fieldset style="border:1px solid #F0000F;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">';
        $output .= "\n";
        $output .= '<legend style="color:#F0000F;">&nbsp;&nbsp;'.$this->CI->lang->line('profiler_server_data').'&nbsp;&nbsp;</legend>';
        $output .= "\n";
                
        if (count($_SERVER) == 0)
        {
            $output .= "<div style='color:#F0000F;font-weight:normal;padding:4px 0 4px 0'>".$this->CI->lang->line('profiler_no_server')."</div>";
        }
        else
        {
            $output .= "\n\n<table cellpadding='4' cellspacing='1' border='0' width='100%'>\n";
        
            foreach ($_SERVER as $key => $val)
            {
                if ( ! is_numeric($key))
                {
                    $key = "'".$key."'";
                }
            
                $output .= "<tr><td width='50%' style='color:#000;background-color:#ddd;'>$_SERVER[".$key."]&nbsp;&nbsp; </td><td width='50%' style='color:#F0000F;font-weight:normal;background-color:#ddd;'>";
                if (is_array($val))
                {
                    $output .= "<pre>" . htmlspecialchars(stripslashes(print_r($val, true))) . "</pre>";
                }
                else
                {
                    $output .= htmlspecialchars(stripslashes($val));
                }
                $output .= "</td></tr>\n";
            }
            
            $output .= "</table>\n";
        }
        $output .= "</fieldset>";

        return $output;    
    }
    
    /**
     * Run the Profiler
     *
     * @access    private
     * @return    string
     */    
    function run()
    {
        $output = "<div id='codeigniter_profiler' style='clear:both;background-color:#fff;padding:10px;'>";

        $output .= $this->_compile_uri_string();
        $output .= $this->_compile_controller_info();
        $output .= $this->_compile_memory_usage();
        $output .= $this->_compile_benchmarks();
        $output .= $this->_compile_get();
        $output .= $this->_compile_post();
        $output .= $this->_compile_session();
        $output .= $this->_compile_server();
        $output .= $this->_compile_queries();

        $output .= '</div>';

        return $output;
    }

}

// END CI_Profiler class

/* End of file Profiler.php */
/* Location: ./system/libraries/Profiler.php */
#2

[eluser]redwiz[/eluser]
The Language File
&lt;?php

$lang['profiler_database'] = 'DATABASE';
$lang['profiler_controller_info'] = 'CLASS/METHOD';
$lang['profiler_benchmarks'] = 'BENCHMARKS';
$lang['profiler_queries'] = 'QUERIES';
$lang['profiler_get_data'] = 'GET DATA';
$lang['profiler_post_data'] = 'POST DATA';
$lang['profiler_session_data'] = 'SESSION DATA';
$lang['profiler_server_data'] = 'SERVER DATA';
$lang['profiler_uri_string'] = 'URI STRING';
$lang['profiler_memory_usage'] = 'MEMORY USAGE';
$lang['profiler_no_db'] = 'Database driver is not currently loaded';
$lang['profiler_no_queries'] = 'No queries were run';
$lang['profiler_no_post'] = 'No POST data exists';
$lang['profiler_no_get'] = 'No GET data exists';
$lang['profiler_no_session'] = 'No SESSION data exists';
$lang['profiler_no_uri'] = 'No URI data exists';
$lang['profiler_no_memory'] = 'Memory Usage Unavailable';

/* End of file profiler_lang.php */
/* Location: ./system/application/language/english/profiler_lang.php */




Theme © iAndrew 2016 - Forum software by © MyBB