Ejemplo n.º 1
0
/**
 * Regenerate all the theme image paths in the database.
 *
 * @param  ID_TEXT	The theme we're searching in.
 * @param  ?array		A map of languages (lang=>1) (NULL: find it in-function).
 * @param  ?ID_TEXT  The theme we're storing in (NULL: same as $theme).
 */
function regen_theme_images($theme, $langs = NULL, $target_theme = NULL)
{
    if (is_null($langs)) {
        $langs = find_all_langs(true);
    }
    if (is_null($target_theme)) {
        $target_theme = $theme;
    }
    $images = array_merge(find_images_do_dir($theme, 'images/', $langs), find_images_do_dir($theme, 'images_custom/', $langs));
    foreach (array_keys($langs) as $lang) {
        $existing = $GLOBALS['SITE_DB']->query_select('theme_images', array('id', 'path'), array('lang' => $lang, 'theme' => $target_theme));
        foreach ($images as $id => $path) {
            $found = false;
            foreach ($existing as $e) {
                if ($e['path'] == $path || $e['id'] == $id) {
                    $found = true;
                    break;
                }
            }
            if (!$found) {
                $nql_backup = $GLOBALS['NO_QUERY_LIMIT'];
                $GLOBALS['NO_QUERY_LIMIT'] = true;
                $correct_path = find_theme_image($id, false, true, $theme, $lang);
                $GLOBALS['SITE_DB']->query_insert('theme_images', array('id' => $id, 'lang' => $lang, 'theme' => $target_theme, 'path' => $correct_path), false, true);
                // race conditions
                $GLOBALS['NO_QUERY_LIMIT'] = $nql_backup;
            }
        }
    }
    persistant_cache_delete('THEME_IMAGES');
}
Ejemplo n.º 2
0
/**
 * Get list of staff contextual actions.
 *
 * @return string		The list
 */
function get_staff_actions_list()
{
    require_lang('lang');
    $list = array('view' => do_lang_tempcode('SCREEN_DEV_TOOLS'));
    $list += array('spacer_1' => do_lang_tempcode('THEME'), 'show_edit_links' => do_lang_tempcode('TEMPLATES_WITH_EDIT_LINKS'), 'show_markers' => do_lang_tempcode('TEMPLATES_WITH_HTML_COMMENT_MARKERS'), 'tree' => do_lang_tempcode('TEMPLATE_TREE'), 'templates' => do_lang_tempcode('TEMPLATES'), 'theme_images' => do_lang_tempcode('THEME_IMAGE_EDITING'), 'code' => do_lang_tempcode('VALIDATION'), 'site_tree' => do_lang_tempcode('FIND_IN_SITE_TREE'));
    require_code('lang2');
    $list += array('spacer_2' => do_lang_tempcode('LANGUAGE'));
    $all_langs = multi_lang() ? find_all_langs() : array(user_lang() => 'lang_custom');
    $tcode = do_lang('lang:TRANSLATE_CODE');
    foreach (array_keys($all_langs) as $lang) {
        $list += array('lang_' . $lang => $tcode . (count($all_langs) == 1 ? '' : ': ' . lookup_language_full_name($lang)));
    }
    if (multi_lang()) {
        $tcontent = do_lang('TRANSLATE_CONTENT');
        foreach (array_keys($all_langs) as $lang) {
            $list['lang_content_' . $lang] = $tcontent . ': ' . lookup_language_full_name($lang);
        }
    }
    $list += array('spacer_3' => do_lang_tempcode('DEVELOPMENT_VIEWS'), 'query' => do_lang_tempcode('VIEW_PAGE_QUERIES'), 'ide_linkage' => do_lang_tempcode('IDE_LINKAGE'));
    if (function_exists('xdebug_enable')) {
        $list['profile'] = do_lang_tempcode('PROFILING');
    }
    if (function_exists('memory_get_usage')) {
        $list['memory'] = do_lang_tempcode('_MEMORY_USAGE');
    }
    $special_page_type = get_param('special_page_type', 'view');
    $staff_actions = '';
    foreach ($list as $name => $text) {
        $disabled = $name[0] == 's' && substr($name, 0, 7) == 'spacer_';
        $staff_actions .= '<option ' . ($disabled ? 'disabled="disabled" ' : '') . ($name == $special_page_type ? 'selected="selected" ' : '') . 'value="' . escape_html($name) . '">' . (is_object($text) ? $text->evaluate() : escape_html($text)) . '</option>';
        // XHTMLXHTML
        //$staff_actions.=static_evaluate_tempcode(form_input_list_entry($name,($name==$special_page_type),$text,false,$disabled));
    }
    return $staff_actions;
}
Ejemplo n.º 3
0
 /**
  * Standard modular uninstall function.
  */
 function uninstall()
 {
     $langs = find_all_langs(true);
     foreach (array_keys($langs) as $lang) {
         deldir_contents(get_custom_file_base() . '/lang_cached/' . $lang, true);
         // lang_custom purposely left
     }
 }
Ejemplo n.º 4
0
/**
 * Erase all template caches (caches in all themes).
 *
 * @param  boolean	Whether to preserve CSS and JS files that might be linked to between requests
 */
function erase_cached_templates($preserve_some = false)
{
    global $ERASED_TEMPLATES_ONCE;
    $ERASED_TEMPLATES_ONCE = true;
    require_code('themes2');
    $themes = find_all_themes();
    $langs = find_all_langs(true);
    foreach (array_keys($themes) as $theme) {
        foreach (array_keys($langs) as $lang) {
            $path = get_custom_file_base() . '/themes/' . $theme . '/templates_cached/' . $lang . '/';
            $_dir = @opendir($path);
            if ($_dir === false) {
                @mkdir($path, 0777);
                // OR warn_exit(do_lang_tempcode('WRITE_ERROR_DIRECTORY_REPAIR',escape_html($path)));
                fix_permissions($path, 0777);
            } else {
                while (false !== ($file = readdir($_dir))) {
                    if (substr($file, -4) == '.tcd' || substr($file, -4) == '.tcp' || !$preserve_some && (substr($file, -3) == '.js' || substr($file, -4) == '.css')) {
                        $i = 0;
                        while (@unlink($path . $file) === false && $i < 5) {
                            if (!file_exists($path . $file)) {
                                break;
                            }
                            // Race condition, gone already
                            sleep(1);
                            // May be race condition, lock
                            $i++;
                        }
                        if ($i >= 5) {
                            if (file_exists($path . $file)) {
                                @unlink($path . $file) or intelligent_write_error($path . $file);
                            }
                        }
                    }
                }
                closedir($_dir);
            }
        }
    }
    // Often the back button will be used to return to a form, so we need to ensure we have not broken the Javascript
    if (function_exists('get_member')) {
        javascript_enforce('javascript_validation');
        javascript_enforce('javascript_editing');
    }
}
Ejemplo n.º 5
0
/**
 * Get a bit of SQL to make sure that a DB field is not like a spacer post in any of the languages.
 *
 * @param  ID_TEXT		The field name
 * @return string			The SQL
 */
function not_like_spacer_posts($field)
{
    $ret = '';
    $langs = find_all_langs();
    foreach (array_keys($langs) as $lang) {
        if (@filesize(get_file_base() . '/lang/' . $lang . '/global.ini') || @filesize(get_file_base() . '/lang_custom/' . $lang . '/global.ini')) {
            // Check it's a real lang and not a stub dir
            $ret .= ' AND ' . $field . ' NOT LIKE \'%' . db_encode_like(do_lang('SPACER_POST_MATCHER', '', '', '', $lang) . '%') . '\'';
        }
    }
    return $ret;
}
Ejemplo n.º 6
0
/**
 * Add a theme.
 *
 * @param  ID_TEXT		The theme name
 */
function actual_add_theme($name)
{
    $GLOBALS['NO_QUERY_LIMIT'] = true;
    if (file_exists(get_custom_file_base() . '/themes/' . $name) || $name == 'default') {
        warn_exit(do_lang_tempcode('ALREADY_EXISTS', escape_html($name)));
    }
    require_code('abstract_file_manager');
    force_have_afm_details();
    // Create directories
    $dir_list = array('', 'images', 'images/logo', 'images_custom', 'templates', 'templates_custom', 'templates_cached', 'css', 'css_custom');
    $langs = find_all_langs(true);
    foreach (array_keys($langs) as $lang) {
        $dir_list[] = 'templates_cached/' . $lang;
    }
    $dir_list_access = array('', 'images', 'images_custom', 'css');
    foreach ($dir_list as $dir) {
        $path = 'themes/' . $name . '/' . $dir;
        afm_make_directory($path, true);
        if (!in_array($dir, $dir_list_access)) {
            //			$path='themes/'.$name.'/'.$dir.'/.htaccess';
            //			afm_copy('themes/default/templates_cached/.htaccess',$path,false);
        }
        $path = 'themes/' . $name . '/' . ($dir == '' ? '' : $dir . '/') . 'index.html';
        if (file_exists(get_file_base() . '/themes/default/templates_cached/index.html')) {
            afm_copy('themes/default/templates_cached/index.html', $path, false);
        }
    }
    afm_copy('themes/default/theme.ini', 'themes/' . $name . '/theme.ini', true);
    /*$_dir=opendir(get_custom_file_base().'/themes/default/css');
    	while (false!==($file=readdir($_dir)))
    	{
    		if (strtolower(substr($file,-4,4))=='.css')
    		{
    			$path='themes/'.$name.'/css_custom/'.$file;
    			$new_css_file="@import url(../../../default/css/$file);\n\n".file_get_contents(get_custom_file_base().'/themes/default/css/'.$file,FILE_TEXT);
    			afm_make_file($path,$new_css_file,false);
    		}
    	}
    	closedir($_dir);*/
    // Copy image references from default
    $start = 0;
    do {
        $theme_images = $GLOBALS['SITE_DB']->query_select('theme_images', array('*'), array('theme' => 'default'), '', 100, $start);
        foreach ($theme_images as $theme_image) {
            $test = $GLOBALS['SITE_DB']->query_value_null_ok('theme_images', 'id', array('theme' => $name, 'id' => $theme_image['id'], 'lang' => $theme_image['lang']));
            if (is_null($test)) {
                $GLOBALS['SITE_DB']->query_insert('theme_images', array('id' => $theme_image['id'], 'theme' => $name, 'path' => $theme_image['path'], 'lang' => $theme_image['lang']));
            }
        }
        $start += 100;
    } while (count($theme_images) == 100);
    log_it('ADD_THEME', $name);
}
Ejemplo n.º 7
0
/**
 * Make a theme. Note that this will trigger the AFM.
 *
 * @param  string		Name of the theme.
 * @param  ID_TEXT	The theme it's being generated from
 * @param  ID_TEXT	The algorithm to use
 * @set equations hsv
 * @param  string		Seed colour to use.
 * @param  boolean	Whether to use the theme immediately.
 * @param  ?boolean  Whether it will be a dark theme (NULL: autodetect).
 * @param  boolean	Whether to inherit the CSS, for easier theme upgrading.
 */
function make_theme($themename, $source_theme, $algorithm, $seed, $use, $dark = false, $inherit_css = false)
{
    $GLOBALS['NO_QUERY_LIMIT'] = true;
    load_themewizard_params_from_theme($source_theme, $algorithm == 'hsv');
    if (file_exists(get_custom_file_base() . '/themes/' . $themename)) {
        require_code('abstract_file_manager');
        force_have_afm_details();
        $extending_existing = true;
    } else {
        if ($source_theme == 'default') {
            actual_add_theme($themename);
        } else {
            require_code('themes3');
            actual_copy_theme($source_theme, $themename);
        }
        $extending_existing = false;
    }
    if ($seed != find_theme_seed($source_theme) || $dark != find_theme_dark($source_theme)) {
        list($colours, $landscape) = calculate_theme($seed, $source_theme, $algorithm, 'colours', $dark);
        // Make images
        global $THEME_WIZARD_IMAGES, $THEME_WIZARD_IMAGES_NO_WILD, $IMG_CODES;
        if (function_exists('imagecolorallocatealpha')) {
            require_code('themes2');
            $full_img_set = array();
            foreach ($THEME_WIZARD_IMAGES as $expression) {
                if (substr($expression, -1) == '*') {
                    $expression = substr($expression, 0, strlen($expression) - 2);
                    // remove "/*"
                    $full_img_set = array_merge($full_img_set, array_keys(get_all_image_codes(get_file_base() . '/themes/' . filter_naughty($source_theme) . '/images', $expression)));
                    $full_img_set = array_merge($full_img_set, array_keys(get_all_image_codes(get_file_base() . '/themes/' . filter_naughty($source_theme) . '/images/' . fallback_lang(), $expression)));
                } else {
                    $full_img_set[] = $expression;
                }
            }
            if ($extending_existing) {
                $temp_all_ids = collapse_2d_complexity('id', 'path', $GLOBALS['SITE_DB']->query_select('theme_images', array('id', 'path'), array('theme' => $themename)));
            } else {
                $temp_all_ids = array();
            }
            $_langs = find_all_langs(true);
            foreach ($full_img_set as $image_code) {
                if (!in_array($image_code, $THEME_WIZARD_IMAGES_NO_WILD)) {
                    if ($extending_existing && array_key_exists($image_code, $temp_all_ids) && strpos($temp_all_ids[$image_code], $themename . '/images_custom/') !== false && (!url_is_local($temp_all_ids[$image_code]) || file_exists(get_custom_file_base() . '/' . $temp_all_ids[$image_code]))) {
                        continue;
                    }
                    foreach (array_keys($_langs) as $lang) {
                        $orig_path = find_theme_image($image_code, true, true, $source_theme, $lang);
                        if ($orig_path == '') {
                            continue;
                        }
                        // Theme has specified non-existent image as themewizard-compatible
                        if (strpos($orig_path, '/' . $lang . '/') === false && $lang != fallback_lang()) {
                            continue;
                        }
                        if (strpos($orig_path, '/' . fallback_lang() . '/') !== false) {
                            $composite = 'themes/' . filter_naughty($themename) . '/images/' . $lang . '/';
                        } else {
                            $composite = 'themes/' . filter_naughty($themename) . '/images/';
                        }
                        $saveat = get_custom_file_base() . '/' . $composite . $image_code . '.png';
                        $saveat_url = $composite . $image_code . '.png';
                        // Wipe out ones that might have been copied from source theme
                        if ($source_theme != 'default' && strpos($orig_path, 'images_custom') !== false) {
                            @unlink(str_replace('/images/', '/images_custom/', basename($saveat, '.png')) . '.png');
                            @unlink(str_replace('/images/', '/images_custom/', basename($saveat, '.png')) . '.jpg');
                            @unlink(str_replace('/images/', '/images_custom/', basename($saveat, '.png')) . '.gif');
                            @unlink(str_replace('/images/', '/images_custom/', basename($saveat, '.png')) . '.jpeg');
                        }
                        if (!file_exists($saveat) || $source_theme != 'default' || $algorithm == 'hsv') {
                            $image = calculate_theme($seed, $source_theme, $algorithm, $image_code, $dark, $colours, $landscape, $lang);
                            if (!is_null($image)) {
                                $pos = strpos($image_code, '/');
                                if ($pos !== false || strpos($orig_path, '/' . fallback_lang() . '/') !== false) {
                                    afm_make_directory($composite . substr($image_code, 0, $pos), true, true);
                                }
                                @imagepng($image, $saveat) or intelligent_write_error($saveat);
                                imagedestroy($image);
                                fix_permissions($saveat);
                                sync_file($saveat);
                                actual_edit_theme_image($image_code, $themename, $lang, $image_code, $saveat_url, true);
                                //if ($lang==fallback_lang()) $IMG_CODES['site'][$image_code]=$saveat_url;
                            }
                        } else {
                            actual_edit_theme_image($image_code, $themename, $lang, $image_code, $saveat_url, true);
                        }
                    }
                }
            }
        }
        // Make sheets
        $dh = opendir(get_file_base() . '/themes/' . filter_naughty($source_theme) . ($source_theme == 'default' ? '/css/' : '/css_custom/'));
        while (($sheet = readdir($dh)) !== false) {
            if (substr($sheet, -4) == '.css') {
                $saveat = get_custom_file_base() . '/themes/' . filter_naughty($themename) . '/css_custom/' . $sheet;
                if (!file_exists($saveat) || $source_theme != 'default' || $algorithm == 'hsv') {
                    $fp = @fopen($saveat, 'wt') or intelligent_write_error(get_custom_file_base() . '/themes/' . filter_naughty($themename) . '/css_custom/' . $sheet);
                    if ($inherit_css) {
                        $output = '{+START,CSS_INHERIT,' . basename($sheet, '.css') . ',' . filter_naughty($source_theme) . ',' . $seed . ',' . ($dark ? '1' : '0') . ',' . $algorithm . '}{+END}';
                    } else {
                        $output = theme_wizard_colours_to_sheet($sheet, $landscape, $source_theme, $algorithm, $seed);
                    }
                    if (fwrite($fp, $output) < strlen($output)) {
                        warn_exit(do_lang_tempcode('COULD_NOT_SAVE_FILE'));
                    }
                    fclose($fp);
                    fix_permissions($saveat);
                    sync_file($saveat);
                    if (!$inherit_css) {
                        $c_success = @copy(get_file_base() . '/themes/' . filter_naughty($source_theme) . '/css/' . $sheet, $saveat . '.editfrom');
                        if ($c_success !== false) {
                            fix_permissions($saveat . '.editfrom');
                            sync_file($saveat . '.editfrom');
                        }
                    } else {
                        @unlink($saveat . '.editfrom');
                    }
                }
            }
        }
    }
    // Use it, if requested
    if ($use) {
        $GLOBALS['SITE_DB']->query('UPDATE ' . get_table_prefix() . 'zones SET zone_theme=\'' . db_escape_string($themename) . '\' WHERE ' . db_string_not_equal_to('zone_name', 'cms') . ' AND ' . db_string_not_equal_to('zone_name', 'adminzone'));
        $admin_groups = $GLOBALS['FORUM_DRIVER']->get_super_admin_groups();
        $groups = $GLOBALS['FORUM_DRIVER']->get_usergroup_list(false, true);
        $GLOBALS['SITE_DB']->query_delete('group_category_access', array('module_the_name' => 'theme', 'category_name' => $themename));
        foreach (array_keys($groups) as $group_id) {
            if (in_array($group_id, $admin_groups)) {
                continue;
            }
            $GLOBALS['SITE_DB']->query_insert('group_category_access', array('module_the_name' => 'theme', 'category_name' => $themename, 'group_id' => $group_id));
        }
        persistant_cache_empty();
    }
}
Ejemplo n.º 8
0
 /**
  * The actualiser to delete a page.
  *
  * @return tempcode		The UI
  */
 function __delete()
 {
     $GLOBALS['HELPER_PANEL_PIC'] = 'pagepics/deletepage';
     $zone = post_param('zone', NULL);
     $afm_needed = false;
     $pages = find_all_pages_wrap($zone);
     foreach ($pages as $page => $type) {
         if (is_integer($page)) {
             $page = strval($page);
         }
         if (post_param_integer('page__' . $page, 0) == 1) {
             if (get_file_base() != get_custom_file_base() && strpos($type, 'comcode_custom') !== false) {
                 warn_exit(do_lang_tempcode('SHARED_INSTALL_PROHIBIT'));
             }
             if ($type != 'comcode_custom') {
                 $afm_needed = true;
             }
         }
     }
     if ($afm_needed) {
         require_code('abstract_file_manager');
         force_have_afm_details();
     }
     foreach ($pages as $page => $type) {
         if (is_integer($page)) {
             $page = strval($page);
         }
         if (post_param_integer('page__' . $page, 0) == 1) {
             if (substr($type, 0, 7) == 'modules') {
                 $_page = $page . '.php';
             } elseif (substr($type, 0, 7) == 'comcode') {
                 $_page = $page . '.txt';
             } elseif (substr($type, 0, 4) == 'html') {
                 $_page = $page . '.htm';
             }
             $GLOBALS['SITE_DB']->query_delete('menu_items', array('i_url' => $zone . ':' . $page));
             if (substr($type, 0, 7) == 'comcode' || substr($type, 0, 4) == 'html') {
                 $type_shortened = preg_replace('#/.+#', '', $type);
                 if (substr($type, 0, 7) == 'comcode' && get_option('store_revisions') == '1') {
                     $time = time();
                     $fullpath = zone_black_magic_filterer((strpos($type, 'comcode/') !== false ? get_file_base() : get_custom_file_base()) . '/' . filter_naughty($zone) . ($zone != '' ? '/' : '') . 'pages/' . filter_naughty($type) . '/' . $_page);
                     $bs_path = zone_black_magic_filterer(str_replace('/comcode/', '/comcode_custom/', $fullpath) . '.' . strval($time));
                     @copy($fullpath, $bs_path) or intelligent_write_error($fullpath);
                     sync_file($bs_path);
                     fix_permissions($bs_path);
                 }
                 $langs = find_all_langs(true);
                 foreach (array_keys($langs) as $lang) {
                     $_path = zone_black_magic_filterer(filter_naughty($zone) . ($zone != '' ? '/' : '') . 'pages/' . filter_naughty($type_shortened) . '/' . $lang . '/' . $_page, true);
                     $path = (strpos($type, 'comcode/') !== false ? get_file_base() : get_custom_file_base()) . '/' . $_path;
                     if (file_exists($path)) {
                         if ($afm_needed) {
                             afm_delete_file($_path);
                         } else {
                             unlink(get_custom_file_base() . '/' . $_path);
                         }
                     }
                 }
                 if (substr($type, 0, 7) == 'comcode') {
                     require_code('attachments2');
                     require_code('attachments3');
                     delete_comcode_attachments('comcode_page', $zone . ':' . $page);
                     $GLOBALS['SITE_DB']->query_delete('cached_comcode_pages', array('the_page' => $page, 'the_zone' => $zone));
                     $GLOBALS['SITE_DB']->query_delete('comcode_pages', array('the_page' => $page, 'the_zone' => $zone));
                     persistant_cache_empty();
                     decache('main_comcode_page_children');
                     require_code('seo2');
                     seo_meta_erase_storage('comcode_page', $zone . ':' . $page);
                 }
             } else {
                 $_path = zone_black_magic_filterer(filter_naughty($zone) . ($zone != '' ? '/' : '') . 'pages/' . filter_naughty($type) . '/' . $_page, true);
                 $path = (strpos($type, '_custom') === false ? get_file_base() : get_custom_file_base()) . '/' . $_path;
                 if (file_exists($path)) {
                     if ($afm_needed) {
                         afm_delete_file($_path);
                     } else {
                         unlink(get_custom_file_base() . '/' . $_path);
                     }
                 }
             }
             $GLOBALS['SITE_DB']->query_delete('https_pages', array('https_page_name' => $page), '', 1);
             log_it('DELETE_PAGES', $page);
         }
     }
     persistant_cache_empty();
     decache('main_sitemap');
     $title = get_page_title('DELETE_PAGES');
     breadcrumb_set_self(do_lang_tempcode('DONE'));
     breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('PAGES')), array('_SELF:_SELF:delete', do_lang_tempcode('DELETE_PAGES'))));
     return $this->do_next_manager($title, NULL, $zone, new ocp_tempcode());
 }
Ejemplo n.º 9
0
 /**
  * The actualiser to add a theme image.
  *
  * @return tempcode		The UI
  */
 function _add_image()
 {
     require_code('uploads');
     $title = get_page_title('ADD_THEME_IMAGE');
     $theme = post_param('theme');
     //if ((get_file_base()!=get_custom_file_base()) && ($theme=='default')) warn_exit(do_lang_tempcode('SHARED_INSTALL_PROHIBIT'));
     $lang = post_param('lang');
     $id = post_param('id');
     $use_all_themes = post_param_integer('use_all_themes', 0);
     $use_all_langs = post_param_integer('use_all_langs', 0);
     $path = get_url('path', 'file', 'themes/' . ($use_all_themes == 1 ? 'default' : $theme) . '/images_custom');
     if ($path[0] == '') {
         return warn_screen($title, do_lang_tempcode('IMPROPERLY_FILLED_IN_UPLOAD'));
     }
     $theme_list = array_keys(find_all_themes());
     $lang_list = find_all_langs(true);
     if ($use_all_themes == 1 && $use_all_langs == 1) {
         foreach ($theme_list as $theme) {
             foreach (array_keys($lang_list) as $lang) {
                 actual_add_theme_image($theme, $lang, $id, $path[0], true);
             }
         }
     } elseif ($use_all_themes == 1) {
         foreach ($theme_list as $theme) {
             actual_add_theme_image($theme, $lang, $id, $path[0], true);
         }
     } elseif ($use_all_langs == 1) {
         foreach (array_keys($lang_list) as $lang) {
             actual_add_theme_image($theme, $lang, $id, $path[0], true);
         }
     } else {
         actual_add_theme_image($theme, $lang, $id, $path[0]);
     }
     breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('MANAGE_THEMES')), array('_SELF:_SELF:add_image:theme=' . post_param('theme'), do_lang_tempcode('CHOOSE'))));
     breadcrumb_set_self(do_lang_tempcode('DONE'));
     persistant_cache_delete('THEME_IMAGES');
     erase_cached_templates();
     return $this->do_next_manager($title, do_lang_tempcode('SUCCESS'), $theme, $lang, 'image', $id);
 }
Ejemplo n.º 10
0
/**
 * Get form fields for adding/editing/finishing a member profile.
 *
 * @param  boolean			Whether we are only handling the essential details of a profile.
 * @param  ?MEMBER			The ID of the member we are handling (NULL: new member).
 * @param  ?array				A list of usergroups (NULL: default/current usergroups).
 * @param  SHORT_TEXT		The e-mail address.
 * @param  BINARY				Whether posts are previewed before they are made.
 * @param  ?integer			Day of date of birth (NULL: not known).
 * @param  ?integer			Month of date of birth (NULL: not known).
 * @param  ?integer			Year of date of birth (NULL: not known).
 * @param  ?ID_TEXT			The member timezone (NULL: site default).
 * @param  ?ID_TEXT			The members default theme (NULL: not known).
 * @param  BINARY				Whether the members age may be shown.
 * @param  BINARY				Whether the member sees signatures in posts.
 * @param  ?BINARY			Whether the member automatically is enabled for notifications for content they contribute to (NULL: get default from config).
 * @param  ?LANGUAGE_NAME	The members language (NULL: auto detect).
 * @param  BINARY				Whether the member allows e-mails via the site.
 * @param  BINARY				Whether the member allows e-mails from staff via the site.
 * @param  BINARY				Whether the profile has been validated.
 * @param  ?GROUP				The members primary (NULL: not known).
 * @param  SHORT_TEXT		The username.
 * @param  BINARY				Whether the member is permanently banned.
 * @param  ID_TEXT			The special type of profile this is (blank: not a special type).
 * @param  BINARY				Whether the member likes to view zones without menus, when a choice is available.
 * @param  BINARY				Whether the member username will be highlighted.
 * @param  SHORT_TEXT		Usergroups that may PT the member.
 * @param  LONG_TEXT			Rules that other members must agree to before they may start a PT with the member.
 * @param  ?TIME				When the member is on probation until (NULL: just finished probation / or effectively was never on it)
 * @return array				A pair: The form fields, Hidden fields (both Tempcode).
 */
function ocf_get_member_fields_settings($mini_mode = true, $member_id = NULL, $groups = NULL, $email_address = '', $preview_posts = 0, $dob_day = NULL, $dob_month = NULL, $dob_year = NULL, $timezone = NULL, $theme = NULL, $reveal_age = 1, $views_signatures = 1, $auto_monitor_contrib_content = NULL, $language = NULL, $allow_emails = 1, $allow_emails_from_staff = 1, $validated = 1, $primary_group = NULL, $username = '', $is_perm_banned = 0, $special_type = '', $zone_wide = 1, $highlighted_name = 0, $pt_allow = '*', $pt_rules_text = '', $on_probation_until = NULL)
{
    if (is_null($auto_monitor_contrib_content)) {
        $auto_monitor_contrib_content = get_value('no_auto_notifications') === '1' ? 0 : 1;
    }
    $hidden = new ocp_tempcode();
    if (has_actual_page_access(get_member(), 'admin_ocf_join')) {
        $dob_optional = true;
    } else {
        $dob_optional = get_option('no_dob_ask') == '2';
    }
    if ($member_id === $GLOBALS['OCF_DRIVER']->get_guest_id()) {
        fatal_exit(do_lang_tempcode('INTERNAL_ERROR'));
    }
    require_code('form_templates');
    require_code('encryption');
    if ($special_type == '' && !is_null($member_id)) {
        if (ocf_is_ldap_member($member_id)) {
            $special_type = 'ldap';
        }
        if (ocf_is_httpauth_member($member_id)) {
            $special_type = 'httpauth';
        }
        if ($GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id, 'm_password_compat_scheme') == 'remote') {
            $special_type = 'remote';
        }
    }
    if (is_null($groups)) {
        $groups = is_null($member_id) ? ocf_get_all_default_groups(true) : $GLOBALS['OCF_DRIVER']->get_members_groups($member_id);
    }
    $fields = new ocp_tempcode();
    // Human name / Username
    if ($special_type != 'ldap' && $special_type != 'remote' && $GLOBALS['FORUM_DRIVER']->get_member_row_field($member_id, 'm_password_compat_scheme') != 'facebook') {
        if (is_null($member_id) || has_actual_page_access(get_member(), 'admin_ocf_join') || has_specific_permission($member_id, 'rename_self')) {
            if (get_option('signup_fullname') == '1') {
                $fields->attach(form_input_line(do_lang_tempcode('NAME'), do_lang_tempcode('_DESCRIPTION_NAME'), is_null($member_id) ? 'username' : 'edit_username', $username, true));
            } else {
                $prohibit_username_whitespace = get_option('prohibit_username_whitespace', true);
                if ($prohibit_username_whitespace == '1') {
                    $fields->attach(form_input_codename(do_lang_tempcode('USERNAME'), do_lang_tempcode('DESCRIPTION_USERNAME'), is_null($member_id) ? 'username' : 'edit_username', $username, true));
                } else {
                    $fields->attach(form_input_line(do_lang_tempcode('USERNAME'), do_lang_tempcode('DESCRIPTION_USERNAME'), is_null($member_id) ? 'username' : 'edit_username', $username, true));
                }
            }
        }
    }
    // Password
    if ($special_type == '') {
        if (is_null($member_id) || $member_id == get_member() || has_specific_permission(get_member(), 'assume_any_member')) {
            $fields->attach(form_input_password(do_lang_tempcode('PASSWORD'), do_lang_tempcode('DESCRIPTION_PASSWORD' . (!is_null($member_id) ? '_EDIT' : '')), is_null($member_id) ? 'password' : 'edit_password', $mini_mode));
            $fields->attach(form_input_password(do_lang_tempcode('CONFIRM_PASSWORD'), '', 'password_confirm', $mini_mode));
        }
    }
    // E-mail address
    if ($email_address == '') {
        $email_address = trim(get_param('email_address', ''));
    }
    if ($special_type != 'remote') {
        $fields->attach(form_input_email(do_lang_tempcode('EMAIL_ADDRESS'), get_option('skip_email_confirm_join') == '1' ? new ocp_tempcode() : do_lang_tempcode('MUST_BE_REAL_ADDRESS'), 'email_address', $email_address, !has_specific_permission(get_member(), 'member_maintenance')));
        if (is_null($member_id) && $email_address == '' && get_option('skip_email_confirm_join') == '0') {
            $fields->attach(form_input_email(do_lang_tempcode('CONFIRM_EMAIL_ADDRESS'), '', 'email_address_confirm', '', !has_specific_permission(get_member(), 'member_maintenance')));
        }
    }
    // DOB
    $default_time = is_null($dob_month) ? NULL : usertime_to_utctime(mktime(0, 0, 0, $dob_month, $dob_day, $dob_year));
    if (get_option('no_dob_ask') != '1') {
        $fields->attach(form_input_date(do_lang_tempcode(get_option('no_dob_ask') == '2' ? 'BIRTHDAY' : 'DATE_OF_BIRTH'), '', 'dob', $dob_optional, false, false, $default_time, -130));
        if (addon_installed('ocf_forum')) {
            $fields->attach(form_input_tick(do_lang_tempcode('RELATED_FIELD', do_lang_tempcode('REVEAL_AGE')), do_lang_tempcode('DESCRIPTION_REVEAL_AGE'), 'reveal_age', $reveal_age == 1));
        }
    }
    // Work out what options we need to present
    $doing_international = get_option('allow_international') == '1' && $special_type != 'remote';
    $_langs = find_all_langs();
    $doing_langs = multi_lang() && $special_type != 'remote';
    $doing_email_option = get_option('allow_email_disable') == '1';
    $doing_email_from_staff_option = get_option('allow_email_from_staff_disable') == '1';
    $unspecced_width_zone_exists = $GLOBALS['SITE_DB']->query_value_null_ok('zones', 'zone_name', array('zone_wide' => NULL));
    $unspecced_theme_zone_exists = $GLOBALS['SITE_DB']->query_value_null_ok_full('SELECT COUNT(*) FROM ' . get_table_prefix() . 'zones WHERE ' . db_string_equal_to('zone_theme', '') . ' OR ' . db_string_equal_to('zone_theme', '-1'));
    $doing_wide_option = $special_type != 'remote' && !is_null($unspecced_width_zone_exists) && !$mini_mode;
    $doing_theme_option = $unspecced_theme_zone_exists != 0 && !$mini_mode;
    $doing_local_forum_options = addon_installed('ocf_forum') && $special_type != 'remote' && !$mini_mode;
    if ($doing_international || $doing_langs || $doing_email_option || $doing_wide_option || $doing_theme_option || $doing_local_forum_options) {
        $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('FORCE_OPEN' => is_null($member_id) ? true : NULL, 'TITLE' => do_lang_tempcode('SETTINGS'))));
    }
    require_lang('config');
    // Timezones, if enabled
    if ($doing_international) {
        $timezone_list = nice_get_timezone_list($timezone);
        $fields->attach(form_input_list(do_lang_tempcode('TIME_ZONE'), do_lang_tempcode('DESCRIPTION_TIMEZONE_MEMBER'), 'timezone', $timezone_list));
    }
    // Language choice, if we have multiple languages on site
    if ($doing_langs) {
        $lang_list = new ocp_tempcode();
        $no_lang_set = is_null($language) || $language == '';
        $allow_no_lang_set = get_value('allow_no_lang_selection') === '1';
        if ($allow_no_lang_set) {
            $lang_list->attach(form_input_list_entry('', $no_lang_set, do_lang_tempcode('UNSET')));
        } else {
            if ($no_lang_set) {
                $language = user_lang();
            }
        }
        $lang_list->attach(nice_get_langs($language));
        $fields->attach(form_input_list(do_lang_tempcode('LANGUAGE'), '', 'language', $lang_list, NULL, false, !$allow_no_lang_set));
    }
    // Email privacy
    if ($doing_email_option) {
        $fields->attach(form_input_tick(do_lang_tempcode('ALLOW_EMAILS'), do_lang_tempcode('DESCRIPTION_ALLOW_EMAILS'), 'allow_emails', $allow_emails == 1));
    }
    if ($doing_email_from_staff_option) {
        $fields->attach(form_input_tick(do_lang_tempcode('ALLOW_EMAILS_FROM_STAFF'), do_lang_tempcode('DESCRIPTION_ALLOW_EMAILS_FROM_STAFF'), 'allow_emails_from_staff', $allow_emails_from_staff == 1));
    }
    if (!$mini_mode) {
        // Wide-option, if we have any zones giving a choice
        require_lang('zones');
        if ($doing_wide_option) {
            $fields->attach(form_input_tick(do_lang_tempcode('WIDE'), do_lang_tempcode('DESCRIPTION_MEMBER_ZONE_WIDE'), 'zone_wide', $zone_wide == 1));
        }
        // Theme, if we have any zones giving a choice
        require_code('themes2');
        $entries = nice_get_themes($theme, false, false, 'RELY_SITE_DEFAULT');
        require_lang('themes');
        if ($doing_theme_option) {
            $fields->attach(form_input_list(do_lang_tempcode('THEME'), do_lang_tempcode('DESCRIPTION_THEME'), 'theme', $entries));
        }
        // Various forum options
        if (addon_installed('ocf_forum')) {
            if ($special_type != 'remote') {
                if (get_option('forced_preview_option') == '1') {
                    $fields->attach(form_input_tick(do_lang_tempcode('PREVIEW_POSTS'), do_lang_tempcode('DESCRIPTION_PREVIEW_POSTS'), 'preview_posts', $preview_posts == 1));
                }
                if (get_value('disable_views_sigs_option') !== '1') {
                    if (addon_installed('ocf_signatures')) {
                        $fields->attach(form_input_tick(do_lang_tempcode('VIEWS_SIGNATURES'), do_lang_tempcode('DESCRIPTION_VIEWS_SIGNATURES'), 'views_signatures', $views_signatures == 1));
                    }
                } else {
                    $hidden->attach(form_input_hidden('views_signatures', '1'));
                }
                //$fields->attach(form_input_tick(do_lang_tempcode('AUTO_NOTIFICATION_CONTRIB_CONTENT'),do_lang_tempcode('DESCRIPTION_AUTO_NOTIFICATION_CONTRIB_CONTENT'),'auto_monitor_contrib_content',$auto_monitor_contrib_content==1));
                $usergroup_list = new ocp_tempcode();
                $lgroups = $GLOBALS['OCF_DRIVER']->get_usergroup_list(true, true);
                foreach ($lgroups as $key => $val) {
                    if ($key != db_get_first_id()) {
                        $usergroup_list->attach(form_input_list_entry(strval($key), $pt_allow == '*' || count(array_intersect(array(strval($key)), explode(',', $pt_allow))) != 0, $val));
                    }
                }
                if (get_value('disable_pt_restrict') !== '1') {
                    $fields->attach(form_input_multi_list(do_lang_tempcode('PT_ALLOW'), addon_installed('chat') ? do_lang_tempcode('PT_ALLOW_DESCRIPTION_CHAT') : do_lang_tempcode('PT_ALLOW_DESCRIPTION'), 'pt_allow', $usergroup_list));
                    $fields->attach(form_input_text_comcode(do_lang_tempcode('PT_RULES_TEXT'), do_lang_tempcode('PT_RULES_TEXT_DESCRIPTION'), 'pt_rules_text', $pt_rules_text, false));
                }
            }
        }
        // Prepare list of usergroups, if maybe we are gonna let (a) usergroup-change field(s)
        $group_count = $GLOBALS['FORUM_DB']->query_value('f_groups', 'COUNT(*)');
        $rows = $GLOBALS['FORUM_DB']->query_select('f_groups', array('id', 'g_name', 'g_hidden', 'g_open_membership'), $group_count > 200 ? array('g_is_private_club' => 0) : NULL, 'ORDER BY g_order');
        $_groups = new ocp_tempcode();
        $default_primary_group = get_first_default_group();
        $current_primary_group = NULL;
        foreach ($rows as $group) {
            if ($group['id'] != db_get_first_id()) {
                $selected = $group['id'] == $primary_group || is_null($primary_group) && $group['id'] == $default_primary_group;
                if ($selected) {
                    $current_primary_group = $group['id'];
                }
                $_groups->attach(form_input_list_entry(strval($group['id']), $selected, get_translated_text($group['g_name'], $GLOBALS['FORUM_DB'])));
            }
        }
        // Some admin options...
        if (has_specific_permission(get_member(), 'member_maintenance')) {
            $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang_tempcode('MEMBER_ACCESS'))));
            // Probation
            if (has_specific_permission(get_member(), 'probate_members')) {
                $fields->attach(form_input_date(do_lang_tempcode('ON_PROBATION_UNTIL'), do_lang_tempcode('DESCRIPTION_ON_PROBATION_UNTIL'), 'on_probation_until', true, is_null($on_probation_until) || $on_probation_until <= time(), true, $on_probation_until, 2));
            }
            // Primary usergroup
            if ($special_type != 'ldap') {
                if (has_specific_permission(get_member(), 'assume_any_member')) {
                    if (is_null($member_id) || !$GLOBALS['FORUM_DRIVER']->is_super_admin($member_id) || count($GLOBALS['FORUM_DRIVER']->member_group_query($GLOBALS['FORUM_DRIVER']->get_super_admin_groups(), 2)) > 1) {
                        $fields->attach(form_input_list(do_lang_tempcode('PRIMARY_GROUP'), do_lang_tempcode('DESCRIPTION_PRIMARY_GROUP'), 'primary_group', $_groups));
                    }
                }
            }
        }
        // Secondary usergroups
        if ($special_type != 'ldap') {
            $_groups2 = new ocp_tempcode();
            $members_groups = is_null($member_id) ? array() : $GLOBALS['OCF_DRIVER']->get_members_groups($member_id, false, false);
            foreach ($rows as $group) {
                if ($group['g_hidden'] == 1 && !array_key_exists($group['id'], $members_groups) && !has_specific_permission(get_member(), 'see_hidden_groups')) {
                    continue;
                }
                if ($group['id'] != db_get_first_id() && $group['id'] != $current_primary_group && (array_key_exists($group['id'], $members_groups) || has_specific_permission(get_member(), 'assume_any_member') || $group['g_open_membership'] == 1)) {
                    $selected = array_key_exists($group['id'], $members_groups);
                    $_groups2->attach(form_input_list_entry(strval($group['id']), $selected, get_translated_text($group['g_name'], $GLOBALS['FORUM_DB'])));
                }
            }
            $sec_url = build_url(array('page' => 'groups', 'type' => 'misc'), get_module_zone('groups'));
            if (!$_groups2->is_empty()) {
                $fields->attach(form_input_multi_list(do_lang_tempcode('SECONDARY_GROUP_MEMBERSHIP'), do_lang_tempcode('DESCRIPTION_SECONDARY_GROUP', escape_html($sec_url->evaluate())), 'secondary_groups', $_groups2));
            }
        }
        // Special admin options
        if (has_specific_permission(get_member(), 'member_maintenance')) {
            if ($validated == 0) {
                $validated = get_param_integer('validated', 0);
                if ($validated == 1) {
                    attach_message(do_lang_tempcode('WILL_BE_VALIDATED_WHEN_SAVING'));
                }
            }
            if (addon_installed('unvalidated')) {
                $fields->attach(form_input_tick(do_lang_tempcode('VALIDATED'), do_lang_tempcode('DESCRIPTION_MEMBER_VALIDATED'), 'validated', $validated == 1));
            }
            if (get_value('disable_highlight_name') !== '1') {
                $fields->attach(form_input_tick(do_lang_tempcode('HIGHLIGHTED_NAME'), do_lang_tempcode(addon_installed('pointstore') ? 'DESCRIPTION_HIGHLIGHTED_NAME_P' : 'DESCRIPTION_HIGHLIGHTED_NAME'), 'highlighted_name', $highlighted_name == 1));
            }
            if (!is_null($member_id) && $member_id != get_member()) {
                // Can't ban someone new, and can't ban yourself
                $fields->attach(form_input_tick(do_lang_tempcode('_BANNED'), do_lang_tempcode('DESCRIPTION_MEMBER_BANNED'), 'is_perm_banned', $is_perm_banned == 1));
            }
        }
    }
    return array($fields, $hidden);
}
Ejemplo n.º 11
0
 /**
  * The actualiser to edit a comcode page.
  *
  * @return tempcode		The UI
  */
 function __ed()
 {
     $simple_add = get_param_integer('simple_add', 0) == 1;
     $title = get_page_title($simple_add ? 'COMCODE_PAGE_ADD' : 'COMCODE_PAGE_EDIT');
     $GLOBALS['HELPER_PANEL_PIC'] = 'pagepics/comcode_page_edit';
     $file = filter_naughty(post_param('file'));
     $lang = filter_naughty(post_param('lang'));
     $zone = filter_naughty(post_param('zone'));
     if (addon_installed('page_management')) {
         $new_file = filter_naughty(has_actual_page_access(get_member(), 'admin_sitetree') ? post_param('title', $file) : $file);
     } else {
         $new_file = filter_naughty($file);
     }
     if ($file == '') {
         $file = $new_file;
     }
     require_code('type_validation');
     if (!is_alphanumeric($file, true)) {
         warn_exit(do_lang_tempcode('BAD_CODENAME'));
     }
     $fullpath = zone_black_magic_filterer(get_custom_file_base() . '/' . $zone . '/pages/comcode_custom/' . $lang . '/' . $file . '.txt');
     $renaming_page = $new_file != $file;
     if ($renaming_page) {
         if (!is_alphanumeric($new_file, true)) {
             warn_exit(do_lang_tempcode('BAD_CODENAME'));
         }
         $langs = find_all_langs(true);
         $rename_map = array();
         $afm_needed = false;
         // Actually will stay false as we don't allow renaming original-pages at the moment
         foreach (array_keys($langs) as $lang) {
             $path = zone_black_magic_filterer(filter_naughty($zone) . ($zone != '' ? '/' : '') . 'pages/comcode_custom/' . $lang . '/' . $file . '.txt', true);
             if (is_file(get_file_base() . '/' . $path)) {
                 $new_path = zone_black_magic_filterer(filter_naughty($zone) . ($zone != '' ? '/' : '') . 'pages/comcode_custom/' . $lang . '/' . $new_file . '.txt', true);
                 if (is_file($new_path)) {
                     warn_exit(do_lang_tempcode('ALREADY_EXISTS', escape_html($zone . ':' . $new_file)));
                 }
                 $rename_map[$path] = $new_path;
             }
             if (is_file(get_file_base() . '/' . str_replace('/comcode_custom/', '/comcode/', $path))) {
                 $completion_text = do_lang_tempcode('ORIGINAL_PAGE_NO_RENAME');
             }
         }
         if ($afm_needed) {
             require_code('abstract_file_manager');
             force_have_afm_details();
         }
     }
     $validated = post_param_integer('validated', 0);
     if (!has_specific_permission(get_member(), 'bypass_validation_highrange_content')) {
         $validated = 0;
     }
     $parent_page = post_param('parent_page', '');
     $show_as_edit = post_param_integer('show_as_edit', 0);
     $resource_owner = $GLOBALS['SITE_DB']->query_value_null_ok('comcode_pages', 'p_submitter', array('the_zone' => $zone, 'the_page' => $file));
     check_edit_permission('high', $resource_owner);
     if ($GLOBALS['FORUM_DRIVER']->is_super_admin(get_member())) {
         $_owner = post_param('owner', $GLOBALS['FORUM_DRIVER']->get_username(get_member()));
         $owner = $GLOBALS['FORUM_DRIVER']->get_member_from_username($_owner);
         if (is_null($owner)) {
             $owner = get_member();
         }
     } else {
         $owner = get_member();
     }
     if (is_null($resource_owner)) {
         check_submit_permission('high');
         require_code('submit');
         give_submit_points('COMCODE_PAGE_ADD');
         if (!addon_installed('unvalidated')) {
             $validated = 1;
         }
         $GLOBALS['SITE_DB']->query_insert('comcode_pages', array('the_zone' => $zone, 'the_page' => $file, 'p_parent_page' => $parent_page, 'p_validated' => $validated, 'p_edit_date' => NULL, 'p_add_date' => time(), 'p_submitter' => $owner, 'p_show_as_edit' => 0));
     } else {
         if (!has_actual_page_access(get_member(), $file, $zone)) {
             access_denied('PAGE_ACCESS');
         }
         require_code('submit');
         $just_validated = !content_validated('comcode_page', $zone . ':' . $file) && $validated == 1;
         if ($just_validated) {
             send_content_validated_notification('comcode_page', $zone . ':' . $file);
         }
         if (!addon_installed('unvalidated')) {
             $validated = 1;
         }
         $GLOBALS['SITE_DB']->query_update('comcode_pages', array('p_parent_page' => $parent_page, 'p_validated' => $validated, 'p_edit_date' => time(), 'p_submitter' => $owner, 'p_show_as_edit' => $show_as_edit), array('the_zone' => $zone, 'the_page' => $file), '', 1);
     }
     if ($validated == 0) {
         require_code('submit');
         $edit_url = build_url(array('page' => '_SELF', 'type' => '_ed', 'page_link' => $zone . ':' . $new_file), '_SELF', NULL, false, false, true);
         if (addon_installed('unvalidated')) {
             send_validation_request('COMCODE_PAGE_EDIT', 'comcode_pages', true, $zone . ':' . $new_file, $edit_url);
         }
     }
     $new = post_param('post');
     require_code('attachments2');
     $_new = do_comcode_attachments($new, 'comcode_page', $zone . ':' . $file);
     $new = $_new['comcode'];
     if (!file_exists($fullpath) || $new != file_get_contents($fullpath, FILE_TEXT)) {
         $myfile = @fopen($fullpath, 'wt');
         if ($myfile === false) {
             intelligent_write_error($fullpath);
         }
         final_attachments_from_preview($zone . ':' . $file);
         if (fwrite($myfile, $new) < strlen($new)) {
             warn_exit(do_lang_tempcode('COULD_NOT_SAVE_FILE'));
         }
         fclose($myfile);
         sync_file($fullpath);
         $file_changed = true;
     } else {
         $file_changed = false;
     }
     require_code('seo2');
     $new_keywords = post_param('meta_keywords', '');
     $new_description = post_param('meta_description', '');
     if ($new_keywords == '' && $new_description == '') {
         seo_meta_set_for_implicit('comcode_page', $zone . ':' . $file, array($new), $new);
     } else {
         seo_meta_set_for_explicit('comcode_page', $zone . ':' . $file, $new_keywords, $new_description);
     }
     $completion_text = $validated == 0 ? do_lang_tempcode('SUBMIT_UNVALIDATED') : do_lang_tempcode('SUCCESS');
     // Update cache  NO WE CAN'T - THEY'RE MULTI-THEME NOW
     /*	$string_index=$GLOBALS['SITE_DB']->query_value_null_ok('cached_comcode_pages','string_index',array('the_zone'=>$zone,'the_page'=>$file));
     		if (!is_null($string_index))
     		{
     			lang_remap_comcode($string_index,$new);
     		} else
     		{
     			$string_index=insert_lang_comcode($new,1,NULL,false,NULL,NULL,false,NULL,NULL,60,true,true);
     			$GLOBALS['SITE_DB']->query_insert('cached_comcode_pages',array('the_zone'=>$zone,'the_page'=>$file,'string_index'=>$string_index));
     		}*/
     require_code('permissions2');
     set_page_permissions_from_environment($zone, $file);
     $caches = $GLOBALS['SITE_DB']->query_select('cached_comcode_pages', array('string_index'), array('the_zone' => $zone, 'the_page' => $file));
     $GLOBALS['SITE_DB']->query_delete('cached_comcode_pages', array('the_zone' => $zone, 'the_page' => $file));
     foreach ($caches as $cache) {
         delete_lang($cache['string_index']);
     }
     persistant_cache_empty();
     persistant_cache_delete(array('PAGE_INFO'));
     decache('main_comcode_page_children');
     fix_permissions($fullpath);
     if (is_file($fullpath) && get_option('store_revisions') == '1' && $file_changed) {
         $time = time();
         @copy($fullpath, $fullpath . '.' . strval($time)) or intelligent_write_error($fullpath . '.' . strval($time));
         fix_permissions($fullpath . '.' . strval($time));
         sync_file($fullpath . '.' . strval($time));
     }
     log_it('COMCODE_PAGE_EDIT', $file, $zone);
     require_code('autosave');
     clear_ocp_autosave();
     if ($renaming_page) {
         $GLOBALS['SITE_DB']->query_delete('comcode_pages', array('the_zone' => $zone, 'the_page' => $new_file), '', 1);
         $GLOBALS['SITE_DB']->query_update('comcode_pages', array('the_page' => $new_file), array('the_zone' => $zone, 'the_page' => $file), '', 1);
         $GLOBALS['SITE_DB']->query_update('comcode_pages', array('p_parent_page' => $new_file), array('the_zone' => $zone, 'p_parent_page' => $file));
         foreach ($rename_map as $path => $new_path) {
             if ($afm_needed) {
                 afm_move($path, $new_path);
             } else {
                 rename(get_custom_file_base() . '/' . $path, get_custom_file_base() . '/' . $new_path);
             }
         }
         if (addon_installed('awards')) {
             $types = $GLOBALS['SITE_DB']->query_select('award_types', array('id'), array('a_content_type' => 'comcode_page'));
             foreach ($types as $type) {
                 $GLOBALS['SITE_DB']->query_update('award_archive', array('content_id' => $new_file), array('content_id' => $file, 'a_type_id' => $type['id']));
             }
         }
         $file = $new_file;
     }
     if (post_param_integer('delete', 0) == 1) {
         unlink(get_custom_file_base() . '/' . $path);
     }
     if (addon_installed('awards')) {
         require_code('awards');
         handle_award_setting('comcode_page', $zone . ':' . $file);
     }
     decache('main_sitemap');
     breadcrumb_set_self(do_lang_tempcode('DONE'));
     // Look for bad title semantics
     $_new['html'] = $_new['tempcode']->evaluate();
     if (substr($file, 0, 1) != '_' && substr($file, 0, 6) != 'panel_' && trim($_new['html']) != '') {
         if (strpos($_new['html'], '<h1') === false && strpos($_new['comcode'], '[title]') === false && strpos($_new['comcode'], '[title="1"]') === false) {
             attach_message(do_lang_tempcode('NO_LEVEL_1_HEADERS'), 'notice');
         }
         $matches = array();
         if (strpos($_new['html'], '<h2') === false && preg_match_all('#\\n\\[(b|font|size)\\][^\\.]+\\[/(b|font|size)\\]\\n#', $_new['comcode'], $matches) >= 2) {
             attach_message(do_lang_tempcode('NO_LEVEL_2_HEADERS'), 'inform');
         }
     }
     // Show it worked / Refresh
     $url = post_param('redirect', '');
     if ($url != '') {
         return redirect_screen($title, $url, $completion_text);
     }
     return $this->do_next_manager($title, $file, $zone, $completion_text);
 }
Ejemplo n.º 12
0
/**
 * Get form fields for adding/editing a chatroom.
 *
 * @param  boolean		Whether the room is being made as a private room by the current member
 * @param  SHORT_TEXT	The room name
 * @param  LONG_TEXT		The welcome message
 * @param  SHORT_TEXT	The owner username
 * @param  LONG_TEXT		The comma-separated list of users that may access it (blank: no restriction)
 * @param  LONG_TEXT		The comma-separated list of usergroups that may access it (blank: no restriction)
 * @param  LONG_TEXT		The comma-separated list of users that may NOT access it (blank: no restriction)
 * @param  LONG_TEXT		The comma-separated list of usergroups that may NOT access it (blank: no restriction)
 * @return tempcode		The fields
 */
function get_chatroom_fields($is_made_by_me = false, $room_name = '', $welcome = '', $username = '', $allow2 = '', $allow2_groups = '', $disallow2 = '', $disallow2_groups = '')
{
    require_code('form_templates');
    $fields = new ocp_tempcode();
    $fields->attach(form_input_line(do_lang_tempcode('ROOM_NAME'), do_lang_tempcode('DESCRIPTION_ROOM_NAME'), 'room_name', $room_name, true));
    $fields->attach(form_input_line_comcode(do_lang_tempcode('WELCOME_MESSAGE'), do_lang_tempcode('DESCRIPTION_WELCOME_MESSAGE'), 'c_welcome', $welcome, false));
    if (!$is_made_by_me) {
        $fields->attach(form_input_username(do_lang_tempcode('ROOM_OWNER'), do_lang_tempcode('DESCRIPTION_ROOM_OWNER'), 'room_owner', $username, false));
    }
    $langs = find_all_langs();
    if (count($langs) > 1) {
        $fields->attach(form_input_list(do_lang_tempcode('ROOM_LANG'), do_lang_tempcode('DESCRIPTION_ROOM_LANG'), 'room_lang', nice_get_langs()));
    }
    require_lang('permissions');
    $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('SECTION_HIDDEN' => $allow2 == '' && $allow2_groups == '' && !$is_made_by_me, 'TITLE' => do_lang_tempcode($is_made_by_me ? 'PERMISSIONS' : 'LOWLEVEL_PERMISSIONS'))));
    $fields->attach(form_input_username_multi(do_lang_tempcode('ALLOW_LIST'), do_lang_tempcode('DESCRIPTION_ALLOW_LIST'), 'allow_list', array_map(array($GLOBALS['FORUM_DRIVER'], 'get_username'), $allow2 == '' ? array() : array_map('intval', explode(',', $allow2))), 0, true));
    if (!$is_made_by_me || get_option('group_private_chatrooms') == '1') {
        $usergroup_list = new ocp_tempcode();
        $groups = $GLOBALS['FORUM_DRIVER']->get_usergroup_list(true);
        foreach ($groups as $key => $val) {
            if ($key != db_get_first_id()) {
                if (get_forum_type() == 'ocf') {
                    require_code('ocf_groups2');
                    $num_members = ocf_get_group_members_raw_count($key);
                    if ($num_members >= 1 && $num_members <= 6) {
                        $group_members = ocf_get_group_members_raw($key);
                        $group_member_usernames = '';
                        foreach ($group_members as $group_member) {
                            if ($group_member_usernames != '') {
                                $group_member_usernames = do_lang('LIST_SEP');
                            }
                            $group_member_usernames .= $GLOBALS['FORUM_DRIVER']->get_username($group_member);
                        }
                        $val = do_lang('GROUP_MEMBERS_SPECIFIC', $val, $group_member_usernames);
                    } else {
                        $val = do_lang('GROUP_MEMBERS', $val, number_format($num_members));
                    }
                }
                $usergroup_list->attach(form_input_list_entry(strval($key), $allow2_groups == '*' || count(array_intersect(array($key), $allow2_groups == '' ? array() : explode(',', $allow2_groups))) != 0, $val));
            }
        }
        $fields->attach(form_input_multi_list(do_lang_tempcode('ALLOW_LIST_GROUPS'), do_lang_tempcode($is_made_by_me ? 'DESCRIPTION_ALLOW_LIST_GROUPS_SIMPLE' : 'DESCRIPTION_ALLOW_LIST_GROUPS'), 'allow_list_groups', $usergroup_list));
    }
    $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('SECTION_HIDDEN' => $disallow2 == '' && $disallow2_groups == '', 'TITLE' => do_lang_tempcode('ADVANCED'))));
    $fields->attach(form_input_username_multi(do_lang_tempcode('DISALLOW_LIST'), do_lang_tempcode('DESCRIPTION_DISALLOW_LIST'), 'disallow_list', array_map(array($GLOBALS['FORUM_DRIVER'], 'get_username'), $disallow2 == '' ? array() : array_map('intval', explode(',', $disallow2))), 0, true));
    if (!$is_made_by_me || get_option('group_private_chatrooms') == '1') {
        $usergroup_list = new ocp_tempcode();
        $groups = $GLOBALS['FORUM_DRIVER']->get_usergroup_list(true);
        foreach ($groups as $key => $val) {
            if ($key != db_get_first_id()) {
                if (get_forum_type() == 'ocf') {
                    require_code('ocf_groups2');
                    $num_members = ocf_get_group_members_raw_count($key);
                    if ($num_members >= 1 && $num_members <= 6) {
                        $group_members = ocf_get_group_members_raw($key);
                        $group_member_usernames = '';
                        foreach ($group_members as $group_member) {
                            if ($group_member_usernames != '') {
                                $group_member_usernames = do_lang('LIST_SEP');
                            }
                            $group_member_usernames .= $GLOBALS['FORUM_DRIVER']->get_username($group_member);
                        }
                        $val = do_lang('GROUP_MEMBERS_SPECIFIC', $val, $group_member_usernames);
                    } else {
                        $val = do_lang('GROUP_MEMBERS', $val, number_format($num_members));
                    }
                }
                $usergroup_list->attach(form_input_list_entry(strval($key), $disallow2_groups == '*' || count(array_intersect(array($key), $disallow2_groups == '' ? array() : explode(',', $disallow2_groups))) != 0, $val));
            }
        }
        $fields->attach(form_input_multi_list(do_lang_tempcode('DISALLOW_LIST_GROUPS'), do_lang_tempcode('DESCRIPTION_DISALLOW_LIST_GROUPS'), 'disallow_list_groups', $usergroup_list));
    }
    return $fields;
}
Ejemplo n.º 13
0
 /**
  * The UI to sign up to the newsletter (actually, generally manage subscription).
  *
  * @return tempcode		The UI
  */
 function newsletter_form()
 {
     $title = get_page_title('_NEWSLETTER_JOIN', true, array(escape_html(get_option('newsletter_title'))));
     $newsletters = $GLOBALS['SITE_DB']->query_select('newsletters', array('*'));
     if (count($newsletters) == 0) {
         warn_exit(do_lang_tempcode('NO_ENTRIES'));
     }
     $post_url = build_url(array('page' => '_SELF', 'type' => 'do'), '_SELF');
     $submit_name = do_lang_tempcode('NEWSLETTER_JOIN');
     if (!is_guest()) {
         $their_email = get_param('email', $GLOBALS['FORUM_DRIVER']->get_member_email_address(get_member()));
     } else {
         $their_email = get_param('email', '');
     }
     $forename = '';
     $surname = '';
     $message = get_option('newsletter_text');
     if (has_actual_page_access(get_member(), 'admin_config')) {
         if ($message != '') {
             $message .= ' [[page="_SEARCH:admin_config:category:FEATURE#group_NEWSLETTER"]' . do_lang('EDIT') . '[/page]]';
         }
     }
     $text = comcode_to_tempcode($message, NULL, true);
     // Build up the join form
     $fields = new ocp_tempcode();
     require_code('form_templates');
     $fields->attach(form_input_line(do_lang_tempcode('EMAIL_ADDRESS'), do_lang_tempcode('DESCRIPTION_SUBSCRIBE_ADDRESS'), 'email', $their_email, true));
     $fields->attach(form_input_line(do_lang_tempcode('FORENAME'), '', 'forename', $forename, false));
     $fields->attach(form_input_line(do_lang_tempcode('SURNAME'), '', 'surname', $surname, false));
     $fields->attach(form_input_password(do_lang_tempcode('YOUR_PASSWORD'), do_lang_tempcode('DESCRIPTION_MAINTENANCE_PASSWORD'), 'password', true));
     $fields->attach(form_input_password(do_lang_tempcode('CONFIRM_PASSWORD'), '', 'password_confirm', true));
     if (count(find_all_langs()) != 1) {
         $fields->attach(form_input_list(do_lang_tempcode('LANGUAGE'), '', 'lang', nice_get_langs(user_lang())));
     }
     $level = get_param_integer('level', NULL);
     if (is_null($level)) {
         $level = 3;
     }
     $l = form_input_list_entry('0', false, do_lang_tempcode('NEWSLETTER_0'));
     $l->attach(form_input_list_entry('1', $level == 1, do_lang_tempcode('NEWSLETTER_1')));
     $l->attach(form_input_list_entry('2', $level == 2, do_lang_tempcode('NEWSLETTER_2')));
     $l->attach(form_input_list_entry('3', $level == 3, do_lang_tempcode('NEWSLETTER_3')));
     $l->attach(form_input_list_entry('4', $level == 4, do_lang_tempcode('NEWSLETTER_4')));
     $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang_tempcode('NEWSLETTER_SUBSCRIPTIONS'))));
     foreach ($newsletters as $newsletter) {
         $newsletter_title = get_translated_text($newsletter['title']);
         $newsletter_description = get_translated_text($newsletter['description']);
         if (get_option('interest_levels') == '1') {
             $fields->attach(form_input_list(do_lang_tempcode('SUBSCRIPTION_LEVEL_FOR', make_string_tempcode(escape_html($newsletter_title))), do_lang_tempcode('DESCRIPTION_SUBSCRIPTION_LEVEL', escape_html($newsletter_description)), 'level' . strval($newsletter['id']), $l));
         } else {
             $fields->attach(form_input_tick(do_lang_tempcode('SUBSCRIBE_TO', make_string_tempcode(escape_html($newsletter_title))), make_string_tempcode(escape_html($newsletter_description)), 'level' . strval($newsletter['id']), $level != 0));
         }
     }
     $text->attach(paragraph(do_lang_tempcode('CHANGE_SETTINGS_BY_RESUBSCRIBING')));
     $javascript = "\n\t\t\tvar form=document.getElementById('password').form;\n\t\t\tform.old_submit=form.onsubmit;\n\t\t\tform.onsubmit=function()\n\t\t\t\t{\n\t\t\t\t\tif ((form.elements['password_confirm']) && (form.elements['password_confirm'].value!=form.elements['password'].value))\n\t\t\t\t\t{\n\t\t\t\t\t\twindow.fauxmodal_alert('" . php_addslashes(do_lang('PASSWORD_MISMATCH')) . "');\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\t\t\t\t\tif (typeof form.old_submit!='undefined' && form.old_submit) return form.old_submit();\n\t\t\t\t\treturn true;\n\t\t\t\t};\n\t\t";
     return do_template('FORM_SCREEN', array('_GUID' => '24d7575465152f450c5a8e62650bf6c8', 'JAVASCRIPT' => $javascript, 'HIDDEN' => '', 'FIELDS' => $fields, 'SUBMIT_NAME' => $submit_name, 'URL' => $post_url, 'TITLE' => $title, 'TEXT' => $text));
 }
Ejemplo n.º 14
0
/**
 * Get a nice formatted XHTML listed language selector.
 *
 * @param  ?LANGUAGE_NAME	The language to have selected by default (NULL: uses the current language)
 * @param  boolean			Whether to show languages that have no language details currently defined for them
 * @return tempcode			The language selector
 */
function _nice_get_langs($select_lang = NULL, $show_unset = false)
{
    global $LANGS_MAP;
    if ($LANGS_MAP === NULL) {
        $map_a = get_file_base() . '/lang/langs.ini';
        $map_b = get_custom_file_base() . '/lang_custom/langs.ini';
        if (!is_file($map_b)) {
            $map_b = $map_a;
        }
        $LANGS_MAP = better_parse_ini_file($map_b);
    }
    $langs = new ocp_tempcode();
    $_langs = find_all_langs();
    if (is_null($select_lang)) {
        $select_lang = user_lang();
    }
    foreach (array_keys($_langs) as $lang) {
        $langs->attach(form_input_list_entry($lang, $lang == $select_lang, array_key_exists($lang, $LANGS_MAP) ? $LANGS_MAP[$lang] : $lang));
    }
    if ($show_unset) {
        asort($LANGS_MAP);
        foreach ($LANGS_MAP as $lang => $full) {
            if (!array_key_exists($lang, $_langs)) {
                $_full = make_string_tempcode($full);
                $_full->attach(do_lang_tempcode('_UNSET'));
                $langs->attach(form_input_list_entry($lang, false, protect_from_escaping($_full)));
            }
        }
    }
    return $langs;
}
Ejemplo n.º 15
0
/**
 * Get an array of all the pages everywhere in the zone (for small sites everything will be returned, for larger ones it depends on the show method).
 *
 * @param  ID_TEXT		The zone name
 * @param  boolean		Whether to leave file extensions on the page name
 * @param  boolean		Whether to take redirects into account
 * @param  integer		Selection algorithm constant
 * @set 0 1 2
 * @param  ?ID_TEXT		Page type to show (NULL: all)
 * @return array			A map of page name to type (modules_custom, etc)
 */
function _find_all_pages_wrap($zone, $keep_ext_on = false, $consider_redirects = false, $show_method = 0, $page_type = NULL)
{
    $pages = array();
    if (is_null($page_type) || $page_type == 'modules') {
        if (!in_safe_mode()) {
            $pages += find_all_pages($zone, 'modules_custom', 'php', $keep_ext_on, NULL, $show_method);
        }
        $pages += find_all_pages($zone, 'modules', 'php', $keep_ext_on, NULL, $show_method);
    }
    $langs = multi_lang() ? array_keys(find_all_langs()) : array(get_site_default_lang());
    foreach ($langs as $lang) {
        if (is_null($page_type) || $page_type == 'comcode') {
            if (!in_safe_mode()) {
                $pages += find_all_pages($zone, 'comcode_custom/' . $lang, 'txt', $keep_ext_on, NULL, $show_method);
            }
            $pages += find_all_pages($zone, 'comcode/' . $lang, 'txt', $keep_ext_on, NULL, $show_method);
        }
        if (is_null($page_type) || $page_type == 'html') {
            if (!in_safe_mode()) {
                $pages += find_all_pages($zone, 'html_custom/' . $lang, 'htm', $keep_ext_on, NULL, $show_method);
            }
            $pages += find_all_pages($zone, 'html/' . $lang, 'htm', $keep_ext_on, NULL, $show_method);
        }
    }
    if (is_null($page_type) || $page_type == 'minimodules') {
        if (!in_safe_mode()) {
            $pages += find_all_pages($zone, 'minimodules_custom', 'php', $keep_ext_on, NULL, $show_method);
        }
        $pages += find_all_pages($zone, 'minimodules', 'php', $keep_ext_on, NULL, $show_method);
    }
    if (addon_installed('redirects_editor')) {
        if ($consider_redirects) {
            $redirects = $GLOBALS['SITE_DB']->query_select('redirects', array('*'), array('r_from_zone' => $zone));
            foreach ($redirects as $r) {
                if ($r['r_is_transparent'] == 0) {
                    //unset($pages[$r['r_from_page']]); // We don't want to link to anything that is a full redirect		-	Actually, we don't want to hide things too much, could be confusing
                } else {
                    $pages[$r['r_from_page']] = 'redirect:' . $r['r_to_zone'] . ':' . $r['r_to_page'];
                }
            }
        }
    }
    return $pages;
}
Ejemplo n.º 16
0
 /**
  * Standard modular run function for CRON hooks. Searches for tasks to perform.
  */
 function run()
 {
     if (get_param('keep_lang', NULL) === NULL || get_param('keep_theme', NULL) === NULL) {
         // We need to run this for each language and for each theme
         $langs = find_all_langs();
         require_code('themes2');
         $themes = find_all_themes();
         foreach (array_keys($langs) as $lang) {
             foreach (array_keys($themes) as $theme) {
                 if ($theme == 'default' || has_category_access(get_member(), 'theme', $theme)) {
                     $where = array('c_theme' => $theme, 'c_lang' => $lang);
                     $count = $GLOBALS['SITE_DB']->query_value('cron_caching_requests', 'COUNT(*)', $where);
                     if ($count > 0) {
                         $url = get_base_url() . '/data/cron_bridge.php?limit_hook=block_caching&keep_lang=' . urlencode($lang) . '&keep_theme=' . urlencode($theme);
                         http_download_file($url, NULL, false);
                     }
                 }
             }
         }
         // Force re-loading of values that we use to mark progress (as above calls probably resulted in changes happening)
         global $VALUES;
         $VALUES = $GLOBALS['SITE_DB']->query_select('values', array('*'));
         $VALUES = list_to_map('the_name', $VALUES);
         return;
     }
     $where = array('c_theme' => $GLOBALS['FORUM_DRIVER']->get_theme(), 'c_lang' => user_lang());
     $requests = $GLOBALS['SITE_DB']->query_select('cron_caching_requests', array('id', 'c_codename', 'c_map', 'c_timezone', 'c_is_bot', 'c_in_panel', 'c_interlock', 'c_store_as_tempcode'), $where);
     foreach ($requests as $request) {
         $GLOBALS['NO_QUERY_LIMIT'] = true;
         $codename = $request['c_codename'];
         $map = unserialize($request['c_map']);
         $object = do_block_hunt_file($codename, $map);
         if (is_object($object)) {
             global $LANGS_REQUESTED, $JAVASCRIPTS, $CSSS, $LANGS_REQUESTED, $DO_NOT_CACHE_THIS, $TIMEZONE_MEMBER_CACHE;
             $backup_langs_requested = $LANGS_REQUESTED;
             $backup_javascripts = $JAVASCRIPTS;
             $backup_csss = $CSSS;
             get_users_timezone();
             $backup_timezone = $TIMEZONE_MEMBER_CACHE[get_member()];
             $LANGS_REQUESTED = array();
             $JAVASCRIPTS = array('javascript' => 1, 'javascript_thumbnails' => 1);
             $CSSS = array('no_cache' => 1, 'global' => 1);
             $cache = $object->run($map);
             $TIMEZONE_MEMBER_CACHE[get_member()] = $backup_timezone;
             $cache->handle_symbol_preprocessing();
             if (!$DO_NOT_CACHE_THIS) {
                 if (method_exists($object, 'cacheing_environment')) {
                     $info = $object->cacheing_environment();
                 } else {
                     $info = array();
                     $info['cache_on'] = 'array($map,$GLOBALS[\'FORUM_DRIVER\']->get_members_groups(get_member()))';
                     $info['ttl'] = 60 * 24;
                 }
                 $ttl = $info['ttl'];
                 $_cache_identifier = array();
                 $cache_on = $info['cache_on'];
                 if (is_array($cache_on)) {
                     $_cache_identifier = call_user_func($cache_on[0], $map);
                 } else {
                     if ($cache_on != '' && !defined('HIPHOP_PHP')) {
                         $_cache_on = eval('return ' . $cache_on . ';');
                         // NB: This uses $map, as $map is referenced inside $cache_on
                         if (is_null($_cache_on)) {
                             return NULL;
                         }
                         foreach ($_cache_on as $on) {
                             $_cache_identifier[] = $on;
                         }
                     } elseif (defined('HIPHOP_PHP')) {
                         return NULL;
                     }
                 }
                 $_cache_identifier[] = $request['c_timezone'];
                 $_cache_identifier[] = $request['c_is_bot'] == 0;
                 $_cache_identifier[] = strval($request['c_in_panel']);
                 $_cache_identifier[] = strval($request['c_interlock']);
                 $cache_identifier = serialize($_cache_identifier);
                 require_code('caches2');
                 if ($request['c_store_as_tempcode'] == 1) {
                     $cache = make_string_tempcode($cache->evaluate());
                 }
                 put_into_cache($codename, $ttl, $cache_identifier, $cache, array_keys($LANGS_REQUESTED), array_keys($JAVASCRIPTS), array_keys($CSSS), true);
             }
             $LANGS_REQUESTED += $backup_langs_requested;
             $JAVASCRIPTS += $backup_javascripts;
             $CSSS += $backup_csss;
         }
         $GLOBALS['SITE_DB']->query_delete('cron_caching_requests', $request);
     }
 }
Ejemplo n.º 17
0
/**
 * Convert the specified language codename to the default content, and return the language key.
 *
 * @param  ID_TEXT		The language codename
 * @param  boolean		Whether the given codes value is to be parsed as comcode
 * @param  integer		The level of importance this language string holds
 * @return integer		The language ID
 */
function lang_code_to_default_content($code, $comcode = false, $level = 2)
{
    $lang_key = insert_lang(do_lang($code), $level, NULL, $comcode);
    $langs = find_all_langs();
    foreach ($langs as $lang => $lang_type) {
        if ($lang != user_lang()) {
            if (is_file(get_file_base() . '/' . $lang_type . '/' . $lang . '/critical_error.ini')) {
                // Make sure it's a reasonable looking pack, not just a stub (Google Translate addon can be made to go nuts otherwise)
                insert_lang(do_lang($code, '', '', '', $lang), $level, NULL, true, $lang_key, $lang);
            }
        }
    }
    return $lang_key;
}
Ejemplo n.º 18
0
 /**
  * The UI to export an addon (1).
  *
  * @return tempcode		The UI
  */
 function addon_export()
 {
     $title = get_page_title('EXPORT_ADDON');
     // Lang packs
     $url = build_url(array('page' => '_SELF', 'type' => '_addon_export', 'exp' => 'lang'), '_SELF');
     $all_langs = find_all_langs();
     ksort($all_langs);
     $i = 0;
     $tpl_languages = new ocp_tempcode();
     $_lang_file_map = get_custom_file_base() . '/lang_custom/langs.ini';
     if (!file_exists($_lang_file_map)) {
         $_lang_file_map = get_file_base() . '/lang/langs.ini';
     }
     $lang_file_map = better_parse_ini_file($_lang_file_map);
     foreach ($all_langs as $lang => $dir) {
         if ($dir == 'lang_custom') {
             $files = $this->do_dir($dir . '/' . $lang);
             $frm_langs = new ocp_tempcode();
             $frm_langs->attach(form_input_hidden('lang', $lang));
             foreach (array_keys($files) as $file) {
                 $frm_langs->attach(form_input_hidden('file_' . strval($i), $file));
                 $i++;
             }
             $nice_name = array_key_exists($lang, $lang_file_map) ? $lang_file_map[$lang] : $lang;
             $tpl_languages->attach(do_template('ADDON_EXPORT_LINE', array('_GUID' => '4e2f56799bdb3c4930396315236e2383', 'NAME' => $nice_name, 'URL' => $url, 'FILES' => $frm_langs)));
         }
     }
     // Theme packs
     $url = build_url(array('page' => '_SELF', 'type' => '_addon_export', 'exp' => 'theme'), '_SELF');
     require_code('themes2');
     $all_themes = find_all_themes();
     ksort($all_themes);
     $i = 0;
     $tpl_themes = new ocp_tempcode();
     foreach ($all_themes as $theme => $theme_title) {
         if ($theme != 'default') {
             $files = $this->do_dir('themes/' . $theme);
             $frm_themes = new ocp_tempcode();
             foreach (array_keys($files) as $file) {
                 $frm_themes->attach(form_input_hidden('file_' . strval($i), $file));
                 $i++;
             }
             $tpl_themes->attach(do_template('ADDON_EXPORT_LINE', array('_GUID' => '9c1dab6d6e6c13b5e01c86c83c3acde1', 'NAME' => $theme_title, 'URL' => $url, 'FILES' => $frm_themes)));
         }
     }
     // Files for choice export
     $url = build_url(array('page' => '_SELF', 'type' => '_addon_export', 'exp' => 'custom'), '_SELF');
     $files = $this->do_dir('');
     ksort($files);
     $frm_files = new ocp_tempcode();
     $i = 0;
     foreach (array_keys($files) as $file) {
         $frm_files->attach(do_template('ADDON_EXPORT_FILE_CHOICE', array('_GUID' => '77a91b947259c5e0cc7b5240b24425ca', 'ID' => strval($i), 'PATH' => $file)));
         $i++;
     }
     $tpl_files = do_template('ADDON_EXPORT_LINE_CHOICE', array('_GUID' => '525b161afe5d84268360e960da5e759f', 'URL' => $url, 'FILES' => $frm_files));
     breadcrumb_set_parents(array(array('_SELF:_SELF:misc', do_lang_tempcode('ADDONS'))));
     return do_template('ADDON_EXPORT_SCREEN', array('_GUID' => 'd89367c0bbc3d6b8bd19f736d9474dfa', 'TITLE' => $title, 'LANGUAGES' => $tpl_languages, 'FILES' => $tpl_files, 'THEMES' => $tpl_themes));
 }
Ejemplo n.º 19
0
/**
 * Callback for writing a page-link into the Sitemaps XML file.
 *
 * @param  string		The page-link.
 * @param  string		The parent page-link in the ocPortal site tree.
 * @param  ?TIME		When the node was added (NULL: unknown).
 * @param  ?TIME 		When the node was last edited (NULL: unknown/never).
 * @param  float		The priority of this for spidering, 0.0-1.0.
 * @param  string		The title of the node.
 * @param  boolean	Whether the category is accessible by the user the sitemap is being generated for (Guest for a Sitemaps XML file).
 */
function pagelink_to_sitemapsxml($pagelink, $parent_pagelink, $add_date, $edit_date, $priority, $title, $accessible = true)
{
    global $SITEMAPS_OUT_FILE;
    if (!$accessible) {
        return;
    }
    // $accessible is false and we're not building up a structure, so just leave
    unset($parent_pagelink);
    // Structure not used for Sitemaps
    unset($title);
    // Title not used for Sitemaps
    list($zone, $attributes, $hash) = page_link_decode($pagelink);
    $langs = find_all_langs();
    foreach (array_keys($langs) as $lang) {
        $url = _build_url($attributes + ($lang == get_site_default_lang() ? array() : array('keep_lang' => $lang)), $zone, NULL, false, false, true, $hash);
        $_lastmod_date = is_null($edit_date) ? $add_date : $edit_date;
        if (!is_null($_lastmod_date)) {
            $lastmod_date = '<lastmod>' . xmlentities(date('Y-m-d\\TH:i:s', $_lastmod_date) . substr_replace(date('O', $_lastmod_date), ':', 3, 0)) . '</lastmod>';
        } else {
            $lastmod_date = '<changefreq>yearly</changefreq>';
        }
        $url_blob = '
   <url>
      <loc>' . xmlentities($url) . '</loc>
      ' . $lastmod_date . '
      <priority>' . float_to_raw_string($priority) . '</priority>
   </url>
		';
        fwrite($SITEMAPS_OUT_FILE, $url_blob);
    }
}