Skip to content

Commit

Permalink
Rename functions to prevent naming conflicts
Browse files Browse the repository at this point in the history
git-svn-id: https://phpfreechat.svn.sourceforge.net/svnroot/phpfreechat/trunk@1155 2772adf2-ac07-0410-9d30-e29d8120292e
  • Loading branch information
kerphi committed Aug 29, 2007
1 parent 40b3e39 commit fabc499
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 46 deletions.
42 changes: 5 additions & 37 deletions src/pfcglobalconfig.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -488,8 +488,6 @@ function init()
{
$ok = true;

if ($this->debug) pxlog("pfcGlobalConfig::init()", "chatconfig", $this->getId());

// check the parameters types
$array_params = $this->_params_type["array"];
foreach( $array_params as $ap )
Expand Down Expand Up @@ -564,8 +562,7 @@ function init()
// test client script
// try to find the path into server configuration
if ($this->client_script_path == '')
$this->client_script_path = getScriptFilename();

$this->client_script_path = pfc_GetScriptFilename();

if ($this->server_script_url == '' && $this->server_script_path == '')
{
Expand All @@ -578,12 +575,9 @@ function init()
$this->server_script_url = './'.basename($filetotest).$this->_query_string;
}

//if ($this->client_script_url == "")
// $this->client_script_url = "./".basename($filetotest);

// calculate datapublic url
if ($this->data_public_url == "")
$this->data_public_url = relativePath($this->client_script_path, $this->data_public_path);
$this->data_public_url = pfc_RelativePath($this->client_script_path, $this->data_public_path);

if ($this->server_script_path == '')
$this->server_script_path = $this->client_script_path;
Expand All @@ -598,7 +592,7 @@ function init()
$filetotest = $res[1];
if ( !file_exists($filetotest) )
$this->errors[] = _pfc("%s doesn't exist", $filetotest);
$this->server_script_url = relativePath($this->client_script_path, $this->server_script_path).'/'.basename($filetotest).$this->_query_string;
$this->server_script_url = pfc_RelativePath($this->client_script_path, $this->server_script_path).'/'.basename($filetotest).$this->_query_string;
}

// check if the theme_path parameter are correctly setup
Expand Down Expand Up @@ -648,14 +642,11 @@ function init()
// ---
// run specific container initialisation
$ct =& pfcContainer::Instance();
/* $container_classname = "pfcContainer_".$this->container_type;
require_once dirname(__FILE__)."/containers/".strtolower($this->container_type).".class.php";
$container = new $container_classname($this);*/
$ct_errors = $ct->init($this);
$this->errors = array_merge($this->errors, $ct_errors);

// load debug url
$this->debugurl = relativePath($this->client_script_path, dirname(__FILE__)."/../debug");
$this->debugurl = pfc_RelativePath($this->client_script_path, dirname(__FILE__)."/../debug");

// check the language is known
$lg_list = pfcI18N::GetAcceptedLanguage();
Expand Down Expand Up @@ -740,15 +731,6 @@ function getId()
return $this->serverid;
}

/*
function _getProxyFile($serverid = "", $data_public_path = "")
{
if ($serverid == "") $serverid = $this->getId();
if ($data_public_path == "") $data_public_path = $this->data_public_path;
return $data_public_path."/".$serverid."/proxy.php";
}
*/

function _GetCacheFile($serverid = "", $data_private_path = "")
{
if ($serverid == '') $serverid = $this->getId();
Expand Down Expand Up @@ -838,7 +820,6 @@ function saveInCache()
$data .= '?>';

file_put_contents($cachefile, $data/*serialize(get_object_vars($this))*/);
if ($this->debug) pxlog("pfcGlobalConfig::saveInCache()", "chatconfig", $this->getId());
}

function isDefaultFile($file)
Expand All @@ -848,19 +829,6 @@ function isDefaultFile($file)
return ($this->theme == "default" ? $fexists1 : !$fexists2);
}

/*
function getFileUrlByProxy($file, $addprefix = true)
{
if (file_exists($this->theme_path."/".$this->theme."/".$file))
return ($addprefix ? $this->data_public_url."/".$this->getId()."/proxy.php" : "")."?p=".$this->theme."/".$file;
else
if (file_exists($this->theme_default_path."/default/".$file))
return ($addprefix ? $this->data_public_url."/".$this->getId()."/proxy.php" : "")."?p=default/".$file;
else
die(_pfc("Error: '%s' could not be found, please check your theme_path '%s' and your theme '%s' are correct", $file, $this->theme_path, $this->theme));
}
*/

function getFilePathFromTheme($file)
{
if (file_exists($this->theme_path."/".$this->theme."/".$file))
Expand Down Expand Up @@ -896,4 +864,4 @@ function filterNickname($nickname)
}
}

?>
?>
42 changes: 33 additions & 9 deletions src/pfctools.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,25 +36,49 @@
* Returns the absolute script filename
* takes care of php cgi configuration which do not support SCRIPT_FILENAME variable.
*/
function getScriptFilename()
function pfc_GetScriptFilename()
{
$sf = isset($_SERVER["PATH_TRANSLATED"]) ? $_SERVER["PATH_TRANSLATED"] : ""; // check for a cgi configurations
if ( $sf == "" ||
!file_exists($sf))
$sf = isset($_SERVER["SCRIPT_FILENAME"]) ? $_SERVER["SCRIPT_FILENAME"] : ""; // for 'normal' configurations
if ( $sf == "" ||
!file_exists($sf))
$sf = '';
if(function_exists('debug_backtrace'))
{
// browse the backtrace history and take the first unknown filename as the client script
foreach(debug_backtrace() as $db)
{
$f = $db['file'];
if (!preg_match('/phpfreechat.class.php/',$f) &&
!preg_match('/pfcglobalconfig.class.php/',$f) &&
!preg_match('/pfctools.class.php/',$f) &&
!preg_match('/pfcinfo.class.php/',$f)
)
{
$sf = $f;
break;
}
}
}
else if (isset($_SERVER['PATH_TRANSLATED']) &&
file_exists($_SERVER['SCRIPT_FILENAME'])) // check for a cgi configurations
{
$sf = $_SERVER['PATH_TRANSLATED'];
}
else if (isset($_SERVER['SCRIPT_FILENAME'])&&
file_exists($_SERVER['SCRIPT_FILENAME'])) // for non-cgi configurations
{
$sf = $_SERVER['SCRIPT_FILENAME'];
}
else
{
echo "<pre>";
echo "<span style='color:red'>Error: GetScriptFilename function returns a wrong path. Please contact the pfc team ([email protected]) and copy/paste this array to help debugging.</span>\n";
echo "<span style='color:red'>Error: pfc_GetScriptFilename function returns a wrong path. Please contact the pfc team ([email protected]) and copy/paste these data to help debugging:</span>\n";
print_r($_SERVER);
print_r(debug_backtrace());
echo "</pre>";
exit;
}
return $sf;
}

function relativePath($p1, $p2)
function pfc_RelativePath($p1, $p2)
{
if (is_file($p1)) $p1 = dirname($p1);
if (is_file($p2)) $p2 = dirname($p2);
Expand Down

0 comments on commit fabc499

Please sign in to comment.