$string = preg_replace($regex, '', $string); $string = str_replace('"', "", $string); if (!preg_match_all('%css%', $string)) { continue; } if (substr($string, 0, 1) == '/') { $string = substr($string, 1); } echo $string . '<br>'; if (substr($string, 0, 2) == '//') { $cssArray[] = 'http:' . $string; } else { if (substr($string, 0, 4) == 'http') { $cssArray[] = $string; } else { $cssArray[] = $url . $string; } } } } $masterCss = ''; echo "<br><hr><br>"; foreach ($cssArray as $key => $value) { // $masterCss .= file_get_contents($value); echo $value . '<br>'; } return $masterCss; } $url = 'http://wisdom.com/'; echo find_and_combine_css($url);
if (strlen($_POST['input']) < 1) { $inputSource = 'url'; $url = htmlspecialchars($_POST['url']); $urlSize = curl_get_file_size($url); $extension = preg_replace('%\\?.+%', '', pathinfo($url, PATHINFO_EXTENSION)); // minify the css if it's a css file, crawl it if not if ($extension == 'css') { if ($urlSize < 1000000) { file_put_contents($file, fopen($url, 'r')); $originalLength = filesize($file); } else { echo '<script>console.log("file is too big");</script>'; } } else { // file is not css. file_put_contents($file, find_and_combine_css($url)); $originalLength = filesize($file); } } else { $inputSource = 'input'; file_put_contents($file, $_POST['input']); $originalLength = filesize($file); } if ($originalLength == 0) { $originalLength = 1; } $originalFile = 'results/testing.txt'; file_put_contents($originalFile, file_get_contents($file)); // Actions. Not sure about what the best order is? if ($_POST['removeWhiteSpace']) { remove_whitespace($file);