Fixed an array_combine object issue.
[fa-stable.git] / includes / main.inc
index 11746a288b386bc254d0ea2b6ab4fdd6b436480e..df31aa17a52a4e84d4ea6a0e968fdbc7ebe56d30 100644 (file)
@@ -68,6 +68,24 @@ function end_page($no_menu=false, $is_index=false, $final_screen=false, $type_no
        page_footer($no_menu, $is_index);
 }
 
+function css_files_ensure_init() {
+       global $css_files, $path_to_root;
+
+       if (!isset($css_files))
+       {
+               $theme = user_theme();
+               $css_files = array();
+               $css_files[] = $path_to_root . "/themes/$theme/default.css";
+       }
+}
+
+function add_css_file($filename)
+{
+       global $css_files;
+       css_files_ensure_init();
+       $css_files[] = $filename;
+}
+
 function cache_js_file($fpath, $text) 
 {
        global $SysPrefs;
@@ -383,3 +401,24 @@ function clean_file_name($filename) {
     return preg_replace('/[^a-zA-Z0-9.\-_]/', '_', $filename);
 }
 
+/*
+       Simple random password generator.
+*/
+function generate_password()
+{
+       if (PHP_VERSION >= '5.3')
+               $bytes = openssl_random_pseudo_bytes(8, $cstrong);
+       else
+               $bytes = sprintf("08%x", mt_rand(0,0xffffffff));
+
+       return  base64_encode($bytes);
+}
+
+if (!function_exists('array_fill_keys')) // since 5.2
+{
+       function array_fill_keys($keys, $value)
+       {
+               return (object)array_combine($keys, array_fill(count($keys), $value));
+       }
+}
+