Exemple #1
0
 public function ls($path = null)
 {
     xapp_import('xapp.Directory.Utils');
     xapp_import('xapp.VFS.Local');
     //we listen to VFS messages
     Xapp_Hook::connect(XApp_VFS_Base::EVENT_ON_NODE_META_CREATED, $this, "_onItem");
     Xapp_Hook::connect(XApp_VFS_Base::EVENT_ON_NODE_ADD, $this, "_addNode");
     //create a single scope for now
     //prepare vfs
     $vfsItems = array();
     //mount one item at root, the system scope.
     $vfsItems[] = array('name' => 'root', 'path' => $path . DIRECTORY_SEPARATOR);
     //vfs ctor
     $this->_vfs = XApp_VFS_Local::factory($vfsItems);
     //vfs dir scanning options
     $directoryOptions = array(XApp_Directory_Utils::OPTION_ONLY_DIRS => false, XApp_Directory_Utils::OPTION_ONLY_FILES => false, XApp_Directory_Utils::OPTION_RECURSIVE => true, XApp_Directory_Utils::OPTION_CLEAR_PATH => true);
     //prepare result
     $this->_currentNodes = array();
     $this->_currentNodes['items'] = array();
     //fire vfs
     $items = $this->_vfs->ls('root/', true, array(XApp_File_Utils::OPTION_DIR_LIST_FIELDS => XAPP_XFILE_SHOW_ISDIR, XApp_File_Utils::OPTION_DIR_LIST => $directoryOptions, XApp_Directory_Utils::OPTION_INCLUDE_LIST => array('*')));
     //complete tree-store data
     $this->_currentNodes['identifier'] = 'path';
     $this->_currentNodes['label'] = 'name';
     return $this->_currentNodes;
 }
Exemple #2
0
 /**
  * class constructor will include the external console class, initialize it and store
  * its instance as $console property. the class can not be instantiated other
  * then using singleton method create. the loaded console class will be init and map
  * with its log types to this classed log types.
  *
  * @error 10901
  * @param string $driver expects the driver string to load
  * @param array $options expects an driver dependent option array
  * @throws Xapp_Error
  */
 protected function __construct($driver, array $options = array())
 {
     $this->_driver = strtolower(trim($driver));
     switch ($this->_driver) {
         case 'firephp':
             xapp_import('firephp.firephp-core.*');
             if (sizeof(ob_list_handlers()) === 0) {
                 ob_start();
             }
             $this->console = FirePHP::init();
             $this->console->setOptions($options);
             self::$_typeMap = array_merge(self::$_typeMap, array('log' => FirePHP::LOG, 'warn' => FirePHP::WARN, 'info' => FirePHP::INFO, 'error' => FirePHP::ERROR, 'dump' => FirePHP::DUMP, 'trace' => FirePHP::TRACE, 'group' => FirePHP::GROUP_START, 'ungroup' => FirePHP::GROUP_END));
             break;
         case 'chromephp':
             xapp_import('xapp.Ext.ChromePhp');
             $this->console = ChromePhp::getInstance();
             if (!isset($options[ChromePhp::BACKTRACE_LEVEL])) {
                 $options[ChromePhp::BACKTRACE_LEVEL] = 2;
             }
             $this->console->addSettings($options);
             self::$_typeMap = array_merge(self::$_typeMap, array('log' => ChromePhp::LOG, 'warn' => ChromePhp::WARN, 'info' => ChromePhp::INFO, 'error' => ChromePhp::ERROR, 'dump' => ChromePhp::INFO, 'trace' => ChromePhp::INFO, 'group' => ChromePhp::GROUP, 'ungroup' => ChromePhp::GROUP_END));
             break;
         default:
             throw new Xapp_Error(xapp_sprintf(_("xapp console driver: %s not supported"), $driver), 1090101);
     }
 }
Exemple #3
0
 public static function download($url, $timeout = 3000)
 {
     xapp_import('xapp.Commons.Error');
     xapp_import('xapp.Utils.Strings');
     xapp_import('xapp.Http.MiniHTTP');
     xapp_import('xapp.Directory.Utils');
     xapp_import('xapp.File.Utils');
     if (!$url) {
         return new XApp_Error('http_no_url', 'Invalid URL Provided.');
     }
     $tmpfname = XApp_Directory_Utils::tempname($url);
     if (!$tmpfname) {
         return new XApp_Error_Base('http_no_file', 'Could not create Temporary file.');
     }
     $http = new XApp_Http();
     $response = $http->request($url, array('timeout' => $timeout, 'stream' => true, 'filename' => $tmpfname));
     /*xapp_clog($response);*/
     if (XApp_Error_Base::is_error($response)) {
         unlink($tmpfname);
         return $response;
     }
     /*
     		if ( 200 != self::remote_retrieve_response_code( $response ) ){
     			unlink( $tmpfname );
     			return self::remote_retrieve_response_message( $response );
     		}*/
     $content_md5 = self::remote_retrieve_header($response, 'content-md5');
     if ($content_md5) {
         $md5_check = XApp_File_Utils::verify_file_md5($tmpfname, $content_md5);
         if (XApp_Error::is_error($md5_check)) {
             unlink($tmpfname);
             return $md5_check;
         }
     }
     return $tmpfname;
 }
Exemple #4
0
<?php

/**
 * @version 0.1.0
 *
 * @author Luis Ramos
 * @author Guenter Baumgart
 * @license : GPL v2. http://www.gnu.org/licenses/gpl-2.0.html
 * @package XApp\xide\Controller
 */
xapp_import("xapp.Commons.Entity");
xapp_import('xapp.Utils.Strings');
xapp_import('xapp.xide.Base.Scoped');
/***
 * Class XIDE_Manager
 */
class XIDE_Manager extends XIDE_Scoped
{
    public $logger = null;
    /**
     * @param $message
     * @param string $prefix
     * @param bool $stdError
     * @return null
     */
    public function log($message, $prefix = '', $stdError = true)
    {
        if (function_exists('xp_log')) {
            xp_log(__CLASS__ . ' : ' . $message);
        }
        if ($stdError) {
Exemple #5
0
<?php

defined('XAPP') || (require_once dirname(__FILE__) . '/../Core/core.php');
xapp_import('xapp.Config');
xapp_import('xapp.Config.Exception');
/**
 * Config Xml class
 *
 * @package Config
 * @class Xapp_Config_Xml
 * @error 128
 * @author Frank Mueller <*****@*****.**>
 */
class Xapp_Config_Xml extends Xapp_Config
{
    /**
     * load xml config structure from xml string or xml file pointer converting the xml
     * to json and back to array to get xml to array result
     *
     * @error 12801
     * @param string $xml expects xml string or xml file pointer
     * @return array
     * @throws Xapp_Config_Exception
     */
    public static function load($xml)
    {
        if ((bool) preg_match('/\\.xml$/i', $xml)) {
            if (is_file($xml) && ($xml = simplexml_load_file($xml, 'SimpleXMLElement', LIBXML_NOBLANKS | LIBXML_NOCDATA)) === false) {
                throw new Xapp_Config_Exception(xapp_sprintf(_("unable to load xml config from file: %s, error: %s"), $xml, libxml_get_last_error()), 1280101);
            }
        } else {
Exemple #6
0
/**
 * @param $XAPP_BASE_DIRECTORY
 * @param $XAPP_APP_NAME
 * @param $XAPP_CLIENT_DIRECTORY
 * @param $REPOSITORY_ROOT
 * @param $REPOSITORY_START_PATH
 * @param $UPLOAD_EXTENSIONS
 * @param $XFILE_CONFIG
 * @param string $XAPP_JQUERY_THEME
 * @param $LOG_DIRECTORY
 * @param $CONF_FILE
 * @param $XAPP_SALT_KEY
 * @param $XF_PROHIBITED_PLUGINS
 * @param $RELATIVE_VARIABLES
 * @param $XAPP_COMPONENTS
 * @param $XAPP_RESOURCE_CONFIG
 * @param null $XAPP_BOOTSTRAP_OVERRIDE
 *
 * @return array
 */
function createApp($XAPP_BASE_DIRECTORY, $XAPP_APP_NAME, $XAPP_CLIENT_DIRECTORY, $REPOSITORY_ROOT, $REPOSITORY_START_PATH, $UPLOAD_EXTENSIONS, $XFILE_CONFIG, $XAPP_JQUERY_THEME = 'dot-luv', $LOG_DIRECTORY, $CONF_FILE, $XAPP_SALT_KEY, $XF_PROHIBITED_PLUGINS, $RELATIVE_VARIABLES, $XAPP_COMPONENTS, $XAPP_RESOURCE_CONFIG, $XAPP_BOOTSTRAP_OVERRIDE = null)
{
    /***
     * prepare and adjust bootstrapper for stand-alone
     */
    if (!defined('XAPP_BASEDIR')) {
        define('XAPP_BASEDIR', $XAPP_BASE_DIRECTORY);
    }
    require_once XAPP_BASEDIR . 'XApp_Service_Entry_Utils.php';
    XApp_Service_Entry_Utils::includeXAppCore();
    XApp_Service_Entry_Utils::includeXAppRPC();
    require_once XAPP_BASEDIR . 'app/Renderer.php';
    require_once XAPP_BASEDIR . 'commander/Commander.php';
    XApp_App_Commander::loadDependencies();
    xapp_setup_language_standalone();
    xapp_import('xapp.Utils.Strings');
    xapp_import('xapp.Utils.Debugging');
    $urlParams = array();
    if (isset($_SERVER["QUERY_STRING"])) {
        XApp_Utils_Strings::parse_str($_SERVER["QUERY_STRING"], $urlParams);
        if (isset($urlParams['view'])) {
            unset($urlParams['view']);
        }
    }
    define('XAPP_INDEX', xapp_fix_index());
    /***
     * Quick'n dirty auth delegate
     * @TODO replace with new ACL/Permission system
     */
    class XAPP_AUTH_DELEGATE
    {
        // salt key, passed from index.php
        public static $_salt;
        // xf config, passed from index.php
        public static $_config;
        /**
         * Reject RPC methods
         * @param $what
         * @return bool
         */
        public static function authorize($what)
        {
            /**
             * Option 1. Use the xfile config passed from index.php
             */
            if (self::$_config) {
                $data = (array) json_decode(self::$_config);
                $allowedActions = $data['ALLOWED_ACTIONS'];
                $intOp = intval(XApp_Service_Entry_Utils::opToInteger($what));
                if ($intOp != XC_OPERATION_UNKOWN) {
                    if ($intOp > 0 && $intOp < count($allowedActions)) {
                        //boundary check
                        return $allowedActions[$intOp];
                    }
                }
            }
            /**
             * Option 2. Reject via string match if you like
             */
            switch ($what) {
                case XC_OPERATION_COPY_STR:
                case XC_OPERATION_MOVE_STR:
                case XC_OPERATION_DELETE_STR:
                case XC_OPERATION_READ_STR:
                case XC_OPERATION_EDIT_STR:
                case XC_OPERATION_COMPRESS_STR:
                case XC_OPERATION_RENAME_STR:
                case XC_OPERATION_DOWNLOAD_STR:
                case XC_OPERATION_FILE_UPDATE_STR:
                case XC_OPERATION_NEW_DIRECTORY_STR:
                case XC_OPERATION_NEW_FILE_STR:
                case XC_OPERATION_UPLOAD:
                case XC_OPERATION_DOWNLOAD:
                case XC_OPERATION_EXTRACT:
                    return true;
            }
            return true;
        }
        public function getUserName()
        {
            return 'admin';
        }
        public function getToken()
        {
            return md5(self::$_salt);
        }
    }
    XAPP_AUTH_DELEGATE::$_salt = $XAPP_SALT_KEY;
    XAPP_AUTH_DELEGATE::$_config = $XFILE_CONFIG;
    $authDelegate = new XAPP_AUTH_DELEGATE();
    $XAPP_XFILE_CONFIG_ARRAY = array();
    $XAPP_XFILE_CONFIG_ARRAY['XAPP_FILE_START_PATH'] = '';
    $XAPP_XFILE_CONFIG_ARRAY['XAPP_FILE_ROOT'] = $REPOSITORY_ROOT;
    require_once XAPP_BASEDIR . 'lib/standalone/StoreDelegate.php';
    $extraParams = count($urlParams) ? '&' . http_build_query($urlParams) : '';
    if (!$XAPP_RESOURCE_CONFIG) {
        $XAPP_RESOURCE_CONFIG = '';
    }
    $renderStruct = xapp_commander_render_app(XAPP_BASEDIR, 'xbox', $XAPP_CLIENT_DIRECTORY, $REPOSITORY_ROOT, $REPOSITORY_START_PATH, $UPLOAD_EXTENSIONS, $XFILE_CONFIG, $XAPP_JQUERY_THEME, dirname(XApp_Service_Entry_Utils::getUrl()) . '/', dirname(XApp_Service_Entry_Utils::getUrl()) . '/xapp/commander/plugins/', dirname(XApp_Service_Entry_Utils::getUrl()) . '/' . XAPP_INDEX . '?view=rpc', $authDelegate, '', '', $LOG_DIRECTORY, $XF_PROHIBITED_PLUGINS, 'standalone', 'XCOM_Resource_Renderer', '', new stdClass(), null, null, null, null, dirname(XApp_Service_Entry_Utils::getUrl()) . '/' . XAPP_INDEX . '?view=smdCall' . $extraParams, dirname(XApp_Service_Entry_Utils::getUrl()) . '/' . XAPP_INDEX . '?view=rpc' . $extraParams, 'XApp_Store_Delegate', $CONF_FILE, $XAPP_SALT_KEY, $RELATIVE_VARIABLES, XApp_Service_Entry_Utils::isDebug() === true, $XAPP_COMPONENTS, $XAPP_RESOURCE_CONFIG, $XAPP_BOOTSTRAP_OVERRIDE);
    return $renderStruct;
}
Exemple #7
0
<?php

/**
 * Image manipulation functions for extension Imagick
 *
 *
 * Created by PhpStorm.
 * User: Luigi
 * Date: 5/03/14
 * Time: 12:38
 */
xapp_import("xapp.Image.Interface.ImageHandler");
class XApp_ImageImagick implements Xapp_ImageHandler
{
    /**
     *  Default imagick resize filter
     */
    const IMAGICK_RESIZE_FILTER = imagick::FILTER_LANCZOS;
    /**
     * Opens an Image file
     *
     * @param $src
     * @param $errors
     * @return mixed
     */
    public static function open($src, &$errors)
    {
        $file_ext = XApp_Image_Utils::imageExtension($src);
        if (!array_key_exists($file_ext, XApp_Image_Utils::$compatibleImageTypes)) {
            $errors[] = XAPP_TEXT_FORMATTED("IMAGE_TYPE_NOT_SUPPORTED", $file_ext);
            return false;
Exemple #8
0
<?php

/**
 * @version 0.1.0
 *
 * @author https://github.com/mc007
 * @license : GPL v2. http://www.gnu.org/licenses/gpl-2.0.html
 * @package XApp\xide\Directory
 */
xapp_import('xapp.Service.Service');
xapp_import('xapp.Directory.Service');
/***
 * Class XIDE_Service extends the standard service
 */
class XIDE_Service extends XApp_Service
{
    /**
     * class constructor
     * call parent constructor for class initialization
     *
     * @error 14601
     * @param null|array|object $options expects optional options
     */
    public function __construct($options = null)
    {
        parent::__construct($options);
        //standard constructor
        xapp_set_options($options, $this);
    }
}
Exemple #9
0
<?php

/**
 * @version 0.1.0
 *
 * @author Guenter Baumgart
 * @license : GPL v2. http://www.gnu.org/licenses/gpl-2.0.html
 * @package XApp\xide\Models
 */
xapp_import("xapp.Commons.Entity");
xapp_import('xapp.Utils.Strings');
xapp_import('xapp.Option.Utils');
xapp_import('xapp.Xapp.Registry');
/***
 * Class XIDE_Scope
 */
class XIDE_Scope extends XApp_Entity
{
    ////////////////////////////////////////////////////////////////////////////
    //
    //  Constants
    //
    ////////////////////////////////////////////////////////////////////////////
    //default scope names
    const SYSTEM = "system";
    const USER = "******";
    const APP = "app";
    ////////////////////////////////////////////////////////////////////////////
    //
    //  Options
    //
Exemple #10
0
 * This file is part of the Nette Framework (http://nette.org)
 * Copyright (c) 2004 David Grudl (http://davidgrudl.com)
 */
/**
 * Default implementation of IIdentity.
 *
 * @author     David Grudl
 *
 * @serializationVersion 1.0
 *
 * @property   mixed $id
 * @property   array $roles
 * @property-read array $data
 */
xapp_import('xapp.Commons.Object');
xapp_import('xapp.Security.IIdentity');
class XApp_Security_Identity extends XApp_Object implements XApp_Security_IIdentity
{
    /** @var mixed */
    private $id;
    /** @var array */
    private $roles;
    /** @var array */
    private $data;
    /**
     * @param  mixed   identity ID
     * @param  mixed   roles
     * @param  array   user data
     */
    public function __construct($id, $roles = NULL, $data = NULL)
    {
Exemple #11
0
<?php

/**
 * @version 0.1.0
 *
 * @author https://github.com/mc007
 * @license : GPL v2. http://www.gnu.org/licenses/gpl-2.0.html
 */
defined('XAPP') || (require_once dirname(__FILE__) . '/../../Core/core.php');
xapp_import('xapp.Rpc.Server.Exception');
xapp_import('xapp.Rpc.Fault');
xapp_import('xapp.Rpc.Server.Json');
xapp_import('xapp.Rpc.Smd.Jsonp');
xapp_import('xapp.Rpc.Server.Jsonp');
xapp_import('xapp.Rpc.Response.Json');
xapp_import('xapp.Rpc.Request.Json');
/**
 * Rpc server jsonp class
 *
 * @package Rpc
 * @subpackage Rpc_Server
 * @class Xapp_Rpc_Server_Raw
 * @error 147
 * @author Guenter Baumgart
 */
class Xapp_Rpc_Server_Raw extends Xapp_Rpc_Server_Jsonp
{
    /**
     * 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
Exemple #12
0
<?php

/**
 * @version 0.1.0
 *
 * @author https://github.com/mc007
 * @license : GPL v2. http://www.gnu.org/licenses/gpl-2.0.html
 */
defined('XAPP') || (require_once dirname(__FILE__) . '/../Core/core.php');
xapp_import('xapp.Util.Json.Exception');
xapp_import('xapp.Util.Json');
/**
 * Util json store class
 *
 * @package Util
 * @subpackage Util_Json
 * @class Xapp_Util_Json_Store
 * @error 169
 * @author Frank Mueller
 */
class Xapp_Util_Json_Store extends Xapp_Util_Std_Store
{
    /**
    * query the object with path and query parameters from Xapp_Util_Json_Query::find method and use store
    * methods on search result, e.g.
    * <code>
    * $store = Xapp_Util_Json_Store::create($object)
        ->query('/firstElement', array("id=1000"))
        ->query('.', array('title=foo'))
        ->set(null, 1);
    * </code>
Exemple #13
0
<?php

/**
 * @version 0.1.0
 *
 * @author https://github.com/mc007
 * @license : GPL v2. http://www.gnu.org/licenses/gpl-2.0.html
 */
defined('XAPP') || (require_once dirname(__FILE__) . '/../Core/core.php');
xapp_import('xapp.Cache.Exception');
/**
 * Cache base class
 *
 * @package Cache
 * @class Xapp_Cache
 * @error 153
 * @author Frank Mueller
 */
abstract class Xapp_Cache
{
    /**
     * cache option value default expiration when cache key expires after
     *
     * @const DEFAULT_EXPIRATION
     */
    const DEFAULT_EXPIRATION = 'XAPP_CACHE_DEFAULT_EXPIRATION';
    /**
     * contains the current active last created instance either with instance or factory
     * method
     *
     * @var null|Xapp_Cache
Exemple #14
0
 public function isLoggedIn()
 {
     $flags = xapp_get_option(self::FLAGS);
     if ($this->testFlag(XAPP_BOOTSTRAP_NEEDS_AUTHENTICATION, $flags) && xapp_get_option(self::USER_CONF, $this)) {
         self::loadJSONTools();
         self::loadXAppJSONStoreClasses();
         xapp_import('xapp.Store.Json.Json');
         $userMgr = new XApp_UserManager(array(XApp_UserManager::STORE_CONF => array(XApp_Store_JSON::CONF_FILE => xapp_get_option(self::USER_CONF, $this))));
         $userMgr->init();
         $userMgr->initSessionStorage();
         $result = $userMgr->isLoggedIn();
         return $result;
     }
     return true;
 }
Exemple #15
0
<?php

defined('XAPP') || (require_once dirname(__FILE__) . '/../Core/core.php');
xapp_import('xapp.Xapp.Error');
xapp_import('xapp.Xapp.Reflection');
/**
 * Autoloader class
 *
 * @package Xapp
 * @class Xapp_Autoloader
 * @error 107
 * @author Frank Mueller <*****@*****.**>
 */
class Xapp_Autoloader implements Xapp_Singleton_Interface
{
    /**
     * expects a string value or empty string for no value if classes use namespaces
     * like Xapp_ or Zend_. this default value defines the default path divider
     * which can only be a string or an empty value. the value can be also passed in first constructor
     * parameter $dir as array key lil array('path to dir', 'ns', 'divider') overwriting
     * default value. With this value you can match class name namespaces to file/dir namespace e.g.
     * a file in /app/foo/class.php will be stored as app_foo_class in cache map. use the ns divider
     * to overwrite the default value "_" to anything else
     *
     * @const PATH_SEPARATOR
     */
    const PATH_SEPARATOR = 'AUTOLOADER_PATH_SEPARATOR';
    /**
     * expects the default php real namespace separator so it can be replaced with PATH_DIVIDER value
     * when looking for class name. e.g. a class Namespace\Foo will be replaced to Namespace_Foo with
     * default path separator making sure that namespaces match folder/file separator syntax.
Exemple #16
0
<?php

defined('XAPP') || (require_once dirname(__FILE__) . '/../Core/core.php');
xapp_import('xapp.Rpc.Server');
xapp_import('xapp.Rpc.Exception');
/**
 * Rpc abstract base class
 *
 * @package Rpc
 * @class Xapp_Rpc
 * @error 139
 * @author Frank Mueller <*****@*****.**>
 */
abstract class Xapp_Rpc
{
    /**
     * contains all instances created with server factory method
     *
     * @var array
     */
    protected static $_instances = array();
    /**
     * factory method to create a rpc server instance by either passing an server
     * instance in first parameter or string with server driver name, e.g. "json"
     * or null value which will return the last added instance. will return instance
     * of Xapp_Rpc_Server in all cases
     *
     * @error 13901
     * @param null|string|Xapp_Rpc_Server $mixed expects value as explained above
     * @param null|array|object $options expects optional options to pass to server instance when constructing
     * @return Xapp_Rpc_Server
Exemple #17
0
<?php

xapp_import('xapp.VFS.Archive.new.ExtractableInterface');
class xapp_Zip implements xapp_ExtractableInterface
{
    /**
     * ZIP compression methods.
     *
     * @var    array
     * @since  1.0
     */
    private $methods = array(0x0 => 'None', 0x1 => 'Shrunk', 0x2 => 'Super Fast', 0x3 => 'Fast', 0x4 => 'Normal', 0x5 => 'Maximum', 0x6 => 'Imploded', 0x8 => 'Deflated');
    /**
     * Beginning of central directory record.
     *
     * @var    string
     * @since  1.0
     */
    private $ctrlDirHeader = "PK";
    /**
     * End of central directory record.
     *
     * @var    string
     * @since  1.0
     */
    private $ctrlDirEnd = "PK";
    /**
     * Beginning of file contents.
     *
     * @var    string
     * @since  1.0
Exemple #18
0
require_once XAPP_BASEDIR . '/Bootstrap.php';
XApp_Bootstrap::loadMin();
XApp_Bootstrap::loadRPC();
xapp_setup_language_standalone();
xapp_import('xapp.Service');
xapp_import('xapp.File.Utils');
xapp_import('xapp.Directory.Utils');
xapp_import('xapp.Directory.Service');
xapp_import('xapp.xide.Directory.Service');
xapp_import('xapp.Path.Utils');
xapp_import('xapp.VFS.Interface.Access');
xapp_import('xapp.VFS.Base');
xapp_import('xapp.VFS.Local');
xapp_import('xapp.Resource.Renderer');
xapp_import('xapp.Xapp.Hook');
xapp_import('xapp.Option.*');
xapp_import("xapp.xide.Models.User");
xapp_import('xapp.xide.Controller.UserManager');
xapp_import('xapp.xide.Controller.UserService');
xapp_import('xapp.xide.Workbench.Service');
xapp_import('xapp.Store.Json.Json');
/***
 * Build bootstrap config for the RPC service
 */
$user = new XApp_User();
$user->setName('A');
$opt = array(XApp_Bootstrap::BASEDIR => XAPP_BASEDIR, XApp_Bootstrap::FLAGS => array(XAPP_BOOTSTRAP_SETUP_XAPP, XAPP_BOOTSTRAP_SETUP_RPC, XAPP_BOOTSTRAP_SETUP_GATEWAY, XAPP_BOOTSTRAP_SETUP_SERVICES), XApp_Bootstrap::RPC_TARGET => $XAPP_SMD_TARGET, XApp_Bootstrap::SIGNED_SERVICE_TYPES => array(), XApp_Bootstrap::GATEWAY_CONF => array(Xapp_Rpc_Gateway::OMIT_ERROR => XApp_Service_Entry_Utils::isDebug()), XApp_Bootstrap::LOGGING_FLAGS => array(), XApp_Bootstrap::LOGGING_CONF => array(Xapp_Log::PATH => $XAPP_LOG_DIRECTORY, Xapp_Log::EXTENSION => 'log', Xapp_Log::NAME => 'xide'), XApp_Bootstrap::XAPP_CONF => array(XAPP_CONF_DEBUG_MODE => null, XAPP_CONF_AUTOLOAD => false, XAPP_CONF_DEV_MODE => XApp_Service_Entry_Utils::isDebug(), XAPP_CONF_HANDLE_BUFFER => true, XAPP_CONF_HANDLE_SHUTDOWN => false, XAPP_CONF_HTTP_GZIP => true, XAPP_CONF_CONSOLE => false, XAPP_CONF_HANDLE_ERROR => true, XAPP_CONF_HANDLE_EXCEPTION => true), XApp_Bootstrap::SERIVCE_CONF => array(XApp_Service::instance('XIDE_Directory_Service', array(XApp_Directory_Service::REPOSITORY_ROOT => $XAPP_WORKSPACE_DIRECTORY, XApp_Directory_Service::FILE_SYSTEM => 'XApp_VFS_Local', XApp_Directory_Service::VFS_CONFIG_PATH => $XAPP_VFS_CONFIG_PATH, XApp_Directory_Service::FILE_SYSTEM_CONF => array(XApp_VFS_Base::ABSOLUTE_VARIABLES => array('WS_ABS_PATH' => $XAPP_WORKSPACE_DIRECTORY), XApp_VFS_Base::RELATIVE_VARIABLES => array()))), XApp_Service::factory('xapp.xide.Workbench.Service', array(XApp_XIDE_Workbench_Service::WORKBENCH_USER => $user, XApp_XIDE_Workbench_Service::WORKBENCH_DIRECTORY => $XAPP_WORKSPACE_DIRECTORY, XApp_XIDE_Workbench_Service::SITE_CONFIG_DIRECTORY => realpath(XAPP_BASEDIR . '/xide/Workbench/siteconfig/'))), XApp_Service::instance('XApp_XIDE_Controller_UserService', array(XApp_Service::MANAGED_CLASS_OPTIONS => array(XApp_UserManager::STORE_CONF => array(XApp_Store_JSON::CONF_FILE => $XAPP_BASE_DIRECTORY . "xide" . DIRECTORY_SEPARATOR . "Data" . DIRECTORY_SEPARATOR . "Users.json"))))));
$xappBootrapper = new XApp_Bootstrap($opt);
$xappBootrapper->init();
//$userService = XApp_XIDE_Controller_UserService::instance();
//$xappBootrapper->run();
Exemple #19
0
<?php

/**
 * @version 0.1.0
 *
 * @author https://github.com/mc007
 * @license : GPL v2. http://www.gnu.org/licenses/gpl-2.0.html
 */
defined('XAPP') || (require_once dirname(__FILE__) . '/../Core/core.php');
xapp_import('xapp.Util.Exception.Json');
class Xapp_Util_Json_Query extends Xapp_Util_Std_Query
{
}
Exemple #20
0
<?php

/**
 * @version 0.1.0
 *
 * @author https://github.com/mc007
 * @license : GPL v2. http://www.gnu.org/licenses/gpl-2.0.html
 */
xapp_import('xapp.Path.Utils');
/***
 * Example server plugin.
 * @remarks
    - This class is running in the CMS context already!
    - A function's result will be wrapped automatically into the specified transport envelope, eg: JSON-RPC-2.0 or JSONP
    - Implementing Xapp_Rpc_Interface_Callable is just for demonstration
    -
 */
class XShell extends Xapp_Commander_Plugin
{
    /***
     * @param $command
     * @param null $cwd current working directory in this format root://myfolder.
     * @return string
     */
    protected function runBash($command, $cwd = null)
    {
        $shell_result_final = "";
        $command = $command . " 2>&1";
        if ($cwd && file_exists($cwd)) {
            chdir($cwd);
        }
<?php

/**
 * @author     Guenter Baumgart
 * @author     David Grudl
 * @copyright 2004 David Grudl (http://davidgrudl.com)
 * @license : GPL v2. http://www.gnu.org/licenses/gpl-2.0.html
 * @license : http://opensource.org/licenses/BSD-3-Clause
 * @package XApp-Commander
 *
 * @original header : This file is part of the Nette Framework (http://nette.org)
 */
xapp_import('xapp.Utils.Strings');
/**
 * Annotations support for PHP.
 *
 * @author     David Grudl
 * @Annotation
 */
class XApp_Reflection_AnnotationsParser
{
    /** @internal single & double quoted PHP string */
    const RE_STRING = '\'(?:\\\\.|[^\'\\\\])*\'|"(?:\\\\.|[^"\\\\])*"';
    /** @internal identifier */
    const RE_IDENTIFIER = '[_a-zA-Z\\x7F-\\xFF][_a-zA-Z0-9\\x7F-\\xFF-\\\\]*';
    /** @var bool */
    public static $useReflection;
    /** @var array */
    public static $inherited = array('description', 'param', 'return');
    /** @var array */
    private static $cache;
Exemple #22
0
<?php

/**
 * @version 0.1.0
 *
 * @author Guenter Baumgart
 * @license : GPL v2. http://www.gnu.org/licenses/gpl-2.0.html
 * @package XApp\Image\Service
 */
xapp_import("xapp.Commons.Entity");
xapp_import("xapp.Service.Service");
xapp_import("xapp.Image.Utils");
/***
 * Class XApp_UserService is the RPC wrapper for UserManager
 */
class XApp_Image_Service extends XApp_Service implements Xapp_Singleton_Interface
{
    const IMAGE_CACHE_DIR = 'XAPP_IMAGE_CACHE_DIR';
    /**
     * options dictionary for this class containing all data type values
     *
     * @var array
     */
    public static $optionsDict = array(self::MANAGED_CLASS => XAPP_TYPE_STRING, self::IMAGE_CACHE_DIR => XAPP_TYPE_DIR);
    /**
     * options mandatory map for this class contains all mandatory values
     *
     * @var array
     */
    public static $optionsRule = array(self::MANAGED_CLASS => 0, self::IMAGE_CACHE_DIR => 1);
    /**
<?php

xapp_import('xapp.Security.IAuthorizator');
class XApp_Security_SimpleAuthorizator implements XApp_Security_IAuthorizator
{
    function isAllowed($role, $resource, $privilege)
    {
        error_log('calling is allowed : ' . ' role : ' . $role . ' resource ' . $resource . ' = action = ' . $privilege);
        return true;
    }
}
Exemple #24
0
<?php

defined('XAPP') || (require_once dirname(__FILE__) . '/../Core/core.php');
xapp_import('xapp.Rpc.Request.Exception');
/**
 * Rpc request class
 *
 * @package Rpc
 * @class Xapp_Rpc_Request
 * @error 144
 * @author Frank Mueller <*****@*****.**>
 */
abstract class Xapp_Rpc_Request
{
    /**
     * global variable constant for params
     *
     * @const PARAMS
     */
    const PARAMS = 'PARAMS';
    /**
     * global variable constant for rpc
     *
     * @const RPC
     */
    const RPC = 'RPC';
    /**
     * global variable constant for post
     *
     * @const POST
     */
Exemple #25
0
 /**
  * Get a file compression adapter.
  *
  * @param   string  $type  The type of adapter (bzip2|gzip|tar|zip).
  *
  * @return  ExtractableInterface  Adapter for the requested type
  *
  * @since   1.0
  * @throws  Exception
  */
 public function getAdapter($type)
 {
     $type = strtolower($type);
     if (!isset($this->adapters[$type])) {
         // Try to load the adapter object
         /* @var  ExtractableInterface  $class */
         $class = 'xapp_' . ucfirst($type);
         xapp_clog('class ' . $class . ' t ' . $type);
         xapp_import('xapp.VFS.Archive.new.' . ucfirst($type));
         if (!class_exists($class) || !$class::isSupported()) {
             throw new Exception(sprintf('Archive adapter "%s" (class "%s") not found or supported.', $type, $class));
         }
         $this->adapters[$type] = new $class($this->options);
     }
     return $this->adapters[$type];
 }
Exemple #26
0
<?php

/**
 * @version 0.1.0
 *
 * @author https://github.com/mc007
 * @license : GPL v2. http://www.gnu.org/licenses/gpl-2.0.html
 */
defined('XAPP') || (require_once dirname(__FILE__) . '/../Core/core.php');
xapp_import('xapp.Util.Std.Exception');
xapp_import('xapp.Util.Std');
/**
 * Util std store class
 *
 * @package Util
 * @subpackage Util_Std
 * @class Xapp_Util_Std_Store
 * @error 170
 * @author Frank Mueller
 */
class Xapp_Util_Std_Store
{
    /**
     * contains the std object either constructor by class or passed/loaded in constructor
     *
     * @var mixed|null
     */
    protected $_object = null;
    /**
     * contains result value when using Xapp_Util_Std_Store::query building
     *
Exemple #27
0
 public static function decodeSecureMagic($data, $sanitizeLevel = self::SANITIZE_HTML)
 {
     xapp_import('xapp.Utils.SystemTextEncoding');
     return XApp_SystemTextEncoding::fromUTF8(self::sanitizeEx(self::securePath(XApp_SystemTextEncoding::magicDequote($data)), $sanitizeLevel));
 }
Exemple #28
0
 public function ls($path = '/', $recursive = false, $options = array())
 {
     xapp_import('xapp.Xapp.Hook');
     xapp_import('xapp.File.Utils');
     xapp_import('xapp.Commons.ErrorHandler');
     $options = (array) $options;
     // Default options
     if (!isset($options[XApp_File_Utils::OPTION_DIR_LIST_FIELDS])) {
         $options[XApp_File_Utils::OPTION_DIR_LIST_FIELDS] = 0;
     }
     // Default option : emit new node
     if (!isset($options[XApp_File_Utils::OPTION_EMIT])) {
         $options[XApp_File_Utils::OPTION_EMIT] = true;
     }
     //default scan options
     $get_list_options = array(XApp_Directory_Utils::OPTION_CLEAR_PATH => true, XApp_Directory_Utils::OPTION_RECURSIVE => $recursive);
     //overwrite from options
     if (isset($options[XApp_File_Utils::OPTION_DIR_LIST])) {
         $get_list_options = $options[XApp_File_Utils::OPTION_DIR_LIST];
     }
     //default include & exclude list
     $inclusionMask = XApp_File_Utils::defaultInclusionPatterns();
     $exclusionMask = XApp_File_Utils::defaultExclusionPatterns();
     /*
     //overwrite include from options
     if (isset($options[XApp_Directory_Utils::OPTION_INCLUDE_LIST])) {
     	if (is_string($options[XApp_Directory_Utils::OPTION_INCLUDE_LIST])) {
     		$inclusionMask = explode(',', $options[XApp_Directory_Utils::OPTION_INCLUDE_LIST]);
     	} else {
     		if (is_array($options[XApp_Directory_Utils::OPTION_INCLUDE_LIST])) {
     			$inclusionMask = $options[XApp_Directory_Utils::OPTION_INCLUDE_LIST];
     		}
     	}
     }
     */
     if (isset($options[XApp_Directory_Utils::OPTION_INCLUDE_LIST])) {
         //	$inclusionMask = $options[XApp_Directory_Utils::OPTION_INCLUDE_LIST];
     }
     //overwrite excludes from options
     if (isset($options[XApp_Directory_Utils::OPTION_EXCLUDE_LIST])) {
         //		$exclusionMask = explode(',', $options[XApp_Directory_Utils::OPTION_EXCLUDE_LIST]);
     }
     //XApp_ErrorHandler::start();
     $list = $this->getFilteredDirList($path, $inclusionMask, $exclusionMask, $get_list_options);
     $ret_list = array();
     /***
      * Use 'readOnly' from the paths's resource information
      */
     $isReadOnly = null;
     foreach ($list as $item_name) {
         $item = new stdClass();
         $item->{XAPP_NODE_FIELD_NAME} = $item_name;
         if ($path != "/") {
             self::add_ls_file_information($this->toRealPath($path . DIRECTORY_SEPARATOR . $item_name), $item, $options[XApp_File_Utils::OPTION_DIR_LIST_FIELDS]);
             //tell plugins, if anyone doesnt want the item, skip it
             $addItem = Xapp_Hook::trigger(self::EVENT_ON_NODE_ADD, array('item' => $item));
             if ($addItem === false) {
                 continue;
             }
             //tell plugins, if anyone doesnt want the item, skip it
             if ($options[XApp_File_Utils::OPTION_EMIT] === true) {
                 $item = Xapp_Hook::trigger(self::EVENT_ON_NODE_META_CREATED, array('item' => $item));
                 if ($item === null) {
                     continue;
                 }
             }
             //now overwrite readOnly flag
             if ($isReadOnly != null && ($options[XApp_File_Utils::OPTION_DIR_LIST_FIELDS] & XAPP_XFILE_SHOW_ISREADONLY) == XAPP_XFILE_SHOW_ISREADONLY) {
                 $item->{XAPP_NODE_FIELD_READ_ONLY} = $isReadOnly;
             }
             //tell plugins
             Xapp_Hook::trigger(self::EVENT_ON_NODE_ADDED, array('item' => $item));
         }
         $ret_list[] = $item;
     }
     /*
     		error_log('test',E_WARNING);
     		$error = XApp_ErrorHandler::stop();
     		xapp_clog($error);*/
     return $ret_list;
 }
Exemple #29
0
<?php

/**
 * @author     Guenter Baumgart
 * @author     David Grudl
 * @copyright 2004 David Grudl (http://davidgrudl.com)
 * @license : GPL v2. http://www.gnu.org/licenses/gpl-2.0.html
 * @license : http://opensource.org/licenses/BSD-3-Clause
 * @package XApp-Commander
 *
 * @original header : This file is part of the Nette Framework (http://nette.org)
 */
xapp_import('xapp.Http.Url');
/**
 * Extended HTTP URL.
 *
 * <pre>
 * http://nette.org/admin/script.php/pathinfo/?name=param#fragment
 *                 \_______________/\________/
 *                        |              |
 *                   scriptPath       pathInfo
 * </pre>
 *
 * - scriptPath:  /admin/script.php (or simply /admin/ when script is directory index)
 * - pathInfo:    /pathinfo/ (additional path information)
 *
 * @author     David Grudl
 *
 * @property   string $scriptPath
 * @property-read string $pathInfo
 */
Exemple #30
0
<?php

xapp_import('xapp.Commons.Entity');
xapp_import('xapp.Security.IIdentity');
xapp_import('xapp.Security.User');
/**
 * Class XApp_User
 */
class XApp_User extends XApp_Security_User implements XApp_Security_IIdentity
{
    /**
     *  Default fields: Name, Password, Role, Permissions
     */
    const USER_NAME = "Name";
    const USER_PASSWORD = "******";
    const USER_ROLE = "Role";
    const USER_PERMISSIONS = "Permissions";
    static $entity_default_fields = array(array(self::ENTITY_FIELD_NAME => self::USER_NAME, self::ENTITY_FIELD_DESCRIPTION => "User name", self::ENTITY_FIELD_TYPE => XAPP_TYPE_STRING), array(self::ENTITY_FIELD_NAME => self::USER_PASSWORD, self::ENTITY_FIELD_DESCRIPTION => "User Password", self::ENTITY_FIELD_TYPE => XAPP_TYPE_STRING), array(self::ENTITY_FIELD_NAME => self::USER_ROLE, self::ENTITY_FIELD_DESCRIPTION => "User Role/s", self::ENTITY_FIELD_TYPE => XAPP_TYPE_ARRAY, self::ENTITY_FIELD_DEFAULT => array()), array(self::ENTITY_FIELD_NAME => self::USER_PERMISSIONS, self::ENTITY_FIELD_DESCRIPTION => "User additional permissions", self::ENTITY_FIELD_TYPE => XAPP_TYPE_ARRAY, self::ENTITY_FIELD_DEFAULT => array()));
    /**
     *  Initialize all default fields
     */
    public function __construct()
    {
        self::_createDefaultFields(self::$entity_default_fields);
    }
    /**
     * XApp_Security_IIdentity impl.
     * Returns the ID of user.
     * @return mixed
     */
    function getId()