/** * * @return string */ public static function fileTree() { $root = JchPlatformPaths::rootPath(); $dir = urldecode(JchPlatformUtility::get('dir', '', 'string', 'post')); $dir = JchPlatformUtility::decrypt($dir); $response = ''; if (file_exists($root . $dir)) { $files = scandir($root . $dir); natcasesort($files); if (count($files) > 2) { /* The 2 accounts for . and .. */ $response .= '<ul class="jqueryFileTree" style="display: none; ">'; // All dirs foreach ($files as $file) { if (file_exists($root . $dir . $file) && $file != '.' && $file != '..' && is_dir($root . $dir . $file)) { $response .= '<li class="directory collapsed"><a href="#" rel="' . JchPlatformUtility::encrypt($dir . $file . '/') . '">' . htmlentities($file) . '</a></li>'; } } // All files foreach ($files as $file) { if (file_exists($root . $dir . $file) && $file != '.' && $file != '..' && !is_dir($root . $dir . $file)) { $ext = preg_replace('/^.*\\./', '', $file); $response .= '<li class="file ext_' . $ext . '"><a href="#" rel="' . JchPlatformUtility::encrypt($dir . $file) . '">' . htmlentities($file) . '</a></li>'; } } $response .= '</ul>'; } } return $response; }
/** * * @return string */ public static function leverageBrowserCaching() { $htaccess = JchPlatformPaths::rootPath() . '.htaccess'; if (file_exists($htaccess)) { $contents = file_get_contents($htaccess); if (!preg_match('#ExpiresByType#', $contents)) { $sExpires = <<<JCHEXPIRES ## BEGIN EXPIRES CACHING - JCH OPTIMIZE ## <IfModule mod_expires.c> ExpiresActive on # Perhaps better to whitelist expires rules? Perhaps. ExpiresDefault "access plus 1 month" # cache.appcache needs re-requests in FF 3.6 (thanks Remy ~Introducing HTML5) ExpiresByType text/cache-manifest "access plus 0 seconds" # Your document html ExpiresByType text/html "access plus 0 seconds" # Data ExpiresByType text/xml "access plus 0 seconds" ExpiresByType application/xml "access plus 0 seconds" ExpiresByType application/json "access plus 0 seconds" # Feed ExpiresByType application/rss+xml "access plus 1 hour" ExpiresByType application/atom+xml "access plus 1 hour" # Favicon (cannot be renamed) ExpiresByType image/x-icon "access plus 1 week" # Media: images, video, audio ExpiresByType image/gif "access plus 1 month" ExpiresByType image/png "access plus 1 month" ExpiresByType image/jpg "access plus 1 month" ExpiresByType image/jpeg "access plus 1 month" ExpiresByType video/ogg "access plus 1 month" ExpiresByType audio/ogg "access plus 1 month" ExpiresByType video/mp4 "access plus 1 month" ExpiresByType video/webm "access plus 1 month" # HTC files (css3pie) ExpiresByType text/x-component "access plus 1 month" # Webfonts ExpiresByType application/x-font-ttf "access plus 1 month" ExpiresByType font/opentype "access plus 1 month" ExpiresByType application/x-font-woff "access plus 1 month" ExpiresByType image/svg+xml "access plus 1 month" ExpiresByType application/vnd.ms-fontobject "access plus 1 month" # CSS and JavaScript ExpiresByType text/css "access plus 1 year" ExpiresByType text/javascript "access plus 1 year" ExpiresByType application/javascript "access plus 1 year" <IfModule mod_headers.c> Header append Cache-Control "public" </IfModule> </IfModule> ## END EXPIRES CACHING - JCH OPTIMIZE ## JCHEXPIRES; return file_put_contents($htaccess, $sExpires, FILE_APPEND); } else { return 'CODEALREADYINFILE'; } } else { return 'FILEDOESNTEXIST'; } }
private static function item($file, $dir, $view, $path) { $encrypt_dir = JchPlatformUtility::encrypt($dir . $file); $encrypt_file = JchPlatformUtility::encrypt(rtrim(JchPlatformPaths::rootPath(), '/\\') . $dir . $file); $anchor = '<a href="#" rel="' . $encrypt_dir . '">' . htmlentities($file) . '</a>'; $html = ''; if ($view == 'tree') { $html .= $anchor; } else { if ($path == 'dir') { $html .= '<span><input type="checkbox" value="' . $encrypt_dir . '"></span>'; $html .= $anchor; } else { $html .= '<span><input type="checkbox" value="' . $encrypt_file . '"></span>'; $html .= '<span>' . htmlentities($file) . '</span>' . '<span><input type="text" pattern="[0-9]*" size="10" maxlength="5" name="width" ></span>' . '<span><input type="text" pattern="[0-9]*" size="10" maxlength="5" name="height" ></span>'; } } return $html; }