function user_setup($theme = false) { global $_CLASS, $_CORE_CONFIG, $site_file_root; if ($this->user_setup) { return; } $this->user_setup = true; $this->data['user_unread_privmsg'] = 0; // TEMP if (!is_null($theme)) { // Do the theme $theme_prev = get_variable('theme_preview', 'REQUEST', false); $theme = $theme ? $theme : $_CLASS['core_user']->session_data_get('user_theme'); if ($theme_prev && $theme_prev != $theme && check_theme($theme_prev)) { $theme = $theme_prev; if (!get_variable('temp_preview', 'REQUEST', false)) { $_CLASS['core_user']->session_data_set('user_theme', $theme); } } elseif (!$theme || !check_theme($theme)) { $theme = $_CLASS['core_user']->data['user_theme'] ? $_CLASS['core_user']->data['user_theme'] : $_CORE_CONFIG['global']['default_theme']; if (!check_theme($theme)) { if (check_theme($_CORE_CONFIG['global']['default_theme'])) { $theme = $_CORE_CONFIG['global']['default_theme']; } else { // We need a theme, don't we ? $handle = opendir('themes'); $theme = false; while ($file = readdir($handle)) { if ($file[0] !== '.' && check_theme($file)) { $theme = $file; break; } } closedir($handle); if (!$theme) { trigger_error('Something here'); } } } } $path = $site_file_root . 'themes/' . $theme; $_CLASS['core_display']->load_theme($theme, $path); } $this->lang_name = $_CORE_CONFIG['global']['default_lang']; $this->lang_path = $site_file_root . 'language/' . $this->lang_name . '/'; $this->time_format = $this->data['user_time_format'] ? $this->data['user_time_format'] : $_CORE_CONFIG['global']['default_dateformat']; $this->timezone = $this->data['user_timezone'] ? $this->data['user_timezone'] : $_CORE_CONFIG['global']['default_timezone']; require $this->lang_path . 'common.php'; }
/** * check_install * This checks folders + permissions, .php files and settings. */ function check_install() { global $config, $install_errors; // Error friendly messages $requirements_error = array('There is a problem regarding server requirements. This means that Chevereto can\'t run because of the following:', 'Please notice that this issue is because your server setup. If you want to run Chevereto please contact your hosting company or system admin regarding this report.'); $folder_error = array('There is a problem regarding folders. This means that Chevereto can\'t run because one or more folders required doesn\'t exists. The missing folders are:', 'Please double-check your current setup for the missing files.'); $admin_folder_error = array('There is a problem regarding the admin folder and Chevereto won\'t run because the admin folder doesn\'t exists.', 'Please double-check <code>$config[\'admin_folder\']</code> in the <code>includes/config.php</code> file.'); $htaccess = 'In some operating systems this files are hidden, therefore you can\'t upload them. You need to <a href="http://www.google.com/search?q=show+hidden+htaccess" target="_blank">show this file</a> and then upload it.'; $htaccess_error = array('Some <code>.htaccess</code> file(s) doesn\'t exists and the system can\'t create this files.', $htaccess); $root_htaccess_error = array('The <code>.htaccess</code> file doesn\'t exists in the Chevereto root directory. This file must be uploaded to run Chevereto.', $htaccess); $file_error = array(str_replace('folders', 'files', $folder_error[0]), str_replace('folders', 'files', $folder_error[1])); $permission_error = array('There is a problem regarding permissions. This means that Chevereto can\'t upload files because of the following:', 'Chevereto needs a way to write in this folders. You can do this by doing <a href="http://www.google.com/search?q=chmod+777" target="_blank">chmod 0777</a> on the above folders or use <a href="http://www.suphp.org/" target="_blank">suPHP</a> or <a href="http://httpd.apache.org/docs/current/suexec.html" target="_blank">suEXEC</a> on your server setup.'); $config_error = array('There is a problem regarding your config setup. This means that Chevereto won\'t run because the config is not valid:', 'Please double-check your settings in the <code>includes/config.php</code> file.'); $definitions_error = array('Please take note that you must edit the <code>definitions.php</code> file the first time that you install Chevereto.', 'Please double-check your definitions in the <code>includes/definitions.php</code> file.'); $theme_error = array('There is a problem regarding your current theme. This means that Chevereto won\'t run because <code>' . $config['theme'] . '</code> theme has missing files:', 'Please double-check the theme hierarchy.'); $theme_data_error = array('There is a problem regarding your current theme data. This means that Chevereto won\'t run because <code>' . $config['theme'] . '</code> theme has not valid theme data in <code>style.css</code> header comments:', 'Please double-check the <code>style.css</code> header comments and refer to the <a href="http://chevereto.com/docs#themes">theme documentation</a> page.'); $virtual_folder_error = array('There is a problem regarding your virtual folders setup:', 'Either you set different values for virtual folders in <code>includes/config.php</code> or you delete this directories.'); // Check for the server requirements if (!check_requirements()) { chevereto_die($install_errors, 'System error', $requirements_error); } // Check for the image folders $image_folders = array(__CHV_PATH_IMAGES__); if (!check_files_folders($image_folders, 'Directory')) { chevereto_die($install_errors, 'Folder error', $folder_error); } if (!check_permissions($image_folders)) { chevereto_die($install_errors, 'Permissions error', $permission_error); } // Check for virtual folders $virtual_folders = array(sanitize_path($config['virtual_folder_image']), sanitize_path($config['virtual_folder_uploaded'])); foreach ($virtual_folders as $folder) { if (file_exists(__CHV_ROOT_DIR__ . $folder)) { $install_errors[] = 'The directory <code>' . __CHV_RELATIVE_ROOT__ . $folder . '</code> must not exists'; } } if (count($install_errors) > 0) { chevereto_die($install_errors, 'Virtual folders error', $virtual_folder_error); } // Check for upload.php if (!file_exists(__CHV_ROOT_DIR__ . 'upload.php')) { chevereto_die('Can\'t find <code>upload.php</code>', 'Missing upload.php', $file_error); } // Check for the root .htaccess file if (!file_exists(__CHV_ROOT_DIR__ . '.htaccess')) { chevereto_die('', '.htaccess error', $root_htaccess_error); } // Admin folder if (!check_value($config["admin_folder"])) { $config["admin_folder"] = "admin"; } if (!file_exists(__CHV_PATH_ADMIN__)) { chevereto_die('', 'Admin folder doesn\'t exists', $admin_folder_error); } // Check for the other .htaccess files $htaccess_files = array(__CHV_PATH_IMAGES__, __CHV_PATH_INCLUDES__, __CHV_PATH_ADMIN_INCLUDES__); foreach ($htaccess_files as $dir) { if (!file_exists($dir . '.htaccess')) { switch ($dir) { case __CHV_PATH_IMAGES__: $rules = 'static'; break; case __CHV_PATH_INCLUDES__: case __CHV_PATH_ADMIN_INCLUDES__: $rules = 'deny'; break; } if (!htaccess($rules, $dir)) { $install_errors[] = 'Can\'t create <code>' . $dir . '.htaccess</code> file. Please upload the <code>.htaccess</code> file to the target dir'; } } } if (count($install_errors) > 0) { chevereto_die($install_errors, '.htaccess error', $htaccess_error); } // Files check $include_files = array('chevereto.php', 'uploader.php', 'shorturl.php', 'definitions.php', 'template.functions.php'); $classes_files = array('class.handler.php', 'class.db.php', 'class.upload.php', 'class.filelist.php', 'class.imageresize.php', 'class.imageconvert.php', 'class.minify.php', 'class.shorturl.php'); $system_files = array('login.php', 'error.php', 'style.css', 'img/chevereto.png', 'img/logo.png', 'img/ico-warn.png', 'img/background.png', 'img/bkg-content.png'); $system_files_minify = array('style.css'); $system_files = array_merge_minified($system_files, $system_files_minify); $system_js_files = array('uploadify.swf', 'ZeroClipboard.swf', 'pref.php'); $system_js_files_minify = array('jquery.js', 'chevereto.js', 'functions.js', 'jquery.uploadify-3.1_chevereto.js'); $system_js_files = array_merge_minified($system_js_files, $system_js_files_minify); // Admin files $admin_classes_files = array('class.adminhandler.php', 'class.manage.php'); $admin_system_files = array('header.php', 'filemanager.php'); $admin_system_files_minify = array('style.css', 'js/admin.js'); $admin_system_files = array_merge_minified($admin_system_files, $admin_system_files_minify); foreach ($include_files as $key => $value) { $include_files[$key] = __CHV_PATH_INCLUDES__ . $value; } foreach ($classes_files as $key => $value) { $classes_files[$key] = __CHV_PATH_CLASSES__ . $value; } foreach ($system_files as $key => $value) { $system_files[$key] = __CHV_PATH_SYSTEM__ . $value; } foreach ($system_js_files as $key => $value) { $system_js_files[$key] = __CHV_PATH_SYSTEM_JS__ . $value; } foreach ($admin_classes_files as $key => $value) { $admin_classes_files[$key] = __CHV_PATH_ADMIN_CLASSES__ . $value; } foreach ($admin_system_files as $key => $value) { $admin_system_files[$key] = __CHV_PATH_ADMIN_SYSTEM__ . $value; } /*** The complete file check array ***/ $check_files = array('Includes' => $include_files, 'Classes' => $classes_files, 'System Files' => array_merge($system_files, $system_js_files), 'Admin .htaccess' => array(__CHV_PATH_ADMIN_INCLUDES__ . '.htaccess'), 'Admin Classes' => $admin_classes_files, 'Admin System' => $admin_system_files); foreach ($check_files as $key => $value) { check_files_folders($value, 'File'); } if (count($install_errors) > 0) { chevereto_die($install_errors, 'Setup error', $file_error); } if (!check_config()) { chevereto_die($install_errors, 'Config error', $config_error); } if (!check_definitions()) { chevereto_die($install_errors, 'Please change definitions.php', $definitions_error); } if (!check_theme()) { chevereto_die($install_errors, 'Theme error', $theme_error); } if (!check_theme_data()) { chevereto_die($install_errors, 'Theme data error', $theme_data_error); } }
function user_setup($theme = false) { global $_CLASS, $_CORE_CONFIG; if ($this->user_setup) { return; } $this->user_setup = true; if (!is_null($theme)) { // Do the theme $theme_prev = get_variable('theme_preview', 'REQUEST', false); $theme = $theme ? $theme : $_CLASS['core_user']->session_data_get('user_theme'); if ($theme_prev && $theme_prev != $theme && check_theme($theme_prev)) { $theme = $theme_prev; if (!get_variable('temp_preview', 'REQUEST', false)) { $_CLASS['core_user']->session_data_set('user_theme', $theme); } } elseif (!$theme || !check_theme($theme)) { $theme = $_CLASS['core_user']->data['user_theme'] ? $_CLASS['core_user']->data['user_theme'] : $_CORE_CONFIG['global']['default_theme']; if (!check_theme($theme)) { if (check_theme($_CORE_CONFIG['global']['default_theme'])) { $theme = $_CORE_CONFIG['global']['default_theme']; } else { // We need a theme, don't we ? $handle = opendir('themes'); $theme = false; while ($file = readdir($handle)) { if ($file[0] !== '.' && check_theme($file)) { $theme = $file; break; } } closedir($handle); if (!$theme) { trigger_error('Something here'); } } } } $path = SITE_FILE_ROOT . 'themes/' . $theme; $_CLASS['core_display']->load_theme($theme, $path); } $this->lang_name = $_CORE_CONFIG['global']['default_lang']; $this->time_format = $this->data['user_time_format'] ? $this->data['user_time_format'] : $_CORE_CONFIG['global']['default_dateformat']; $this->time_offset = $this->data['user_timezone'] ? $this->data['user_timezone'] : $_CORE_CONFIG['global']['default_timezone']; if ($this->data['user_dst']) { $this->time_offset += 3600; } $this->add_lang('common', null); }