Example #1
0
function check_backend_login()
{
    if (!empty($_SESSION['USER_ID']) and $_SESSION['USER_LEVEL'] <= 3 and userInfo()) {
        load_themes();
    } else {
        $_SESSION['USER'] = null;
        $_SESSION['USER_ID'] = null;
        $_SESSION['USER_LOG'] = null;
        $_SESSION['USER_NAME'] = null;
        $_SESSION['USER_EMAIL'] = null;
        $_SESSION['USER_LEVEL'] = null;
        load_login();
    }
}
 public function app_step($step)
 {
     $this->load->library('tendoo');
     // Refreshing Tendoo Clss
     $this->load->library('tendoo_admin');
     // loading Admin Class
     $this->load->library('roles');
     // loading Admin Class
     // Base config, creating tables and saving firt name
     if ($step == 1) {
         // Working 100%
         if ($this->createTables() && get_instance()->meta_datas->set('site_name', $this->input->post('site_name'), 'from_install_interface', 'system')) {
             // Get all module and exec sql queries
             load_modules();
             $modules = get_modules('all');
             if ($modules) {
                 foreach ($modules as $namespace => $app_datas) {
                     // Activate module
                     active_module($namespace);
                     // Executing Sql queries
                     if (is_array($queries = riake('sql_queries', $app_datas))) {
                         foreach ($queries as $sql_line) {
                             get_db('from_install_interface')->query($sql_line);
                         }
                     }
                     // Registering Actions : Deprecated
                     /**
                     						if( is_array( $actions	=	riake ( 'declared_actions' , $app_datas ) ) ){
                     							foreach( $actions  as $_action ){
                     								if( $this->tendoo_admin->_action_keys_is_allowed( array_keys( $_action ) ) ){
                     									foreach( $_action as $key => $value ){
                     										$$key	=	$value;
                     									}
                     									$this->tendoo_admin->createModuleAction($mod_namespace,$action,$action_name,$action_description);
                     								}
                     							}
                     						}
                     						**/
                 }
             }
             // Get unique available theme
             load_themes();
             $themes = get_themes('all');
             // Creating Config File
             $this->createConfigFile();
             // Setting Logo URL
             get_instance()->meta_datas->set('site_logo', img_url('start_logo.png'));
             // Creating Controllers
             // Home
             $this->tendoo_admin->controller("Accueil", "home", "tim", "Accueil - " . get_meta('site_name'), "Un site Web utilisant Tendoo.", "TRUE", $obj = 'create', $id = '', $visible = 'TRUE', $childOf = 'none', $page_link = '', $keywords = 'tendoo, cms');
             // Blog
             $this->tendoo_admin->controller("Blog", "blog", "blogster", "Blog - " . get_meta('site_name'), "Un site Web utilisant Tendoo.", "FALSE", $obj = 'create', $id = '', $visible = 'TRUE', $childOf = 'none', $page_link = '', $keywords = 'tendoo, cms, blog');
             // Static
             $this->tendoo_admin->controller("Nouvelle page", "nouvelle-page", "pages_editor", "Nouvelle page", "Un site Web utilisant Tendoo.", "FALSE", $obj = 'create', $id = '', $visible = 'TRUE', $childOf = 'none', $page_link = '', $keywords = 'tendoo, cms, new page');
             // Setting Theme Config
             get_instance()->meta_datas->set('flaty_theme_settings', '{"slider":{"api_limit":"10","declared_apis":"blogster_get_blog_post","declared_item":"slider"},"testimony":{"testimony_big_title":"Tendoo is also","testimony_big_description":"Many features, more themes and a growing community. Why should you use Tendoo ?","testimony_content":{"level":{"0":"I find this project more accomplished.","1":"i wasn\'t expecting such result with huge work done by contributors.","2":"I hope this project will keep going ahead. I\'m about to contribute as i can, with issues submission.","3":"We worked hard to reach this result, and we\'re proud. We intend to offer a real free web application for both web site and web applications."}},"testimony_authors":{"level":{"0":"B. Jersyer","1":"Afromaster","2":"Lucas Ferry","3":"Sergey Rakovsky"}}},"list_services":{"section_text":"","section_textarea":"","title":{"level":{"0":"Follow us on Facebook","1":"Follow us on Twitter","2":"Google+"}},"link":{"level":{"0":"http:\\/\\/facebook.com\\/tendoocms","1":"http:\\/\\/twitter.com\\/","2":"http:\\/\\/plus.google.com"}},"description":{"level":{"0":"All news and updates details are available on facebook, the official website and sourceforge.","1":"We are also on Twitter. Don\'t miss our tweets..","2":"Don\'t miss our Google+ updates. Add us to your circles."}},"icons":{"level":{"0":"facebook","1":"twitter","2":"google-plus"}}}}');
             // Eva theme settings
             get_instance()->meta_datas->set('eva_theme_settings', '{"contact_datas":{"contact_description_title":"A propos de nous","contact_description_content":"Tendoo est un logiciel Open-Source disponible sur <a href=\\"http:\\/\\/github.com\\/Blair2004\\/tendoo-cms\\">github<\\/a> et t\\u00e9l\\u00e9chargeable gratuitement. Nous esp\\u00e9rons qu\'il saura vous s\\u00e9duire, mais surtout nous sommes en attente de vos avis. N\'h\\u00e9sitez pas \\u00e0 \\"Fork\\" le repertoire.","contact_details_title":"Contactez-nous","contact_details_content":"Suivez nos actualit\\u00e9s sur les r\\u00e9seaux sociaux ou sur <a href=\\"http:\\/\\/tendoo.org\\">tendoo.org<\\/a>.","social_feeds_icon":{"level":{"0":"map-marker","1":"envelope"}},"social_feeds_title":{"level":{"0":"Adresse","1":"Mail"}},"social_feeds_value":{"level":{"0":"World, Earth","1":"*****@*****.**"}}},"theme_color_and_style":{"background":"red","box_style":"fullwidth","bg_image":"black_mamba"},"social_feeds":{"social_links":{"level":{"0":"https:\\/\\/www.facebook.com\\/tendoocms"}},"social_icons":{"level":{"0":"facebook"}}},"list_services":{"title":{"level":{"0":"Plusieurs fonctionnalit\\u00e9s","1":"Une performance am\\u00e9lior\\u00e9","2":"Devenir un contributeur","3":"Administration","4":"Statistiques & Utilisateurs","5":"Suivez-nous sur Facebook"}},"link":{"level":{"0":"#","1":"#","2":"http:\\/\\/github.com\\/Blair2004\\/tendoo-cms","3":"#","4":"#","5":"https:\\/\\/www.facebook.com\\/tendoocms"}},"description":{"level":{"0":"La version 1.3 de Tendoo propose plusieurs fonctionnalit\\u00e9s. C\'est assur\\u00e9ment la version la plus stable de Tendoo. Avec un code revisit\\u00e9 et corrig\\u00e9.","1":"Le syst\\u00e8me a \\u00e9t\\u00e9 modifi\\u00e9. La gestion des th\\u00e8mes et des modules \\u00e0 \\u00e9t\\u00e9 am\\u00e9lior\\u00e9, ainsi que leur gestion. D\\u00e9couvrez des th\\u00e8mes beaucoup plus beau mais surtout \\"Responsive\\".","2":"Tendoo est un logiciel gratuit disponible sur Github. Vous pouvez apporter votre contribution comme vous le souhaitez depuis le r\\u00e9pertoire officiel. \\"Forkez-nous\\" sur Gihub.","3":"D\\u00e9couvrez un panneau d\'administration pas comme les autres. Avec des zones de widgets personnalisables, qui peuvent \\u00eatre administr\\u00e9s depuis les param\\u00e8tres.","4":"Tendoo mets des outils d\'analyse et de statistiques \\u00e0 la disposition de ses utilisateurs. Am\\u00e9liorer votre strat\\u00e9gie en fonction de vos performances.","5":"Suivez nos actualit\\u00e9s directement sur Facebook et ne manquez pas \\u00e0 l\'occasion de donner votre avis. Vous resterez connect\\u00e9 aux nouveaut\\u00e9s sur Tendoo."}},"icons":{"level":{"0":"gift","1":"thumbs-o-up","2":"github-alt","3":"home","4":"group","5":"facebook"}}},"recents_works":{"title":{"level":{"0":"Ceci est un projet de feu","1":"Cold Bold","2":"","3":"","4":"","5":"Dark Cat","6":"Children"}},"category":{"level":{"0":"Fire Bold","1":"une cat\\u00e9gorie","2":"","3":"","4":"","5":"Dark Cat","6":"Les enfants"}},"full_image":{"level":{"0":"http:\\/\\/127.0.0.1\\/tendoo-cms\\/tendoo-modules\\/app_tendoo_contents_620140902154910PqALJ6NSaBKqWW53ryP1t\\/content_repository\\/tendoo_content_5201409062005303213383.jpg","1":"http:\\/\\/127.0.0.1\\/tendoo-cms\\/tendoo-modules\\/app_tendoo_contents_620140902154910PqALJ6NSaBKqWW53ryP1t\\/content_repository\\/tendoo_content_5201409062005303213383.jpg","2":"http:\\/\\/127.0.0.1\\/tendoo-cms\\/tendoo-modules\\/app_tendoo_contents_620140902154910PqALJ6NSaBKqWW53ryP1t\\/content_repository\\/tendoo_content_5201409062005303213383.jpg","3":"http:\\/\\/127.0.0.1\\/tendoo-cms\\/tendoo-modules\\/app_tendoo_contents_620140902154910PqALJ6NSaBKqWW53ryP1t\\/content_repository\\/tendoo_content_5201409062005303213383.jpg","4":"http:\\/\\/127.0.0.1\\/tendoo-cms\\/tendoo-modules\\/app_tendoo_contents_620140902154910PqALJ6NSaBKqWW53ryP1t\\/content_repository\\/tendoo_content_5201409062005303213383.jpg","5":"http:\\/\\/127.0.0.1\\/tendoo-cms\\/tendoo-modules\\/app_tendoo_contents_620140902154910PqALJ6NSaBKqWW53ryP1t\\/content_repository\\/tendoo_content_5201409062005303213383.jpg","6":"http:\\/\\/127.0.0.1\\/tendoo-cms\\/tendoo-modules\\/app_tendoo_contents_620140902154910PqALJ6NSaBKqWW53ryP1t\\/content_repository\\/tendoo_content_5201409062005303213383.jpg"}},"thumb_image":{"level":{"0":"http:\\/\\/127.0.0.1\\/tendoo-cms\\/tendoo-modules\\/app_tendoo_contents_620140902154910PqALJ6NSaBKqWW53ryP1t\\/content_repository\\/tendoo_content_5201409062005303213383.jpg","1":"http:\\/\\/127.0.0.1\\/tendoo-cms\\/tendoo-modules\\/app_tendoo_contents_620140902154910PqALJ6NSaBKqWW53ryP1t\\/content_repository\\/tendoo_content_5201409062005303213383.jpg","2":"http:\\/\\/127.0.0.1\\/tendoo-cms\\/tendoo-modules\\/app_tendoo_contents_620140902154910PqALJ6NSaBKqWW53ryP1t\\/content_repository\\/tendoo_content_5201409062005303213383.jpg","3":"http:\\/\\/127.0.0.1\\/tendoo-cms\\/tendoo-modules\\/app_tendoo_contents_620140902154910PqALJ6NSaBKqWW53ryP1t\\/content_repository\\/tendoo_content_5201409062005303213383.jpg","4":"http:\\/\\/127.0.0.1\\/tendoo-cms\\/tendoo-modules\\/app_tendoo_contents_620140902154910PqALJ6NSaBKqWW53ryP1t\\/content_repository\\/tendoo_content_5201409062005303213383.jpg","5":"http:\\/\\/127.0.0.1\\/tendoo-cms\\/tendoo-modules\\/app_tendoo_contents_620140902154910PqALJ6NSaBKqWW53ryP1t\\/content_repository\\/tendoo_content_5201409062005303213383.jpg","6":"http:\\/\\/127.0.0.1\\/tendoo-cms\\/tendoo-modules\\/app_tendoo_contents_620140902154910PqALJ6NSaBKqWW53ryP1t\\/content_repository\\/tendoo_content_5201409062005303213383.jpg"}},"link":{"level":{"0":"#","1":"#","2":"","3":"","4":"","5":"#","6":"#Les enfants"}},"global_title":"Nos projets"},"feature_list":{"feature_list_title":"Quoi de neuf avec Tendoo 1.3","feature_list_description":"D\\u00e9couvrez une version beaucoup plus stable que les pr\\u00e9c\\u00e9dentes. Nous avons longuement travailler pour proposer une application \\u00e9pur\\u00e9 et simple \\u00e0 prendre en main, avec 3 th\\u00e8mes disponibles par d\\u00e9faut. Tendoo c\'est \\u00e9galement.","feature_list_loop_title":{"level":{"0":"Une application web robuste","1":"Un CMS pas comme les autres","2":"Plein de fonctionnalit\\u00e9 et de services"}},"feature_list_loop_link":{"level":{"0":"#","1":"#","2":"#"}},"icons":{"level":{"0":"thumbs-o-up","1":"rocket","2":"gift"}}},"testimonials":{"feature_list_title":"Nos t\\u00e9moignages","testimonial_author":{"level":{"0":"John Doe","1":"Sacha"}},"testimonial_author_subinfo":{"level":{"0":"Proceder","1":"Reviewer"}},"testimonial_author_img":{"level":{"0":"http:\\/\\/127.0.0.1\\/tendoo-cms\\/tendoo-modules\\/app_tendoo_contents_620140902154910PqALJ6NSaBKqWW53ryP1t\\/content_repository\\/tendoo_content_5201409062004228196593.jpg","1":"http:\\/\\/127.0.0.1\\/tendoo-cms\\/tendoo-modules\\/app_tendoo_contents_620140902154910PqALJ6NSaBKqWW53ryP1t\\/content_repository\\/tendoo_content_5201409062005303213383.jpg"}},"testimonial_author_content":{"level":{"0":"Lorem ipsum dolor sit amet, cons adipiscing elit. Aenean commodo ligula eget dolor. Cum sociis natoque penatibus mag dis parturient. Lorem ipsum dolor sit amet, cons adipiscing elit. Aenean commodo ligula eget dolor. Cum sociis natoque penatibus mag dis parturient.","1":"Lorem ipsum dolor sit amet, cons adipiscing elit. Aenean commodo ligula eget dolor. Cum sociis natoque penatibus mag dis parturient. Lorem ipsum dolor sit amet, cons adipiscing elit. Aenean commodo ligula eget dolor. Cum sociis natoque penatibus mag dis parturient.Lorem ipsum dolor sit amet, cons adipiscing elit. Aenean commodo ligula eget dolor. Cum sociis natoque penatibus mag dis parturient."}},"testimonials_title":"Nos t\\u00e9moignages"},"promo_box":{"promo_title":"D\\u00e9couvrez Tendoo 1.3","promo_description":"D\\u00e9couvrez une version beaucoup plus stable de tendoo 1.3, avec de nouveaux outils et de nouvelles fonctionnalit\\u00e9s.","promo_icon":"archive","promo_button_text":"T\\u00e9l\\u00e9charger Tendoo","promo_button_link":"https:\\/\\/github.com\\/Blair2004\\/tendoo-cms\\/releases","promo_visibility":"1"},"fraction_slider":{"slider_namespaces":"item1, item2","slider_anims":"fade, fade","item_slide_id":{"level":{"0":"item1","1":"item1","2":"item2","3":"item2","4":"item2","5":"item2"}},"item_position":{"level":{"0":"180,800","1":"50,485","2":"0,0","3":"150,100","4":"50,750","5":"200,100"}},"item_anim_start":{"level":{"0":"fade"}},"item_anim_end":{"level":{"0":""}},"item_anim_ease":{"level":{"0":"linear","1":"linear"}},"item_anim_delay":{"level":{"0":"0","1":"","2":"","3":"2000","4":"0","5":"1000"}},"item_anim_speed":{"level":{"0":"","1":"","2":"","3":"","4":"","5":""}},"item_anim_dim":{"level":{"0":""}},"item_anim_type":{"level":{"0":"p"}},"item_anim_fixed":{"level":{"0":"fixed","1":"animated","2":"animated","3":"animated","4":"animated","5":"animated"}},"item_anim_start_type":{"level":{"0":"bottom","1":"top","2":"fade","3":"right","4":"top","5":"right"}},"item_anim_end_type":{"level":{"0":"bottom","1":"top","2":"fade","3":"left","4":"top","5":"left"}},"item_anim_ease_in":{"level":{"0":"easeInOutCubic","1":"easeInOutCubic","2":"linear","3":"","4":"","5":""}},"item_anim_ease_out":{"level":{"0":"","1":"","2":"linear","3":"","4":"","5":""}},"item_dim":{"level":{"0":"","1":"","2":"2000x750","3":"","4":"","5":""}},"item_type":{"level":{"0":"img","1":"p","2":"img","3":"p","4":"p","5":"p"}},"item_content":{"level":{"0":"http:\\/\\/127.0.0.1\\/tendoo-cms\\/tendoo-assets\\/img\\/tendoo_darken.png","1":"Bienvenue sur Tendoo CMS","2":"http:\\/\\/127.0.0.1\\/tendoo-cms\\/tendoo-assets\\/eve-theme-images\\/2.jpg","3":"Simple et facile \\u00e0 utiliser","4":"Ses atouts","5":"Rapide et Puissant"}},"item_class":{"level":{"0":"","1":"para-new","2":"","3":"teaser turky small","4":"claim light-pink","5":"teaser turky small"}},"item_css_style":{"level":{"0":"","1":"","2":"","3":"","4":"","5":""}},"display_slider":"0","item_step":{"level":{"0":"","1":"","2":"","3":"","4":"","5":""}},"item_anim_time":{"level":{"0":"","1":"","2":"","3":"","4":"","5":""}}},"header_datas":{"header_text":{"level":{"0":"*****@*****.**"}},"header_icon":{"level":{"0":"envelope"}}},"footer_social_feeds":{"social_links":{"level":{"0":"https:\\/\\/www.facebook.com\\/tendoocms"}},"social_icons":{"level":{"0":"facebook"}}},"contact_get_social":{"get_social_title":"Suivez-nous","social_links":{"level":{"0":"https:\\/\\/www.facebook.com\\/tendoocms"}},"social_icons":{"level":{"0":"facebook"}}},"contact_gmap_data":{"gmap_longitude":"2.3522219","gmap_latitude":"48.8566140"}}');
             // Creating Base Roles
             $this->roles->create(__('Administrator'), '', 0);
             $this->roles->create(__('User'), '', 0);
             if ($themes) {
                 foreach ($themes as $namespace => $app_datas) {
                     // Activate module
                     if ($namespace == 'eva') {
                         active_theme($namespace);
                     }
                     // Executing Sql queries
                     if (is_array($queries = riake('sql_queries', $app_datas))) {
                         foreach ($queries as $sql_line) {
                             get_db('from_install_interface')->query($sql_line);
                         }
                     }
                 }
             }
             return json_encode(array('response' => translate("Installation is now complete. We're taking you to your new website. <br>Thank you for using Tendoo CMS..."), 'type' => 'warning', 'step' => 2, 'progress' => 100));
         } else {
             return json_encode(array('response' => translate('Error occurred during tables creation. Please check out the server configuration, and try again.'), 'type' => 'warning', 'step' => 0, 'progress' => 0));
         }
     }
     return json_encode(array('response' => translate('Unknow install step, please try again.'), 'type' => 'warning'));
 }
Example #3
0
 public function boot()
 {
     if ($this->db_connect()) {
         $this->date = new Tdate();
         $this->meta_datas = new Meta_datas();
     }
     /* =-=-=-=-=-=-=-=-= URI HANDLER	-=-=-=-=-=-=-=-=-=-= */
     set_core_vars('base_url', $baseUrl = $this->url->site_url(array('index')));
     set_core_vars('controller', $Class = $this->url->controller());
     set_core_vars('method', $Method = $this->url->method());
     set_core_vars('parameters', $Parameters = $this->url->parameters());
     /* =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= */
     /**
      * Check out if current server support tendoo
      **/
     is_compatible();
     /**
      * Load module and Themes if tendoo is installed
      **/
     if ($this->is_installed === true) {
         // Load Themes Only if Website mode is enabled.
         if (get_core_vars('tendoo_mode') !== 'website') {
             load_themes();
         }
         load_modules();
     }
     /**
      * Load Core Vars
      **/
     new Load_Core_Values($this->is_installed);
     /**
      * Checking Controller
      **/
     if (in_array($Class, array('install', 'registration', 'logoff', 'admin', 'login', 'error'))) {
         $Class === 'admin' ? define('SCRIPT_CONTEXT', 'ADMIN') : define('SCRIPT_CONTEXT', 'PUBLIC');
         if ($this->is_installed) {
             if ($this->db_connected()) {
                 include_once CONTROLLERS_DIR . $Class . '.php';
                 include_once SYSTEM_DIR . 'Executer.php';
             } else {
                 $this->tendoo->error('db_connect_error');
                 die;
             }
         } else {
             if ($Class === 'install') {
                 include_once CONTROLLERS_DIR . $Class . '.php';
                 include_once SYSTEM_DIR . 'Executer.php';
             } else {
                 $this->url->redirect(array('install'));
             }
         }
     } else {
         // Define Script context
         define('SCRIPT_CONTEXT', 'PUBLIC');
         // Checks install status
         if (!$this->is_installed) {
             include_once CONTROLLERS_DIR . 'tendoo_index.php';
             include_once SYSTEM_DIR . 'Executer.php';
         } else {
             /**
              * Attemps connecting to database
              **/
             !$this->db_connected() ? $this->tendoo->error('db_connect_error') : null;
             $options = get_core_vars('options');
             /**
              * Loading Users Class
              **/
             $this->load->library('users_global');
             // Conditional if webmode is enabled
             get_core_vars('tendoo_mode') == 'webapp' ? $this->url->redirect(array('admin', 'index?notice=web-app-mode-enabled')) : null;
             /**
              * Setting Core vars
              **/
             set_core_vars('controllers', $loaded_controllers = $this->controller->get('', FALSE), 'readonly');
             // ??
             set_core_vars('page', $unique_controller = $this->controller->_get($Class), 'readonly');
             set_core_vars('active_theme', $active_theme = get_themes('filter_active'));
             set_core_vars('module_url', $module_url = $Class, 'readonly');
             set_core_vars('module', $module = get_modules('filter_active_namespace', $unique_controller[0]['PAGE_MODULES']), 'readonly');
             set_core_vars('opened_module', $module, 'readonly');
             set_core_vars('app_module', $app_module = get_modules('filter_active_app'), 'readonly');
             /**
              * 	Trigger each init.php file within module and theme folders
              *	init.php is the main file for modules and themes.
              *	@since 1.4
              **/
             $this->trigger_inits();
             /**
              * 	Declare Notices : Notices are internal(system) or module/theme alert.
              **/
             set_core_vars('tendoo_notices', trigger_filters('declare_notices', array(get_core_vars('default_notices'))));
             // @since 1.4
             if (is_string($unique_controller)) {
                 $this->url->redirect(array('error', 'code', $unique_controller));
             } else {
                 // If selected module is valid
                 if (!$module) {
                     $this->url->redirect(array('error', 'code', 'moduleBug'));
                 }
                 /**
                  * Setting page meta datas
                  **/
                 set_page('title', $unique_controller[0]['PAGE_TITLE']);
                 set_page('description', $unique_controller[0]['PAGE_DESCRIPTION']);
                 set_page('keywords', $unique_controller[0]['PAGE_KEYWORDS']);
                 // Saved First BreadCrumbs
                 $INDEX = $this->controller->_get('index');
                 set_bread(array('link' => $module_url, 'text' => $INDEX[0]['PAGE_NAMES']));
                 /**
                  * Checks if current module is supported by active theme
                  **/
                 if (TRUE !== does_active_theme_support($module['handle'])) {
                     $this->url->redirect(array('error', 'code', 'unsupported-by-current-theme'));
                 }
                 if ($module_url == 'noMainPage') {
                     $this->url->redirect(array('error', 'code', 'noMainPage'));
                 }
                 if ($active_theme == FALSE) {
                     $this->url->redirect(array('error', 'code', 'no-theme-installed'));
                 } else {
                     // Load theme handler file
                     include_if_file_exists($active_theme['uri_path'] . '/handler.php');
                     if (class_exists($active_theme['namespace'] . '_theme_handler')) {
                         eval('set_core_vars("active_theme_object",new ' . $active_theme['namespace'] . '_theme_handler());');
                         // Initialize Theme handler;
                     } else {
                         $this->url->redirect(array('error', 'code', 'themeCrashed'));
                     }
                     $TENDOO_MODULE = $module;
                     $Class = $module['namespace'];
                     // REAFFECT CLASS VALUE DUE TO EXISTENT MODULE CLASS
                     include_if_file_exists(MODULES_DIR . $module['encrypted_dir'] . '/library.php');
                     include_once MODULES_DIR . $module['encrypted_dir'] . '/frontend.php';
                 }
                 include_once SYSTEM_DIR . 'Executer.php';
                 /// MODULE EXECUTER
             }
         }
     }
 }
Example #4
0
function nanoweb_init($conffile)
{
    global $conf, $themes, $cmdline_conf_overrides, $cmdline_conf_adds, $modules, $posix_av, $pcntl_av, $gz_av, $mime, $access_policy, $sysusr, $sysgrp, $icnt, $banned_ips, $srvlog_levels;
    $dc = get_defined_constants();
    foreach ($dc as $cname => $cval) {
        if (substr($cname, 0, 6) == "NW_EL_") {
            $srvlog_levels[strtolower(substr($cname, 6))] = $cval;
        }
    }
    $iconf = parseconfig(file($conffile));
    if (is_string($iconf)) {
        if ($icnt) {
            techo($iconf, NW_EL_WARNING);
            return false;
        } else {
            errexit($iconf);
        }
    } else {
        if (is_array($iconf)) {
            $conf = $iconf;
        }
    }
    $conf = cmdline_conf_upd($conf, $cmdline_conf_overrides, $cmdline_conf_adds);
    $modules = load_modules($conf);
    modules_init();
    $themes = load_themes($conf);
    ++$icnt;
    $ap_aliases = array("parseext" => "_parseext", "alias" => "_aliases", "errordocument" => "_errordocument", "errorheader" => "_errorheader");
    $access_policy = array();
    foreach ($conf["global"]["accessoverride"] as $ov_dir) {
        if ($ov_dir) {
            $access_policy[strtolower($ov_dir)] = "override";
        }
    }
    foreach ($conf["global"]["accessmerge"] as $mg_dir) {
        if ($mg_dir) {
            $access_policy[strtolower($mg_dir)] = "merge";
        }
    }
    foreach ($conf["global"]["accessblock"] as $bl_dir) {
        if ($bl_dir) {
            $access_policy[strtolower($bl_dir)] = "block";
        }
    }
    foreach ($ap_aliases as $rk => $ak) {
        if ($access_policy[$rk]) {
            $access_policy[$ak] = $access_policy[$rk];
        }
    }
    $posix_av = is_callable("posix_setuid");
    $pcntl_av = is_callable("pcntl_fork");
    $gz_av = is_callable("gzencode");
    if (count($themes) == 0) {
        techo("WARN: No theme loaded, server generated content is disabled", NW_EL_WARNING);
    }
    if ($posix_av) {
        foreach ($conf as $vconf) {
            if ($u = $vconf["user"][0]) {
                $sysusr[$u] = @posix_getpwnam($u);
            }
            if ($g = $vconf["group"][0]) {
                $sysgrp[$g] = @posix_getgrnam($g);
            }
        }
    }
    if (!$conf["global"]["singleprocessmode"][0] && (!$posix_av || !$pcntl_av || $conf["global"]["servermode"][0] == "inetd")) {
        techo("WARN: forcing single process mode", NW_EL_WARNING);
        $conf["global"]["singleprocessmode"][0] = true;
    }
    if ($conf["global"]["servermode"][0] == "inetd") {
        unset($conf["global"]["logtoconsole"]);
        unset($conf["global"]["pidfile"]);
    }
    if ($conf["global"]["singleprocessmode"][0]) {
        $conf["global"]["loggerprocess"] = 0;
        if ($conf["global"]["keepalive"][0]) {
            techo("WARN: KeepAlive should be set to 0 in single process mode", NW_EL_WARNING);
        }
    }
    if ($pcntl_av) {
        pcntl_signal(SIGTERM, "nanoweb_shutdown");
        pcntl_signal(SIGHUP, "nanoweb_reload");
    }
    $mime = array();
    if (!@is_readable($conf["global"]["mimetypes"][0])) {
        techo("WARN: unable to read mime types file (" . $conf["global"]["mimetypes"][0] . "), using internals", NW_EL_WARNING);
        $mime = array("html" => "text/html", "xml" => "text/xml", "gif" => "image/gif", "jpeg" => "image/jpeg", "png" => "image/png", "tgz" => "application/gtar");
    } else {
        if ($mimetypes = @file($conf["global"]["mimetypes"][0])) {
            foreach ($mimetypes as $s) {
                if (trim($s) && $s[0] != "#") {
                    if (ereg("([a-zA-Z0-9/.-]+)[ \t]+([a-zA-Z0-9 -]+)", $s, $res)) {
                        if ($exts = explode(" ", trim($res[2]))) {
                            foreach ($exts as $ext) {
                                if (trim($res[1]) && trim($ext)) {
                                    $mime[$ext] = trim($res[1]);
                                }
                            }
                        }
                    }
                }
            }
            unset($mimetypes);
        }
    }
    if ($at = $conf["global"]["addtype"]) {
        foreach ($at as $adt) {
            $mt = strtok(trim($adt), " ");
            while ($s = strtok(" ")) {
                $mime[ltrim($s, ".")] = $mt;
            }
        }
    }
    $conf["_complete"] = true;
    $banned_ips = array();
    if (is_array($conf["global"]["blockipaddr"])) {
        foreach ($conf["global"]["blockipaddr"] as $ip) {
            nw_block_ip_address($ip, "PERM", "config.BlockIPAddr");
        }
    }
    return true;
}