/** * Make sure the file is a css or js file and that it exists * @static */ static function CheckFile(&$file) { global $dataDir; $comment_start = '<!--'; $comment_end = '-->'; $file = gp_combine::TrimQuery($file); if (empty($file)) { return false; } //translate addon paths $pos = strpos($file, '/data/_addoncode/'); if ($pos !== false) { $file_parts = substr($file, $pos + 17); $file_parts = explode('/', $file_parts); $addon_key = array_shift($file_parts); $addon_config = gpPlugin::GetAddonConfig($addon_key); if ($addon_config) { $file = $addon_config['code_folder_rel'] . '/' . implode('/', $file_parts); } } //remove null charachters $file = gpFiles::NoNull($file); //require .js or .css $test = strtolower($file); if (substr($test, -3) != '.js' && substr($test, -4) != '.css' && substr($test, -5) != '.less') { echo "\n{$comment_start} File Not CSS, LESS or JS {$file} {$comment_end}\n"; return false; } //paths that have been urlencoded if (strpos($file, '%') !== false) { $decoded_file = rawurldecode($file); if ($full_path = gp_combine::CheckFileSub($decoded_file)) { $file = $decoded_file; return $full_path; } } //paths that have not been encoded if ($full_path = gp_combine::CheckFileSub($file)) { return $full_path; } echo "\n{$comment_start} File Not Found {$dataDir}{$file} {$comment_end}\n"; return false; }
/** * Make sure the fiel is a css or js file and that it exists * @static */ function CheckFile(&$file, $css_comments = true) { global $dataDir, $dirPrefix, $dirPrefixEncoded; $file = gp_combine::TrimQuery($file); if ($css_comments) { $comment_start = '/*'; $comment_end = '*/'; } else { $comment_start = '<!--'; $comment_end = '-->'; } if (empty($file)) { return false; } //remove null charachters $file = gpFiles::NoNull($file); //require .js or .css $test = strtolower($file); if (substr($test, -3) != '.js' && substr($test, -4) != '.css') { echo "\n{$comment_start} File Not CSS or JS {$file} {$comment_end}\n"; return false; } //paths that have been urlencoded if (strpos($file, '%') !== false) { $decoded_file = rawurldecode($file); if ($full_path = gp_combine::CheckFileSub($decoded_file)) { $file = $decoded_file; return $full_path; } } //paths that have not been encoded if ($full_path = gp_combine::CheckFileSub($file)) { return $full_path; } echo "\n{$comment_start} File Not Found {$dataDir}{$file} {$comment_end}\n"; return false; }