-
Notifications
You must be signed in to change notification settings - Fork 0
/
api.php
68 lines (57 loc) · 1.78 KB
/
api.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
63
64
65
66
67
68
<?php
if (!defined('PHORUM')) return;
/**
* Load the configuration of all available authentication providers.
*
* @return array
* An array, containing a list of providers. Each provider in the
* list is an array, containing the data from the provider's
* config.ini file.
*/
function mod_social_authentication_list_providers()
{
$providers = array();
$dir = dirname(__FILE__) . '/providers';
$dh = opendir($dir);
if (!$dh) trigger_error("Cannot open directory: $dir", E_USER_ERROR);
while ($entry = readdir($dh))
{
if ($entry[0] == '.' || $entry == 'TEMPLATE') continue;
if (!file_exists("$dir/$entry/config.ini") ||
!file_exists("$dir/$entry/button.png")) {
phorum_admin_error(
"Provider '" . htmlspecialchars($entry) . "' does not " .
"contain both the files config.ini and button.png"
);
continue;
}
$providers[$entry] = parse_ini_file("$dir/$entry/config.ini", TRUE);
$providers[$entry]['id'] = $entry;
}
uasort($providers, 'mod_social_authentication_cmp_providers');
return $providers;
}
function mod_social_authentication_cmp_providers($a, $b)
{
$name_a = strtolower($a['provider']['name']);
$name_b = strtolower($b['provider']['name']);
return strcmp($name_a, $name_b);
}
/**
* Load the configuration for an authentication provider.
*
* @param string $id
* @return array
*/
function mod_social_authentication_get_provider($id)
{
$id = basename($id);
$file = dirname(__FILE__) . '/providers/' . $id . '/config.ini';
if (file_exists($file)) {
$config = parse_ini_file($file, TRUE);
} else {
trigger_error("Illegal provider requested: $id", E_USER_ERROR);
}
return $config;
}
?>