123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194 |
- <?php
- if (!defined ('XAJAX_DEFAULT_CHAR_ENCODING'))
- {
- define ('XAJAX_DEFAULT_CHAR_ENCODING', 'utf-8' );
- }
- if (!defined ('XAJAX_GET'))
- {
- define ('XAJAX_GET', 0);
- }
- if (!defined ('XAJAX_POST'))
- {
- define ('XAJAX_POST', 1);
- }
- class xajax
- {
-
-
- var $aFunctions;
-
- var $aObjects;
-
- var $aFunctionRequestTypes;
-
- var $aFunctionIncludeFiles;
-
- var $sCatchAllFunction;
-
- var $sPreFunction;
-
- var $sRequestURI;
-
- var $sWrapperPrefix;
-
- var $bDebug;
-
- var $bStatusMessages;
-
- var $bExitAllowed;
-
- var $bWaitCursor;
-
- var $bErrorHandler;
-
- var $sLogFile;
-
- var $bCleanBuffer;
-
- var $sEncoding;
-
- var $bDecodeUTF8Input;
-
- var $bOutputEntities;
-
- var $aObjArray;
-
- var $iPos;
-
-
- public function __construct($sRequestURI="",$sWrapperPrefix="xajax_",$sEncoding=XAJAX_DEFAULT_CHAR_ENCODING,$bDebug=false)
- {
- $this->aFunctions = array();
- $this->aObjects = array();
- $this->aFunctionIncludeFiles = array();
- $this->sRequestURI = $sRequestURI;
- if ($this->sRequestURI == "")
- $this->sRequestURI = $this->_detectURI();
- $this->sWrapperPrefix = $sWrapperPrefix;
- $this->bDebug = $bDebug;
- $this->bStatusMessages = false;
- $this->bWaitCursor = true;
- $this->bExitAllowed = true;
- $this->bErrorHandler = false;
- $this->sLogFile = "";
- $this->bCleanBuffer = false;
- $this->setCharEncoding($sEncoding);
- $this->bDecodeUTF8Input = false;
- $this->bOutputEntities = false;
- }
-
- function setRequestURI($sRequestURI)
- {
- $this->sRequestURI = $sRequestURI;
- }
-
-
- function setWrapperPrefix($sPrefix)
- {
- $this->sWrapperPrefix = $sPrefix;
- }
-
- function debugOn()
- {
- $this->bDebug = true;
- }
-
- function debugOff()
- {
- $this->bDebug = false;
- }
-
- function statusMessagesOn()
- {
- $this->bStatusMessages = true;
- }
-
- function statusMessagesOff()
- {
- $this->bStatusMessages = false;
- }
-
- function waitCursorOn()
- {
- $this->bWaitCursor = true;
- }
-
- function waitCursorOff()
- {
- $this->bWaitCursor = false;
- }
-
- function exitAllowedOn()
- {
- $this->bExitAllowed = true;
- }
-
- function exitAllowedOff()
- {
- $this->bExitAllowed = false;
- }
-
- function errorHandlerOn()
- {
- $this->bErrorHandler = true;
- }
-
- function errorHandlerOff()
- {
- $this->bErrorHandler = false;
- }
-
- function setLogFile($sFilename)
- {
- $this->sLogFile = $sFilename;
- }
-
- function cleanBufferOn()
- {
- $this->bCleanBuffer = true;
- }
-
- function cleanBufferOff()
- {
- $this->bCleanBuffer = false;
- }
-
- function setCharEncoding($sEncoding)
- {
- $this->sEncoding = $sEncoding;
- }
-
- function decodeUTF8InputOn()
- {
- $this->bDecodeUTF8Input = true;
- }
-
- function decodeUTF8InputOff()
- {
- $this->bDecodeUTF8Input = false;
- }
-
- function outputEntitiesOn()
- {
- $this->bOutputEntities = true;
- }
-
- function outputEntitiesOff()
- {
- $this->bOutputEntities = false;
- }
-
- function registerFunction($mFunction,$sRequestType=XAJAX_POST)
- {
- if (is_array($mFunction)) {
- $this->aFunctions[$mFunction[0]] = 1;
- $this->aFunctionRequestTypes[$mFunction[0]] = $sRequestType;
- $this->aObjects[$mFunction[0]] = array_slice($mFunction, 1);
- }
- else {
- $this->aFunctions[$mFunction] = 1;
- $this->aFunctionRequestTypes[$mFunction] = $sRequestType;
- }
- }
-
- function registerExternalFunction($mFunction,$sIncludeFile,$sRequestType=XAJAX_POST)
- {
- $this->registerFunction($mFunction, $sRequestType);
- if (is_array($mFunction)) {
- $this->aFunctionIncludeFiles[$mFunction[0]] = $sIncludeFile;
- }
- else {
- $this->aFunctionIncludeFiles[$mFunction] = $sIncludeFile;
- }
- }
-
- function registerCatchAllFunction($mFunction)
- {
- if (is_array($mFunction)) {
- $this->sCatchAllFunction = $mFunction[0];
- $this->aObjects[$mFunction[0]] = array_slice($mFunction, 1);
- }
- else {
- $this->sCatchAllFunction = $mFunction;
- }
- }
-
- function registerPreFunction($mFunction)
- {
- if (is_array($mFunction)) {
- $this->sPreFunction = $mFunction[0];
- $this->aObjects[$mFunction[0]] = array_slice($mFunction, 1);
- }
- else {
- $this->sPreFunction = $mFunction;
- }
- }
-
- function canProcessRequests()
- {
- if ($this->getRequestMode() != -1) return true;
- return false;
- }
-
- function getRequestMode()
- {
- if (!empty($_GET["xajax"]))
- return XAJAX_GET;
- if (!empty($_POST["xajax"]))
- return XAJAX_POST;
- return -1;
- }
-
- function processRequests()
- {
- $requestMode = -1;
- $sFunctionName = "";
- $bFoundFunction = true;
- $bFunctionIsCatchAll = false;
- $sFunctionNameForSpecial = "";
- $aArgs = array();
- $sPreResponse = "";
- $bEndRequest = false;
- $sResponse = "";
- $requestMode = $this->getRequestMode();
- if ($requestMode == -1) return;
- if ($requestMode == XAJAX_POST)
- {
- $sFunctionName = $_POST["xajax"];
- if (!empty($_POST["xajaxargs"]))
- $aArgs = $_POST["xajaxargs"];
- }
- else
- {
- header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
- header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
- header ("Cache-Control: no-cache, must-revalidate");
- header ("Pragma: no-cache");
- $sFunctionName = $_GET["xajax"];
- if (!empty($_GET["xajaxargs"]))
- $aArgs = $_GET["xajaxargs"];
- }
-
- if ($this->bErrorHandler) {
- $GLOBALS['xajaxErrorHandlerText'] = "";
- set_error_handler("xajaxErrorHandler");
- }
- if ($this->sPreFunction) {
- if (!$this->_isFunctionCallable($this->sPreFunction)) {
- $bFoundFunction = false;
- $objResponse = new xajaxResponse();
- $objResponse->addAlert("Unknown Pre-Function ". $this->sPreFunction);
- $sResponse = $objResponse->getXML();
- }
- }
-
- if (array_key_exists($sFunctionName,$this->aFunctionIncludeFiles))
- {
- ob_start();
- include_once($this->aFunctionIncludeFiles[$sFunctionName]);
- ob_end_clean();
- }
- if ($bFoundFunction) {
- $sFunctionNameForSpecial = $sFunctionName;
- if (!array_key_exists($sFunctionName, $this->aFunctions))
- {
- if ($this->sCatchAllFunction) {
- $sFunctionName = $this->sCatchAllFunction;
- $bFunctionIsCatchAll = true;
- }
- else {
- $bFoundFunction = false;
- $objResponse = new xajaxResponse();
- $objResponse->addAlert("Unknown Function $sFunctionName.");
- $sResponse = $objResponse->getXML();
- }
- }
- else if ($this->aFunctionRequestTypes[$sFunctionName] != $requestMode)
- {
- $bFoundFunction = false;
- $objResponse = new xajaxResponse();
- $objResponse->addAlert("Incorrect Request Type.");
- $sResponse = $objResponse->getXML();
- }
- }
- if ($bFoundFunction)
- {
- for ($i = 0; $i < sizeof($aArgs); $i++)
- {
-
- if (get_magic_quotes_gpc() == 1 && is_string($aArgs[$i])) {
- $aArgs[$i] = stripslashes($aArgs[$i]);
- }
- if (stristr($aArgs[$i],"<xjxobj>") != false)
- {
- $aArgs[$i] = $this->_xmlToArray("xjxobj",$aArgs[$i]);
- }
- else if (stristr($aArgs[$i],"<xjxquery>") != false)
- {
- $aArgs[$i] = $this->_xmlToArray("xjxquery",$aArgs[$i]);
- }
- else if ($this->bDecodeUTF8Input)
- {
- $aArgs[$i] = $this->_decodeUTF8Data($aArgs[$i]);
- }
- }
- if ($this->sPreFunction) {
- $mPreResponse = $this->_callFunction($this->sPreFunction, array($sFunctionNameForSpecial, $aArgs));
- if (is_array($mPreResponse) && $mPreResponse[0] === false) {
- $bEndRequest = true;
- $sPreResponse = $mPreResponse[1];
- }
- else {
- $sPreResponse = $mPreResponse;
- }
- if (is_a($sPreResponse, "xajaxResponse")) {
- $sPreResponse = $sPreResponse->getXML();
- }
- if ($bEndRequest) $sResponse = $sPreResponse;
- }
- if (!$bEndRequest) {
- if (!$this->_isFunctionCallable($sFunctionName)) {
- $objResponse = new xajaxResponse();
- $objResponse->addAlert("The Registered Function $sFunctionName Could Not Be Found.");
- $sResponse = $objResponse->getXML();
- }
- else {
- if ($bFunctionIsCatchAll) {
- $aArgs = array($sFunctionNameForSpecial, $aArgs);
- }
- $sResponse = $this->_callFunction($sFunctionName, $aArgs);
- }
- if (is_a($sResponse, "xajaxResponse")) {
- $sResponse = $sResponse->getXML();
- }
- if (!is_string($sResponse) || strpos($sResponse, "<xjx>") === FALSE) {
- $objResponse = new xajaxResponse();
- $objResponse->addAlert("No XML Response Was Returned By Function $sFunctionName.");
- $sResponse = $objResponse->getXML();
- }
- else if ($sPreResponse != "") {
- $sNewResponse = new xajaxResponse($this->sEncoding, $this->bOutputEntities);
- $sNewResponse->loadXML($sPreResponse);
- $sNewResponse->loadXML($sResponse);
- $sResponse = $sNewResponse->getXML();
- }
- }
- }
- $sContentHeader = "Content-type: text/xml;";
- if ($this->sEncoding && strlen(trim($this->sEncoding)) > 0)
- $sContentHeader .= " charset=".$this->sEncoding;
- header($sContentHeader);
- if ($this->bErrorHandler && !empty( $GLOBALS['xajaxErrorHandlerText'] )) {
- $sErrorResponse = new xajaxResponse();
- $sErrorResponse->addAlert("** PHP Error Messages: **" . $GLOBALS['xajaxErrorHandlerText']);
- if ($this->sLogFile) {
- $fH = @fopen($this->sLogFile, "a");
- if (!$fH) {
- $sErrorResponse->addAlert("** Logging Error **\n\nxajax was unable to write to the error log file:\n" . $this->sLogFile);
- }
- else {
- fwrite($fH, "** xajax Error Log - " . strftime("%b %e %Y %I:%M:%S %p") . " **" . $GLOBALS['xajaxErrorHandlerText'] . "\n\n\n");
- fclose($fH);
- }
- }
- $sErrorResponse->loadXML($sResponse);
- $sResponse = $sErrorResponse->getXML();
- }
- if ($this->bCleanBuffer) while (@ob_end_clean());
- print $sResponse;
- if ($this->bErrorHandler) restore_error_handler();
- if ($this->bExitAllowed)
- exit();
- }
-
- function printJavascript($sJsURI="", $sJsFile=NULL)
- {
- print $this->getJavascript($sJsURI, $sJsFile);
- }
-
- function getJavascript($sJsURI="", $sJsFile=NULL)
- {
- $html = $this->getJavascriptConfig();
- $html .= $this->getJavascriptInclude($sJsURI, $sJsFile);
- return $html;
- }
-
- function getJavascriptConfig()
- {
- $html = "\t<script type=\"text/javascript\">\n";
- $html .= "var xajaxRequestUri=\"".$this->sRequestURI."\";\n";
- $html .= "var xajaxDebug=".($this->bDebug?"true":"false").";\n";
- $html .= "var xajaxStatusMessages=".($this->bStatusMessages?"true":"false").";\n";
- $html .= "var xajaxWaitCursor=".($this->bWaitCursor?"true":"false").";\n";
- $html .= "var xajaxDefinedGet=".XAJAX_GET.";\n";
- $html .= "var xajaxDefinedPost=".XAJAX_POST.";\n";
- $html .= "var xajaxLoaded=false;\n";
- foreach($this->aFunctions as $sFunction => $bExists) {
- $html .= $this->_wrap($sFunction,$this->aFunctionRequestTypes[$sFunction]);
- }
- $html .= "\t</script>\n";
- return $html;
- }
-
- function getJavascriptInclude($sJsURI="", $sJsFile=NULL)
- {
- if ($sJsFile == NULL) $sJsFile = "xajax_js/xajax.js";
- if ($sJsURI != "" && substr($sJsURI, -1) != "/") $sJsURI .= "/";
- $html = "\t<script type=\"text/javascript\" src=\"" . $sJsURI . $sJsFile . "\"></script>\n";
- $html .= "\t<script type=\"text/javascript\">\n";
- $html .= "window.setTimeout(function () { if (!xajaxLoaded) { alert('Error: the xajax Javascript file could not be included. Perhaps the URL is incorrect?\\nURL: {$sJsURI}{$sJsFile}'); } }, 6000);\n";
- $html .= "\t</script>\n";
- return $html;
- }
-
- function _detectURI()
- {
- $aURL = array();
-
- if (!empty($_SERVER['REQUEST_URI'])) {
- $aURL = parse_url($_SERVER['REQUEST_URI']);
- }
-
- if (empty($aURL['scheme'])) {
- if (!empty($_SERVER['HTTP_SCHEME'])) {
- $aURL['scheme'] = $_SERVER['HTTP_SCHEME'];
- } else {
- $aURL['scheme'] = (!empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) != 'off') ? 'https' : 'http';
- }
- }
- if (empty($aURL['host'])) {
- if (!empty($_SERVER['HTTP_HOST'])) {
- if (strpos($_SERVER['HTTP_HOST'], ':') > 0) {
- list($aURL['host'], $aURL['port']) = explode(':', $_SERVER['HTTP_HOST']);
- } else {
- $aURL['host'] = $_SERVER['HTTP_HOST'];
- }
- } else if (!empty($_SERVER['SERVER_NAME'])) {
- $aURL['host'] = $_SERVER['SERVER_NAME'];
- } else {
- print "xajax Error: xajax failed to automatically identify your Request URI.";
- print "Please set the Request URI explicitly when you instantiate the xajax object.";
- exit();
- }
- }
- if (empty($aURL['port']) && !empty($_SERVER['SERVER_PORT'])) {
- $aURL['port'] = $_SERVER['SERVER_PORT'];
- }
- if (empty($aURL['path'])) {
- if (!empty($_SERVER['PATH_INFO'])) {
- $sPath = parse_url($_SERVER['PATH_INFO']);
- } else {
- $sPath = parse_url(api_get_self());
- }
- $aURL['path'] = $sPath['path'];
- unset($sPath);
- }
- if (!empty($aURL['query'])) {
- $aURL['query'] = '?'.$aURL['query'];
- }
-
- $sURL = api_get_self();
-
- $sURL.= @$aURL['query'];
-
- unset($aURL);
- return $sURL;
- }
-
- function _isObjectCallback($sFunction)
- {
- if (array_key_exists($sFunction, $this->aObjects)) return true;
- return false;
- }
-
- function _isFunctionCallable($sFunction)
- {
- if ($this->_isObjectCallback($sFunction)) {
- if (is_object($this->aObjects[$sFunction][0])) {
- return method_exists($this->aObjects[$sFunction][0], $this->aObjects[$sFunction][1]);
- }
- else {
- return is_callable($this->aObjects[$sFunction]);
- }
- }
- else {
- return function_exists($sFunction);
- }
- }
-
- function _callFunction($sFunction, $aArgs)
- {
- if ($this->_isObjectCallback($sFunction)) {
- $mReturn = call_user_func_array($this->aObjects[$sFunction], $aArgs);
- }
- else {
- $mReturn = call_user_func_array($sFunction, $aArgs);
- }
- return $mReturn;
- }
-
- function _wrap($sFunction,$sRequestType=XAJAX_POST)
- {
- $js = "function ".$this->sWrapperPrefix."$sFunction(){return xajax.call(\"$sFunction\", arguments, ".$sRequestType.");}\n";
- return $js;
- }
-
- function _xmlToArray($rootTag, $sXml)
- {
- $aArray = array();
- $sXml = str_replace("<$rootTag>","<$rootTag>|~|",$sXml);
- $sXml = str_replace("</$rootTag>","</$rootTag>|~|",$sXml);
- $sXml = str_replace("<e>","<e>|~|",$sXml);
- $sXml = str_replace("</e>","</e>|~|",$sXml);
- $sXml = str_replace("<k>","<k>|~|",$sXml);
- $sXml = str_replace("</k>","|~|</k>|~|",$sXml);
- $sXml = str_replace("<v>","<v>|~|",$sXml);
- $sXml = str_replace("</v>","|~|</v>|~|",$sXml);
- $sXml = str_replace("<q>","<q>|~|",$sXml);
- $sXml = str_replace("</q>","|~|</q>|~|",$sXml);
- $this->aObjArray = explode("|~|",$sXml);
- $this->iPos = 0;
- $aArray = $this->_parseObjXml($rootTag);
- return $aArray;
- }
-
- function _parseObjXml($rootTag)
- {
- $aArray = array();
- if ($rootTag == "xjxobj")
- {
- while(!stristr($this->aObjArray[$this->iPos],"</xjxobj>"))
- {
- $this->iPos++;
- if(stristr($this->aObjArray[$this->iPos],"<e>"))
- {
- $key = "";
- $value = null;
- $this->iPos++;
- while(!stristr($this->aObjArray[$this->iPos],"</e>"))
- {
- if(stristr($this->aObjArray[$this->iPos],"<k>"))
- {
- $this->iPos++;
- while(!stristr($this->aObjArray[$this->iPos],"</k>"))
- {
- $key .= $this->aObjArray[$this->iPos];
- $this->iPos++;
- }
- }
- if(stristr($this->aObjArray[$this->iPos],"<v>"))
- {
- $this->iPos++;
- while(!stristr($this->aObjArray[$this->iPos],"</v>"))
- {
- if(stristr($this->aObjArray[$this->iPos],"<xjxobj>"))
- {
- $value = $this->_parseObjXml("xjxobj");
- $this->iPos++;
- }
- else
- {
- $value .= $this->aObjArray[$this->iPos];
- if ($this->bDecodeUTF8Input)
- {
- $value = $this->_decodeUTF8Data($value);
- }
- }
- $this->iPos++;
- }
- }
- $this->iPos++;
- }
- $aArray[$key]=$value;
- }
- }
- }
- if ($rootTag == "xjxquery")
- {
- $sQuery = "";
- $this->iPos++;
- while(!stristr($this->aObjArray[$this->iPos],"</xjxquery>"))
- {
- if (stristr($this->aObjArray[$this->iPos],"<q>") || stristr($this->aObjArray[$this->iPos],"</q>"))
- {
- $this->iPos++;
- continue;
- }
- $sQuery .= $this->aObjArray[$this->iPos];
- $this->iPos++;
- }
- parse_str($sQuery, $aArray);
- if ($this->bDecodeUTF8Input)
- {
- foreach($aArray as $key => $value)
- {
- $aArray[$key] = $this->_decodeUTF8Data($value);
- }
- }
-
-
- if (get_magic_quotes_gpc() == 1) {
- $newArray = array();
- foreach ($aArray as $sKey => $sValue) {
- if (is_string($sValue))
- $newArray[$sKey] = stripslashes($sValue);
- else
- $newArray[$sKey] = $sValue;
- }
- $aArray = $newArray;
- }
- }
- return $aArray;
- }
-
- function _decodeUTF8Data($sData)
- {
- $sValue = $sData;
- if ($this->bDecodeUTF8Input)
- {
- $sFuncToUse = NULL;
-
- if (function_exists('api_convert_encoding'))
- {
- $sFuncToUse = "api_convert_encoding";
- }
-
- elseif (function_exists('iconv'))
-
- {
- $sFuncToUse = "iconv";
- }
- else if (function_exists('mb_convert_encoding'))
- {
- $sFuncToUse = "mb_convert_encoding";
- }
- else if ($this->sEncoding == "ISO-8859-1")
- {
- $sFuncToUse = "utf8_decode";
- }
- else
- {
- trigger_error("The incoming xajax data could not be converted from UTF-8", E_USER_NOTICE);
- }
- if ($sFuncToUse)
- {
- if (is_string($sValue))
- {
- if ($sFuncToUse == "iconv")
- {
- $sValue = iconv("UTF-8", $this->sEncoding.'//TRANSLIT', $sValue);
- }
- else if ($sFuncToUse == "mb_convert_encoding")
- {
- $sValue = mb_convert_encoding($sValue, $this->sEncoding, "UTF-8");
- }
-
- else if ($sFuncToUse == "api_convert_encoding")
- {
- $sValue = api_convert_encoding($sValue, $this->sEncoding, "UTF-8");
- }
-
- else
- {
- $sValue = utf8_decode($sValue);
- }
- }
- }
- }
- return $sValue;
- }
- }
- function xajaxErrorHandler($errno, $errstr, $errfile, $errline)
- {
- $errorReporting = error_reporting();
- if (($errno & $errorReporting) == 0) return;
- if ($errno == E_NOTICE) {
- $errTypeStr = "NOTICE";
- }
- else if ($errno == E_WARNING) {
- $errTypeStr = "WARNING";
- }
- else if ($errno == E_USER_NOTICE) {
- $errTypeStr = "USER NOTICE";
- }
- else if ($errno == E_USER_WARNING) {
- $errTypeStr = "USER WARNING";
- }
- else if ($errno == E_USER_ERROR) {
- $errTypeStr = "USER FATAL ERROR";
- }
- else if ($errno == E_STRICT) {
- return;
- }
- else {
- $errTypeStr = "UNKNOWN: $errno";
- }
- $GLOBALS['xajaxErrorHandlerText'] .= "\n----\n[$errTypeStr] $errstr\nerror in line $errline of file $errfile";
- }
- ?>
|