Ejemplo n.º 1
0
/**
 * Theme branding
 */
function miss_style_option()
{
    $styles = array();
    $sort_styles = array();
    if (is_dir(THEME_SKINS)) {
        if ($open_dirs = opendir(THEME_SKINS)) {
            while (($style = readdir($open_dirs)) !== false) {
                // if(stristr($style, '.css') !== false) {
                if (stristr($style, '.php') !== false) {
                    $styles[$style] = @filemtime(TEMPLATEPATH . '/assets/styles/skins' . $style);
                }
            }
        }
    }
    $styles = array_merge($styles, miss_wpmu_style_option());
    arsort($styles);
    $nt_writable = get_option(MISS_SKIN_NT_WRITABLE);
    if (!empty($nt_writable)) {
        foreach ($nt_writable as $key => $val) {
            $val = $val . '.css';
            $sort_styles[$val] = $val;
        }
    }
    foreach ($styles as $key => $val) {
        $sort_styles[$key] = ucwords(str_replace(array('.php', '.'), array('', ' '), $key));
    }
    unset($sort_styles['_create_new.css'], $sort_styles['ux.model.php']);
    return $sort_styles;
}
Ejemplo n.º 2
0
 /**
  *
  */
 public function get_contents($filename)
 {
     if (array_key_exists($filename, miss_wpmu_style_option())) {
         global $blog_id;
         $uri = get_blog_option($blog_id, 'fileupload_url') . '/styles/skins/' . md5(THEME_NAME) . 'muskin_' . $filename;
         $dir = $_SERVER['DOCUMENT_ROOT'] . '/' . get_blog_option($blog_id, 'upload_path') . '/styles/skins/' . md5(THEME_NAME) . 'muskin_' . $filename;
     } else {
         $uri = THEME_ASSETS . '/styles/skins/' . $filename;
         $dir = THEME_ASSETS_DIR . '/styles/skins/' . $filename;
     }
     # Use curl if it exists
     if (function_exists('curl_init')) {
         $ch = curl_init();
         curl_setopt($ch, CURLOPT_URL, $uri);
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
         $contents = curl_exec($ch);
         $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
         curl_close($ch);
         # Read from database if there is a bad response
         $bad_responses = array('400', '401', '403', '404', '0');
         if (in_array($http_code, $bad_responses)) {
             $skin_name = str_replace('.css', '', $filename);
             $content = get_option(MISS_SKINS);
             if (!empty($content[$skin_name])) {
                 return miss_decode($content[$skin_name]);
                 # If we still don't have any content fopen css file and get contents
             } elseif ($fh_input = @fopen($dir, 'r')) {
                 $input_data = fread($fh_input, filesize($dir));
                 fclose($fh_input);
                 # Return content if response is good
                 if ($input_data) {
                     return $input_data;
                 } else {
                     return false;
                 }
             }
         }
         # Return content if response is good
         if ($contents) {
             return $contents;
         } else {
             # If we still don't have any content read from the database
             $skin_name = str_replace('.css', '', $filename);
             $content = get_option(MISS_SKINS);
             if (!empty($content[$skin_name])) {
                 return miss_decode($content[$skin_name]);
                 # If we still don't have any content fopen css file and get contents
             } elseif ($fh_input = @fopen($dir, 'r')) {
                 $input_data = fread($fh_input, filesize($dir));
                 fclose($fh_input);
                 # Return content if response is good
                 if ($input_data) {
                     return $input_data;
                 } else {
                     return false;
                 }
             }
         }
         # If curl is not installed fopen css file and get contents
     } elseif ($fh_input = @fopen($dir, 'r')) {
         $input_data = fread($fh_input, filesize($dir));
         fclose($fh_input);
         # Return content if response is good
         if ($input_data) {
             return $input_data;
         } else {
             # If we still don't have any content read from the database
             $skin_name = str_replace('.css', '', $filename);
             $content = get_option(MISS_SKINS);
             if (!empty($content[$skin_name])) {
                 return miss_decode($content[$skin_name]);
             } else {
                 return false;
             }
         }
     } else {
         # Read from database
         $skin_name = str_replace('.css', '', $filename);
         $content = get_option(MISS_SKINS);
         if (!empty($content[$skin_name])) {
             return miss_decode($content[$skin_name]);
         } else {
             return false;
         }
     }
 }