function processRequest()
 {
     if ($this->canProcessRequest()) {
         $aSections =& $this->_getSections($this->sRequest);
         //			echo "<!--" . print_r($aSections, true) . "-->";
         // validate the hash
         $sHash = md5(implode($aSections));
         if (false == $this->bValidateHash || $sHash == $this->sHash) {
             $sType = 'text/javascript';
             if ('style' == $this->sRequest) {
                 $sType = 'text/css';
             }
             $objResponse =& new xajaxCustomResponse($sType);
             foreach ($aSections as $sSection) {
                 $objResponse->append($sSection . "\n");
             }
             $objResponseManager =& xajaxResponseManager::getInstance();
             $objResponseManager->append($objResponse);
             header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 60 * 60 * 24) . ' GMT');
             return true;
         }
         return 'Invalid script or style request.';
         trigger_error('Hash mismatch: ' . $this->sRequest . ': ' . $sHash . ' <==> ' . $this->sHash, E_USER_ERROR);
     }
 }
 public function call($aArgs = array())
 {
     $objResponseManager = xajaxResponseManager::getInstance();
     if (NULL != $this->sInclude) {
         ob_start();
         require_once $this->sInclude;
         $sOutput = ob_get_clean();
         //SkipDebug
         if (0 < strlen($sOutput)) {
             $sOutput = 'From include file: ' . $this->sInclude . ' => ' . $sOutput;
             $objResponseManager->debug($sOutput);
         }
         //EndSkipDebug
     }
     $mFunction = $this->uf;
     $objResponseManager->append(call_user_func_array($mFunction, $aArgs));
 }
Exemplo n.º 3
0
 function xajaxCustomResponse($sContentType)
 {
     $this->sOutput = '';
     $this->sContentType = $sContentType;
     $objResponseManager = xajaxResponseManager::getInstance();
     $this->sCharacterEncoding = $objResponseManager->getCharacterEncoding();
     $this->bOutputEntities = $objResponseManager->getOutputEntities();
 }
Exemplo n.º 4
0
 function fire($aArgs)
 {
     $objResponseManager = xajaxResponseManager::getInstance();
     foreach (array_keys($this->aHandlers) as $sKey) {
         $this->aHandlers[$sKey]->call($aArgs);
     }
 }
Exemplo n.º 5
0
 function __wakeup()
 {
     ob_start();
     $sLocalFolder = dirname(__FILE__);
     //SkipAIO
     require $sLocalFolder . '/xajaxPluginManager.inc.php';
     require $sLocalFolder . '/xajaxLanguageManager.inc.php';
     require $sLocalFolder . '/xajaxArgumentManager.inc.php';
     require $sLocalFolder . '/xajaxResponseManager.inc.php';
     require $sLocalFolder . '/xajaxRequest.inc.php';
     require $sLocalFolder . '/xajaxResponse.inc.php';
     //EndSkipAIO
     // this is the list of folders where xajax will look for plugins
     // that will be automatically included at startup.
     $aPluginFolders = array();
     $aPluginFolders[] = dirname($sLocalFolder) . '/xajax_plugins';
     //SkipAIO
     $aPluginFolders[] = $sLocalFolder . '/plugin_layer';
     //EndSkipAIO
     // Setup plugin manager
     $this->objPluginManager =& xajaxPluginManager::getInstance();
     $this->objPluginManager->loadPlugins($aPluginFolders);
     $this->objLanguageManager =& xajaxLanguageManager::getInstance();
     $this->objArgumentManager =& xajaxArgumentManager::getInstance();
     $this->objResponseManager =& xajaxResponseManager::getInstance();
     $this->sCoreIncludeOutput = ob_get_clean();
 }
Exemplo n.º 6
0
 function call($sMethod, $aArgs)
 {
     $objResponseManager =& xajaxResponseManager::getInstance();
     $objResponseManager->append(call_user_func_array(array(&$this->obj, $sMethod), $aArgs));
 }
 function call($aArgs = array())
 {
     $objResponseManager =& xajaxResponseManager::getInstance();
     if (NULL != $this->sInclude) {
         ob_start();
         require_once $this->sInclude;
         $sOutput = ob_get_clean();
         if (0 < strlen($sOutput)) {
             $sOutput = 'From include file: ' . $this->sInclude . ' => ' . $sOutput;
             $objResponseManager->debug($sOutput);
         }
     }
     $mFunction = $this->uf;
     // where an alias is specified, strip off the alias (first parameter)
     if (is_array($mFunction) && 2 < count($mFunction)) {
         $mFunction = array_slice($mFunction, 1);
     }
     $objResponseManager->append(call_user_func_array($mFunction, $aArgs));
 }
Exemplo n.º 8
0
 function processRequest()
 {
     // Check to see if headers have already been sent out, in which case we can't do our job
     if (headers_sent($filename, $linenumber)) {
         echo "Output has already been sent to the browser at {$filename}:{$linenumber}.\n";
         echo 'Please make sure the command $xajax->processRequest() is placed before this.';
         exit;
     }
     if ($this->canProcessRequest()) {
         $objPluginManager =& xajaxPluginManager::getInstance();
         $objResponseManager =& xajaxResponseManager::getInstance();
         // Use xajax error handler if necessary
         if ($this->bErrorHandler) {
             $GLOBALS['xajaxErrorHandlerText'] = "";
             set_error_handler("xajaxErrorHandler");
         }
         $mResult = true;
         // handle beforeProcessing event
         if (isset($this->aProcessingEvents[XAJAX_PROCESSING_EVENT_BEFORE])) {
             $bEndRequest = false;
             $this->aProcessingEvents[XAJAX_PROCESSING_EVENT_BEFORE]->call(array(&$bEndRequest));
             $mResult = false === $bEndRequest;
         }
         if (true === $mResult) {
             $mResult = $objPluginManager->processRequest();
         }
         if (true === $mResult) {
             if ($this->bCleanBuffer) {
                 while (@ob_end_clean()) {
                 }
             }
             // handle afterProcessing event
             if (isset($this->aProcessingEvents[XAJAX_PROCESSING_EVENT_AFTER])) {
                 $bEndRequest = false;
                 $this->aProcessingEvents[XAJAX_PROCESSING_EVENT_AFTER]->call(array(&$bEndRequest));
                 if (true === $bEndRequest) {
                     $objResponseManager =& xajaxResponseManager::getInstance();
                     $objResponseManager->clear();
                     $objResponseManager->append($aResult[1]);
                 }
             }
         } else {
             if (is_string($mResult)) {
                 if ($this->bCleanBuffer) {
                     while (@ob_end_clean()) {
                     }
                 }
                 // $mResult contains an error message
                 // the request was missing the cooresponding handler function
                 // or an error occurred while attempting to execute the
                 // handler.  replace the response, if one has been started
                 // and send a debug message.
                 $objResponseManager->clear();
                 $objResponse =& new xajaxResponse();
                 $objResponseManager->append($objResponse);
                 // handle invalidRequest event
                 if (isset($this->aProcessingEvents[XAJAX_PROCESSING_EVENT_INVALID])) {
                     $this->aProcessingEvents[XAJAX_PROCESSING_EVENT_INVALID]->call();
                 } else {
                     $objResponseManager->debug($mResult);
                 }
             }
         }
         if ($this->bErrorHandler) {
             $sErrorMessage = $GLOBALS['xajaxErrorHandlerText'];
             if (!empty($sErrorMessage)) {
                 if (0 < strlen($this->sLogFile)) {
                     $fH = @fopen($this->sLogFile, "a");
                     if (NULL != $fH) {
                         fwrite($fH, "** xajax Error Log - " . strftime("%b %e %Y %I:%M:%S %p") . " **" . $sErrorMessage . "\n\n\n");
                         fclose($fH);
                     } else {
                         $objResponseManager->debug("** Logging Error **\n\nxajax was unable to write to the error log file:\n" . $this->sLogFile);
                     }
                 }
                 $objResponseManager->debug("** PHP Error Messages: **" . $sErrorMessage);
             }
         }
         $objResponseManager->send();
         if ($this->bErrorHandler) {
             restore_error_handler();
         }
         if ($this->bExitAllowed) {
             exit;
         }
     }
 }