Example #1
0
/**
 * Loads all the functions,interfaces,classes
 * @param String $paramLibFolder path to lib folder
 */
function load($paramLibFolder)
{
    define('REVISION', 105);
    define('OSC_VERSION', '1.1b');
    //REGISTER NEW FUNCTIONS, INTERFACES, (ABSTRACT) CLASSES, EXCEPTIONS HERE! :D
    $orongo_functions = array('orongo_query', 'handleSessions', 'l', 'setCurrentPage', 'setDatabase', 'setDisplay', 'setLanguage', 'setMenu', 'setPlugins', 'setStyle', 'setUser');
    $orongo_interfaces = array('IHTMLConvertable', 'IJSConvertable', 'IOrongoPlugin', 'IOrongoStyle', 'IOrongoTerminalPlugin', 'IStorable');
    $orongo_abstracts = array('OrongoDisplayableObject', 'OrongoPluggableObject', 'OrongoFrontendObject');
    $orongo_classes = array('AjaxAction', 'CommentPoster', 'CommentLoader', 'Article', 'Cache', 'Comment', 'Database', 'Display', 'Issue', 'IssueTracker', 'Language', 'MailFactory', 'Menu', 'MessageBox', 'OrongoDefaultEventHandlers', 'OrongoEvent', 'OrongoNotifier', 'OrongoNotification', 'OrongoQuery', 'OrongoQueryHandler', 'OrongoTerminal', 'OrongoUpdateChecker', 'Page', 'Plugin', 'Security', 'Session', 'Settings', 'Storage', 'Style', 'User');
    $orongo_exceptions = array('ClassLoadException', 'IllegalArgumentException', 'IllegalMemoryAccessException', 'OrongoScriptParseException', 'QueryException');
    $orongo_function_packages = array('Utils');
    $orongo_frontend_objects = array('AdminFrontend', 'ArchiveFrontend', 'ErrorFrontend', 'PageFrontend', 'IndexFrontend', 'ArticleFrontend');
    $orongo_script_core = array('OrongoFunction', 'OrongoPackage', 'OrongoScriptPluginBridge', 'OrongoScriptParser', 'OrongoScriptRuntime', 'OrongoVariable', 'OrongoList');
    $raintpl_path = $paramLibFolder . '/rain.tpl.class.php';
    if (!file_exists($raintpl_path)) {
        throw new Exception("Couldn't load RainTPL (" . $raintpl_path . " was missing!)");
    }
    require $raintpl_path;
    $meekro_path = $paramLibFolder . '/meekrodb.2.0.class.php';
    if (!file_exists($meekro_path)) {
        throw new Exception("Could't load MeekroDB (" . $meekro_path . " was missing!)");
    }
    require $meekro_path;
    $ckeditor_path = $paramLibFolder . "/ckeditor/ckeditor_php5.php";
    if (!file_exists($ckeditor_path)) {
        throw new Exception("Could't load CKEditor (" . $ckeditor_path . " was missing!)");
    }
    require $ckeditor_path;
    $ckfinder_path = $paramLibFolder . "/ckfinder/core/ckfinder_php5.php";
    if (!file_exists($ckfinder_path)) {
        throw new Exception("Could't load CKFinder (" . $ckfinder_path . " was missing!)");
    }
    require $ckfinder_path;
    foreach ($orongo_interfaces as $interface) {
        if (!interface_exists($interface)) {
            $path = $paramLibFolder . '/I/' . $interface . '.php';
            if (!file_exists($path)) {
                throw new Exception("Couldn't load all interfaces (" . $path . " was missing!)");
            }
            require $path;
        }
    }
    foreach ($orongo_abstracts as $abstract) {
        if (!class_exists($abstract)) {
            $path = $paramLibFolder . '/class_' . $abstract . '.php';
            if (!file_exists($path)) {
                throw new Exception("Couldn't load all classes (" . $path . " was missing!)");
            }
            require $path;
        }
    }
    foreach ($orongo_exceptions as $exception) {
        if (!class_exists($exception)) {
            $path = $paramLibFolder . '/E/' . $exception . '.php';
            if (!file_exists($path)) {
                throw new Exception("Couldn't load all exceptions (" . $path . " was missing!)");
            }
            require $path;
        }
    }
    foreach ($orongo_classes as $class) {
        if (!class_exists($class)) {
            $path = $paramLibFolder . '/class_' . $class . '.php';
            if (!file_exists($path)) {
                throw new Exception("Couldn't load all classes (" . $path . " was missing!)");
            }
            require $path;
        }
    }
    foreach ($orongo_functions as $function) {
        if (!function_exists($function)) {
            $path = $paramLibFolder . '/function_' . $function . '.php';
            if (!file_exists($path)) {
                throw new Exception("Couldn't load all functions (" . $path . " was missing!)");
            }
            require $path;
        }
    }
    foreach ($orongo_function_packages as $function_package) {
        $path = $paramLibFolder . '/function_package_' . $function_package . '.php';
        if (!file_exists($path)) {
            throw new Exception("Couldn't load all function packages (" . $path . " was missing!)");
        }
        require $path;
    }
    foreach ($orongo_frontend_objects as $frontend_object) {
        if (!class_exists($frontend_object)) {
            $path = $paramLibFolder . '/FO/frontend_' . $frontend_object . '.php';
            if (!file_exists($path)) {
                throw new Exception("Couldn't load all frontend objects (" . $path . " was missing!)");
            }
            require $path;
        }
    }
    foreach ($orongo_script_core as $os_core) {
        if (!class_exists($os_core)) {
            $path = $paramLibFolder . '/OrongoScript/orongocore_' . $os_core . '.php';
            if (!file_exists($path)) {
                throw new Exception("Couldn't load the OrongoScript core objects (" . $path . " was missing!)");
            }
            require $path;
        }
    }
    Article::init();
    User::init();
    Page::init();
    Comment::init();
}
        if (!$currentArticle->checkVariables()) {
            handle(ERROR_INPUT . '01');
        }
        $response = $currentArticle->create();
        if ($response === false) {
            handle(ERROR_SYSTEM . '00');
        }
        handle('0000{"aid":' . $response . '}');
        break;
    case 'renew':
        if (!checkAuthority(9)) {
            handle(ERROR_SYSTEM . '00');
        }
        $currentArticle = new Article();
        $currentArticle->aid = getRequest('aid');
        $response = json_decode($currentArticle->getData(), true);
        $currentArticle->init(getRequest('title'), getRequest('content'), (int) getRequest('visibility'), (int) getRequest('notice'));
        if (!$currentArticle->checkVariables()) {
            handle(ERROR_INPUT . '01');
        }
        $response = $currentArticle->modify();
        if ($response === false) {
            handle(ERROR_SYSTEM . '00');
        } else {
            handle('0000');
        }
        break;
    default:
        ERROR(ERROR_INPUT . '02', 'Request Error.');
        break;
}