/** * * @access public * * @return bool * */ public static function notifyObservers($event = 'default', $arg = null, $className = 'XOAD_Observable') { if (empty($GLOBALS['_XOAD_OBSERVERS'])) { return true; } $globalObservers =& $GLOBALS['_XOAD_OBSERVERS']; $className = strtolower($className); if (empty($globalObservers[$className])) { return true; } $returnValue = true; foreach ($globalObservers[$className] as $observer) { $eventValue = $observer->updateObserver($event, $arg); if (XOAD_Utilities::getType($eventValue) == 'bool') { $returnValue &= $eventValue; } } return $returnValue; }
/** * * @access public * * @return string * */ public function findMethodName($methodName) { if (!empty($this->methodsMap)) { $name = XOAD_Utilities::caseConvert($methodName); if (isset($this->methodsMap[$name])) { return $this->methodsMap[$name]; } } return $methodName; }
class Timeout { function Invoke() { sleep(5); return 'OK'; } function Invoke2() { sleep(5); return 'OK'; } } define('XOAD_AUTOHANDLE', true); require_once '../xoad.php'; echo XOAD_Utilities::header('..') . "\n"; ?> <script type="text/javascript"> var obj = <?php echo XOAD_Client::register(new Timeout()); ?> ; function handleError(error) { if (error.code == XOAD_ERROR_TIMEOUT) { alert('Global: Timeout.'); } };
/** * Registers a custom client control. * * <p>Each control includes a JS file that defines the class that * will handle the control. Additionally, you can attach a server class and * a HTML code.</p> * * @access public * * @param string $tagPrefix The tag prefix for the control, required. * @param mixed $tagName The tag name for the control, required. * @param string $jsFile The relative path to the JS file that * defines the class that will handle the * control, required. * @param string $phpFile The relative/absolute path to the PHP file * that defines the server class that is * associated with the control, optional. * @param string $url The callback URL for the server class, * optional. * @param string $htmlFile The relative/absolute path to the HTML file * that defines the code that is associated * with the control, optional. * * @return string HTML code to register the custom control. * * @static * */ public static function register($tagPrefix = 'xoad', $tagName = null, $jsFile = null, $phpFile = null, $url = null, $htmlFile = null) { if (empty($phpFile) && empty($jsFile)) { return null; } if (XOAD_Utilities::getType($tagName) == 's_array') { $returnValue = ''; foreach ($tagName as $name) { $returnValue .= XOAD_Controls::register($tagPrefix, $name, $jsFile, $phpFile, $url, $htmlFile); } return $returnValue; } if (XOAD_Utilities::getType($tagName) == 'a_array') { $returnValue = ''; foreach ($tagName as $prefix => $name) { $returnValue .= XOAD_Controls::register($prefix, $name, $jsFile, $phpFile, $url, $htmlFile); } return $returnValue; } if (empty($tagPrefix) || empty($tagName)) { return null; } $registerAttribute = $tagName == '@'; $controlName = strtolower($tagPrefix) . ':' . strtolower($tagName); if (!$registerAttribute && in_array($controlName, $GLOBALS['_XOAD_CONTROLS_LIST'])) { return null; } $phpControlName = $tagPrefix . '_Controls_' . $tagName; $jsControlName = $tagPrefix . '.controls.' . $tagName; $includeScript = ''; $returnValue = ''; if (!empty($phpFile)) { require_once XOAD_Controls::getFileName($phpFile); if (empty($url)) { $url = XOAD_Utilities::getRequestUrl(); } $phpObject = new $phpControlName(); XOAD_Client::privateMethods($phpObject, array('getJSCode', 'getHtmlCode')); $returnValue .= XOAD_Client::register($phpControlName, $url) . ';'; } if (!empty($jsFile)) { if (!in_array($jsFile, $GLOBALS['_XOAD_CONTROLS_SCRIPT'])) { $includeScript .= '<script type="text/javascript" src="' . htmlspecialchars($jsFile) . '"></script>'; $GLOBALS['_XOAD_CONTROLS_SCRIPT'][] = $jsFile; } } else { if (isset($phpObject) && method_exists($phpObject, 'getJSCode')) { $returnValue .= $phpObject->getJSCode($jsControlName, $phpControlName); } } $controlHtml = null; if (!empty($htmlFile)) { $controlHtml = @join(null, @file(XOAD_Controls::getFileName($htmlFile))); } else { if (isset($phpObject) && method_exists($phpObject, 'getHtmlCode')) { $controlHtml = $phpObject->getHtmlCode($jsControlName, $phpControlName); } } if (!$registerAttribute) { $returnValue .= 'xoad.controls.list[' . sizeof($GLOBALS['_XOAD_CONTROLS_LIST']) . '] = {'; $returnValue .= 'tagName:' . XOAD_Client::register($controlName); if (!empty($jsFile)) { $returnValue .= ',clientClass:' . XOAD_Client::register($jsControlName); } if (!empty($phpFile)) { $returnValue .= ',serverClass:' . XOAD_Client::register($phpControlName); } if (!empty($controlHtml)) { $returnValue .= ',html:' . XOAD_Client::register($controlHtml); } $returnValue .= '};'; } if (!empty($returnValue)) { $returnValue = '<script type="text/javascript">' . $returnValue . '</script>'; } $returnValue = $includeScript . $returnValue; $GLOBALS['_XOAD_CONTROLS_LIST'][] = $controlName; return $returnValue; }
<?php /** * XOAD_Controls Extension File. * * <p>This file initialized the XOAD_Controls extension * and loads all necessary classes.</p> * <p>Note that this file is not included directly. * You should add the extension manually to the * extensions configuration file.</p> * * @author Stanimir Angeloff * * @package XOAD * * @subpackage XOAD_Controls * * @version 0.6.0.0 * */ /** * Loads the file that defines the {@link XOAD_Controls} class. */ require_once XOAD_CONTROLS_BASE . '/classes/Controls.class.php'; XOAD_Utilities::extensionHeader('controls', 'js/controls.js', 'js/controls_optimized.js'); XOAD_Utilities::customHeader('/extensions/js/cssQuery.js'); XOAD_Utilities::extensionHeader('controls', 'js/library/xoad.controls.js', 'js/library/xoad.controls_optimized.js');
/** * Assigns methods map to the class meta data. * * @param object $var The object where the meta data is stored. * * @param array $methodsMap The class methods map. * * @return void * * @static * */ public static function mapMethods(&$var, $methodsMap) { if (XOAD_Utilities::getType($var) != 'object') { return false; } if (!isset($var->xoadMeta)) { require_once XOAD_BASE . '/classes/Meta.class.php'; $var->xoadMeta = new XOAD_Meta(); } $var->xoadMeta->setMethodsMap($methodsMap); return true; }
} else { echo $all; } } exit; } } else { xRegistry::set('TPA', $TPA = new tPageAgregator()); if (isset($_GET['action'])) { $TPA->dispatch_action($_GET['action']); } elseif ($page = $TPA->execute_page(xConfig::get('PATH', 'baseUrl'))) { if ($TPA->FED_MODE) { $xConnector = new Connector(); $xConnector_obj = XOAD_Client::register($xConnector, array('url' => '/admin.php')); $TMS->AddFileSection($_PATH['ADM'] . 'tpl/FED.html'); $TMS->AddMassReplace('FED', array('front_obj' => XOAD_Client::register(new front_api()), 'xConnector' => $xConnector_obj, 'xoad_header' => XOAD_Utilities::header($_WEBPATH['XOAD']))); $page = preg_replace(array('#<script[^>]*>.*?</script>#is'), array(''), $page); $page .= $TMS->parseSection('FED'); } $all = $page; if (xConfig::get('GLOBAL', 'enable_page_caching') && !$TPA->DisablePageCaching && !$TPA->FED_MODE) { $cache->toCache($all); } if (xConfig::get('GLOBAL', 'show_debug_info')) { $y = Common::getmicrotime() - $x; $all .= '<!-- ' . $y . ' -->'; } if (xConfig::get('GLOBAL', 'output_html_compress')) { $all = Common::compress_output($all); } echo $all;
echo '<?'; ?> xml version="1.0" encoding="utf-8"<?php echo '?>'; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US"> <head> <title>XOAD Advanced Chat</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <?php echo XOAD_Utilities::header('../..'); ?> <?php echo XOAD_Utilities::eventsHeader(); ?> <script type="text/javascript"> xoad.events.refreshInterval = 1000; var client = <?php echo XOAD_Client::register(new ChatClient(), array('class' => 'ChatClient')); ?> ; var users = []; var emoticons = [ [':angry:', 'angry'],
{ if ($a == 0) { return false; } $this->result /= $a; return true; } public function Clear() { $this->result = 0; return true; } } define('XOAD_AUTOHANDLE', true); require_once '../../xoad.php'; echo XOAD_Utilities::header('../..'); ?> <input type="text" id="operationValue" value="1" style="font: normal 0.8em tahoma, verdana, arial, serif; width: 10em;" /> <span id="operationResult" style="font: normal 0.8em tahoma, verdana, arial, serif;"></span> <br /> <button onclick="add()" style="font: normal 1em tahoma, verdana, arial, serif; width: 2em;">+</button> <button onclick="sub()" style="font: normal 1em tahoma, verdana, arial, serif; width: 2em;">-</button> <button onclick="mul()" style="font: normal 1em tahoma, verdana, arial, serif; width: 2em;">*</button> <button onclick="div()" style="font: normal 1em tahoma, verdana, arial, serif; width: 2em;">/</button> <br />
/** * XOAD_HTML Extension File. * * <p>This file initialized the XOAD_HTML extension * and installs all necessary server observers.</p> * <p>Note that this file is not included directly. * You should add the extension manually to the * extensions configuration file.</p> * * @author Stanimir Angeloff * * @package XOAD * * @subpackage XOAD_HTML * * @version 0.6.0.0 * */ /** * Load the file that defines the XOAD_HTML Server observer. */ require_once XOAD_HTML_BASE . '/classes/ServerObserver.class.php'; /** * Loads the file that defines the {@link XOAD_HTML} class. */ require_once XOAD_HTML_BASE . '/classes/HTML.class.php'; XOAD_Server::addObserver(new XOAD_HTML_ServerObserver()); XOAD_Utilities::extensionHeader('html', 'js/html.js', 'js/html_optimized.js'); XOAD_Utilities::customHeader('/extensions/js/cssQuery.js');
/** * Adds specified classes to the denied classes map. * * <p>Example:</p> * <code> * <?php * * class AllowedClass * { * function call() { return 'AllowedClass->call()'; } * } * * class DeniedClass * { * function call() { return 'DeniedClass->call()'; } * } * * require_once('xoad.php'); * * XOAD_Server::denyClasses('DeniedClass'); * * if (XOAD_Server::runServer()) { * * exit; * } * * ?> * <?= XOAD_Utilities::header() ?> * * <script type="text/javascript"> * * var allowedClass = <?= XOAD_Client::register(new AllowedClass()) ?>; * * var deniedClass = <?= XOAD_Client::register(new DeniedClass()) ?>; * * alert(allowedClass.call()); * * // This line will throw an exception. * // DeniedClass is in the denied classes list. * alert(deniedClass.call()); * * </script> * </code> * * @access public * * @param mixed $classes The classes that can NOT be accessed * within a callback request. * * @return void * * @static * */ public static function denyClasses($classes) { $classesType = XOAD_Utilities::getType($classes); if (!isset($GLOBALS['_XOAD_SERVER_DENIED_CLASSES'])) { $GLOBALS['_XOAD_SERVER_DENIED_CLASSES'] = array(); } $deniedClasses =& $GLOBALS['_XOAD_SERVER_DENIED_CLASSES']; if ($classesType == 'string') { $deniedClasses[] = strtolower($classes); } else { if ($classesType == 's_array' || $classesType == 'a_array') { foreach ($classes as $class) { $deniedClasses[] = strtolower($class); } } } }
/** * Registers XOAD Events header data. * * <p>You should call this method after {@link XOAD_Utilities::header}.</p> * <p>XOAD Events header data includes server time and callback URL.</p> * * @access public * * @param string $callbackUrl XOAD Events callback URL. * * @return string HTML code to initialize XOAD Events. * * @static * */ public static function eventsHeader($callbackUrl = null) { if ($callbackUrl == null) { $callbackUrl = XOAD_Utilities::getRequestUrl(); } $returnValue = '<script type="text/javascript">'; $returnValue .= 'xoad.events.callbackUrl = ' . XOAD_Client::register($callbackUrl) . ';'; $returnValue .= 'xoad.events.lastRefresh = ' . XOAD_Client::register(XOAD_Utilities::getMicroTime()) . ';'; $returnValue .= '</script>'; return $returnValue; }
if ($_module->_tree) { $_module->_tree->WriteNodeParam(1, 'Name', $module['alias'] . '(' . $_SERVER["HTTP_HOST"] . ')'); } $this->result['modules'][] = 'Модуль ' . $module['name'] . " инициализирован\r\n"; } } } } } function xoadGetMeta() { XOAD_Client::mapMethods($this, array('execute')); XOAD_Client::publicMethods($this, array('execute')); } } $TMS->AddFileSection('install/install.html'); session_start(); $inst = new x3minstall(); if ($_REQUEST['xoadCall']) { ob_start(); if (XOAD_Server::runServer()) { $all = ob_get_contents(); ob_end_clean(); echo $all; exit; } } else { $TMS->AddReplace('main', 'xoadHeader', XOAD_Utilities::header("http://" . $_SERVER["HTTP_HOST"] . '/inc/xoad/')); $TMS->AddReplace('main', 'xObject', XOAD_Client::register($inst)); echo $inst->start_install($data); }
function getAdminPanelData() { static $apd = array(); if (!$apd) { $apd['version'] = xCore::getVersion(); $apd['charset'] = xConfig::get('GLOBAL', 'site_encoding'); $apd['lisence'] = xCore::getLicense(); if (class_exists('XOAD_Utilities')) { $apd['xoadHeader'] = XOAD_Utilities::header(xConfig::get('WEBPATH', 'XOAD')); } $apd['lang'] = $_SESSION['lang']; $apd['siteByDefault'] = HOST; $apd['XJS'] = xConfig::get('WEBPATH', 'XJS'); } return $apd; }
/** * This method should be called from each successor to add * common data to the event. * * <p>When you call this method you should pass an associative * array that contains the event data. This method will populate * it with the missing information and will check the validity of * the presented.</p> * * @access public * * @return bool true on success, false otherwise * */ public function filterMultipleEvents(&$event) { if (!isset($event['time']) || $event['time'] === null) { $event['time'] = XOAD_Utilities::getMicroTime(); } return true; }
function processMainTemplate() { $this->_TMS->MFFields = array(); $this->_TMS->MFReplacement = array(); $pages = xCore::moduleFactory('pages.front'); jsCollector::pushJsDir('main', xConfig::get('PATH', 'TEMPLATES') . '_base/js', 1); $this->globalFields['HOST'] = HOST; $this->globalFields['PAGE'] = $pages->page; $this->globalFields['DOMAIN'] = $pages->domain; $this->globalFields['LANGVERSION'] = $pages->langVersion; $this->globalFields['JS'] = jsCollector::get('main'); /** * Подключение шаблона страницы если она не является страницей на главном шаблоне */ if (!strstr($this->mainTemplate['path'], '_index.html')) { $this->_TMS->AddFileSection(xConfig::get('PATH', 'COMMON_TEMPLATES') . $this->mainTemplate['path']); } if ($this->externalMeta['Title']) { $this->globalFields['Title'] = $this->externalMeta['Title']; } if ($this->externalMeta['Keywords']) { $this->globalFields['Keywords'] = $this->externalMeta['Keywords']; } if ($this->externalMeta['Description']) { $this->globalFields['Description'] = $this->externalMeta['Description']; } global $cache; //догружаем не объявленные секции /* if(!$_COMMON_SITE_CONF['disable_m_caching']) { // $cache_name=md5($_SERVER['REQUEST_URI']).$_SESSION['currency']['id'].'titles.xtx'; // $cache->setCacheFile($cache_name); if($m_cache=$cache->getCache()) { $seodata=unserialize($m_cache); $this->globalFields['Title']=$seodata['Title']; $this->globalFields['Keywords']=$seodata['Keywords']; $this->globalFields['Description']=$seodata['Description']; }else{ // $cache->setCache(serialize(array('Title'=>$this->globalFields['Title'],'Keywords'=>$this->globalFields['Keywords'],'Description'=>$this->globalFields['Description']))); } } */ /** * Подключение главного шаблона для домена */ $this->_TMS->AddFileSection(xConfig::get('PATH', 'COMMON_TEMPLATES') . $pages->domain['basic'] . '/_index.html'); /** * Подключение главного шаблона кроссдоменного */ if (file_exists($mainTemplate = xConfig::get('PATH', 'TEMPLATES') . '/_index.html')) { $this->_TMS->AddFileSection($mainTemplate); } //компонуем модули $this->_TMS->AddMFMassReplace($this->modules_out); //данные ноды в странице $this->globalFields['ARES'] = xConfig::get('PATH', 'WEB_ARES'); $this->_TMS->AddFileSection(xConfig::get('PATH', 'TEMPLATES') . '_base/tpl/connector.html'); $this->_TMS->AddMassReplace('connector', array('xConnector' => XOAD_Client::register(new connector()), 'xoadHeader' => XOAD_Utilities::header(xConfig::get('WEBPATH', 'XOAD')))); $this->globalFields['XFRONT_API'] = $this->_TMS->parseSection('connector'); if ($this->_TMS->SectionNests['MAIN']) { foreach ($this->_TMS->SectionNests['MAIN'] as $section) { $this->_TMS->AddMassReplace($section, $this->globalFields); } } // $this->_TMS->AddMFMassReplace($_COMMON_SITE_CONF); return $this->_TMS->ParseRecurs('MAIN'); }
/** * Serializes a PHP variable into a {@link http://www.json.org JSON} string. * * <p>Example:</p> * <code> * <script type="text/javascript"> * <?php require_once('xoad.php'); ?> * * var arr = <?= XOAD_Serializer::serialize(array(1, 2, "string", array("Nested"))) ?>; * * alert(arr); * * </script> * </code> * * @access public * * @param mixed $var Variable to serialize. * * @return string {@link http://www.json.org JSON} string that * represents the variable. * * @static * */ public static function serialize(&$var) { $type = XOAD_Utilities::getType($var); if ($type == 'bool') { if ($var) { return "true"; } else { return "false"; } } else { if ($type == 'int') { return sprintf('%d', $var); } else { if ($type == 'float') { return sprintf('%f', $var); } else { if ($type == 'string') { if (strlen($var) >= strlen(XOAD_SERIALIZER_SKIP_STRING)) { if (strcasecmp(substr($var, 0, strlen(XOAD_SERIALIZER_SKIP_STRING)), XOAD_SERIALIZER_SKIP_STRING) == 0) { return substr($var, strlen(XOAD_SERIALIZER_SKIP_STRING), strlen($var) - strlen(XOAD_SERIALIZER_SKIP_STRING)); } } // This code is based on morris_hirsch's // comment in utf8_decode function documentation. // // http://bg.php.net/utf8_decode // // Thank you. // $ascii = ''; $length = strlen($var); for ($iterator = 0; $iterator < $length; $iterator++) { $char = $var[$iterator]; $charCode = ord($char); if ($charCode == 0x8) { $ascii .= '\\b'; } else { if ($charCode == 0x9) { $ascii .= '\\t'; } else { if ($charCode == 0xa) { $ascii .= '\\n'; } else { if ($charCode == 0xc) { $ascii .= '\\f'; } else { if ($charCode == 0xd) { $ascii .= '\\r'; } else { if ($charCode == 0x22 || $charCode == 0x2f || $charCode == 0x5c) { $ascii .= '\\' . $var[$iterator]; } else { if ($charCode < 128) { $ascii .= $char; } else { if ($charCode >> 5 == 6) { $byteOne = $charCode & 31; $iterator++; $char = $var[$iterator]; $charCode = ord($char); $byteTwo = $charCode & 63; $charCode = $byteOne * 64 + $byteTwo; $ascii .= sprintf('\\u%04s', dechex($charCode)); } else { if ($charCode >> 4 == 14) { $byteOne = $charCode & 31; $iterator++; $char = $var[$iterator]; $charCode = ord($char); $byteTwo = $charCode & 63; $iterator++; $char = $var[$iterator]; $charCode = ord($char); $byteThree = $charCode & 63; $charCode = ($byteOne * 64 + $byteTwo) * 64 + $byteThree; $ascii .= sprintf('\\u%04s', dechex($charCode)); } else { if ($charCode >> 3 == 30) { $byteOne = $charCode & 31; $iterator++; $char = $var[$iterator]; $charCode = ord($char); $byteTwo = $charCode & 63; $iterator++; $char = $var[$iterator]; $charCode = ord($char); $byteThree = $charCode & 63; $iterator++; $char = $var[$iterator]; $charCode = ord($char); $byteFour = $charCode & 63; $charCode = (($byteOne * 64 + $byteTwo) * 64 + $byteThree) * 64 + $byteFour; $ascii .= sprintf('\\u%04s', dechex($charCode)); } } } } } } } } } } } return '"' . $ascii . '"'; } else { if ($type == 's_array') { $index = 0; $length = sizeof($var); $returnValue = '['; foreach ($var as $value) { $returnValue .= XOAD_Serializer::serialize($value); if ($index < $length - 1) { $returnValue .= ','; } $index++; } $returnValue .= ']'; return $returnValue; } else { if ($type == 'a_array') { $index = 0; $length = sizeof($var); $returnValue = '{'; foreach ($var as $key => $value) { $returnValue .= XOAD_Serializer::serialize($key); $returnValue .= ':'; $returnValue .= XOAD_Serializer::serialize($value); if ($index < $length - 1) { $returnValue .= ','; } $index++; } $returnValue .= '}'; return $returnValue; } else { if ($type == 'object') { $objectVars = get_object_vars($var); return XOAD_Serializer::serialize($objectVars); } } } } } } } return "null"; }