예제 #1
0
파일: App.php 프로젝트: xamiro-dev/xamiro
/**
 * @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;
}
예제 #2
0
파일: entry.php 프로젝트: xamiro-dev/xamiro
$XAPP_WORKSPACE_DIRECTORY = realpath(XAPP_BASEDIR . '..' . DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . '/user/A/ws/workspace/';
/***
 * The path to the virtual file system configuration, holding all mounted resources
 */
$XAPP_VFS_CONFIG_PATH = realpath(XAPP_BASEDIR . '..' . DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . 'maqetta' . DIRECTORY_SEPARATOR . 'vfs.json';
/***
 * Dojo's JSON-RPC classes need an url to the entry here :
 */
$XAPP_SMD_TARGET = '../xapp/xide/Service/entry.php?view=smdCall';
/***
 * Framework minimal includes, ignore!
 */
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');