Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $jsFile = $_GET["jsFile"];
- $jsBaseUrl = "js/";
- $imports = array($jsFile)
- function importJsFile($package)
- {
- global $jsBaseUrl, $imports;
- $newJS = "";
- // package is in the form of stuff.stuff.stuff
- $fileURL = $jsBaseUrl.str_replace(".", "/", $package).".js";
- // Open the file and begin reading
- $h = fopen($fileURL, "r");
- while(($line = fgets($h)) !== false)
- {
- if(strstr($line, "@import") !== false
- && !in_array(($pac = substr($line, strlen("@import "))), $imports)) {
- $imports[] = $pac;
- $newJS .= importJsFile($pac);
- } else {
- $newJS .= $line;
- }
- }
- // If there was a problem reading the file, we will not be at the end
- if(!feof($h))
- {
- throw new Exception("Problem reading JS file: ".$package);
- }
- fclose($h);
- return newJS;
- }
Add Comment
Please, Sign In to add comment