Просмотр файла quote_bash/bash.php

Размер файла: 1.37Kb
<?php

require ( dirname ( __FILE__ ) . '/config.php' );

$d = 0;

$data = file_get_contents("http://bash.org.ru/");

preg_match_all("#<div>(.+)</div>#", $data, $dat);

foreach($dat[1] AS $value)
{
	$value = str_replace("<br>", "\n", $value);
	$value = str_replace("<br />", "\n", $value);
	$value = str_replace("<br/>", "\n", $value);
	$value = str_replace("&quot;", "\"", $value);
	$value = str_replace("&lt;", "<", $value);
	$value = str_replace("&gt;", ">", $value);
	//echo $value . "\n";
	if ( mysql_num_rows ( mysql_query ( "SELECT * FROM `bashorg_quotes` WHERE `quote`='" . $value . "'")) == 0 )
	mysql_query("INSERT INTO `bashorg_quotes` (quote) VALUES ('" . $value . "')");
	$d++;
	echo "|";
}

for($i = 1; $i <= 350; $i++)
{
	$data = file_get_contents("http://bash.org.ru/index/" . $i);
	
	echo "---=Getting " . $i . "=---\n";

	preg_match_all("#<div>(.+)</div>#", $data, $dat);

	foreach($dat[1] AS $value)
	{
		$value = str_replace("<br>", "\n", $value);
		$value = str_replace("<br />", "\n", $value);
		$value = str_replace("<br/>", "\n", $value);
		$value = str_replace("&quot;", "\"", $value);
		$value = str_replace("&lt;", "<", $value);
		$value = str_replace("&gt;", ">", $value);
		//echo $value;
		mysql_query("INSERT INTO `bashorg_quotes` (quote) VALUES ('" . $value . "')");
		$d++;
		echo "|";
	}
}

echo "\n\nI inserted " . $d;
?>