|
| 1 | +<?php |
| 2 | + |
| 3 | + header("Content-Type: application/javascript"); |
| 4 | + |
| 5 | + # echo "var debug = " . $GLOBALS['DEBUG'] . ";\n"; |
| 6 | + # echo "var language = '" . $GLOBALS['LANGUAGE'] . "';\n"; |
| 7 | + # echo "\n\n"; |
| 8 | + |
| 9 | +/********************************************************************************************************/ |
| 10 | + |
| 11 | + function JScompression( $content ){ |
| 12 | + $pattern = '/(?:(?:\/\*(?:[^*]|(?:\*+[^*\/]))*\*+\/)|(?:(?<!\:|\\\|\'|\")\/\/.*))/'; |
| 13 | + |
| 14 | + $content = trim( $content ); |
| 15 | + $content = preg_replace( $pattern, '', $content ); |
| 16 | + $content = str_replace( ' }', '}', $content ); |
| 17 | + $content = str_replace( '{ ', '{', $content ); |
| 18 | + $content = str_replace( ' =', '=', $content ); |
| 19 | + $content = str_replace( '= ', '=', $content ); |
| 20 | + $content = str_replace( ' ;', ';', $content ); |
| 21 | + $content = str_replace( '; ', ';', $content ); |
| 22 | + $content = str_replace( ' )', ')', $content ); |
| 23 | + $content = str_replace( '( ', '(', $content ); |
| 24 | + $content = preg_replace( '#/\*.*?\*/#', ' ', $content ); |
| 25 | + $content = preg_replace( '/ +/', ' ', $content ); |
| 26 | + $content = preg_replace( '/[[:blank:]]+/', ' ', $content ); |
| 27 | + $content = preg_replace( '/^\s+/', ' ', $content ); |
| 28 | + $content = preg_replace( '/[[:blank:]]+/', ' ', $content ); |
| 29 | + $content = str_replace( '// ', "\n// ", $content ); |
| 30 | + $content = str_replace( '}//', "}\n// ", $content ); |
| 31 | + $content = str_replace( ';//', ";\n// ", $content ); |
| 32 | + $content = str_replace( ',//', ",\n// ", $content ); |
| 33 | + $content = preg_replace( '/ +/', ' ', $content ); |
| 34 | + $content = preg_replace( '#/\*.*?\*/#', ' ', $content ); |
| 35 | + $content = preg_replace( '/^\s+/', ' ', $content ); |
| 36 | + $content = preg_replace( "/([\r\n])(\/\*)[\s\S]*?(\*\/)/", " ", $content ); |
| 37 | + |
| 38 | + $content = preg_replace( '/[ \t]+/', ' ', preg_replace('/[\r\n]+/', "\n", $content )); |
| 39 | + $content = preg_replace( "/([\r\n])(\/\*)[\s\S]*?(\*\/)/", " ", $content ); |
| 40 | + |
| 41 | + $string = $content; |
| 42 | + $array = explode( "\n" , $string ); |
| 43 | + |
| 44 | + foreach( $array as $arr ) { |
| 45 | + if( substr( $arr, 0, 2) != '//' ){ |
| 46 | + $output[] = trim( $arr ); |
| 47 | + } |
| 48 | + } |
| 49 | + |
| 50 | + $code = implode( "\n" , $output ); |
| 51 | + $code = preg_replace( "/ +/", " ", $code ); |
| 52 | + $code = preg_replace( "/[\r\n]+/", "\n", $code ); |
| 53 | + $code = str_replace( "http://","http:\/\/",$code ); |
| 54 | + |
| 55 | + return $code; |
| 56 | + } |
| 57 | + |
| 58 | +/********************************************************************************************************/ |
| 59 | + |
| 60 | + function print_js( $path , $comp ){ |
| 61 | + |
| 62 | + $iter = new RecursiveIteratorIterator( |
| 63 | + new RecursiveDirectoryIterator($_SERVER['DOCUMENT_ROOT'] . $path, RecursiveDirectoryIterator::SKIP_DOTS), |
| 64 | + RecursiveIteratorIterator::SELF_FIRST, RecursiveIteratorIterator::CATCH_GET_CHILD // Ignore "Permission denied" |
| 65 | + ); |
| 66 | + |
| 67 | + $paths = array($path); |
| 68 | + |
| 69 | + foreach ($iter as $path => $dir) { |
| 70 | + |
| 71 | + $valfin = $path; |
| 72 | + $exp = explode('.', $valfin); |
| 73 | + $valfin_end = end($exp); |
| 74 | + |
| 75 | + if($dir->isDir()) { |
| 76 | + $valfin = $valfin; |
| 77 | + } |
| 78 | + $paths[] = $valfin; |
| 79 | + |
| 80 | + } |
| 81 | + |
| 82 | + if($paths > ''){ |
| 83 | + sort($paths); |
| 84 | + } |
| 85 | + |
| 86 | + for($i=0; $i < count($paths);++$i){ |
| 87 | + |
| 88 | + $check = explode('.', $paths[$i]); |
| 89 | + $file_extension = end($check); |
| 90 | + |
| 91 | + if (strpos($paths[$i], "#OLD") === false && strpos($paths[$i], ".DAV") === false){ |
| 92 | + if($file_extension == "js" ){ |
| 93 | + $code .= file_get_contents( $paths[$i] ); |
| 94 | + } |
| 95 | + } |
| 96 | + |
| 97 | + } |
| 98 | + |
| 99 | + if( $comp === true ){ |
| 100 | + return JScompression( $code ); |
| 101 | + }else{ |
| 102 | + return $code; |
| 103 | + } |
| 104 | + |
| 105 | + } |
| 106 | + |
| 107 | +echo <<< EOT |
| 108 | +/* |
| 109 | + CREATED BY DARIO PASSARIELLO |
| 110 | + copyright (c) 2020 |
| 111 | +
|
| 112 | + The MIT License (MIT) |
| 113 | + Copyright (c) 2020 Dario Passariello |
| 114 | + Permission is hereby granted, free of charge, to any person obtaining a copy |
| 115 | + of this software and associated documentation files (the "Software"), to deal |
| 116 | + in the Software without restriction, including without limitation the rights |
| 117 | + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 118 | + copies of the Software, and to permit persons to whom the Software is |
| 119 | + furnished to do so, subject to the following conditions: |
| 120 | + The above copyright notice and this permission notice shall be included in all |
| 121 | + copies or substantial portions of the Software. |
| 122 | + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 123 | + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 124 | + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 125 | + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 126 | + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 127 | + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 128 | + SOFTWARE. |
| 129 | +*/ |
| 130 | +
|
| 131 | +
|
| 132 | +EOT; |
| 133 | + |
| 134 | +echo print_js( "/script/" , true ); |
| 135 | + |
| 136 | +?> |
0 commit comments