-
Notifications
You must be signed in to change notification settings - Fork 1
/
handle-admin-findsite.php
62 lines (50 loc) · 2.33 KB
/
handle-admin-findsite.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php
try {
require_once('Sprinkles.php');
$sprink = new Sprinkles();
$company_sfnid = request_param('company_sfnid');
$oauth_consumer_key = request_param('oauth_consumer_key');
$oauth_consumer_secret = request_param('oauth_consumer_secret');
$sprinkles_root_url = request_param('sprinkles_root_url');
if (!$oauth_consumer_key || !$oauth_consumer_secret) {
redirect('admin-findsite.php?msg=missing_oauth' .
'&company_sfnid=' . $company_sfnid .
'&oauth_consumer_key=' . $oauth_consumer_key .
'&oauth_consumer_secret=' . $oauth_consumer_secret .
'&sprinkles_root_url=' . $sprinkles_root_url);
exit();
}
if (!$sprinkles_root_url) {
redirect('admin-findsite.php?msg=missing_sprinkles_root_url' .
'&company_sfnid=' . $company_sfnid .
'&oauth_consumer_key=' . $oauth_consumer_key .
'&oauth_consumer_secret=' . $oauth_consumer_secret .
'&sprinkles_root_url=' . $sprinkles_root_url);
exit();
}
if (!$company_sfnid) {
redirect('admin-findsite.php?msg=missing_company_sfnid' .
'&company_sfnid=' . $company_sfnid .
'&oauth_consumer_key=' . $oauth_consumer_key .
'&oauth_consumer_secret=' . $oauth_consumer_secret .
'&sprinkles_root_url=' . $sprinkles_root_url);
exit();
}
$sprinkles_root_url = preg_replace('|[^/]*.php$|', '', $sprinkles_root_url);
# Note: the naive regex you'd usee below doesn't work; pcre is not in fact
# Perl-compatible in this case
$sprinkles_root_url = preg_replace('|([^/])/*$|', '\1/', $sprinkles_root_url);
$result = $sprink->set_site_settings(
array('company_id' => $company_sfnid,
'oauth_consumer_key' => $oauth_consumer_key,
'oauth_consumer_secret' => $oauth_consumer_secret,
'sprinkles_root_url' => $sprinkles_root_url));
if (!$result) die (mysql_error());
message($sprink->site_configured());
redirect($sprink->authorize_url('admin.php?hooked=true', true));
exit(0);
} catch (Exception $e) {
error_log("Exception thrown while preparing page: " . $e->getMessage());
$smarty->display('error.t');
}
?>