File tests/http.inc.php changed (mode: 100644) (index 625186d..c8410af) |
... |
... |
function do_req($url, &$data, &$headers) |
154 |
154 |
if ($x === 1) { |
if ($x === 1) { |
155 |
155 |
if (strncmp($url, "http://", 7) == 0) |
if (strncmp($url, "http://", 7) == 0) |
156 |
156 |
$url = substr($url, 7); |
$url = substr($url, 7); |
157 |
|
rg_log("redirect to url=$url"); |
|
158 |
157 |
$t = explode("/", $url, 2); |
$t = explode("/", $url, 2); |
159 |
158 |
$new = "http://" . $t[0] . trim($matches[1]); |
$new = "http://" . $t[0] . trim($matches[1]); |
160 |
|
//rg_log("Redirecting to $new..."); |
|
|
159 |
|
rg_log("Redirecting to $new..."); |
161 |
160 |
$data = array(); |
$data = array(); |
162 |
161 |
if (!empty($ret['sid'])) |
if (!empty($ret['sid'])) |
163 |
162 |
$headers = array("Cookie: sid=" . $ret['sid']); |
$headers = array("Cookie: sid=" . $ret['sid']); |
File tests/http_confirm.php added (mode: 100644) (index 0000000..d6c2705) |
|
1 |
|
<?php |
|
2 |
|
error_reporting(E_ALL | E_STRICT); |
|
3 |
|
ini_set("track_errors", "On"); |
|
4 |
|
|
|
5 |
|
$INC = dirname(__FILE__) . "/../inc"; |
|
6 |
|
require_once(dirname(__FILE__) . "/config.php"); |
|
7 |
|
require_once($INC . "/init.inc.php"); |
|
8 |
|
require_once($INC . "/util.inc.php"); |
|
9 |
|
require_once("http.inc.php"); |
|
10 |
|
|
|
11 |
|
rg_log_set_file("http_confirm.log"); |
|
12 |
|
|
|
13 |
|
$rg_sql = "host=localhost user=rocketgit dbname=rocketgit connect_timeout=10"; |
|
14 |
|
$rg_no_db = TRUE; |
|
15 |
|
require_once("common.php"); |
|
16 |
|
|
|
17 |
|
$_testns = 'http_confirm'; |
|
18 |
|
$rg_cache_enable = TRUE; |
|
19 |
|
$rg_cache_debug = TRUE; |
|
20 |
|
$rg_event_socket = "/var/lib/rocketgit/sockets/event.sock"; |
|
21 |
|
|
|
22 |
|
$uniq = rg_id(10); |
|
23 |
|
|
|
24 |
|
rg_log_enter('Loading confirmation form...'); |
|
25 |
|
// First we need to load the form so we can get the token |
|
26 |
|
$r = do_req($test_url . "/op/create_account", $data, $headers); |
|
27 |
|
if ($r === FALSE) { |
|
28 |
|
rg_log("Cannot load create_account page!"); |
|
29 |
|
exit(1); |
|
30 |
|
} |
|
31 |
|
$good_sid = $r['sid']; |
|
32 |
|
$good_token = $r['tokens']['user_edit_hl']; |
|
33 |
|
rg_log_exit(); |
|
34 |
|
|
|
35 |
|
|
|
36 |
|
rg_log_enter('Adding an account...'); |
|
37 |
|
$data['token'] = $r['tokens']['user_edit_hl']; |
|
38 |
|
$data['username'] = 'http_confirm-' . time(); |
|
39 |
|
$data['email'] = 'http_confirm-' . $uniq . '@a.b'; |
|
40 |
|
$data['pass'] = $uniq; |
|
41 |
|
$data['pass2'] = $uniq; |
|
42 |
|
$data['plan_id'] = 0; |
|
43 |
|
$data['tos'] = 1; |
|
44 |
|
$data['force_confirm'] = 1; |
|
45 |
|
$data['doit'] = 1; |
|
46 |
|
$headers = array("Cookie: sid=" . $good_sid); |
|
47 |
|
$r = do_req($test_url . '/op/create_account?t=create_account', $data, $headers); |
|
48 |
|
if (!strstr($r['body'], 'Your account has been successfully created')) { |
|
49 |
|
rg_log_ml('body: ' . print_r($r['body'], TRUE)); |
|
50 |
|
rg_log('Cannot create account!'); |
|
51 |
|
exit(1); |
|
52 |
|
} |
|
53 |
|
rg_log_exit(); |
|
54 |
|
|
|
55 |
|
|
|
56 |
|
rg_log_enter('Finding uid...'); |
|
57 |
|
$sql = 'SELECT uid FROM users WHERE username = \'' . $data['username'] . '\''; |
|
58 |
|
$res = rg_sql_query($db, $sql); |
|
59 |
|
if ($res === FALSE) { |
|
60 |
|
rg_log('Query error!'); |
|
61 |
|
exit(1); |
|
62 |
|
} |
|
63 |
|
$row = rg_sql_fetch_array($res); |
|
64 |
|
rg_sql_free_result($res); |
|
65 |
|
$uid = $row['uid']; |
|
66 |
|
rg_log_exit(); |
|
67 |
|
|
|
68 |
|
|
|
69 |
|
rg_log_enter('Finding confirmation link...'); |
|
70 |
|
$key = 'DEBUG::' . $uid . '::mail'; |
|
71 |
|
$tries = 10; |
|
72 |
|
while ($tries) { |
|
73 |
|
$c = rg_cache_get($key); |
|
74 |
|
if ($c !== FALSE) |
|
75 |
|
break; |
|
76 |
|
|
|
77 |
|
$tries--; |
|
78 |
|
sleep(1); |
|
79 |
|
} |
|
80 |
|
rg_log_ml('c: ' . print_r($c, TRUE)); |
|
81 |
|
$t = explode('below:', $c['body']); |
|
82 |
|
$t = ltrim($t[1]); |
|
83 |
|
$t = explode("\n", $t); |
|
84 |
|
$link = $t[0]; |
|
85 |
|
rg_log('Link=' . $link); |
|
86 |
|
rg_log_exit(); |
|
87 |
|
|
|
88 |
|
|
|
89 |
|
rg_log_enter('Trying with the wrong link...'); |
|
90 |
|
$data = array(); $headers = array(); |
|
91 |
|
$r = do_req($link . 'XXX?rg_debug=1&t=http_confirm', $data, $headers); |
|
92 |
|
if (!strstr($r['body'], 'Invalid token')) { |
|
93 |
|
rg_log_ml('r: ' . print_r($r, TRUE)); |
|
94 |
|
rg_log('Somethign wrong with the token!'); |
|
95 |
|
exit(1); |
|
96 |
|
} |
|
97 |
|
rg_log_exit(); |
|
98 |
|
|
|
99 |
|
|
|
100 |
|
rg_log_enter('Trying with the good link...'); |
|
101 |
|
$r = do_req($link . '?rg_debug=1&t=http_confirm', $data, $headers); |
|
102 |
|
if (!strstr($r['body'], 'Home page of user')) { |
|
103 |
|
rg_log_ml('r: ' . print_r($r, TRUE)); |
|
104 |
|
rg_log('Somethign wrong with the token!'); |
|
105 |
|
exit(1); |
|
106 |
|
} |
|
107 |
|
rg_log_exit(); |
|
108 |
|
|
|
109 |
|
|
|
110 |
|
rg_log('OK!'); |
|
111 |
|
?> |
File tests/http_top.php changed (mode: 100644) (index b2cd64e..3a01417) |
... |
... |
$rg_cache_enable = TRUE; |
22 |
22 |
|
|
23 |
23 |
$now = time(); |
$now = time(); |
24 |
24 |
|
|
25 |
|
// TODO: donate has some problems with input + border! |
|
|
25 |
|
// TODO: donate has some problems with input + border (tidy)! |
26 |
26 |
$_list = array("features", "discover", "download", "pricing", "tos", |
$_list = array("features", "discover", "download", "pricing", "tos", |
27 |
27 |
"create_account", "login"); |
"create_account", "login"); |
28 |
28 |
foreach ($_list as $op) { |
foreach ($_list as $op) { |