Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow defining custom locations for xhprof_lib and config.php #118

Merged
merged 1 commit into from Aug 15, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 4 additions & 2 deletions external/header.php
@@ -1,12 +1,14 @@
<?php

require_once dirname(dirname(__FILE__)) . '/xhprof_lib/defaults.php';
require_once XHPROF_CONFIG;

if (PHP_SAPI == 'cli') {
$_SERVER['REMOTE_ADDR'] = null;
$_SERVER['HTTP_HOST'] = null;
$_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'];
}

include(dirname(__FILE__) . '/../xhprof_lib/config.php');

function getExtensionName()
{
if (extension_loaded('tideways'))
Expand Down
10 changes: 3 additions & 7 deletions xhprof_html/callgraph.php
Expand Up @@ -28,19 +28,15 @@
*
* @author Changhao Jiang (cjiang@facebook.com)
*/
require_once ("../xhprof_lib/config.php");

require_once dirname(dirname(__FILE__)) . '/xhprof_lib/defaults.php';
require_once XHPROF_CONFIG;

if (false !== $controlIPs && !in_array($_SERVER['REMOTE_ADDR'], $controlIPs))
{
die("You do not have permission to view this page.");
}

// by default assume that xhprof_html & xhprof_lib directories
// are at the same level.
if (!defined('XHPROF_LIB_ROOT')) {
define('XHPROF_LIB_ROOT', dirname(dirname(__FILE__)) . '/xhprof_lib');
}

include_once XHPROF_LIB_ROOT . '/display/xhprof.php';

ini_set('max_execution_time', 100);
Expand Down
8 changes: 4 additions & 4 deletions xhprof_html/index.php
@@ -1,8 +1,8 @@
<?php
if (!defined('XHPROF_LIB_ROOT')) {
define('XHPROF_LIB_ROOT', dirname(dirname(__FILE__)) . '/xhprof_lib');
}
require_once (XHPROF_LIB_ROOT . "/config.php");

require_once dirname(dirname(__FILE__)) . '/xhprof_lib/defaults.php';
require_once XHPROF_CONFIG;

include_once XHPROF_LIB_ROOT . '/display/xhprof.php';
include (XHPROF_LIB_ROOT . "/utils/common.php");

Expand Down
9 changes: 9 additions & 0 deletions xhprof_lib/defaults.php
@@ -0,0 +1,9 @@
<?php

if (!defined('XHPROF_LIB_ROOT')) {
define('XHPROF_LIB_ROOT', dirname(__FILE__));
}

if (!defined('XHPROF_CONFIG')) {
define('XHPROF_CONFIG', XHPROF_LIB_ROOT . '/config.php');
}