location = /captcha.jpg {
//тут либо пхп обработчик либо реврайт
rewrite ^/captcha.jpg /controller/common.php last;
}
$fp = @fsockopen("tcp://".$host, 80, $errno, $errstr, 10);
if (!$fp)
{
die($errstr.':'.$errno);
}
else
{
$out = "GET $path HTTP/1.0\r\n";
$out .= "Host: $host\r\n";
//авторизируемся
$out .= "Authorization: Basic " . base64_encode("$user:$password") . "\r\n";
$out .= "Connection: Close\r\n\r\n";
//посылаем данные
fwrite($fp, $out.$data);
$headers='';
//читаем заголовки
while ($str = trim(fgets($fp, 10000)))
$headers .= "$str\n";
$body='';
//читаем ответ
while (!feof($fp))
$body.= fgets($fp, 10000);
//закрываем сокет
fclose($fp);
}
$dbh = new PDO("mysql:host=$dbhost;dbname=newdb", $user, $password);
<?php
include 'phpQuery.php';
$html = file_get_contents('http://demo.phpost.net/posts/arte/57/qsdfgh.html');
phpQuery::newDocumentHTML($html, $charset = 'utf-8');
$result = array();
$result['title'] = pq('div.post-title')->find('h1')->text();
$result['img'] = array();
foreach (pq('div.post-contenido')->find('img') as $img) {
$result['img'][] = pq($img)->attr('src');
}
$result['tags'] = array();
foreach (pq('div.tags-block')->find('a[rel=tag]') as $a) {
$result['tags'][] = pq($a)->text();
}
print_r($result);
Array
(
[title] => qsdfgh
[img] => Array
(
[0] => http://i.i.imgur.com/HRrtdzw.gif
)
[tags] => Array
(
[0] => gol
[1] => hgg
[2] => ghf
[3] => hjj
)
)