SHOW:
|
|
- or go back to the newest paste.
| 1 | <?php | |
| 2 | - | // парсер ключевых слов |
| 2 | + | |
| 3 | - | // © [email protected] 19.05.2017 |
| 3 | + | |
| 4 | if($error==1){error_reporting(E_ALL);ini_set('display_errors', 'on');}
| |
| 5 | else {error_reporting(0);ini_set('display_errors', 'off');}
| |
| 6 | ||
| 7 | $tema=isset($_GET['tema'])?strip_tags($_GET['tema']):"test"; | |
| 8 | $tm=isset($_GET['tema'])?"&tema=$tema":""; | |
| 9 | $tmg=isset($_GET['tema'])?"?tema=$tema":""; | |
| 10 | if(!file_exists($tema)){mkdir($tema, 0700);echo "<meta http-equiv=\"refresh\" content=\"1; url=$tmg\">";}
| |
| 11 | ||
| 12 | $_db="$tema/$tema.db"; | |
| 13 | $files=array("key","bad");
| |
| 14 | foreach($files as $line) | |
| 15 | {
| |
| 16 | $fil[$line]=$tema.'/'.$line.'_'.$tema.'.txt'; | |
| 17 | if (!file_exists($fil[$line])) | |
| 18 | {
| |
| 19 | $fp = fopen($fil[$line], "w"); | |
| 20 | fwrite($fp, ""); | |
| 21 | fclose($fp); | |
| 22 | } | |
| 23 | $arfil[$line]=file($fil[$line]); | |
| 24 | } | |
| 25 | $p=isset($_GET['p'])?$_GET['p']:0; | |
| 26 | $st=isset($_GET['stop'])?"&stop=":""; | |
| 27 | $p20=$p*20; | |
| 28 | $p2020=$p20+20; | |
| 29 | if (isset($_GET['feed'])) | |
| 30 | {
| |
| 31 | if (!file_exists($_db)) | |
| 32 | {
| |
| 33 | $db = new SQLite3($_db); | |
| 34 | $db->busyTimeout(5000); | |
| 35 | $db->exec('PRAGMA journal_mode=WAL;');
| |
| 36 | $db->exec('CREATE TABLE IF NOT EXISTS pages (id INTEGER PRIMARY KEY, key TEXT UNIQUE);');
| |
| 37 | $db->close(); | |
| 38 | } | |
| 39 | else | |
| 40 | {
| |
| 41 | $db = new SQLite3($_db); | |
| 42 | $db->busyTimeout(5000); | |
| 43 | $db->exec('PRAGMA journal_mode=WAL;');
| |
| 44 | if(isset($_POST['key'])) | |
| 45 | {
| |
| 46 | $ar=explode("\n",strip_tags($_POST['key']));
| |
| 47 | $db->exec('BEGIN IMMEDIATE;');
| |
| 48 | foreach($ar as $key) | |
| 49 | {
| |
| 50 | if(empty($key)) continue; | |
| 51 | $lin = $db->escapeString(trim($key)); | |
| 52 | @$db->exec("INSERT INTO pages (key) VALUES ('".$lin."');");
| |
| 53 | } | |
| 54 | $db->exec('COMMIT;');
| |
| 55 | } | |
| 56 | $lh = $db->query("SELECT * FROM pages ORDER BY id ASC LIMIT $p20,20;");
| |
| 57 | $count = $db->querySingle('SELECT count(*) FROM pages;');
| |
| 58 | ||
| 59 | while ($echo = $lh->fetchArray()) | |
| 60 | {
| |
| 61 | $arkey[]=$echo['key']; | |
| 62 | } | |
| 63 | if ($_GET['feed'] == 'gen') | |
| 64 | {
| |
| 65 | foreach($arkey as $key) | |
| 66 | {
| |
| 67 | $key = mb_strtolower($key, 'utf-8'); | |
| 68 | $keyu=preg_replace("/ /",'+',$key);
| |
| 69 | $keyu=urlencode($keyu); | |
| 70 | ||
| 71 | ////////////////////// ---------- ////////////////////// | |
| 72 | ||
| 73 | $url="http://sgs.sputnik.ru/?format=xml&type=web&query=$keyu"; | |
| 74 | $xml = simplexml_load_file($url); | |
| 75 | $offer=$xml->item; | |
| 76 | foreach($offer as $line){$attr=$line->attributes();$keys[]=$attr['header'];}
| |
| 77 | ||
| 78 | $url="http://suggests.go.mail.ru/ie8?q=$keyu"; | |
| 79 | $xml = simplexml_load_file($url); | |
| 80 | $offer=$xml->Section->Item; | |
| 81 | foreach($offer as $line)$keys[]=$line->Text; | |
| 82 | ||
| 83 | $url="http://autocomplete.nigma.ru/complete/query_help.php?suggest=true&q=$keyu"; | |
| 84 | $fff=file_get_contents($url); | |
| 85 | $response = json_decode($fff, true); | |
| 86 | foreach($response[1] as $lin)$keys[]=$lin; | |
| 87 | ||
| 88 | $url="https://suggest.yandex.ru/suggest-ff.cgi?part=$keyu&uil=ru&sn=50"; | |
| 89 | $fff=file_get_contents($url); | |
| 90 | $response = json_decode($fff, true); | |
| 91 | foreach($response[1] as $lin)$keys[]=$lin; | |
| 92 | ||
| 93 | $url="https://search.yahoo.com/sugg/gossip/gossip-us-fp/?nresults=20&command=$keyu"; | |
| 94 | $fff=file_get_contents($url); | |
| 95 | $fff=preg_replace("/fxsearch\((.*)\,\[\]\,\[\](\])\)/",'\1\2',$fff);
| |
| 96 | $response = json_decode($fff, true); | |
| 97 | foreach($response[1] as $lin)$keys[]=$lin; | |
| 98 | /* | |
| 99 | $url="https://clients1.google.com/s?client=opera&q=$keyu"; | |
| 100 | $fff=file_get_contents($url); | |
| 101 | $response = json_decode($fff, true); | |
| 102 | foreach($response[1] as $lin)$keys[]=$lin; | |
| 103 | */ | |
| 104 | $url="http://ss.ask.com/query?li=ff&sstype=prefix&num=20&q=$keyu"; | |
| 105 | $fff=file_get_contents($url); | |
| 106 | $response = json_decode($fff, true); | |
| 107 | foreach($response[1] as $lin)$keys[]=$lin; | |
| 108 | ||
| 109 | ////////////////////// ---------- ////////////////////// | |
| 110 | ||
| 111 | $keys=array_unique($keys); | |
| 112 | ||
| 113 | $db->exec('BEGIN IMMEDIATE;');
| |
| 114 | foreach($keys as $k=>$line) | |
| 115 | {
| |
| 116 | $rr=""; | |
| 117 | foreach ($arfil['bad'] as $black) | |
| 118 | {
| |
| 119 | $black = trim($black); | |
| 120 | preg_match("/$black/",$line,$re);
| |
| 121 | if(!empty($re)) $rr.=$re[0]; | |
| 122 | } | |
| 123 | if(!empty($rr)) continue; | |
| 124 | $lin = $db->escapeString(trim($line)); | |
| 125 | @$db->exec("INSERT INTO pages (key) VALUES ('$lin');");
| |
| 126 | } | |
| 127 | $db->exec('COMMIT;');
| |
| 128 | } | |
| 129 | $p++; | |
| 130 | if($count<$p20) {echo "Все"; exit;}
| |
| 131 | echo "feed=gen&p=$p$tm$st<br>с $p20 по $p2020<br>"; | |
| 132 | ||
| 133 | if(!empty($st)) | |
| 134 | {
| |
| 135 | echo " | |
| 136 | <form action=\"index.php\" target=\"generator\" method=\"get\"> | |
| 137 | <input type=\"hidden\" name=\"feed\" value=\"gen\"/> | |
| 138 | <input type=\"hidden\" name=\"tema\" value=\"$tema\"/> | |
| 139 | <input type=\"text\" name=\"p\" value=\"$p\" size=\"2\" /> | |
| 140 | <input type=\"submit\"> | |
| 141 | </form>"; | |
| 142 | } | |
| 143 | else | |
| 144 | {
| |
| 145 | echo " | |
| 146 | <A HREF=\"?feed=gen&p=$p$tm&stop=\" target=\"generator\">стоп</A> | |
| 147 | <meta http-equiv=\"refresh\" content=\"1; url=?feed=gen&p=$p$tm$st\">"; | |
| 148 | } | |
| 149 | } | |
| 150 | ||
| 151 | if ($_GET['feed'] == 'html') | |
| 152 | {
| |
| 153 | $list = $db->query('SELECT id, key FROM pages ORDER BY id DESC LIMIT 3000;');
| |
| 154 | echo "<A HREF=\"?feed=html$tm\">обновить</A><br>"; | |
| 155 | while ($echo = $list->fetchArray()) | |
| 156 | {
| |
| 157 | echo $echo['id'].' '.$echo['key'].'<br>'; | |
| 158 | } | |
| 159 | } | |
| 160 | ||
| 161 | if ($_GET['feed'] == 'txt') | |
| 162 | {
| |
| 163 | $list = $db->query('SELECT key FROM pages;');
| |
| 164 | echo "Сохранено: $count ключей $tema"; | |
| 165 | $file = fopen ("$tema/$tema.txt","w+");
| |
| 166 | while ($echo = $list->fetchArray()) | |
| 167 | {
| |
| 168 | fputs($file,$echo['key']."\n"); | |
| 169 | } | |
| 170 | fclose ($file); | |
| 171 | } | |
| 172 | ||
| 173 | foreach($files as $k=>$fk) | |
| 174 | {
| |
| 175 | $line=$fil[$fk]; | |
| 176 | if ($_GET['feed'] == $fk) | |
| 177 | {
| |
| 178 | if(isset($_POST[$fk])) | |
| 179 | {
| |
| 180 | file_put_contents($line, strip_tags($_POST[$fk])); | |
| 181 | echo "<meta http-equiv=\"refresh\" content=\"1; url=?feed=$fk$tm\">"; | |
| 182 | } | |
| 183 | $bf[$k]=@file_get_contents($line); | |
| 184 | echo "$line<br/> | |
| 185 | <form action=\"index.php?feed=$fk$tm\" method=\"post\"> | |
| 186 | <textarea rows=\"42\" cols=\"24\" name=\"$fk\">$bf[$k]</textarea><br/> | |
| 187 | <input type=\"submit\"> | |
| 188 | </form> | |
| 189 | "; | |
| 190 | } | |
| 191 | } | |
| 192 | ||
| 193 | $db->close(); | |
| 194 | } | |
| 195 | } | |
| 196 | else | |
| 197 | {
| |
| 198 | header('Content-Type: text/html; charset=UTF-8');
| |
| 199 | echo " | |
| 200 | <table> | |
| 201 | <tr> | |
| 202 | <td colspan=2> | |
| 203 | <A HREF=\"/\">главная</A> | | |
| 204 | <A HREF=\"?feed=gen$tm&p=$p\" target=\"generator\">пуск</A> | | |
| 205 | <A HREF=\"?feed=txt$tm\" target=\"keytxt\">сохранить</A> | | |
| 206 | <A HREF=\"$tema/$tema.txt\" target=\"keytxt\">скачать</A></td> | |
| 207 | <td colspan=2> | |
| 208 | <form action=\"/\" method=\"get\"> | |
| 209 | <input type=\"text\" name=\"tema\" value=\"$tema\" maxlength=\"10\" /> | |
| 210 | <input type=\"submit\"> | |
| 211 | </form> | |
| 212 | </tr> | |
| 213 | - | </form></td> |
| 213 | + | |
| 214 | <td><iframe src=\"?feed=key$tm\" width=\"220\" height=\"700\" frameborder=\"0\" scrolling=\"yes\"></iframe></td> | |
| 215 | <td><iframe src=\"?feed=bad$tm\" width=\"220\" height=\"700\" frameborder=\"0\" scrolling=\"yes\"></iframe></td> | |
| 216 | <td><iframe src=\"?feed=html$tm\" width=\"500\" height=\"700\" frameborder=\"0\" scrolling=\"yes\"></iframe></td> | |
| 217 | <td><iframe name=\"generator\" width=\"500\" height=\"400\" frameborder=\"0\" scrolling=\"yes\"></iframe><br> | |
| 218 | <iframe name=\"keytxt\" width=\"500\" height=\"300\" frameborder=\"0\" scrolling=\"yes\"></iframe></td> | |
| 219 | </tr> | |
| 220 | </table>"; | |
| 221 | } | |
| 222 | ?> |