[Phpfreechat-svn] SF.net SVN: phpfreechat: [1155] trunk/src
Status: Beta
Brought to you by:
kerphi
|
From: <ke...@us...> - 2007-08-29 12:22:46
|
Revision: 1155
http://phpfreechat.svn.sourceforge.net/phpfreechat/?rev=1155&view=rev
Author: kerphi
Date: 2007-08-29 05:22:44 -0700 (Wed, 29 Aug 2007)
Log Message:
-----------
Rename functions to prevent naming conflicts
Modified Paths:
--------------
trunk/src/pfcglobalconfig.class.php
trunk/src/pfctools.php
Modified: trunk/src/pfcglobalconfig.class.php
===================================================================
--- trunk/src/pfcglobalconfig.class.php 2007-08-29 12:18:19 UTC (rev 1154)
+++ trunk/src/pfcglobalconfig.class.php 2007-08-29 12:22:44 UTC (rev 1155)
@@ -488,8 +488,6 @@
{
$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 )
@@ -564,9 +562,8 @@
// 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 == '')
{
$filetotest = $this->client_script_path;
@@ -578,12 +575,9 @@
$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;
@@ -598,7 +592,7 @@
$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
@@ -648,14 +642,11 @@
// ---
// 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();
@@ -740,15 +731,6 @@
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();
@@ -838,7 +820,6 @@
$data .= '?>';
file_put_contents($cachefile, $data/*serialize(get_object_vars($this))*/);
- if ($this->debug) pxlog("pfcGlobalConfig::saveInCache()", "chatconfig", $this->getId());
}
function isDefaultFile($file)
@@ -848,19 +829,6 @@
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))
@@ -896,4 +864,4 @@
}
}
-?>
\ No newline at end of file
+?>
Modified: trunk/src/pfctools.php
===================================================================
--- trunk/src/pfctools.php 2007-08-29 12:18:19 UTC (rev 1154)
+++ trunk/src/pfctools.php 2007-08-29 12:22:44 UTC (rev 1155)
@@ -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 (co...@ph...) 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 (co...@ph...) 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);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|