Skip to content

Commit 1b39855

Browse files
committed
config init
1 parent 6f9190b commit 1b39855

File tree

2 files changed

+33
-28
lines changed

2 files changed

+33
-28
lines changed

config.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?php
2+
define('USERNAME', '');
3+
define('PASSWORD', '');
4+
define('THEME_URL', '');
5+
define('AUTH_URL', '');

index.php

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,43 @@
11
<?php
2+
include_once 'config.php';
23
include_once 'simple_html_dom.php';
34

4-
$curl = curl_init('http://forumodua.com/');
5+
if(!AUTH_URL){
6+
$curl = curl_init('http://forumodua.com/');
57

6-
curl_setopt($curl, CURLOPT_FRESH_CONNECT, true);
7-
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
8-
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');
9-
curl_setopt($curl, CURLOPT_HTTPHEADER, [
10-
"Content-Type: text/xml; charset=utf-8",
11-
"Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
12-
"Accept-Language: ru-RU,ru;q=0.9,en-US;q=0.8,en;q=0.7,uk;q=0.6"
13-
]);
8+
curl_setopt($curl, CURLOPT_FRESH_CONNECT, true);
9+
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
10+
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');
1411

15-
$result = curl_exec($curl);
12+
$result = curl_exec($curl);
1613

17-
curl_close($curl);
14+
curl_close($curl);
1815

19-
$html = str_get_html($result);
16+
$html = str_get_html($result);
2017

21-
/** @var simple_html_dom_node $form */
22-
$form = $html->find('#navbar_loginform', 0);
23-
$action = $form->attr['action'];
18+
/** @var simple_html_dom_node $form */
19+
$form = $html->find('#navbar_loginform', 0);
20+
$authAction = 'http://forumodua.com/'.$form->attr['action'];
21+
} else{
22+
$authAction = AUTH_URL;
23+
}
2424

25-
$curl = curl_init('http://forumodua.com/'.$action);
25+
$curl = curl_init($authAction);
26+
curl_setopt($curl, CURLOPT_FRESH_CONNECT, true);
2627
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
2728
curl_setopt($curl, CURLOPT_COOKIESESSION, false);
2829
curl_setopt($curl, CURLOPT_POST, true);
2930
curl_setopt($curl, CURLOPT_HEADER, true);
3031
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'),
32+
'vb_login_username' => USERNAME,
33+
'vb_login_md5password' => md5(PASSWORD),
34+
'vb_login_md5password_utf' => md5(PASSWORD),
3435
'securitytoken' => 'guest',
3536
'cookieuser' => 1,
3637
'do' => 'login',
3738
'vb_login_password' => ''
3839
]);
3940
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-
]);
4541

4642
$result = curl_exec($curl);
4743

@@ -53,7 +49,11 @@
5349
$cookies .= $cookies ? '; '.$item : $item;
5450
}
5551

56-
curl_setopt($curl, CURLOPT_URL, 'http://forumodua.com/showthread.php?t=851487');
52+
if(!THEME_URL){
53+
throw new Error('Theme URL is empty');
54+
}
55+
56+
curl_setopt($curl, CURLOPT_URL, THEME_URL);
5757
curl_setopt($curl, CURLOPT_HTTPGET, true);
5858
curl_setopt($curl, CURLOPT_COOKIESESSION, false);
5959
curl_setopt($curl, CURLOPT_COOKIE, $cookies);
@@ -82,16 +82,16 @@
8282
}
8383

8484
$postDate = $message->find('.postdate', 0);
85-
$date = $postDate->find('.date', 0)->text();
86-
$clearDate = preg_replace('/[ &nbsp;\.:]+/', '-', trim($date));
85+
$date = preg_replace('/[&nbsp;]+/', ' ', trim($postDate->find('.date', 0)->text()));
86+
$clearDate = preg_replace('/[ \.:]+/', '-', trim($date));
8787

8888
$fileName = $theme.'-'.$clearDate.'.txt';
8989

9090
$messageTitle = $message->find('h2.title', 0) ? $message->find('h2.title', 0)->text() : '';
9191
$messageAuthor = $message->find('.userinfo', 0)->find('.username', 0)->text();
9292
$messageText = $message->find('.postbody', 0)->find('blockquote.postcontent', 0)->text();
9393

94-
$fileContent = $messageTitle.PHP_EOL.$messageAuthor.PHP_EOL.$messageText;
94+
$fileContent = trim($messageTitle).PHP_EOL.$messageAuthor.PHP_EOL.$date.PHP_EOL.trim($messageText);
9595

9696
file_put_contents($folder.DIRECTORY_SEPARATOR.$fileName, $fileContent);
9797
}

0 commit comments

Comments
 (0)