Skip to content

Commit 6f9190b

Browse files
committed
add authorisation
1 parent 4d2f5b7 commit 6f9190b

File tree

2 files changed

+51
-2
lines changed

2 files changed

+51
-2
lines changed

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
In this branch only parser
1+
#v0.1
2+
Create simple parser
3+
#v0.2
4+
Create authorisation

index.php

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
include_once 'simple_html_dom.php';
33

4-
$curl = curl_init('http://forumodua.com/showthread.php?t=851487');
4+
$curl = curl_init('http://forumodua.com/');
55

66
curl_setopt($curl, CURLOPT_FRESH_CONNECT, true);
77
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
@@ -18,6 +18,52 @@
1818

1919
$html = str_get_html($result);
2020

21+
/** @var simple_html_dom_node $form */
22+
$form = $html->find('#navbar_loginform', 0);
23+
$action = $form->attr['action'];
24+
25+
$curl = curl_init('http://forumodua.com/'.$action);
26+
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
27+
curl_setopt($curl, CURLOPT_COOKIESESSION, false);
28+
curl_setopt($curl, CURLOPT_POST, true);
29+
curl_setopt($curl, CURLOPT_HEADER, true);
30+
curl_setopt($curl, CURLOPT_POSTFIELDS, [
31+
'vb_login_username' => 'K@R@NTiN',
32+
'vb_login_md5password' => md5('100891'),
33+
'vb_login_md5password_utf' => md5('100891'),
34+
'securitytoken' => 'guest',
35+
'cookieuser' => 1,
36+
'do' => 'login',
37+
'vb_login_password' => ''
38+
]);
39+
curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36');
40+
curl_setopt($curl, CURLOPT_HTTPHEADER, [
41+
"Content-Type: text/xml; charset=utf-8",
42+
"Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
43+
"Accept-Language: ru-RU,ru;q=0.9,en-US;q=0.8,en;q=0.7,uk;q=0.6"
44+
]);
45+
46+
$result = curl_exec($curl);
47+
48+
preg_match_all('/Set-Cookie:\s*([^;]*)/', $result, $matches);
49+
50+
$cookies = '';
51+
52+
foreach($matches[1] as $item) {
53+
$cookies .= $cookies ? '; '.$item : $item;
54+
}
55+
56+
curl_setopt($curl, CURLOPT_URL, 'http://forumodua.com/showthread.php?t=851487');
57+
curl_setopt($curl, CURLOPT_HTTPGET, true);
58+
curl_setopt($curl, CURLOPT_COOKIESESSION, false);
59+
curl_setopt($curl, CURLOPT_COOKIE, $cookies);
60+
61+
$result = curl_exec($curl);
62+
63+
curl_close($curl);
64+
65+
$html = str_get_html($result);
66+
2167
$messages = $html->find('.postbitlegacy');
2268
$theme = $html->find('title', 0)->text();
2369
$folder = __DIR__.DIRECTORY_SEPARATOR.'posts';

0 commit comments

Comments
 (0)