include config php function win_utf8 in_text output other 1025 other 1

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<?
include '../config.php';
function win_utf8 ($in_text){
$output="";
$other[1025]="Ё";
$other[1105]="ё";
$other[1028]="Є";
$other[1108]="є";
$other[1030]="I";
$other[1110]="i";
$other[1031]="Ї";
$other[1111]="ї";
for ($i=0; $i<strlen($in_text); $i++){
if (ord($in_text{$i})>191){
$output.="&#".(ord($in_text{$i})+848).";";
} else {
if (array_search($in_text{$i}, $other)===false){
$output.=$in_text{$i};
} else {
$output.="&#".array_search($in_text{$i}, $other).";";
}
}
}
return $output;
}
if($_GET[cat]){
$keys=$_GET[ser];
$num=$howmany;
$url='http://www.google.com/search?hl=ru&lr=&rlz=1G1GGLQ_RURU298&num='.$num.'&start='.$start.'&q='.$keys.'&btnG=Search&aq=f&oq=&aqi=';
$text=win_utf8(file_get_contents($url));
$pattern='#<h3 class=r><a href="(.{1,350})" class=l>(.{1,350}?)</a></h3>#';
preg_match_all($pattern, $text, $matches);
$need=$matches[1];
$nod=$matches[2];
echo '<form method=post action="?all=1&cat='.$_GET[cat].'">';
foreach($need as $k=>$v){
$hre.= $v."\n";
$nam.=strip_tags($nod[$k])."\n";
}
echo '<textarea rows=10 cols=50 name=puti>'.$hre.'</textarea>';
echo '<textarea rows=10 cols=50 name=names>'.$nam.'</textarea>';
echo '<input type=submit value"Парсить!!"></form>';
}
if($_GET[all]){
$puti=explode("\n",$_POST[puti]);
$names=explode("\n",$_POST[names]);
$cat=$_GET[cat];
echo 'start...';
foreach($puti as $num=>$put){
echo '<br>'.$put.' - ';
$text=win_utf8(l($put));
$text=strip_tags($text);
$text=trim($text);
if($text){
$slova=explode("\n", $text);
$nslov=count($slova);
$colpag=ceil($nslov/30); //this is number of count
$nazv=$names[$num];
q("INSERT INTO elements SET name ='$nazv', pages = '$colpag', catid = '$cat'");
$elid=mysql_insert_id();
for($i=1; $i<=$colpag;$i++){
$slott='';
for($piroo=0;$piroo<$koll;$piroo++){
$slott.=$slova[(($i-1)*$koll+$piroo)].'<br />';
}
q("INSERT INTO pages SET num ='$i', text = '".mysql_real_escape_string($slott)."', elemid = '$elid'");
}
echo 'added;';
}
}
}
?>
<form method=get>
<input type=text name=cat>
<input value='+filetype%3Atxt' type=text name=ser>
<input value="ParseSERP" type="submit">
</form>