Example #1
0
 /**
  * Ends the current session, gathering all the available environment data
  */
 public function gather_data($response = '', EurekaProfiler_DB_Adapter $db_adapter = null)
 {
     $this->duration = microtime(true) - $this->start;
     //Request data
     $this->url = EurekaProfiler_Tools::current_url();
     $this->client_ip = EurekaProfiler_Tools::client_ip();
     $this->user_agent = $_SERVER['HTTP_USER_AGENT'];
     $this->get_data = $_GET;
     $this->post_data = $_POST;
     $this->cookies = $_COOKIE;
     if (function_exists('getallheaders')) {
         $this->request_headers = getallheaders();
     } else {
         $this->request_headers = array();
         foreach ($_SERVER as $key => $val) {
             $extra_headers = array('CONTENT_TYPE', 'CONTENT_LENGTH');
             if (strpos($key, 'HTTP_') === 0 || in_array($key, $extra_headers)) {
                 $name = str_replace(array('HTTP_', '_'), array('', '-'), $key);
                 $this->request_headers[$name] = $val;
             }
         }
     }
     $this->request_headers = array_change_key_case($this->request_headers, CASE_UPPER);
     //Response data
     $this->response = $response;
     $this->response_headers = array();
     if (function_exists('apache_response_headers')) {
         $this->response_headers += apache_response_headers();
     }
     foreach (headers_list() as $header) {
         list($name, $value) = explode(':', $header, 2);
         $this->response_headers[$name] = trim($value);
     }
     //Runtime data
     $this->memory_limit = ini_get('memory_limit');
     $this->memory_used = memory_get_peak_usage(true);
     $this->max_execution_time = ini_get('max_execution_time');
     //Included files
     $files = get_included_files();
     foreach ($files as $file) {
         $this->loaded_files[] = new EurekaProfiler_Included(EurekaProfiler_Tools::clean_path($file), filesize($file));
     }
     //Explain queries
     if (isset($db_adapter)) {
         foreach ($this->events_of_type('db') as $query) {
             if (stripos($query->query, 'SELECT') === 0) {
                 $query->explain = $db_adapter->first_row("EXPLAIN {$query->query}");
             } else {
                 $query->explain = false;
             }
         }
     }
 }
Example #2
0
"><i class="icon-white icon-search fa fa-search"></i> View</a>
                        <a class="btn btn-sm btn-default" href="?remove=<?php 
        echo $session['id'];
        ?>
"><i class="icon-times icon-remove fa fa-times"></i> Remove</a>
                    </td>
                </tr>
            <?php 
    }
    ?>
            </tbody>
        </table>
    </div>

    <div class="pager pagination">
        <span class="text-muted muted">
             <?php 
    echo strtr('Showing {offset} - {end} of {total}', array('{offset}' => EurekaProfiler_Tools::readable_number($offset), '{end}' => EurekaProfiler_Tools::readable_number($offset + count($sessions)), '{total}' => EurekaProfiler_Tools::readable_number($total)));
    ?>
        </span>
        <a class="prev btn btn-small" rel="prev nofollow" href="?offset=<?php 
    echo max($offset - $per_page, 0);
    ?>
">«</a>
        <a class="next btn btn-small" rel="next nofollow" href="?offset=<?php 
    echo min($offset + $per_page, $total - 1);
    ?>
">»</a>
    </div>
<?php 
}
Example #3
0
function render_included(EurekaProfiler_Session $session, $tab)
{
    ?>
    <table class="summary">
        <tr>
            <td style="background: <?php 
    echo $tab['color'];
    ?>
;">
                <h3><?php 
    echo EurekaProfiler_Tools::readable_number(count($session->loaded_files));
    ?>
</h3>
                <h4>Total files</h4>
            </td>
        </tr>
        <tr>
            <td style="background: <?php 
    echo $tab['alternate'];
    ?>
;">
                <h3><?php 
    echo EurekaProfiler_Tools::readable_size($session->total_included_size());
    ?>
</h3>
                <h4>Total size</h4>
            </td>
        </tr>
        <tr>
            <td class="border" style="background: <?php 
    echo $tab['color'];
    ?>
;padding-top:0">
                <?php 
    $chart_rows = array();
    foreach ($session->loaded_files as $file) {
        $chart_rows[] = array($file->path, $file->size);
    }
    echo render_chart($chart_rows, 'File');
    ?>
                <h4>Size chart</h4>
            </td>
        </tr>
    </table>
    <div class="data-wrapper">
        <table class="data">
            <?php 
    $show = array();
    foreach ($session->loaded_files as $file) {
        $show[$file->path] = EurekaProfiler_Tools::readable_size($file->size);
    }
    basic_row('', $show);
    ?>
        </table>
    </div>
<?php 
}
 /**
  * Logs an event in the current section
  *
  * @param string|EurekaProfiler_Event $name
  * @param boolean|int                 $backtrace Enable or disable the backtract info for the event. If it's a number, it will represent the number of steps deleted
  *
  * @return EurekaProfiler_Event
  */
 public function log_event($name, $type = 'app', $data = null, $backtrace = true)
 {
     if (!$this->_enabled) {
         return false;
     }
     if ($name instanceof EurekaProfiler_Event) {
         $event = $name;
     } else {
         $event = new EurekaProfiler_Event($this->_session, $name);
         $event->type = $type;
         $event->data = $data;
     }
     if ($backtrace) {
         $event->backtrace = EurekaProfiler_Tools::backtrace_small(null, is_bool($backtrace) ? 2 : 2 + $backtrace);
     }
     $this->_session->events[] = $event;
     return $event;
 }
Example #5
0
 /**
  * Sets special paths that will be replaced in the profiler. E.g.:
  *         APP_PATH => /home/project/www/
  */
 public static function set_special_paths(array $paths)
 {
     self::$_special_paths = $paths;
 }