
Helg
+162
Репутация
478
Рейтинг
Кто знает, как вывести фото в виджете при выводе постов? А при отсутствии оного выводить заглушку.
Видимо такой функционал еще не заложен в систему. Хорошо бы его получить в следующем обновлении, если разработчики сочтут его нужным и найдут время для этого.До сих пор не могу вывести на главную виджетами "список контента" отдельные категории новостей: "политика", "экономика", "происшествия"
Система в целом. конечно получилась очень мощной, за что разработчикам отдельное спасибо за труд. Видно. что труд проделан не малый.
и как правильно его туда в писать?В .htaccess вписал
php_flag magic_quotes_gpc off
Пока настолько не разобрался. Может подскажите как и где ее отключить?отключите в настройках php директиву magic_quotes.
да хорошо бы чтоб такая возможность была в штатных средствах движка в доп настройках виджета например))
Чистая установка с обновлением 2.1 В редакторе при выставлении верхних кавычек "слово", сохраняет вот так \"слово\". Как это можно исправить?
Далее, в тексте новости загружаю картинку. После загрузки ее видно в редакторе нормально, но при сохранении новости картинка исчезает и выводит на ее место только пустое поле от картинки. Права стоят 777 на папку уплоад и вложенные в нее.
Далее, в тексте новости загружаю картинку. После загрузки ее видно в редакторе нормально, но при сохранении новости картинка исчезает и выводит на ее место только пустое поле от картинки. Права стоят 777 на папку уплоад и вложенные в нее.
Возник вопрос, как сформировать похожие записи в двушке и вывести их под текстом? Пробовал виджетом. но получается. что только новые вывожу.
Так это в первой ветке все просто, а на 2ке чет я так и не вкурю как это сдедать
Приветствую всех, вот решил покрутить двоечку, и встал вопрос, как перенести подпункты меню с основного пункта новости в основное меню, вместо пунктов блоги тп. В дакументации пока пробелы. Интуитивно не разобрался. Подскажите как?
Незнаю как на дальнем востоке, но в приморском крае стоит + 25на дальнем востоке морозы -15 как у нас в сибире -30, море всему виной. Может в крым рвануть, так экономическая зона будет.
Ага начнут с яндекса, а потом гугл отрубят, чтоб Обама нам лажу на уши не вешал)) Куда мир катится. А поводов найти всегда можно кучу. Мы же в России. Да и законов новых, уже на ворочали.
ППЦ!!! плин… Прикиньте вынудят яндекс отключить трансляцию сайтов Украины, или того хуже запретят ему транслировать на Россию все буржуйские сайты. И че делать то будем?? Станем вариться в собственном соку, в пределах границ России. Жесть
Меня вот больше интересует всплывающее окно при закрытии окна сайта, кода мыш наводится на крестик в браузере. Чтоб в нем были кнопки соц сетей. Как бы для принудительного расшаривания ресурса. Юзер нынче ленивый стал и ему пинок нужен дополнительный.
Наткнулся в инте на вот такой код автопостинга в ОД. Насколько его реально допилить до Icms? Может есть другие альтернативы у кого?
Ложу под спойлер ( режет код почему то)
Ложу под спойлер ( режет код почему то)
new OK([
'username' => 'логин',
'password' => 'пароль',
'path' => 'ссылка на группу',
'post_link' => 'ссылка которую нужно постить'
]);
Сам Класс :
class OK
{
public $username;
public $password;
public $path;
public $post_link;
public $browser = 'Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.154 Safari/537.36';
public $auth_hash;
public $cookie;
public $response;
private $__group_id;
private $__tkn;
private $__gwt;
private $path_info;
public function __construct($params)
{
foreach($params as $key => $value)
{
$this->$key = $value;
}
if(filter_var($this->path, FILTER_VALIDATE_URL, FILTER_FLAG_PATH_REQUIRED))
{
$path = parse_url($this->path);
$this->path = $path['path'];
}
$this->path = '/'. trim($this->path, '/');
if($this->test_auth())
{
$this->cookie = $this->auth_hash;
}
else
{
$this->cookie = $this->login();
}
if(!$this->cookie)
{
return $this->say('php.loginError');
}
$this->path_info = $this->path_info($this->path, $this->cookie);
if(!is_array($this->path_info))
{
if($this->path_info)
{
return $this->say($this->path_info);
}
else
{
if(isset($this->__group_id) and isset($this->__tkn) and isset($this->__gwt))
{
$this->join_group();
$this->path_info = $this->path_info($this->path, $this->cookie);
if(!is_array($this->path_info))
{
return $this->say('php.groupErrorAfterJoin');
}
}
else
{
return $this->say('php.groupError');
}
}
}
$post = $this->post();
if($post)
{
if($post === true)
{
return $this->say('posted');
}
else
{
return $this->say($post);
}
}
else
{
return $this->say('php.undefinedPostError');
}
}
private function say($response)
{
$this->response = $response;
}
private function join_group()
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_USERAGENT, $this->browser);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, '1=1');
curl_setopt($ch, CURLOPT_COOKIE, 'JSESSIONID='. $this->cookie);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('TKN: '. $this->__tkn));
curl_setopt($ch, CURLOPT_URL, 'http://www.odnoklassniki.ru'. $this->path. '?cmd=LeftColumnTopCardAltGroup&st.cmd=altGroupMain&st.directLink=on&st.groupId='. $this->__group_id. '&st.altGroup.action=groupJoin&st._aid=LBAID_UCM_AltGroupTopCardButtonsJoin_altGroupMain&gwt.requested='. $this->__gwt. '&p_sId=');
$response = curl_exec($ch);
curl_close($ch);
return;
}
private function link_preview()
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_USERAGENT, $this->browser);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, 'linkUrl='. $this->post_link. '&LinkPreviewId=5.linkPreview');
curl_setopt($ch, CURLOPT_COOKIE, 'JSESSIONID='. $this->cookie);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('TKN: '. $this->path_info['tkn']));
curl_setopt($ch, CURLOPT_URL, 'http://www.odnoklassniki.ru'. $this->path. '?cmd=LinkPreview&gwt.requested='. $this->path_info['gwt']. '&st.cmd=altGroupMain&st.directLink=on&st.groupId='. $this->path_info['group_id']);
$response = curl_exec($ch);
curl_close($ch);
preg_match('!style="display: none" class="data-with-image_i" src="([^"]*)"!', $response, $thumb);
preg_match('!,"7":"([^"]*)",!', $response, $title);
preg_match('!,"8":"([^"]*)",!', $response, $description);
preg_match('!,"11":"([^"]*)"!', $response, $url);
if(!$thumb[1] or !$title[1] or !$url[1])
{
return;
}
return '{"linkData":{"title":"'.$title[1].'", "description":"'.$description[1].'", "providerViewer":"1;1", "sourceUrl":"'.$url[1].'", "thumbnail":"'.$thumb[1].'", "movieId":0}}';
}
private function post()
{
$link_preview = $this->link_preview();
if(!$link_preview)
{
return 'php.noLinkPreview';
}
$form_data = '{"formType":"Group", "postDataList":['. $link_preview. '], "news":false, "toStatus":false}';
$ch = curl_init();
curl_setopt($ch, CURLOPT_USERAGENT, $this->browser);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, 'st.status.postpostForm='. $this->path_info['form_id'].
'&st.status.postgroupId='. $this->path_info['group_id'] .
'&postingFormData='. urlencode($form_data));
curl_setopt($ch, CURLOPT_COOKIE, 'JSESSIONID='. $this->cookie);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('TKN: '. $this->path_info['tkn']));
curl_setopt($ch, CURLOPT_URL, 'http://www.odnoklassniki.ru'. $this->path. '?cmd=MediaTopicPost&gwt.requested='. $this->path_info['gwt']. '&st.cmd=altGroupMain&st.directLink=on&st.groupId='. $this->path_info['group_id']. '&p_sId=');
$response = curl_exec($ch);
curl_close($ch);
if(empty($response))
{
return false;
}
if(strpos($response, '"status":"ok"') !== false)
{
return true;
}
preg_match('!"errorCodeValue":"([^"]*)"!', $response, $error);
if($error[1])
{
return $error[1];
}
return false;
}
private function path_info($path, $cookie)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_USERAGENT, $this->browser);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, 'true=true');
curl_setopt($ch, CURLOPT_COOKIE, 'JSESSIONID='. $cookie);
curl_setopt($ch, CURLOPT_URL, 'http://www.odnoklassniki.ru'. $path);
$response = curl_exec($ch);
curl_close($ch);
if(strpos($response, 'HTTP/1.1 404 ') !== false)
{
return 'php.groupRemoved';
}
if(strpos($response, 'Location: www.odnoklassniki.ru/dk?st.cmd=altGroupRestricted') !== false)
{
return 'php.userBlocked';
}
preg_match('!state:"st\.cmd=altGroupMain&st\.groupId=([^"]*)"!', $response, $group_id);
preg_match('!,"s2":"([^"]*)",!', $response, $form_id);
preg_match('!TKN: (.*?)$!m', $response, $tkn);
preg_match('!,gwtHash:"([^"]*)",!', $response, $gwt);
preg_match('!<\!--{"gId":"([^"]*)",!', $response, $id);
if(!$group_id[1] or !$tkn[1] or !$gwt[1] or empty($group_id[1]) or empty($tkn[1]) or empty($gwt[1]))
{
return false;
}
$this->__gwt = $gwt[1];
$this->__tkn = $tkn[1];
$this->__group_id = $group_id[1];
if(!$form_id[1] or empty($form_id[1]) or !$id[1] or empty($id[1]))
{
return false;
}
return array('group_id' => $group_id[1], 'form_id' => $form_id[1], 'tkn' => $tkn[1], 'gwt' => $gwt[1], 'id' => $id[1]);
}
private function login()
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_USERAGENT, $this->browser);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, 'st.email='.urlencode($this->username).'&st.password='.urlencode($this->password).'&st.redirect=/ok&st.posted=set&st.screenSize=&st.screenSize=&st.browserSize=&st.flashVer');
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, 'http://www.odnoklassniki.ru/dk?cmd=AnonymLogin&st.cmd=anonymLogin&tkn='.mt_rand());
$response = curl_exec($ch);
curl_close($ch);
if(!preg_match('!Location: www.odnoklassniki.ru/ok!', $response))
{
return false;
}
preg_match('!JSESSIONID=([^;]*);!', $response, $cookie);
if(!$cookie[1] or empty($cookie[1]))
{
return false;
}
return $cookie[1];
}
private function test_auth()
{
if(!$this->auth_hash)
{
return false;
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.154 Safari/537.36');
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_COOKIE, 'JSESSIONID='. $this->auth_hash);
curl_setopt($ch, CURLOPT_URL, 'http://ok.ru/settings');
$response = curl_exec($ch);
curl_close($ch);
if(strpos($response, 'HTTP/1.1 302') !== false)
{
return false;
}
return true;
}
static function auth($username, $password)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.154 Safari/537.36');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, 'st.email='.urlencode($username).'&st.password='.urlencode($password).'&st.redirect=/ok&st.posted=set&st.screenSize=&st.screenSize=&st.browserSize=&st.flashVer');
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, 'http://www.odnoklassniki.ru/dk?cmd=AnonymLogin&st.cmd=anonymLogin&tkn='.mt_rand());
$response = curl_exec($ch);
curl_close($ch);
if(!preg_match('!Location: www.odnoklassniki.ru/ok!', $response))
{
return false;
}
preg_match('!JSESSIONID=([^;]*);!', $response, $cookie);
if(!$cookie[1] or empty($cookie[1]))
{
return false;
}
return $cookie[1];
}
}
'username' => 'логин',
'password' => 'пароль',
'path' => 'ссылка на группу',
'post_link' => 'ссылка которую нужно постить'
]);
Сам Класс :
class OK
{
public $username;
public $password;
public $path;
public $post_link;
public $browser = 'Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.154 Safari/537.36';
public $auth_hash;
public $cookie;
public $response;
private $__group_id;
private $__tkn;
private $__gwt;
private $path_info;
public function __construct($params)
{
foreach($params as $key => $value)
{
$this->$key = $value;
}
if(filter_var($this->path, FILTER_VALIDATE_URL, FILTER_FLAG_PATH_REQUIRED))
{
$path = parse_url($this->path);
$this->path = $path['path'];
}
$this->path = '/'. trim($this->path, '/');
if($this->test_auth())
{
$this->cookie = $this->auth_hash;
}
else
{
$this->cookie = $this->login();
}
if(!$this->cookie)
{
return $this->say('php.loginError');
}
$this->path_info = $this->path_info($this->path, $this->cookie);
if(!is_array($this->path_info))
{
if($this->path_info)
{
return $this->say($this->path_info);
}
else
{
if(isset($this->__group_id) and isset($this->__tkn) and isset($this->__gwt))
{
$this->join_group();
$this->path_info = $this->path_info($this->path, $this->cookie);
if(!is_array($this->path_info))
{
return $this->say('php.groupErrorAfterJoin');
}
}
else
{
return $this->say('php.groupError');
}
}
}
$post = $this->post();
if($post)
{
if($post === true)
{
return $this->say('posted');
}
else
{
return $this->say($post);
}
}
else
{
return $this->say('php.undefinedPostError');
}
}
private function say($response)
{
$this->response = $response;
}
private function join_group()
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_USERAGENT, $this->browser);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, '1=1');
curl_setopt($ch, CURLOPT_COOKIE, 'JSESSIONID='. $this->cookie);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('TKN: '. $this->__tkn));
curl_setopt($ch, CURLOPT_URL, 'http://www.odnoklassniki.ru'. $this->path. '?cmd=LeftColumnTopCardAltGroup&st.cmd=altGroupMain&st.directLink=on&st.groupId='. $this->__group_id. '&st.altGroup.action=groupJoin&st._aid=LBAID_UCM_AltGroupTopCardButtonsJoin_altGroupMain&gwt.requested='. $this->__gwt. '&p_sId=');
$response = curl_exec($ch);
curl_close($ch);
return;
}
private function link_preview()
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_USERAGENT, $this->browser);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, 'linkUrl='. $this->post_link. '&LinkPreviewId=5.linkPreview');
curl_setopt($ch, CURLOPT_COOKIE, 'JSESSIONID='. $this->cookie);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('TKN: '. $this->path_info['tkn']));
curl_setopt($ch, CURLOPT_URL, 'http://www.odnoklassniki.ru'. $this->path. '?cmd=LinkPreview&gwt.requested='. $this->path_info['gwt']. '&st.cmd=altGroupMain&st.directLink=on&st.groupId='. $this->path_info['group_id']);
$response = curl_exec($ch);
curl_close($ch);
preg_match('!style="display: none" class="data-with-image_i" src="([^"]*)"!', $response, $thumb);
preg_match('!,"7":"([^"]*)",!', $response, $title);
preg_match('!,"8":"([^"]*)",!', $response, $description);
preg_match('!,"11":"([^"]*)"!', $response, $url);
if(!$thumb[1] or !$title[1] or !$url[1])
{
return;
}
return '{"linkData":{"title":"'.$title[1].'", "description":"'.$description[1].'", "providerViewer":"1;1", "sourceUrl":"'.$url[1].'", "thumbnail":"'.$thumb[1].'", "movieId":0}}';
}
private function post()
{
$link_preview = $this->link_preview();
if(!$link_preview)
{
return 'php.noLinkPreview';
}
$form_data = '{"formType":"Group", "postDataList":['. $link_preview. '], "news":false, "toStatus":false}';
$ch = curl_init();
curl_setopt($ch, CURLOPT_USERAGENT, $this->browser);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, 'st.status.postpostForm='. $this->path_info['form_id'].
'&st.status.postgroupId='. $this->path_info['group_id'] .
'&postingFormData='. urlencode($form_data));
curl_setopt($ch, CURLOPT_COOKIE, 'JSESSIONID='. $this->cookie);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('TKN: '. $this->path_info['tkn']));
curl_setopt($ch, CURLOPT_URL, 'http://www.odnoklassniki.ru'. $this->path. '?cmd=MediaTopicPost&gwt.requested='. $this->path_info['gwt']. '&st.cmd=altGroupMain&st.directLink=on&st.groupId='. $this->path_info['group_id']. '&p_sId=');
$response = curl_exec($ch);
curl_close($ch);
if(empty($response))
{
return false;
}
if(strpos($response, '"status":"ok"') !== false)
{
return true;
}
preg_match('!"errorCodeValue":"([^"]*)"!', $response, $error);
if($error[1])
{
return $error[1];
}
return false;
}
private function path_info($path, $cookie)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_USERAGENT, $this->browser);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, 'true=true');
curl_setopt($ch, CURLOPT_COOKIE, 'JSESSIONID='. $cookie);
curl_setopt($ch, CURLOPT_URL, 'http://www.odnoklassniki.ru'. $path);
$response = curl_exec($ch);
curl_close($ch);
if(strpos($response, 'HTTP/1.1 404 ') !== false)
{
return 'php.groupRemoved';
}
if(strpos($response, 'Location: www.odnoklassniki.ru/dk?st.cmd=altGroupRestricted') !== false)
{
return 'php.userBlocked';
}
preg_match('!state:"st\.cmd=altGroupMain&st\.groupId=([^"]*)"!', $response, $group_id);
preg_match('!,"s2":"([^"]*)",!', $response, $form_id);
preg_match('!TKN: (.*?)$!m', $response, $tkn);
preg_match('!,gwtHash:"([^"]*)",!', $response, $gwt);
preg_match('!<\!--{"gId":"([^"]*)",!', $response, $id);
if(!$group_id[1] or !$tkn[1] or !$gwt[1] or empty($group_id[1]) or empty($tkn[1]) or empty($gwt[1]))
{
return false;
}
$this->__gwt = $gwt[1];
$this->__tkn = $tkn[1];
$this->__group_id = $group_id[1];
if(!$form_id[1] or empty($form_id[1]) or !$id[1] or empty($id[1]))
{
return false;
}
return array('group_id' => $group_id[1], 'form_id' => $form_id[1], 'tkn' => $tkn[1], 'gwt' => $gwt[1], 'id' => $id[1]);
}
private function login()
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_USERAGENT, $this->browser);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, 'st.email='.urlencode($this->username).'&st.password='.urlencode($this->password).'&st.redirect=/ok&st.posted=set&st.screenSize=&st.screenSize=&st.browserSize=&st.flashVer');
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, 'http://www.odnoklassniki.ru/dk?cmd=AnonymLogin&st.cmd=anonymLogin&tkn='.mt_rand());
$response = curl_exec($ch);
curl_close($ch);
if(!preg_match('!Location: www.odnoklassniki.ru/ok!', $response))
{
return false;
}
preg_match('!JSESSIONID=([^;]*);!', $response, $cookie);
if(!$cookie[1] or empty($cookie[1]))
{
return false;
}
return $cookie[1];
}
private function test_auth()
{
if(!$this->auth_hash)
{
return false;
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.154 Safari/537.36');
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_COOKIE, 'JSESSIONID='. $this->auth_hash);
curl_setopt($ch, CURLOPT_URL, 'http://ok.ru/settings');
$response = curl_exec($ch);
curl_close($ch);
if(strpos($response, 'HTTP/1.1 302') !== false)
{
return false;
}
return true;
}
static function auth($username, $password)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.154 Safari/537.36');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, 'st.email='.urlencode($username).'&st.password='.urlencode($password).'&st.redirect=/ok&st.posted=set&st.screenSize=&st.screenSize=&st.browserSize=&st.flashVer');
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, 'http://www.odnoklassniki.ru/dk?cmd=AnonymLogin&st.cmd=anonymLogin&tkn='.mt_rand());
$response = curl_exec($ch);
curl_close($ch);
if(!preg_match('!Location: www.odnoklassniki.ru/ok!', $response))
{
return false;
}
preg_match('!JSESSIONID=([^;]*);!', $response, $cookie);
if(!$cookie[1] or empty($cookie[1]))
{
return false;
}
return $cookie[1];
}
}
+10