本文整理汇总了PHP中xapp_get_option函数的典型用法代码示例。如果您正苦于以下问题:PHP xapp_get_option函数的具体用法?PHP xapp_get_option怎么用?PHP xapp_get_option使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了xapp_get_option函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: rename
public function rename($mount, $filePath, $filename_new, $dest = null, &$errors)
{
$filename_new = XApp_Path_Utils::sanitizeEx(XApp_SystemTextEncoding::magicDequote($filename_new), XApp_Path_Utils::SANITIZE_HTML_STRICT);
$filename_new = substr($filename_new, 0, xapp_get_option(self::NODENAME_MAX_LENGTH, $this));
$old = $this->toRealPath($mount . DIRECTORY_SEPARATOR . $filePath);
if (!is_writable($old)) {
$errors[] = XAPP_TEXT_FORMATTED('FILE_NOT_WRITEABLE', array($old), 55100);
return;
}
if ($dest == null) {
$new = dirname($old) . "/" . $filename_new;
} else {
$new = $this->toRealPath($mount . DIRECTORY_SEPARATOR . $dest);
}
if ($filename_new == "" && $dest == null) {
$errors[] = XAPP_TEXT_FORMATTED('DIRECTORY_NOT_WRITEABLE', array($old), 55100);
return;
}
if (file_exists($new)) {
$errors[] = XAPP_TEXT_FORMATTED('FILE_EXISTS', array($filename_new), 55100);
}
if (!file_exists($old)) {
$errors[] = XAPP_TEXT_FORMATTED('CAN_NOT_FIND_FILE', array(basename($filePath)), 55100);
return;
}
rename($old, $new);
}
示例2: write
public function write($data)
{
$pass = null;
if (xapp_has_option(self::CONF_PASSWORD)) {
$pass = xapp_get_option(self::CONF_PASSWORD);
}
return XApp_Utils_JSONUtils::write_json(xo_get(self::CONF_FILE, $this), $data, 'json', true, $pass);
}
示例3: xo_as_instance
/**
* Turns a xapp option into an instance, expects string
*
* @param null $key
* @param null $mixed
* @param null $default
* @return mixed|null
*/
function xo_as_instance($key = null, &$mixed = null, $default = null, $options)
{
if ($mixed == null) {
$mixed = XApp_Options_Utils::optionCallee();
}
$opt = xapp_get_option($key, $mixed, $default);
if (!empty($opt) && is_string($opt) && class_exists($opt)) {
return new $opt($options);
}
return null;
}
示例4: getWriter
public function getWriter()
{
if ($this->_writer) {
return $this->_writer;
}
$writerClass = xapp_get_option(self::WRITER_CLASS, $this);
if (class_exists($writerClass)) {
$this->_writer = new $writerClass(xapp_get_options());
}
return $this->_writer;
}
示例5: write
public function write($data)
{
$path = xapp_get_option(self::CONF_FILE, $this);
if (file_exists($path)) {
$result = null;
$pretty = true;
if ($pretty) {
$result = file_put_contents($path, Xapp_Util_Json::prettify($data), LOCK_EX);
} else {
$result = file_put_contents($path, $data, LOCK_EX);
}
if ($result !== false) {
$result = null;
return true;
} else {
throw new Xapp_Util_Json_Exception("unable to save to file: " . $path, 1690501);
}
}
return $data;
}
示例6: execute
/**
* executing requested service if found passing result from service invoking to response
* or pass compile smd map to response if no service was called. if a callback was supplied
* will wrap result into callback function
*
* @error 14706
* @return void
*/
protected function execute($call)
{
$get = $this->request()->getGet();
$response = $this->response();
try {
$result = $this->invoke($call, $call[3]);
$this->response()->skipHeader();
if (array_key_exists(xapp_get_option(self::CALLBACK, $this), $get)) {
} else {
$result = $response->encode($result);
}
$response->body($result);
} catch (Exception $e) {
if (xapp_is_option(self::EXCEPTION_CALLBACK, $this)) {
$e = call_user_func_array(xapp_get_option(self::EXCEPTION_CALLBACK, $this), array(&$e, $this, $call));
if (!$e instanceof Exception) {
if (xapp_get_option(self::COMPLY_TO_JSONRPC_1_2, $this)) {
if (array_key_exists($e->getCode(), $this->codeMap)) {
xapp_set_option(Xapp_Rpc_Response::STATUS_CODE, $this->codeMap[$e->getCode()], $response);
} else {
xapp_set_option(Xapp_Rpc_Response::STATUS_CODE, 500, $response);
}
}
if (xapp_is_option(self::ERROR_CALLBACK, $this) && array_key_exists(xapp_get_option(self::ERROR_CALLBACK, $this), $get)) {
$e = $get[xapp_get_option(self::ERROR_CALLBACK, $this)] . '(' . $response->encode($e) . ')';
} else {
if (array_key_exists(xapp_get_option(self::CALLBACK, $this), $get)) {
$e = $get[xapp_get_option(self::CALLBACK, $this)] . '(' . $response->encode($e) . ')';
} else {
$e = $response->encode($e);
}
}
$response->body($e);
}
}
}
}
示例7: __destruct
/**
* class destructor iterates through error stack an sorts all errors according to intended action
* or target. since error have different severity level some errors need to be routed to specific
* log writers only. therefore: the default implementation will route all errors to the designated
* log writer. if the default log writers are overwritten than all errors are written to all registered
* log writers at the same time - regardless of error log severity and mapped error action, e.g. only
* mailing alert errors via email.
*
* @error 11605
* @return void
*/
public function __destruct()
{
$all = array();
$mail = array();
$file = array();
$map = xapp_get_option(self::ACTION_MAP, $this);
foreach ($this->stack as $k => $v) {
if (!array_key_exists((int) $v->severity, $map)) {
$v->severity = self::LOG;
}
if (array_key_exists((int) $v->severity, $map)) {
$v->action = $map[(int) $v->severity];
}
if (isset($v->action) && !is_null($v->action)) {
if (in_array($v->action, array(self::DUMP))) {
xapp_console($v->object, null, 'error');
}
if (in_array($v->action, array(self::LOG, self::LOG | self::MAIL))) {
$file[] = $v->message;
}
if (in_array($v->action, array(self::MAIL, self::LOG | self::MAIL))) {
$mail[] = $v->object;
}
$all[] = $v->object;
}
}
if (xapp_is_option(self::WRITER, $this)) {
$this->write($all);
} else {
if (sizeof($file) > 0) {
$this->write($file, 'file');
}
if (sizeof($mail) > 0) {
if (xapp_is_option(self::EMAIL, $this)) {
$this->write($mail, 'mail');
}
}
}
}
示例8: setup
public function setup()
{
/***
* The very basic paths
*/
if (!defined('XAPP_BASEDIR')) {
define("XAPP_BASEDIR", xapp_get_option(self::BASEDIR, $this));
}
if (!defined('XAPP_LIB')) {
define("XAPP_LIB", XAPP_BASEDIR . DIRECTORY_SEPARATOR . "lib" . DIRECTORY_SEPARATOR);
}
/***
* Load utils
*/
if (!class_exists('XApp_Service_Entry_Utils')) {
include_once XAPP_BASEDIR . 'XApp_Service_Entry_Utils.php';
}
/***
* Get run-time configuration, there is 'debug' and 'release'. For both cases there are
* different resources to load.
*/
$XAPP_RUN_TIME_CONFIGURATION = XApp_Service_Utils::_getKey('rtConfig', XApp_Service_Entry_Utils::getRunTimeConfiguration());
/***
* Now include all xapp stuff
*/
//pull in parts of xapp core framework
XApp_Service_Entry_Utils::includeXAppCore();
//pull in registry of xapp core framework
XApp_Service_Entry_Utils::includeXAppRegistry();
//pull in parts of xapp json framework
XApp_Service_Entry_Utils::includeXAppJSONStoreClasses();
//pull in json utils (to read client app's resource configuration
XApp_Service_Entry_Utils::includeXAppJSONTools();
//some debugging tools
XApp_Service_Entry_Utils::includeXAppDebugTools();
//pull in legacy client app renderer
xapp_import('xapp.app.Renderer');
self::loadCommons();
//pull in xapp commander renderer
/*include_once(XAPP_BASEDIR . DIRECTORY_SEPARATOR . 'app'. DIRECTORY_SEPARATOR . 'Commander.php');*/
//pull in xapp resource renderer
include_once XAPP_BASEDIR . '/Resource/Renderer.php';
//pull in xapp resource renderer
xapp_import('xapp.commander.Resource.Renderer');
//pull in xapp resource renderer
xapp_import('xapp.Resource.Renderer');
//pull in xide resource Renderer
xapp_import('xapp.xide.Resource.Renderer');
//pull in xide resource Renderer
//xapp_import('xapp.xcf.Resource.Renderer');
//pull in cms related resource renderer
include_once XAPP_LIB . DIRECTORY_SEPARATOR . xapp_get_option(self::RESOURCE_RENDERER_PREFIX, $this) . DIRECTORY_SEPARATOR . 'ResourceRenderer.php';
/***
* Prepare resource renderer
*/
//clients resource config path
$XAPP_RESOURCE_CONFIG_PATH = '' . xapp_get_option(self::APPDIR, $this) . DIRECTORY_SEPARATOR;
$XAPP_RESOURCE_CONFIG = xapp_get_option(self::XAPP_RESOURCE_CONFIG, $this);
if (strlen($XAPP_RESOURCE_CONFIG)) {
if ($XAPP_RUN_TIME_CONFIGURATION === 'debug') {
$XAPP_RESOURCE_CONFIG_PATH .= 'lib' . DIRECTORY_SEPARATOR . xapp_get_option(self::APP_NAME, $this) . DIRECTORY_SEPARATOR . $XAPP_RESOURCE_CONFIG . xapp_get_option(self::RESOURCE_CONFIG_SUFFIX, $this) . '.json';
} else {
if ($XAPP_RUN_TIME_CONFIGURATION === 'release') {
$XAPP_RESOURCE_CONFIG_PATH .= DIRECTORY_SEPARATOR . xapp_get_option(self::APP_FOLDER, $this) . DIRECTORY_SEPARATOR . xapp_get_option(self::APP_NAME, $this) . DIRECTORY_SEPARATOR . $XAPP_RESOURCE_CONFIG . xapp_get_option(self::RESOURCE_CONFIG_SUFFIX, $this) . '.json';
}
}
} else {
if ($XAPP_RUN_TIME_CONFIGURATION === 'debug') {
$XAPP_RESOURCE_CONFIG_PATH .= 'lib' . DIRECTORY_SEPARATOR . xapp_get_option(self::APP_NAME, $this) . DIRECTORY_SEPARATOR . 'resources-' . $XAPP_RUN_TIME_CONFIGURATION . xapp_get_option(self::RESOURCE_CONFIG_SUFFIX, $this) . '.json';
} else {
if ($XAPP_RUN_TIME_CONFIGURATION === 'release') {
$XAPP_RESOURCE_CONFIG_PATH .= DIRECTORY_SEPARATOR . xapp_get_option(self::APP_FOLDER, $this) . DIRECTORY_SEPARATOR . xapp_get_option(self::APP_NAME, $this) . DIRECTORY_SEPARATOR . 'resources-' . $XAPP_RUN_TIME_CONFIGURATION . xapp_get_option(self::RESOURCE_CONFIG_SUFFIX, $this) . '.json';
}
}
}
//error_log('$XAPP_RESOURCE_CONFIG ' . $XAPP_RESOURCE_CONFIG . " = " . $XAPP_RESOURCE_CONFIG_PATH);
if (!file_exists($XAPP_RESOURCE_CONFIG_PATH)) {
$this->log('have no core resources, ' . $XAPP_RESOURCE_CONFIG_PATH . ' doesnt exists');
return null;
}
$resources = (object) XApp_Utils_JSONUtils::read_json($XAPP_RESOURCE_CONFIG_PATH, 'json', false, true);
$pluginResources = null;
/***
* Load plugin resources
*/
if (xapp_get_option(self::ALLOW_PLUGINS, $this) && xapp_get_option(self::PLUGIN_DIRECTORY, $this) && xapp_get_option(self::PLUGIN_DIRECTORY, $this)) {
//pull in xapp plugin manager
include_once XAPP_BASEDIR . '/commander/PluginManager.php';
//pull in xapp commander plugin base class
include_once XAPP_BASEDIR . '/commander/Plugin.php';
//pull in RPC interface
if (!class_exists('Xapp_Rpc_Interface_Callable')) {
//pull in xapp commander plugin base class
include_once XAPP_BASEDIR . '/Rpc/Interface/Callable.php';
}
$xComPluginManager = new XApp_Commander_PluginManager();
$loadedPlugins = null;
$plugins = $xComPluginManager->loadPlugins(xapp_get_option(self::PLUGIN_DIRECTORY, $this), xapp_get_option(self::PLUGIN_DIRECTORY, $this), xapp_get_option(self::PLUGIN_MASK, $this));
$pluginResources = $this->getPluginResources($plugins, $XAPP_RUN_TIME_CONFIGURATION, $XAPP_RESOURCE_CONFIG);
}
//.........这里部分代码省略.........
示例9: load
/**
* autoload function registered with autoload handler loads class by looking for class in preloaded class map loaded
* by Xapp_Autoloader::preload.
*
* @error 01706
* @param null|string $class expects class to load
* @return bool
*/
public function load($class = null)
{
$file = null;
if ($class !== null && !empty($class)) {
$class = strtolower(trim((string) $class));
if (strpos($class, xapp_get_option(self::NS_SEPARATOR, $this)) !== false) {
$class = trim($class, xapp_get_option(self::NS_SEPARATOR, $this));
$class = str_replace(xapp_get_option(self::NS_SEPARATOR, $this), xapp_get_option(self::PATH_SEPARATOR, $this), $class);
}
if ((bool) xapp_get_option(self::XAPP_ONLY)) {
if (strpos($class, 'Xapp_') === false) {
return true;
}
}
if (empty($this->_classes)) {
$this->preload();
}
foreach ($this->_dirs as $k => $v) {
if (isset($this->_classes[$k]) && array_key_exists($class, $this->_classes[$k])) {
$file = $this->_classes[$k][$class];
break;
}
if (isset($this->_classes[$k]) && array_key_exists("xapp_ext_{$class}", $this->_classes[$k])) {
$file = $this->_classes[$k]["xapp_ext_{$class}"];
break;
}
}
if ($file !== null && is_file($file)) {
require_once $file;
@clearstatcache();
return true;
}
}
return false;
}
示例10: put
/**
* @return array
* @throws Xapp_XFile_Exception
*/
public function put()
{
xapp_import('xapp.Path.Utils');
xapp_import('xapp.Utils.SystemTextEncoding');
$vars = array_merge($_GET, $_POST);
$dstIn = '/';
$mount = '/';
if (array_key_exists('dstDir', $vars)) {
$dstIn = XApp_Path_Utils::decodeSecureMagic($vars['dstDir']);
}
if (array_key_exists('mount', $vars)) {
$mount = preg_replace('@[/\\\\]@', '', XApp_Path_Utils::decodeSecureMagic($vars['mount']));
}
if ($dstIn === '.') {
$dstIn = '/';
}
$vfs = $this->getFileSystem($mount);
$destination = $vfs->toRealPath(XApp_Path_Utils::normalizePath($mount . DIRECTORY_SEPARATOR . $dstIn));
$errors = array();
if (!$this->isLocal($mount, $this->getFSResources())) {
return $this->putRemote($mount, $destination);
}
//writable check
if (!is_writable($destination)) {
throw new Xapp_XFile_Exception(XAPP_TEXT_FORMATTED('DIRECTORY_NOT_WRITEABLE', array($destination), 55100));
}
//parse files
$fileVars = $_FILES;
foreach ($fileVars as $boxName => $boxData) {
if (substr($boxName, 0, 9) != "userfile_") {
continue;
}
$err = self::parseFileDataErrors($boxData);
if ($err != null) {
$errorMessage = $err[1];
$errors[] = XAPP_TEXT_FORMATTED('Error with upload %s', array($errorMessage));
continue;
}
//basic sanitize
$userfile_name = $boxData["name"];
$userfile_name = XApp_Path_Utils::sanitizeEx(XApp_SystemTextEncoding::fromPostedFileName($userfile_name), XApp_Path_Utils::SANITIZE_HTML_STRICT);
$userfile_name = substr($userfile_name, 0, 128);
//rename if needed!
$autorename = xapp_get_option(self::AUTO_RENAME);
if ($autorename) {
$userfile_name = self::autoRenameForDest($destination, $userfile_name);
}
/***
* file extension check
*/
$ext = pathinfo(strtolower($userfile_name), PATHINFO_EXTENSION);
$allowable = explode(',', xapp_get_option(self::UPLOAD_EXTENSIONS, $this));
if ($ext == '' || $ext == false || !in_array($ext, $allowable)) {
$errors[] = XAPP_TEXT_FORMATTED('UPLOAD_EXTENSIONS_NOT_ALLOWED', array($userfile_name, $ext));
xapp_clog('file not allowed');
continue;
}
try {
//no need anymore
if (file_exists($destination . "/" . $userfile_name)) {
}
} catch (Exception $e) {
$errorMessage = $e->getMessage();
$errors[] = XAPP_TEXT_FORMATTED('UPLOAD_UNKOWN_ERROR', array($userfile_name, $errorMessage));
break;
}
if (isset($boxData["input_upload"])) {
try {
$input = fopen("php://input", "r");
$output = fopen("{$destination}/" . $userfile_name, "w");
$sizeRead = 0;
while ($sizeRead < intval($boxData["size"])) {
$chunk = fread($input, 4096);
$sizeRead += strlen($chunk);
fwrite($output, $chunk, strlen($chunk));
}
fclose($input);
fclose($output);
} catch (Exception $e) {
$errorMessage = $e->getMessage();
$errors[] = XAPP_TEXT_FORMATTED('UPLOAD_UNKOWN_ERROR', array($userfile_name, $errorMessage));
break;
}
} else {
$result = @move_uploaded_file($boxData["tmp_name"], "{$destination}/" . $userfile_name);
if (!$result) {
$realPath = $destination . DIRECTORY_SEPARATOR . $userfile_name;
$result = move_uploaded_file($boxData["tmp_name"], $realPath);
}
if (!$result) {
$errors[] = XAPP_TEXT_FORMATTED('UPLOAD_UNKOWN_ERROR', array($userfile_name));
break;
}
}
}
return $errors;
//.........这里部分代码省略.........
示例11: forget
/**
* remove cache key returning boolean value
*
* @error 16205
* @param string $key expects the cache key name as string
* @return bool
*/
public function forget($key)
{
return (bool) apc_delete(xapp_get_option(self::KEY_PREFIX, $this) . $key);
}
示例12: compileService
/**
* compile service part of smd schema
*
* @error 14806
* @param XO $obj expects reference variable of schema object
* @return void
*/
protected function compileService(&$obj)
{
$tmp = array();
$separator = xapp_get_option(self::CLASS_METHOD_SEPARATOR, $this);
if (xapp_is_option(self::SERVICE_OVER_GET, $this)) {
foreach ($this->map() as $key => $val) {
if (is_array($val)) {
foreach ($val as $k => $v) {
$v->transport = 'POST';
if (xapp_is_option(self::METHOD_TARGET, $this)) {
$v->target = $this->getTarget("{$key}.{$k}");
}
$tmp[$key . $separator . $k] = $v;
}
} else {
$val->transport = 'POST';
if (xapp_is_option(self::METHOD_TARGET, $this)) {
$val->target = $this->getTarget($key);
}
$tmp[$key] = $val;
}
}
} else {
foreach ($this->map() as $key => $val) {
if (is_array($val)) {
foreach ($val as $k => $v) {
$v->transport = 'POST';
$v->target = $this->getTarget();
$tmp[$key . $separator . $k] = $v;
}
} else {
$val->transport = 'POST';
if (xapp_is_option(self::METHOD_TARGET, $this)) {
$val->target = $this->getTarget();
}
$tmp[$key] = $val;
}
}
}
$obj->services = $tmp;
}
示例13: setup
/**
* IPugin interface impl.
*
* setup() must be called before load
*
* @error 15404
* @return integer Returns error code due to the initialization.
*/
function setup()
{
//extract service configuration
$this->serviceConfig = xapp_get_option(self::SERVICE_CONF, $this);
//logging
if (xapp_is_option(self::LOGGING_CONF, $this) && $this->serviceConfig) {
$logConfig = xapp_get_option(self::SERVICE_CONF);
if ($logConfig && $logConfig[XC_CONF_LOGGER] != null) {
$this->logger = $logConfig[XC_CONF_LOGGER];
} else {
//setup logger
}
}
//cache
if (xapp_is_option(self::CACHE_CONF, $this) && $this->serviceConfig) {
$cacheConfig = xapp_get_option(self::CACHE_CONF);
if ($cacheConfig) {
$this->cache = Xapp_Cache::instance($this->CACHE_NS, "file", array(Xapp_Cache_Driver_File::PATH => xapp_get_option(XC_CONF_CACHE_PATH, $this->serviceConfig), Xapp_Cache_Driver_File::CACHE_EXTENSION => $this->CACHE_NS, Xapp_Cache_Driver_File::DEFAULT_EXPIRATION => 200));
}
}
}
示例14: flushHeader
/**
* flush headers by setting default header content type, length and charset and
* all registered custom headers in class options or set via the header method
*
* @error 14511
* @return void
*/
protected function flushHeader()
{
if (!$this->_headerSent) {
$charset = xapp_get_option(self::CHARSET, $this);
$contentType = xapp_get_option(self::CONTENT_TYPE, $this);
$statusCode = xapp_get_option(self::STATUS_CODE, $this);
header("Content-Type: {$contentType}; charset={$charset}", true, (int) $statusCode);
if (ob_get_contents() === '') {
header("Content-Length: " . strlen($this->body()));
}
foreach ($this->_header as $h) {
header(trim($h->name, ' :') . ': ' . $h->value, $h->replace, $h->code);
}
$this->_headerSent = true;
}
}
示例15: compileService
/**
* compile service part of smd schema overwriting parent json compile method
*
* @error 14903
* @param XO $obj expects reference variable of schema object
* @return void
*/
protected function compileService(&$obj)
{
$tmp = array();
$separator = xapp_get_option(self::CLASS_METHOD_SEPARATOR, $this);
foreach ($this->map() as $key => $val) {
if (is_array($val)) {
foreach ($val as $k => $v) {
$v->transport = 'GET';
$v->target = $this->getTarget($key . $separator . $k);
$tmp[$k] = $v;
}
} else {
$val->transport = 'GET';
$val->target = $this->getTarget($key);
$tmp[$key] = $val;
}
}
$obj->service = $tmp;
}