1 | <?php |
---|
2 | defined('OAUTH_PATH') or die('Hacking attempt!'); |
---|
3 | |
---|
4 | load_language('help.lang', OAUTH_PATH); |
---|
5 | |
---|
6 | $PROVIDERS_CONFIG = include(OAUTH_PATH . 'include/providers_stats.inc.php'); |
---|
7 | |
---|
8 | if (isset($_POST['save_config'])) |
---|
9 | { |
---|
10 | $providers = array(); |
---|
11 | foreach ($_POST['providers'] as $id => $data) |
---|
12 | { |
---|
13 | $error = false; |
---|
14 | $data['enabled'] = $data['enabled']=='true'; |
---|
15 | |
---|
16 | if ($PROVIDERS_CONFIG[$id]['new_app_link'] and $data['enabled']) |
---|
17 | { |
---|
18 | if (empty($data['keys']['secret']) or |
---|
19 | (@$PROVIDERS_CONFIG[$id]['require_client_id'] and empty($data['keys']['id'])) or |
---|
20 | (!@$PROVIDERS_CONFIG[$id]['require_client_id'] and empty($data['keys']['key'])) |
---|
21 | ) { |
---|
22 | array_push($page['errors'], sprintf(l10n('%s: invalid keys'), $PROVIDERS_CONFIG[$id]['provider_name'])); |
---|
23 | $error = true; |
---|
24 | } |
---|
25 | } |
---|
26 | else |
---|
27 | { |
---|
28 | unset($data['keys']); |
---|
29 | } |
---|
30 | |
---|
31 | if ( ($id=='Wordpress' or $id=='Flickr') and $data['enabled'] and !@$providers['OpenID']['enabled'] ) |
---|
32 | { |
---|
33 | array_push($page['errors'], sprintf(l10n('OpenID must be enabled in order to use %s authentication'), $id)); |
---|
34 | $error = true; |
---|
35 | } |
---|
36 | |
---|
37 | if (isset($PROVIDERS_CONFIG[$id]['scope'])) |
---|
38 | { |
---|
39 | $data['scope'] = $PROVIDERS_CONFIG[$id]['scope']; |
---|
40 | } |
---|
41 | |
---|
42 | if (is_array(@$data['keys'])) |
---|
43 | { |
---|
44 | $data['keys'] = array_map('trim', $data['keys']); |
---|
45 | } |
---|
46 | |
---|
47 | $data['name'] = $PROVIDERS_CONFIG[$id]['provider_name']; |
---|
48 | $providers[$id] = $data; |
---|
49 | } |
---|
50 | |
---|
51 | $hybridauth_conf['providers'] = $providers; |
---|
52 | |
---|
53 | if (!count($page['errors'])) |
---|
54 | { |
---|
55 | // generate config file |
---|
56 | $content = "<?php\ndefined('PHPWG_ROOT_PATH') or die('Hacking attempt!');\n\nreturn "; |
---|
57 | $content.= var_export(array('providers'=>$providers), true); |
---|
58 | $content.= ";\n?>"; |
---|
59 | |
---|
60 | file_put_contents(OAUTH_CONFIG, $content); |
---|
61 | array_push($page['infos'], l10n('Information data registered in database')); |
---|
62 | } |
---|
63 | } |
---|
64 | |
---|
65 | |
---|
66 | $template->assign(array( |
---|
67 | 'PROVIDERS' => $PROVIDERS_CONFIG, |
---|
68 | 'CONFIG' => $hybridauth_conf['providers'], |
---|
69 | 'SERVERNAME' => get_absolute_root_url(), |
---|
70 | 'OAUTH_CALLBACK' => OAUTH_PUBLIC . '?hauth.done=', |
---|
71 | )); |
---|
72 | |
---|
73 | // define template file |
---|
74 | $template->set_filename('oauth_content', realpath(OAUTH_PATH . 'admin/template/providers.tpl')); |
---|
75 | |
---|
76 | ?> |
---|