source: extensions/oAuth/admin/providers.php @ 21584

Last change on this file since 21584 was 21584, checked in by mistic100, 12 years ago

don't delete keys when the provider is removed, hide fieldset when no provider active, use jQuery instead of $

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