示例#1
0
function nvweb_load_website_by_url($url, $exit = true)
{
    global $DB;
    global $idn;
    $website = new website();
    $parsed = parse_url($url);
    $scheme = $parsed['scheme'];
    // http, https...
    $host = $parsed['host'];
    // subdomain.domain.tld
    $path = $parsed['path'];
    // [/folder]page
    $host = $idn->decode($host);
    // look for website aliases
    $DB->query('SELECT aliases FROM nv_websites', 'array');
    $ars = $DB->result('aliases');
    $aliases = array();
    foreach ($ars as $ajson) {
        if (!is_array($aliases)) {
            $aliases = array();
        }
        $ajson = json_decode($ajson, true);
        if (!is_array($ajson)) {
            continue;
        }
        $aliases = array_merge($aliases, $ajson);
    }
    if (!is_array($aliases)) {
        $aliases = array();
    }
    foreach ($aliases as $alias => $real) {
        $alias_parsed = parse_url($alias);
        if ($alias_parsed['host'] == $host) {
            if (!isset($alias_parsed['path'])) {
                $alias_parsed['path'] = "";
            }
            $rud_path = rawurldecode($alias_parsed['path']);
            // check the path section
            if ($path == $alias_parsed['path'] || $path == '/nvweb.home' && empty($alias_parsed['path']) || !empty($path) && !empty($rud_path) && strpos($path, $rud_path, 0) !== false) {
                // alias path is included in the requested path
                // identify the extra part
                // EXAMPLE
                //
                //    ALIAS           http://themes.navigatecms.com
                //    REQUEST         http://themes.navigatecms.com/en/introduction
                //        EXTRA           /en/introduction
                //
                //    REAL PATH       http://www.navigatecms.com/en/documentation/themes
                //    REAL + EXTRA    http://www.navigatecms.com/en/documentation/themes/introduction
                //
                // note that the language part "en" is placed in different order
                // so our approach is to IGNORE the path sections already existing in the real path
                $extra = substr($path, strlen($alias_parsed['path']));
                $real_parsed = parse_url($real);
                $real_path = explode('/', $real_parsed['path']);
                $extra_path = explode('/', $extra);
                if (!is_array($extra_path)) {
                    $extra_path = array();
                }
                $add_to_real = '';
                foreach ($extra_path as $part) {
                    if ($part == 'nvweb.home') {
                        continue;
                    }
                    if (in_array($part, $real_path)) {
                        continue;
                    }
                    $add_to_real .= '/' . $part;
                }
                // TO DO: maybe in a later version full ALIAS support could be implemented
                //        right now we only redirect to the real path
                $url = $real . $add_to_real;
                header('location: ' . $idn->encode($url));
                nvweb_clean_exit();
            }
        }
    }
    // the host is an IP address or a full domain?
    $isIP = filter_var($host, FILTER_VALIDATE_IP);
    if ($isIP) {
        $domain = $host;
        $subdomain = "";
    } else {
        // do we have a subdomain in the url?
        preg_match('/(?:http[s]*\\:\\/\\/)*(.*?)\\.(?=[^\\/]*\\..{2,5})/i', $url, $parts);
        $subdomain = $parts[1];
        $domain = $host;
        if (empty($subdomain)) {
            // may be NULL
            $subdomain = "";
        } else {
            $domain = substr($host, strlen($subdomain) + 1);
        }
    }
    $DB->query('
		SELECT id, folder
		  FROM nv_websites
		 WHERE subdomain = ' . protect($subdomain) . '
		   AND domain = ' . protect($domain) . '
		 ORDER BY folder DESC
	 ');
    $websites = $DB->result();
    if (empty($websites)) {
        // no 'real' website found using this address
        if ($subdomain == 'nv') {
            /*
            			$website->load(); // first available, it doesn't matter
            			$nvweb_absolute = (empty($website->protocol)? 'http://' : $website->protocol);
            			if(!empty($website->subdomain))
            				$nvweb_absolute .= $website->subdomain.'.';
            			$nvweb_absolute .= $website->domain.$website->folder;
            */
            $nvweb_absolute = NAVIGATE_PARENT . NAVIGATE_FOLDER;
            header('location: ' . $nvweb_absolute);
            nvweb_clean_exit();
        } else {
            header("HTTP/1.1 404 Not Found");
            if ($exit) {
                nvweb_clean_exit();
            } else {
                return false;
            }
        }
    }
    // choose which website based on folder name
    foreach ($websites as $web) {
        // there can only be one subdomain.domain.tld without folder
        if (empty($web->folder)) {
            $website->load($web->id);
            break;
        } else {
            $path_segments = explode('/', $path);
            $folder_segments = explode('/', $web->folder);
            $folder_coincidence = true;
            for ($fs = 0; $fs < count($folder_segments); $fs++) {
                $folder_coincidence = $folder_coincidence && $folder_segments[$fs] == $path_segments[$fs];
            }
            if ($folder_coincidence) {
                $website->load($web->id);
                break;
            }
        }
    }
    // website could not be identified, just load the first available
    if (empty($website->id)) {
        $website->load();
    }
    return $website;
}
 public static function elements($template, $element = "", $website_id = null)
 {
     global $DB;
     global $website;
     global $theme;
     $data = array();
     if (empty($website_id)) {
         $website_id = $website->id;
     }
     if (is_numeric($template)) {
         // properties attached to a custom template (not a theme template)
         if (!empty($element)) {
             $element = ' AND element = ' . protect($element);
         } else {
             $element = ' AND element != "block"';
         }
         if ($DB->query('
                SELECT *
                FROM nv_properties
                WHERE template = ' . protect($template) . '
                ' . $element . '
                  AND website = ' . $website_id . '
                ORDER BY position ASC, id ASC')) {
             $data = $DB->result();
         }
     } else {
         if ($element == 'webuser') {
             // webuser properties (set in theme definition)
             $data = $theme->webusers['properties'];
         } else {
             if ($element == 'block') {
                 // block type properties
                 for ($b = 0; $b < count($theme->blocks); $b++) {
                     if ($theme->blocks[$b]->id == $template) {
                         $data = $theme->blocks[$b]->properties;
                         break;
                     }
                 }
             } else {
                 if ($element == 'block_group_block') {
                     // block group blocks properties
                     for ($b = 0; $b < count($theme->block_groups); $b++) {
                         if ($theme->block_groups[$b]->id == $template) {
                             $data = array();
                             foreach ($theme->block_groups[$b]->blocks as $bgb) {
                                 // note: properties in block group blocks can't have the same name
                                 if (isset($bgb->properties)) {
                                     $data = array_merge($data, $bgb->properties);
                                 }
                             }
                             break;
                         }
                     }
                 } else {
                     if ($element == 'comment') {
                         // properties of the comments of a certain template type
                         $theme_template = new template();
                         if (!empty($website_id)) {
                             // force loading website information
                             $ws = new website();
                             $ws->load($website_id);
                             $ws_theme = $ws->theme;
                         }
                         $theme_template->load_from_theme($template, $ws_theme);
                         $comments_properties = $theme_template->comments->properties;
                         if (empty($comments_properties)) {
                             $comments_properties = array();
                         }
                         $data = array();
                         for ($p = 0; $p < count($comments_properties); $p++) {
                             $data[] = $comments_properties[$p];
                         }
                     } else {
                         // properties of a theme template
                         $theme_template = new template();
                         if (!empty($website_id)) {
                             // force loading website information
                             $ws = new website();
                             $ws->load($website_id);
                             $ws_theme = $ws->theme;
                         }
                         $theme_template->load_from_theme($template, $ws_theme);
                         $template_properties = $theme_template->properties;
                         if (empty($template_properties)) {
                             $template_properties = array();
                         }
                         $data = array();
                         for ($p = 0; $p < count($template_properties); $p++) {
                             // if we want all properties, no matter the element assigned or
                             // if the property is not assigned to an element, we assume "item", or
                             // if the property is assigned to an element, we check it
                             // note: in this case, "element" is an alias of "item"
                             if (empty($element) || $element == 'item' && empty($template_properties[$p]->element) || $element == 'item' && $template_properties[$p]->element == "element" || $template_properties[$p]->element == $element) {
                                 $data[] = $template_properties[$p];
                             }
                         }
                     }
                 }
             }
         }
     }
     return $data;
 }
示例#3
0
 function metaWeblog_getPost($args)
 {
     global $DB;
     global $session;
     $out = array();
     list($post_id, $username, $password) = $args;
     $item = new item();
     $item->load(intval($post_id));
     $website_id = $item->website;
     $website = new website();
     $website->load($website_id);
     // check auth
     if (metaWeblog_userAllowed($username, $password, $website_id)) {
         if ($item->embedding == 1) {
             $link = nvweb_source_url('structure', $item->category, $session['lang']);
         } else {
             $link = $item->link($session['lang']);
         }
         $category = new structure();
         $category->load($item->category);
         $content = $item->dictionary[$session['lang']]['section-main'];
         $content = nvweb_template_fix_download_paths($content);
         if (empty($item->date_to_display)) {
             $item->date_to_display = $item->date_created;
         }
         $out = array("postid" => $item->id, "userid" => $item->author, "dateCreated" => new IXR_Date($item->date_to_display), "category" => $item->category, "title" => $item->dictionary[$session['lang']]['title'], "description" => $content, "url" => $link, "permalink" => $link, "mt_keywords" => $item->dictionary[$session['lang']]['tags']);
     } else {
         $out = new IXR_Error(401, "User not allowed.");
     }
     return $out;
 }
function navigate_property_layout_scripts($website_id = "")
{
    global $layout;
    global $website;
    global $current_version;
    $ws = $website;
    if (!empty($website_id) && $website->id != $website_id) {
        $ws = new website();
        $ws->load($website_id);
    }
    $ws_languages = $ws->languages();
    $default_language = array_keys($ws_languages);
    $default_language = $default_language[0];
    $naviforms = new naviforms();
    $layout->add_content('
		<div id="navigate-properties-copy-from-dialog" style=" display: none; ">
			<div class="navigate-form-row">
				<label>' . t(191, 'Source') . '</label>
				' . $naviforms->buttonset('navigate_properties_copy_from_dialog_type', array('language' => t(46, 'Language'), 'item' => t(180, 'Item'), 'structure' => t(16, 'Structure')), '0', "navigate_properties_copy_from_change_origin(this);") . '
			</div>
			<div class="navigate-form-row" style=" display: none; ">
				<label>' . t(46, 'Language') . '</label>
				' . $naviforms->selectfield('navigate_properties_copy_from_language_selector', array_keys($ws_languages), array_values($ws_languages), $default_language, "navigate_properties_copy_from_change_language(this);") . '
			</div>

			<div class="navigate-form-row" style=" display: none; ">
				<label>' . t(67, 'Title') . '</label>
				' . $naviforms->textfield('navigate_properties_copy_from_item_title') . '
				<button id="navigate_properties_copy_from_item_reload"><i class="fa fa-repeat"></i></button>
				' . $naviforms->hidden('navigate_properties_copy_from_item_id', '') . '
			</div>

			<div class="navigate-form-row" style=" display: none; ">
				<label>' . t(67, 'Title') . '</label>
				' . $naviforms->textfield('navigate_properties_copy_from_structure_title') . '
				<button id="navigate_properties_copy_from_structure_reload"><i class="fa fa-repeat"></i></button>
				' . $naviforms->hidden('navigate_properties_copy_from_structure_id', '') . '
			</div>

			<div class="navigate-form-row" style=" display: none; ">
				<label>' . t(239, 'Section') . '</label>
				' . $naviforms->select_from_object_array('navigate_properties_copy_from_section', array(), 'code', 'name', '') . '
			</div>
		</div>
	');
    $layout->add_script('
		$.getScript("lib/packages/properties/properties.js?r=' . $current_version->revision . '", function()
		{
			$(".navigate-form-row-property-action").on("click", function(e)
			{
			    var that = this;
			
				e.stopPropagation();
				e.preventDefault();
				
				if(!$(this).parent().hasClass("navigate-form-row"))
				    that = $(this).parent();
				
				navigate_properties_copy_from_dialog(that);
			});
		});
	');
}
示例#5
0
function process()
{
    global $DB;
    global $website;
    global $events;
    global $theme;
    set_time_limit(0);
    setlocale(LC_ALL, $_SESSION['navigate_install_locale']);
    $lang = navigate_install_load_language();
    switch ($_REQUEST['process']) {
        case 'verify_zip':
            sleep(1);
            if (!file_exists('package.zip')) {
                die(json_encode($lang['missing_package']));
            } else {
                $zip = new ZipArchive();
                if ($zip->open('package.zip') !== TRUE) {
                    die(json_encode($lang['invalid_package']));
                } else {
                    $zip->close();
                    die(json_encode(true));
                }
            }
            break;
        case 'extract_zip':
            $npath = getcwd() . NAVIGATE_FOLDER;
            $npath = str_replace('\\', '/', $npath);
            if (!file_exists($npath)) {
                mkdir($npath);
            }
            if (file_exists($npath)) {
                $zip = new ZipArchive();
                if ($zip->open('package.zip') === TRUE) {
                    $zip->extractTo($npath);
                    $zip->close();
                    copy($npath . '/crossdomain.xml', dirname($npath) . '/crossdomain.xml');
                    die(json_encode(true));
                } else {
                    die(json_encode($lang['extraction_failed']));
                }
            }
            die(json_encode($lang['folder_not_exists']));
            break;
        case 'chmod':
            sleep(1);
            // chmod the directories recursively
            $npath = getcwd() . NAVIGATE_FOLDER;
            if (!navigate_install_chmodr($npath, 0755)) {
                die(json_encode($lang['chmod_failed']));
            } else {
                die(json_encode(true));
            }
            break;
        case 'verify_database':
            if ($_REQUEST['PDO_DRIVER'] == 'mysql' || $_REQUEST['PDO_DRIVER'] == 'mysql-socket') {
                try {
                    $dsn = "mysql:host=" . $_REQUEST['PDO_HOSTNAME'] . ";port=" . $_REQUEST['PDO_PORT'] . ';charset=utf8';
                    if ($_REQUEST['PDO_DRIVER'] == "mysql-socket") {
                        $dsn = "mysql:unix_socket=" . $_REQUEST['PDO_SOCKET'] . ";charset=utf8";
                    }
                    $db_test = @new PDO($dsn, $_REQUEST['PDO_USERNAME'], $_REQUEST['PDO_PASSWORD']);
                    if (!$db_test) {
                        echo json_encode(array('error' => $lang['database_connect_error']));
                    } else {
                        $create_database_privilege = false;
                        $drop_database_privilege = false;
                        $stm = $db_test->query('SHOW DATABASES;');
                        $rs = $stm->fetchAll(PDO::FETCH_COLUMN, 'Database');
                        $rs = array_diff($rs, array('mysql', 'information_schema'));
                        $stm = $db_test->query('SHOW PRIVILEGES;');
                        $privileges = $stm->fetchAll(PDO::FETCH_ASSOC);
                        for ($p = 0; $p < count($privileges); $p++) {
                            if ($privileges[$p]['Privilege'] == 'Create') {
                                if (strpos($privileges[$p]['Context'], 'Databases') !== false) {
                                    $create_database_privilege = true;
                                }
                            }
                            if ($privileges[$p]['Privilege'] == 'Drop') {
                                if (strpos($privileges[$p]['Context'], 'Databases') !== false) {
                                    $drop_database_privilege = true;
                                }
                            }
                        }
                        if ($create_database_privilege && $drop_database_privilege) {
                            // check if we are really allowed to create databases
                            $dbname = 'navigate_test_' . time();
                            $create_result = $db_test->exec('CREATE DATABASE ' . $dbname);
                            if ($create_result) {
                                $db_test->exec('DROP DATABASE ' . $dbname);
                            }
                            if (!$create_result) {
                                $create_database_privilege = false;
                            }
                        }
                        $db_test = NULL;
                        echo json_encode(array('databases' => array_values($rs), 'create_database_privilege' => $create_database_privilege));
                    }
                } catch (Exception $e) {
                    echo json_encode(array('error' => $e->getMessage()));
                }
            } else {
                echo json_encode(array('error' => $lang['database_driver_error']));
            }
            exit;
            break;
        case 'database_create':
            $DB = new database();
            if (!$DB->connect()) {
                // try to create the database automatically
                if (PDO_DRIVER == 'mysql') {
                    if (PDO_DATABASE != '') {
                        if (PDO_HOSTNAME != "") {
                            $dsn = "mysql:host=" . PDO_HOSTNAME . ";port=" . PDO_PORT . ";charset=utf8";
                        } else {
                            $dsn = "mysql:unix_socket=" . PDO_SOCKET . ";charset=utf8";
                        }
                        $db_test = new PDO($dsn, PDO_USERNAME, PDO_PASSWORD);
                        $db_test->exec('CREATE DATABASE IF NOT EXISTS `' . PDO_DATABASE . '` DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;');
                        $db_test = NULL;
                    }
                    if (!$DB->connect()) {
                        echo json_encode(array('error' => $DB->get_last_error()));
                    } else {
                        echo json_encode(array('ok' => $lang['database_created']));
                    }
                }
            } else {
                echo json_encode(array('ok' => $lang['database_exists']));
            }
            exit;
            break;
        case 'database_import':
            $DB = new database();
            if (!$DB->connect()) {
                die(json_encode(array('error' => $DB->get_last_error())));
            }
            try {
                $sql = file_get_contents('navigate.sql');
                $sql = str_replace("{#!NAVIGATE_FOLDER!#}", NAVIGATE_PARENT . NAVIGATE_FOLDER, $sql);
                $sql = explode("\n\n", $sql);
                // can't do it in one step => SQLSTATE[HY000]: General error: 2014
                foreach ($sql as $sqlline) {
                    $sqlline = trim($sqlline);
                    if (empty($sqlline)) {
                        continue;
                    }
                    if (!@$DB->execute($sqlline)) {
                        $error = $DB->get_last_error();
                    }
                    if (!empty($error)) {
                        break;
                    }
                }
            } catch (Exception $e) {
                $error = $e->getMessage();
            }
            if (!empty($error) && false) {
                echo json_encode(array('error' => $error));
            } else {
                echo json_encode(array('ok' => $lang['done']));
            }
            exit;
            break;
        case 'create_account':
            // create admin
            try {
                $DB = new database();
                if (!$DB->connect()) {
                    die(json_encode(array('error' => $DB->get_last_error())));
                }
                $user = new user();
                $user->id = 0;
                $user->username = $_SESSION['NAVIGATE-SETUP']['ADMIN_USERNAME'];
                $user->set_password($_SESSION['NAVIGATE-SETUP']['ADMIN_PASSWORD']);
                $user->email = $_SESSION['NAVIGATE-SETUP']['ADMIN_EMAIL'];
                $user->profile = 1;
                $user->skin = 'cupertino';
                $user->language = $_SESSION['navigate_install_lang'];
                $user->blocked = 0;
                $user->timezone = 'UTC';
                $user->date_format = 'Y-m-d H:i';
                $user->decimal_separator = ',';
                $user->thousands_separator = '';
                $user->attempts = 0;
                $user->cookie_hash = '';
                $user->activation_key = '';
                $ok = $user->insert();
                if (!$ok) {
                    throw new Exception($lang['error']);
                }
                // create default website details
                $website = new website();
                $website->create_default();
                $_SESSION['NAVIGATE-SETUP']['WEBSITE_DEFAULT'] = $website->id;
                echo json_encode(array('ok' => $lang['done']));
            } catch (Exception $e) {
                echo json_encode(array('error' => $e->getMessage()));
            }
            exit;
            break;
        case 'install_default_theme':
            try {
                $DB = new database();
                if (!$DB->connect()) {
                    die(json_encode(array('error' => $DB->get_last_error())));
                }
                if (@$_SESSION['NAVIGATE-SETUP']['DEFAULT_THEME'] == 'theme_kit') {
                    $website = new website();
                    $website->load($_SESSION['NAVIGATE-SETUP']['WEBSITE_DEFAULT']);
                    $website->theme = 'theme_kit';
                    $website->languages = array('en' => array('language' => 'en', 'variant' => '', 'code' => 'en', 'system_locale' => 'en_US.utf8'), 'es' => array('language' => 'es', 'variant' => '', 'code' => 'es', 'system_locale' => 'es_ES.utf8'));
                    $website->languages_published = array('en', 'es');
                    $website->save();
                    // default objects (first user, no events bound...)
                    $user = new user();
                    $user->load(1);
                    $events = new events();
                    $zip = new ZipArchive();
                    $zip_open_status = $zip->open(NAVIGATE_PATH . '/themes/theme_kit.zip');
                    if ($zip_open_status === TRUE) {
                        $zip->extractTo(NAVIGATE_PATH . '/themes/theme_kit');
                        $zip->close();
                        $theme = new theme();
                        $theme->load('theme_kit');
                        $theme->import_sample($website);
                    }
                    echo json_encode(array('ok' => $lang['done']));
                } else {
                    // user does not want to install the default theme
                    echo json_encode(array('ok' => $lang['not_selected']));
                }
            } catch (Exception $e) {
                echo json_encode(array('error' => $e->getMessage()));
            }
            exit;
            break;
        case 'apache_htaccess':
            try {
                $nvweb = dirname($_SERVER['REQUEST_URI']) . NAVIGATE_FOLDER . '/web/nvweb.php';
                $nvweb = str_replace('//', '/', $nvweb);
                $data = array();
                $data[] = 'Options +FollowSymLinks';
                $data[] = 'Options -Indexes';
                $data[] = 'RewriteEngine On';
                $data[] = 'RewriteBase /';
                $data[] = 'RewriteCond %{REQUEST_FILENAME} !-f';
                $data[] = 'RewriteCond %{REQUEST_FILENAME} !-d';
                $data[] = 'RewriteRule ^(.+) ' . $nvweb . '?route=$1 [QSA]';
                $data[] = 'RewriteRule ^$ ' . $nvweb . '?route=nv.empty [L,QSA]';
                $ok = @file_put_contents(dirname(NAVIGATE_PATH) . '/.htaccess', implode("\n", $data));
                if (!$ok) {
                    throw new Exception($lang['unexpected_error']);
                }
                echo json_encode('true');
            } catch (Exception $e) {
                echo json_encode(array('error' => $e->getMessage()));
            }
            exit;
            break;
    }
}
 public static function hierarchy($id_parent = 0, $ws_id = null)
 {
     global $website;
     global $theme;
     if (empty($ws_id)) {
         $ws_id = $website->id;
     }
     $ws = new website();
     $ws->load($ws_id);
     $flang = $ws->languages_list[0];
     if (empty($flang)) {
         return array();
     }
     $tree = array();
     if ($id_parent == -1) {
         // create the virtual root structure entry (the website)
         $obj = new structure();
         $obj->id = 0;
         $obj->label = $ws->name;
         $obj->_multilanguage_label = $ws->name;
         $obj->parent = -1;
         $obj->children = structure::hierarchy(0, $ws_id);
         $tree[] = $obj;
     } else {
         $tree = structure::loadTree($id_parent, $ws_id);
         $templates = template::elements('structure');
         if (empty($templates)) {
             $templates = array();
         }
         for ($i = 0; $i < count($tree); $i++) {
             $tree[$i]->dictionary = webdictionary::load_element_strings('structure', $tree[$i]->id);
             $tree[$i]->label = $tree[$i]->dictionary[$ws->languages_list[0]]['title'];
             $tree[$i]->template_title = $tree[$i]->template;
             foreach ($templates as $template_def) {
                 if ($template_def->type == $tree[$i]->template) {
                     $tree[$i]->template_title = $template_def->title;
                     break;
                 }
             }
             if (method_exists($theme, "t")) {
                 $tree[$i]->template_title = $theme->t($tree[$i]->template_title);
             }
             for ($wl = 0; $wl < count($ws->languages_list); $wl++) {
                 $lang = $ws->languages_list[$wl];
                 if (empty($tree[$i]->dictionary[$lang]['title'])) {
                     $tree[$i]->dictionary[$lang]['title'] = '[ ? ]';
                 }
                 $style = '';
                 if ($lang != $flang) {
                     $style = 'display: none';
                 }
                 $label[] = '<span class="structure-label" lang="' . $lang . '" style="' . $style . '">' . $tree[$i]->dictionary[$lang]['title'] . '</span>';
                 $bc[$tree[$i]->id][$lang] = $tree[$i]->dictionary[$lang]['title'];
             }
             $children = structure::hierarchy($tree[$i]->id, $ws_id);
             $tree[$i]->children = $children;
         }
     }
     return $tree;
 }
示例#7
0
    }
}
if (!empty($_POST['login-username']) && !empty($_POST['login-password'])) {
    $error = !$user->authenticate($_POST['login-username'], $_POST['login-password']);
    if (empty($error) && $user->blocked == '1') {
        $error = true;
    }
    if (!$error) {
        $_SESSION['APP_USER#' . APP_UNIQUE] = $user->id;
        if ($_REQUEST['login-remember'] == '1') {
            $user->set_cookie();
        } else {
            $user->remove_cookie();
        }
        $login_request_uri = $_SESSION["login_request_uri"];
        $website->load();
        // load first website available (needed in the users log)
        users_log::action(0, $user->id, 'login', $user->username);
        $_SESSION["login_request_uri"] = '';
        setcookie('navigate-session-id', session_id(), time() + 60, '/');
        // 60 seconds
        session_write_close();
        header('location: ' . NAVIGATE_MAIN . '?' . $login_request_uri);
        exit;
    }
}
/* CHECK USER BROWSER LANGUAGE PREFERENCES */
$language_default = 'en';
$DB->query('SELECT code 
			FROM nv_languages
			WHERE nv_dictionary != ""', 'array');
示例#8
0
function run()
{
    global $user;
    global $layout;
    global $DB;
    global $website;
    $out = '';
    $item = new website();
    switch ($_REQUEST['act']) {
        case 'json':
        case 1:
            // json data retrieval & operations
            switch ($_REQUEST['oper']) {
                case 'search_links':
                    // active website only!
                    $text = $_REQUEST['text'];
                    $lang = $_REQUEST['lang'];
                    if (empty($lang)) {
                        $lang = array_keys($website->languages)[0];
                    }
                    $DB->query('
						SELECT p.path, d.text
						  FROM nv_paths p, nv_webdictionary d
						 WHERE p.website = ' . protect($website->id) . ' AND
						       p.lang = ' . protect($lang) . ' AND
						       d.website = p.website AND
						       d.node_type = p.type AND
						       d.node_id = p.object_id AND
						       d.lang = p.lang AND
						       d.subtype = "title" AND 
						       (    
						            p.path LIKE ' . protect('%' . $text . '%') . '  OR  
									d.text LIKE ' . protect('%' . $text . '%') . ' 
						       )
						 ORDER BY d.id DESC
						 LIMIT 10
					');
                    $result = $DB->result();
                    echo json_encode($result);
                    core_terminate();
                    break;
                case 'del':
                    // remove rows
                    if ($user->permission('websites.delete') == 'true') {
                        $ids = $_REQUEST['ids'];
                        foreach ($ids as $id) {
                            $item->load($id);
                            $item->delete();
                        }
                        echo json_encode(true);
                    }
                    core_terminate();
                    break;
                default:
                    // list or search
                    $page = intval($_REQUEST['page']);
                    $max = intval($_REQUEST['rows']);
                    $offset = ($page - 1) * $max;
                    $orderby = $_REQUEST['sidx'] . ' ' . $_REQUEST['sord'];
                    $where = " 1=1 ";
                    if ($_REQUEST['_search'] == 'true' || isset($_REQUEST['quicksearch'])) {
                        if (isset($_REQUEST['quicksearch'])) {
                            $where .= $item->quicksearch($_REQUEST['quicksearch']);
                        } else {
                            if (isset($_REQUEST['filters'])) {
                                $where .= navitable::jqgridsearch($_REQUEST['filters']);
                            } else {
                                // single search
                                $where .= ' AND ' . navitable::jqgridcompare($_REQUEST['searchField'], $_REQUEST['searchOper'], $_REQUEST['searchString']);
                            }
                        }
                    }
                    $DB->queryLimit('id,name,subdomain,domain,folder,homepage,permission,favicon', 'nv_websites', $where, $orderby, $offset, $max);
                    $dataset = $DB->result();
                    $total = $DB->foundRows();
                    //echo $DB->get_last_error();
                    $out = array();
                    $permissions = array(0 => '<img src="img/icons/silk/world.png" align="absmiddle" /> ' . t(69, 'Published'), 1 => '<img src="img/icons/silk/world_dawn.png" align="absmiddle" /> ' . t(70, 'Private'), 2 => '<img src="img/icons/silk/world_night.png" align="absmiddle" /> ' . t(81, 'Hidden'));
                    for ($i = 0; $i < count($dataset); $i++) {
                        $homepage = 'http://';
                        $homepage_relative_url = $dataset[$i]['homepage'];
                        if (is_numeric($homepage_relative_url)) {
                            $homepage_relative_url = path::loadElementPaths('structure', $homepage_relative_url);
                            $homepage_relative_url = array_shift($homepage_relative_url);
                        }
                        if (!empty($dataset[$i]['subdomain'])) {
                            $homepage .= $dataset[$i]['subdomain'] . '.';
                        }
                        $homepage .= $dataset[$i]['domain'] . $dataset[$i]['folder'] . $homepage_relative_url;
                        $favicon = '';
                        if (!empty($dataset[$i]['favicon'])) {
                            $favicon = '<img src="' . NVWEB_OBJECT . '?type=img&id=' . $dataset[$i]['favicon'] . '&width=16&height=16" align="absmiddle" height="16" />';
                        }
                        $out[$i] = array(0 => $dataset[$i]['id'], 1 => $favicon, 2 => $dataset[$i]['name'], 3 => '<a href="' . $homepage . '" target="_blank"><img align="absmiddle" src="' . NAVIGATE_URL . '/img/icons/silk/house_link.png"></a> ' . $homepage, 4 => $permissions[$dataset[$i]['permission']]);
                    }
                    navitable::jqgridJson($out, $page, $offset, $max, $total);
                    break;
            }
            session_write_close();
            exit;
            break;
        case 'edit':
        case 2:
            // edit/new form
            if (!empty($_REQUEST['id'])) {
                $item->load(intval($_REQUEST['id']));
            }
            if (isset($_REQUEST['form-sent']) && $user->permission('websites.edit') == 'true') {
                $item->load_from_post();
                try {
                    $item->save();
                    $id = $item->id;
                    unset($item);
                    $item = new website();
                    $item->load($id);
                    $layout->navigate_notification(t(53, "Data saved successfully."), false, false, 'fa fa-check');
                } catch (Exception $e) {
                    $layout->navigate_notification($e->getMessage(), true, true);
                }
                if (!empty($item->id)) {
                    users_log::action($_REQUEST['fid'], $item->id, 'save', $item->name, json_encode($_REQUEST));
                }
            } else {
                if (!empty($item->id)) {
                    users_log::action($_REQUEST['fid'], $item->id, 'load', $item->name);
                }
            }
            $out = websites_form($item);
            break;
        case 'remove':
        case 4:
            if (!empty($_REQUEST['id']) && $user->permission('websites.delete') == 'true') {
                $item->load(intval($_REQUEST['id']));
                if ($item->delete() > 0) {
                    $layout->navigate_notification(t(55, 'Item removed successfully.'), false);
                    if (!empty($item->id)) {
                        users_log::action($_REQUEST['fid'], $item->id, 'remove', $item->name, json_encode($_REQUEST));
                    }
                    // if we don't have any websites, tell user a new one will be created
                    $test = $DB->query_single('id', 'nv_websites');
                    if (empty($test) || !$test) {
                        $layout->navigate_notification(t(520, 'No website found; a default one has been created.'), false, true);
                        $nwebsite = new website();
                        $nwebsite->create_default();
                    }
                    $out = websites_list();
                } else {
                    $layout->navigate_notification(t(56, 'Unexpected error.'), false);
                    $out = websites_form($item);
                }
            }
            break;
        case 5:
            // search an existing path
            $DB->query('SELECT path as id, path as label, path as value
						  FROM nv_paths
						 WHERE path LIKE ' . protect('%' . $_REQUEST['term'] . '%') . '
						   AND website = ' . protect($_REQUEST['wid']) . '
				      ORDER BY path ASC
					     LIMIT 30', 'array');
            echo json_encode($DB->result());
            core_terminate();
            break;
        case 'email_test':
            $website->mail_mailer = $_REQUEST['mail_mailer'];
            $website->mail_server = $_REQUEST['mail_server'];
            $website->mail_port = $_REQUEST['mail_port'];
            $website->mail_address = $_REQUEST['mail_address'];
            $website->mail_user = $_REQUEST['mail_user'];
            $website->mail_security = $_REQUEST['mail_security'] == "true" || $_REQUEST['mail_security'] == "1" ? "1" : "0";
            if (!empty($_REQUEST['mail_password'])) {
                $website->mail_password = $_REQUEST['mail_password'];
            }
            $ok = navigate_send_email(APP_NAME, APP_NAME . '<br /><br />' . NAVIGATE_URL, $_REQUEST['send_to']);
            echo json_encode($ok);
            core_terminate();
            break;
        case 'reset_statistics':
            if ($user->permission('websites.edit') == 'true') {
                $website_id = trim($_REQUEST['website']);
                $website_id = intval($website_id);
                $DB->execute('UPDATE nv_items SET views = 0 WHERE website = ' . $website_id);
                $DB->execute('UPDATE nv_paths SET views = 0 WHERE website = ' . $website_id);
                $DB->execute('UPDATE nv_structure SET views = 0 WHERE website = ' . $website_id);
                echo 'true';
                users_log::action($_REQUEST['fid'], $website_id, 'reset_statistics', "", json_encode($_REQUEST));
            }
            core_terminate();
            break;
        case 'replace_urls':
            $old = trim($_REQUEST['old']);
            $new = trim($_REQUEST['new']);
            $website_id = trim($_REQUEST['website']);
            if (!empty($old) && !empty($new)) {
                // replace occurrences in nv_webdictionary
                $ok = $DB->execute('
					UPDATE nv_webdictionary
					   SET text = replace(text, :old, :new)
					 WHERE website = :wid', array(':old' => $old, ':new' => $new, ':wid' => $website_id));
                // replace occurrences in nv_blocks (triggers & actions)
                $ok = $DB->execute('
					UPDATE nv_blocks
					   SET `trigger` = replace(`trigger`, :old, :new),
					   	   `action` = replace(`action`, :old, :new)
					 WHERE website = :wid', array(':old' => $old, ':new' => $new, ':wid' => $website_id));
                echo $ok ? 'true' : 'false';
                if ($ok) {
                    users_log::action($_REQUEST['fid'], $website_id, 'replace_urls', "", json_encode($_REQUEST));
                }
            } else {
                echo 'false';
            }
            core_terminate();
            break;
        case 'remove_content':
            $website_id = trim($_REQUEST['website']);
            $website_id = intval($website_id);
            $password = trim($_REQUEST['password']);
            $authenticated = $user->authenticate($user->username, $password);
            if ($authenticated) {
                // remove all content except Webusers and Files
                @set_time_limit(0);
                $ok = $DB->execute('
					DELETE FROM nv_blocks WHERE website = ' . $website_id . ';
					DELETE FROM nv_block_groups WHERE website = ' . $website_id . ';
					DELETE FROM nv_comments WHERE website = ' . $website_id . ';
					DELETE FROM nv_structure WHERE website = ' . $website_id . ';
					DELETE FROM nv_feeds WHERE website = ' . $website_id . ';
					DELETE FROM nv_items WHERE website = ' . $website_id . ';
					DELETE FROM nv_notes WHERE website = ' . $website_id . ';
					DELETE FROM nv_paths WHERE website = ' . $website_id . ';
					DELETE FROM nv_properties WHERE website = ' . $website_id . ';
					DELETE FROM nv_properties_items WHERE website = ' . $website_id . ';
					DELETE FROM nv_search_log WHERE website = ' . $website_id . ';
					DELETE FROM nv_webdictionary WHERE website = ' . $website_id . ';
					DELETE FROM nv_webdictionary_history WHERE website = ' . $website_id . ';
				');
                if ($ok) {
                    users_log::action($_REQUEST['fid'], $website_id, 'remove_content', "", json_encode($_REQUEST));
                }
                echo $ok ? 'true' : $DB->error();
            } else {
                echo '';
            }
            core_terminate();
            break;
        case 0:
            // list / search result
        // list / search result
        default:
            $out = websites_list();
            break;
    }
    return $out;
}
示例#9
0
global $events;
global $webgets;
$idn = new idna_convert();
$events = new events();
// create database connection
$DB = new database();
if (!$DB->connect()) {
    die(APP_NAME . ' # ERROR<br /> ' . $DB->get_last_error());
}
// global exception catcher
try {
    // which website do we have to load?
    $url = nvweb_self_url();
    if (!empty($_REQUEST['wid'])) {
        $website = new website();
        $website->load(intval($_REQUEST['wid']));
    } else {
        $website = nvweb_load_website_by_url($url);
    }
    if ($website->permission == 2 || $website->permission == 1 && empty($_SESSION['APP_USER#' . APP_UNIQUE])) {
        if (!empty($website->redirect_to)) {
            header('location: ' . $website->redirect_to);
        }
        nvweb_clean_exit();
    }
    // global helper variables
    $session = array();
    // webuser session
    $structure = array();
    // web menu structure
    $webgets = array();
示例#10
0
function nv_plugin_init()
{
    global $DB;
    global $webuser;
    global $config;
    global $website;
    global $current;
    global $dictionary;
    global $session;
    global $events;
    global $idn;
    // create database connection
    $DB = new database();
    if (!$DB->connect()) {
        die(APP_NAME . ' # ERROR<br /> ' . $DB->get_last_error());
    }
    // global exception catcher
    try {
        $idn = new idna_convert();
        // which website do we have to load?
        $url = nvweb_self_url();
        if (!empty($_REQUEST['wid'])) {
            $website = new website();
            $website->load(intval($_REQUEST['wid']));
        } else {
            $website = nvweb_load_website_by_url($url);
        }
        if ($website->permission == 2 || $website->permission == 1 && empty($_SESSION['APP_USER#' . APP_UNIQUE])) {
            nvweb_clean_exit();
        }
        // global helper variables
        $session = array();
        // user session
        $webuser = new webuser();
        $nvweb_absolute = empty($website->protocol) ? 'http://' : $website->protocol;
        if (!empty($website->subdomain)) {
            $nvweb_absolute .= $website->subdomain . '.';
        }
        $nvweb_absolute .= $website->domain . $website->folder;
        define('NVWEB_ABSOLUTE', $nvweb_absolute);
        define('NVWEB_OBJECT', $nvweb_absolute . '/object');
        if (!defined('NAVIGATE_URL')) {
            define('NAVIGATE_URL', NAVIGATE_PARENT . NAVIGATE_FOLDER);
        }
        if (!isset($_SESSION['nvweb.' . $website->id])) {
            $_SESSION['nvweb.' . $website->id] = array();
            $session['lang'] = nvweb_country_language();
        } else {
            $session = $_SESSION['nvweb.' . $website->id];
            if (empty($session['lang'])) {
                $session['lang'] = nvweb_country_language();
            }
        }
        if (isset($_REQUEST['lang'])) {
            $session['lang'] = $_REQUEST['lang'];
        }
        if (!empty($session['webuser'])) {
            $webuser->load($session['webuser']);
        } else {
            if (!empty($_COOKIE["webuser"])) {
                $webuser->load_by_hash($_COOKIE['webuser']);
            }
        }
        @setlocale(LC_ALL, $website->languages[$session['lang']]['system_locale']);
        // remove the "folder" part of the route
        $route = '';
        if (!empty($_REQUEST['route'])) {
            $route = $_REQUEST['route'];
            // remove the "folder" part of the route (only if this url is really under a folder)
            if (!empty($website->folder) && strpos('/' . $route, $website->folder) === 0) {
                $route = substr('/' . $route, strlen($website->folder) + 1);
            }
        }
        // global data across webgets
        $current = array('lang' => $session['lang'], 'route' => $route, 'object' => '', 'template' => '', 'category' => '', 'webuser' => @$session['webuser'], 'navigate_session' => !empty($_SESSION['APP_USER#' . APP_UNIQUE]), 'html_after_body' => array(), 'js_after_body' => array());
        $dictionary = nvweb_dictionary_load();
        $_SESSION['nvweb.' . $website->id] = $session;
    } catch (Exception $e) {
        ?>
		<html>
			<body>
				ERROR
				<br /><br />
				<?php 
        echo $e->getMessage();
        ?>
			</body>
		</html>
		<?php 
    }
    $events = new events();
    nvweb_plugins_load();
    $events->extension_backend_bindings();
}
    public function editorfield($name, $value, $width = "80%", $lang = "es", $website_id = NULL)
    {
        global $layout;
        global $website;
        global $user;
        $height = 400;
        $ws = $website;
        if (!empty($website_id) && $website_id != $website->id) {
            $ws = new website();
            $ws->load($website_id);
        }
        $text = htmlentities($value, ENT_HTML5 | ENT_NOQUOTES, 'UTF-8', true);
        // remove unneeded new lines (to fix a problem of extra spaces in pre/code tags)
        $text = str_replace('&NewLine;', '', $text);
        $out = '<textarea name="' . $name . '" id="' . $name . '" style=" width: ' . $width . '; height: ' . $height . 'px; ">' . $text . '</textarea>';
        $content_css = $ws->content_stylesheets('tinymce', 'content');
        $content_css_selectable = $ws->content_stylesheets('tinymce', 'content_selectable');
        /* disabled for tiny mce 4.x, problems with the compressor
                // remove cache if the server address has changed
                $tinymce_gz = glob(NAVIGATE_PATH.'/lib/external/tinymce4/*.gz');
        
                if(!empty($tinymce_gz))
                {
                    if(file_exists(NAVIGATE_PATH.'/lib/external/tinymce4/server_name'))
                    {
                        $server_name = file_get_contents(NAVIGATE_PATH.'/lib/external/tinymce4/server_name');
                        if($server_name != md5($_SERVER['SERVER_NAME'].$_SERVER['SCRIPT_NAME']))
                            @unlink($tinymce_gz[0]);
                    }
                    file_put_contents(NAVIGATE_PATH.'/lib/external/tinymce4/server_name', md5($_SERVER['SERVER_NAME'].$_SERVER['SCRIPT_NAME']));
                }
        		*/
        $tinymce_language = $user->language;
        $layout->add_script('    
            tinyMCE.baseURL = "' . NAVIGATE_URL . '/lib/external/tinymce4";
            $("#' . $name . '").tinymce(
            {
                language: "' . $tinymce_language . '",
                
                width: ($("#' . $name . '").width()) + "px",
                height: $("#' . $name . '").height() + "px",
                resize: "both",
                
                menubar: false,
                theme: "modern",
                skin: "navigatecms-cupertino",
                			    
			    plugins: [
				    "compat3x noneditable",
				    "advlist autolink nv_link image lists charmap print preview hr anchor pagebreak",
				    "searchreplace wordcount visualblocks visualchars fullscreen media nonbreaking",
				    "table directionality template textcolor paste textcolor colorpicker textpattern",
				    "codesample codemirror imagetools importcss paste magicline fontawesome nv_rollups" // add fullpage to edit full HTML code with head and body tags
				],
				
				external_plugins: {
				    "loremipsum": "' . NAVIGATE_URL . '/lib/external/tinymce4/plugins/loremipsum/editor_plugin.js",
				    "imgmap": "' . NAVIGATE_URL . '/lib/external/tinymce4/plugins/imgmap/editor_plugin.js",
				    "style": "' . NAVIGATE_URL . '/lib/external/tinymce4/plugins/style/editor_plugin.js",
				    "xhtmlxtras": "' . NAVIGATE_URL . '/lib/external/tinymce4/plugins/xhtmlxtras/editor_plugin.js"
				},
				
				toolbar: [
					"formatselect fontselect fontsizeselect | forecolor | backcolor | removeformat | searchreplace code",
                    "bold italic underline strikethrough | alignleft aligncenter alignright alignjustify | outdent indent blockquote | bullist numlist | nv_rollup_special_char",
                    "styleselect | styleprops attribs | table | nv_rollup_links | image imgmap media codesample | magicline | undo redo"
                ],

				toolbar_items_size: "small",
				
				// forced fix to avoid tinymce adding <p> element on non block elements (span, i, etc)
				// needed mainly for Codemirror plugin, but force_p_newlines is deprecated by the TinyMCE team
				forced_root_block: "",
				force_br_newlines : true,
                force_p_newlines : true,
				
			    browser_spellcheck: true,
                spellchecker_language: "' . $lang . '",
                
                noneditable_noneditable_class: "fa",    // without this, TinyMCE removes the Font Awesome icons when editing the content
                
                media_live_embeds: false, // disable iframe loading (like videos) to allow resizing
                
                magicline_color: "#0070a3",
                magicline_targetedItems: ["DIV", "IMG", "IFRAME", "PRE", "TABLE", "ARTICLE", "UL", "OL", "BLOCKQUOTE"],
                magicline_triggerMargin: 16,
			    
			    codemirror: {
					path:  "' . NAVIGATE_URL . '/lib/external/codemirror",
				    indentOnInit: true,
                    config: {
                        mode: "htmlmixed",
                        lineNumbers: true
                    },
                    jsFiles: [
                        "mode/htmlmixed/htmlmixed.js"
                    ]
				},
				
				image_advtab: true,
				
				automatic_uploads: true,
			    paste_data_images: true,
				images_upload_url: "navigate_upload.php?engine=tinymce&session_id=' . session_id() . '&debug",
				
				fontsize_formats: "8px 9px 10px 11px 12px 13px 14px 15px 16px 17px 18px 20px 24px 26px 28px 30px 32px 36px", 
                
                content_css: "' . $content_css . '",
                
				style_formats_merge: true,
                importcss_append: false,
                importcss_file_filter: function(value) 
                {
                    var files = "' . $content_css_selectable . '";
                    
                    if(files.indexOf(",") > -1)
                    {
                        files = files.split(",");
	                    for(var i=0; i<files.length; i++)
	                    {
	                        if(value.indexOf(files[i]) !== -1)
	                        {
	                            return true;
	                        }
	                    }
	                    return false;
                    }
                    else
                    {
                        return (value==files);
                    }
                },               
                                
                //  https://www.tinymce.com/docs/configure/url-handling
                convert_urls: false,
                relative_urls: true,
                remove_script_host: false,
                
                // https://www.tinymce.com/docs/configure/content-filtering/
                valid_elements: "*[*],+a[*],+p[*],#i",
                custom_elements: "nv,code,pre,nvlist,nvlist_conditional,figure,article,header,footer,post,nav",
                extended_valid_elements: "+nv[*],+pre[*],+code[*],+nvlist[*],+nvlist_conditional[*],+figure[*],+article[*],+nav[*],+i[*],+span[*],+em[*],+b[*],*[*]",
                valid_children: "+a[div|p|li],+body[style|script|nv|nvlist|nvlist_conditional],+code[nv|nvlist|nvlist_conditional]",
                
                paste_as_text: true,
                
                // https://www.tinymce.com/docs/configure/content-filtering/#allow_html_in_named_anchor
                allow_html_in_named_anchor: true,          
                
                // events
                handle_event_callback : "navigate_tinymce_event",
                
                // before rendering this tinymce
                setup: function(editor)
                {
	                editor.on("init", function() 
	                { 
				        $(editor.getWin()).bind("scroll blur focus", function(e)
				        {
                            navigate_tinymce_event(e, "' . $name . '");
				        });
				        
				        // restore last known iframe scroll position
				        navigate_tinymce_event({type: "focus"}, "' . $name . '", true);
	                    setTimeout(function()
	                    {
	                        navigate_tinymce_event({type: "focus"}, "' . $name . '", true);
	                    }, 25);
				    });			    				    
                },
                
                // just after rendering this tinymce 
                init_instance_callback: function(editor)
                {                           
					// find missing images
					$("#' . $name . '").parent().find("iframe").contents().find("img").each(function()
					{
						if( (typeof this.naturalWidth != "undefined" && this.naturalWidth == 0 ) 
					        || this.readyState == "uninitialized" )					         
				        {
					        $(this).addClass("nomagicline");
					    }
					});
                
                    $("#' . $name . '").parent().find("iframe").droppable(
                    {
                        drop: function(event, ui)
                        {
                            if(!$(ui.draggable).attr("id")) // not a file!
                            {
                                $("#' . $name . '_tbl").css("opacity", 1);
                                return;
                            }

                            var file_id = $(ui.draggable).attr("id").substring(5);
                            if(!file_id || file_id=="" || file_id==0) return;
                            var media = $(ui.draggable).attr("mediatype");
                            var mime = $(ui.draggable).attr("mimetype");
                            var web_id = "' . $ws->id . '";
                            navigate_tinymce_add_content($("#' . $name . ':tinymce").attr("id"), file_id, media, mime, web_id, ui.draggable);
                            $("#' . $name . '").parent().find("> .mce-tinymce").css("opacity", 1);
                        },
                        over: function(event, ui)
                        {
                            if(!$(ui.draggable).attr("id")) // not a file!
                                return;

                            $("#' . $name . '").parent().find("> .mce-tinymce").css("opacity", 0.75);
                        },
                        out: function(event, ui)
                        {
                            $("#' . $name . '").parent().find("> .mce-tinymce").css("opacity", 1);
                        }
                    });
                    
                    // deprecated, but the only way we found to set the button on on init
	                tinyMCE.get("' . $name . '").controlManager.setActive("magicline", true);	                
                }
            });
        ');
        $layout->navigate_editorfield_link_dialog();
        return $out;
    }
示例#12
0
            $website->load();
        }
    }
}
// if there are no websites, auto-create the first one
if (empty($website->id)) {
    $website->create_default();
}
// check allowed websites for this user
$wa = $user->websites;
if (!empty($wa)) {
    if (array_search($website->id, $wa) === false) {
        $website = new website();
        if (!empty($wa[0])) {
            // load first website allowed
            $website->load(intval($wa[0]));
        }
        if (empty($website->id) && $user->permission('websites.edit') == 'false') {
            // NO website allowed AND can't create websites, so auto sign out
            core_session_remove();
            session_start();
            session_write_close();
            header('location: login.php');
            core_terminate();
        }
    }
}
$_SESSION['website_active'] = $website->id;
$events = new events();
$events->extension_backend_bindings(null, false);
// no valid website found; show Create first website wizard