/** * Проверка галеры на наличие заданого цвета */ function checkPages($urls) { foreach ($urls as $url) { print "Load " . $url . "...\n"; $content = file_get_contents($url); if (!preg_match('{<body([^>]*)>}si', $content, $matches)) { continue; } if (!preg_match('{bgcolor=(\\"#.+?\\"|\'#.+?\'|#.+?)(\\s+|>)}si', $matches[1], $m)) { continue; } $color = removeQuotes($m[1]); list($r, $g, $b) = colorRGB($color); if (hexdec($r) < hexdec(RED_MIN) || hexdec($r) > hexdec(RED_MAX)) { continue; } if (hexdec($g) < hexdec(GREEN_MIN) || hexdec($g) > hexdec(GREEN_MAX)) { continue; } if (hexdec($b) < hexdec(BLUE_MIN) || hexdec($b) > hexdec(BLUE_MAX)) { continue; } saveContents("urls_ok.txt", $url . "\n", true); } }
// PHP script to put data into a file function saveContents() { $filename = $_GET["filename"]; //echo "The filename is $filename"; $contents = $_GET["contents"]; //echo "The contents of the file are $contents"; if (strlen($contents) > 0) { $contents = stripslashes($contents); $contents .= "\n"; } $append = $_GET["append"]; $fname = "data/" . $filename; $myfile = fopen($fname, "a+"); if ($myfile == FALSE) { exit("Error opening file: " . $fname); } fwrite($myfile, $contents, strlen($contents)); fclose($myfile); // if(isset($append) && $append == "true") { // $outputFile = file_put_contents($filename, $contents, FILE_APPEND | LOCK_EX); // echo "The return value is (1) ".$outputFile; // } // else { // $outputFile= file_put_contents($filename, $contents, LOCK_EX); // echo "The return value is (2) ".$outputFile; // } // echo "Finally the contents of the file are $contents"; } saveContents();