mirror of
https://github.com/easy-wi/developer.git
synced 2025-02-20 11:23:28 +08:00
#1 Social Auth with hybridauth.sourceforge.net
This commit is contained in:
parent
b8be8986a5
commit
9cf71b9cca
@ -38,8 +38,15 @@ https://github.com/PHPMailer/PHPMailer
|
||||
GNU Lesser General Public License (LGPL), Version 2.1
|
||||
http://www.gnu.org/licenses/lgpl-2.1.html
|
||||
|
||||
* HybridAuth
|
||||
http://hybridauth.sourceforge.net/
|
||||
GNU GENERAL PUBLIC LICENSE Version 3
|
||||
https://www.gnu.org/licenses/gpl.html
|
||||
Released under the MIT license
|
||||
http://opensource.org/licenses/MIT
|
||||
|
||||
Used but included with CDN servers:
|
||||
|
||||
Used but included with CDN servers:
|
||||
|
||||
* Bootstrap v2.3.2
|
||||
http://getbootstrap.com/2.3.2/
|
||||
|
50
web/css/default/social_buttons.css
Normal file
50
web/css/default/social_buttons.css
Normal file
@ -0,0 +1,50 @@
|
||||
.btn-social{position:relative;padding-left:44px;text-align:left;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.btn-social :first-child{position:absolute;left:0;top:0;bottom:0;width:32px;line-height:34px;font-size:1.6em;text-align:center;border-right:1px solid rgba(0,0,0,0.2)}
|
||||
|
||||
.btn-facebook.active {color: rgba(255,255,255,0.75);}
|
||||
.btn-facebook {color: #ffffff;text-shadow: 0 -1px 0 rgba(0,0,0,0.25);background-color: #4262a5;background-image: -moz-linear-gradient(top,#3b5998,#4c70ba);background-image: -webkit-gradient(linear,0 0,0 100%,from(#3b5998),to(#4c70ba));background-image: -webkit-linear-gradient(top,#3b5998,#4c70ba);background-image: -o-linear-gradient(top,#3b5998,#4c70ba);background-image: linear-gradient(to bottom,#3b5998,#4c70ba);background-repeat: repeat-x;filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff3b5998',endColorstr='#ff4c70ba',GradientType=0);border-color: #4c70ba #4c70ba #344e86;border-color: rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);*background-color: #4c70ba;filter: progid:DXImageTransform.Microsoft.gradient(enabled = false);}
|
||||
.btn-facebook:hover,.btn-facebook:focus,.btn-facebook:active,.btn-facebook.active,.btn-facebook.disabled,.btn-facebook[disabled] {color: #ffffff;background-color: #4c70ba;*background-color: #4264aa;}
|
||||
.btn-facebook:active,.btn-facebook.active {background-color: #3b5998 ;}
|
||||
.btn-github.active {color: rgba(255,255,255,0.75);}
|
||||
.btn-github {color: #ffffff;text-shadow: 0 -1px 0 rgba(0,0,0,0.25);background-color: #78cb54;background-image: -moz-linear-gradient(top,#6cc644,#8bd26b);background-image: -webkit-gradient(linear,0 0,0 100%,from(#6cc644),to(#8bd26b));background-image: -webkit-linear-gradient(top,#6cc644,#8bd26b);background-image: -o-linear-gradient(top,#6cc644,#8bd26b);background-image: linear-gradient(to bottom,#6cc644,#8bd26b);background-repeat: repeat-x;filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff6cc644',endColorstr='#ff8bd26b',GradientType=0);border-color: #8bd26b #8bd26b #60b838;border-color: rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);*background-color: #8bd26b;filter: progid:DXImageTransform.Microsoft.gradient(enabled = false);}
|
||||
.btn-github:hover,.btn-github:focus,.btn-github:active,.btn-github.active,.btn-github.disabled,.btn-github[disabled] {color: #ffffff;background-color: #8bd26b;*background-color: #7bcc58;}
|
||||
.btn-github:active,.btn-github.active {background-color: #6cc644;}
|
||||
.btn-google.active {color: rgba(255,255,255,0.75);}
|
||||
.btn-google {color: #ffffff;text-shadow: 0 -1px 0 rgba(0,0,0,0.25);background-color: #e05b4a;background-image: -moz-linear-gradient(top,#dd4b39,#e47365);background-image: -webkit-gradient(linear,0 0,0 100%,from(#dd4b39),to(#e47365));background-image: -webkit-linear-gradient(top,#dd4b39,#e47365);background-image: -o-linear-gradient(top,#dd4b39,#e47365);background-image: linear-gradient(to bottom,#dd4b39,#e47365);background-repeat: repeat-x;filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffdd4b39',endColorstr='#ffe47365',GradientType=0);border-color: #e47365 #e47365 #d73925;border-color: rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);*background-color: #e47365;filter: progid:DXImageTransform.Microsoft.gradient(enabled = false);}
|
||||
.btn-google:hover,.btn-google:focus,.btn-google:active,.btn-google.active,.btn-google.disabled,.btn-google[disabled] {color: #ffffff;background-color: #e47365;*background-color: #e15f4f;}
|
||||
.btn-google:active,.btn-google.active {background-color: #dd4b39;}
|
||||
.btn-linkedin.active {color: rgba(255,255,255,0.75);}
|
||||
.btn-linkedin {color: #ffffff;text-shadow: 0 -1px 0 rgba(0,0,0,0.25);background-color: #0089ca;background-image: -moz-linear-gradient(top,#007bb6,#009de9);background-image: -webkit-gradient(linear,0 0,0 100%,from(#007bb6),to(#009de9));background-image: -webkit-linear-gradient(top,#007bb6,#009de9);background-image: -o-linear-gradient(top,#007bb6,#009de9);background-image: linear-gradient(to bottom,#007bb6,#009de9);background-repeat: repeat-x;filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff007bb6',endColorstr='#ff009de9',GradientType=0);border-color: #009de9 #009de9 #006a9d;border-color: rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);*background-color: #009de9;filter: progid:DXImageTransform.Microsoft.gradient(enabled = false);}
|
||||
.btn-linkedin:hover,.btn-linkedin:focus,.btn-linkedin:active,.btn-linkedin.active,.btn-linkedin.disabled,.btn-linkedin[disabled] {color: #ffffff;background-color: #009de9;*background-color: #008cd0;}
|
||||
.btn-linkedin:active,.btn-linkedin.active {background-color: #007bb6;}
|
||||
.btn-live.active {color: rgba(255,255,255,0.75);}
|
||||
.btn-live {color: #ffffff;text-shadow: 0 -1px 0 rgba(0,0,0,0.25);background-color: #397eee;background-image: -moz-linear-gradient(top,#2672ec,#5590f0);background-image: -webkit-gradient(linear,0 0,0 100%,from(#2672ec),to(#5590f0));background-image: -webkit-linear-gradient(top,#2672ec,#5590f0);background-image: -o-linear-gradient(top,#2672ec,#5590f0);background-image: linear-gradient(to bottom,#2672ec,#5590f0);background-repeat: repeat-x;filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff2672ec',endColorstr='#ff5590f0',GradientType=0);border-color: #5590f0 #5590f0 #1464e4;border-color: rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);*background-color: #5590f0;filter: progid:DXImageTransform.Microsoft.gradient(enabled = false);}
|
||||
.btn-live:hover,.btn-live:focus,.btn-live:active,.btn-live.active,.btn-live.disabled,.btn-live[disabled] {color: #ffffff;background-color: #5590f0;*background-color: #3d81ee;}
|
||||
.btn-live:active,.btn-live.active {background-color: #2672ec;}
|
||||
.btn-mailru.active {color: rgba(255,255,255,0.75);}
|
||||
.btn-mailru {color: #ffffff;text-shadow: 0 -1px 0 rgba(0,0,0,0.25);background-color: #0961b9;background-image: -moz-linear-gradient(top,#0857a6,#0a70d7);background-image: -webkit-gradient(linear,0 0,0 100%,from(#0857a6),to(#0a70d7));background-image: -webkit-linear-gradient(top,#0857a6,#0a70d7);background-image: -o-linear-gradient(top,#0857a6,#0a70d7);background-image: linear-gradient(to bottom,#0857a6,#0a70d7);background-repeat: repeat-x;filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff0857a6',endColorstr='#ff0a70d7',GradientType=0);border-color: #0a70d7 #0a70d7 #074a8e;border-color: rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);*background-color: #0a70d7;filter: progid:DXImageTransform.Microsoft.gradient(enabled = false);}
|
||||
.btn-mailru:hover,.btn-mailru:focus,.btn-mailru:active,.btn-mailru.active,.btn-mailru.disabled,.btn-mailru[disabled] {color: #ffffff;background-color: #0a70d7;*background-color: #0964be;}
|
||||
.btn-mailru:active,.btn-mailru.active {background-color: #0857a6 ;}
|
||||
.btn-openid.active {color: rgba(255,255,255,0.75);}
|
||||
.btn-openid {color: #ffffff;text-shadow: 0 -1px 0 rgba(0,0,0,0.25);background-color: #f89854;background-image: -moz-linear-gradient(top,#f78c40,#f9a971);background-image: -webkit-gradient(linear,0 0,0 100%,from(#f78c40),to(#f9a971));background-image: -webkit-linear-gradient(top,#f78c40,#f9a971);background-image: -o-linear-gradient(top,#f78c40,#f9a971);background-image: linear-gradient(to bottom,#f78c40,#f9a971);background-repeat: repeat-x;filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff78c40',endColorstr='#fff9a971',GradientType=0);border-color: #f9a971 #f9a971 #f67d28;border-color: rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);*background-color: #f9a971;filter: progid:DXImageTransform.Microsoft.gradient(enabled = false);}
|
||||
.btn-openid:hover,.btn-openid:focus,.btn-openid:active,.btn-openid.active,.btn-openid.disabled,.btn-openid[disabled] {color: #ffffff;background-color: #f9a971;*background-color: #f89b58;}
|
||||
.btn-openid:active,.btn-openid.active {background-color: #f78c40 ;}
|
||||
.btn-steam.active {color: rgba(255,255,255,0.75);}
|
||||
.btn-steam {color: #ffffff;text-shadow: 0 -1px 0 rgba(0,0,0,0.25);background-color: #0a0a0a;background-image: -moz-linear-gradient(top,#000000,#1a1a1a);background-image: -webkit-gradient(linear,0 0,0 100%,from(#000000),to(#1a1a1a));background-image: -webkit-linear-gradient(top,#000000,#1a1a1a);background-image: -o-linear-gradient(top,#000000,#1a1a1a);background-image: linear-gradient(to bottom,#000000,#1a1a1a);background-repeat: repeat-x;filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff000000',endColorstr='#ff1a1a1a',GradientType=0);border-color: #1a1a1a #1a1a1a #000000;border-color: rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);*background-color: #1a1a1a;filter: progid:DXImageTransform.Microsoft.gradient(enabled = false);}
|
||||
.btn-steam:hover,.btn-steam:focus,.btn-steam:active,.btn-steam.active,.btn-steam.disabled,.btn-steam[disabled] {color: #ffffff;background-color: #1a1a1a;*background-color: #0d0d0d;}
|
||||
.btn-steam:active,.btn-steam.active {background-color: #000000 ;}
|
||||
.btn-twitchtv.active {color: rgba(255, 255, 255, 0.75);}
|
||||
.btn-twitchtv {color: #ffffff;text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);background-color: #6e4baf;background-image: -moz-linear-gradient(top, #6441a5, #7e5bbe);background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#6441a5), to(#7e5bbe));background-image: -webkit-linear-gradient(top, #6441a5, #7e5bbe);background-image: -o-linear-gradient(top, #6441a5, #7e5bbe);background-image: linear-gradient(to bottom, #6441a5, #7e5bbe);background-repeat: repeat-x;filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff6441a5', endColorstr='#ff7e5bbe', GradientType=0);border-color: #7e5bbe #7e5bbe #593a93;border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);*background-color: #7e5bbe;filter: progid:DXImageTransform.Microsoft.gradient(enabled = false);}
|
||||
.btn-twitchtv:hover,.btn-twitchtv:focus,.btn-twitchtv:active,.btn-twitchtv.active,.btn-twitchtv.disabled,.btn-twitchtv[disabled] {color: #ffffff;background-color: #7e5bbe;*background-color: #6f48b7;}
|
||||
.btn-twitchtv:active,.btn-twitchtv.active {background-color: #6441a5 ;}
|
||||
.btn-twitter.active {color: rgba(255,255,255,0.75);}
|
||||
.btn-twitter {color: #ffffff;text-shadow: 0 -1px 0 rgba(0,0,0,0.25);background-color: #3db0e4;background-image: -moz-linear-gradient(top,#2ba9e1,#58bbe7);background-image: -webkit-gradient(linear,0 0,0 100%,from(#2ba9e1),to(#58bbe7));background-image: -webkit-linear-gradient(top,#2ba9e1,#58bbe7);background-image: -o-linear-gradient(top,#2ba9e1,#58bbe7);background-image: linear-gradient(to bottom,#2ba9e1,#58bbe7);background-repeat: repeat-x;filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff2ba9e1',endColorstr='#ff58bbe7',GradientType=0);border-color: #58bbe7 #58bbe7 #1e9cd4;border-color: rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);*background-color: #58bbe7;filter: progid:DXImageTransform.Microsoft.gradient(enabled = false);}
|
||||
.btn-twitter:hover,.btn-twitter:focus,.btn-twitter:active,.btn-twitter.active,.btn-twitter.disabled,.btn-twitter[disabled] {color: #ffffff;background-color: #58bbe7;*background-color: #41b2e4;}
|
||||
.btn-twitter:active,.btn-twitter.active {background-color: #2ba9e1 ;}
|
||||
.btn-xing.active {color: rgba(255,255,255,0.75);}
|
||||
.btn-xing {color: #ffffff;text-shadow: 0 -1px 0 rgba(0,0,0,0.25);background-color: #00797b;background-image: -moz-linear-gradient(top,#006567,#00979a);background-image: -webkit-gradient(linear,0 0,0 100%,from(#006567),to(#00979a));background-image: -webkit-linear-gradient(top,#006567,#00979a);background-image: -o-linear-gradient(top,#006567,#00979a);background-image: linear-gradient(to bottom,#006567,#00979a);background-repeat: repeat-x;filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff006567',endColorstr='#ff00979a',GradientType=0);border-color: #00979a #00979a #004c4e;border-color: rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);*background-color: #00979a;filter: progid:DXImageTransform.Microsoft.gradient(enabled = false);}
|
||||
.btn-xing:hover,.btn-xing:focus,.btn-xing:active,.btn-xing.active,.btn-xing.disabled,.btn-xing[disabled] {color: #ffffff;background-color: #00979a;*background-color: #007e81;}
|
||||
.btn-xing:active,.btn-xing.active {background-color: #006567 ;}
|
||||
.btn-yandex.active {color: rgba(255,255,255,0.75);}
|
||||
.btn-yandex {color: #ffffff;text-shadow: 0 -1px 0 rgba(0,0,0,0.25);background-color: #ffd014;background-image: -moz-linear-gradient(top,#ffcc00,#ffd633);background-image: -webkit-gradient(linear,0 0,0 100%,from(#ffcc00),to(#ffd633));background-image: -webkit-linear-gradient(top,#ffcc00,#ffd633);background-image: -o-linear-gradient(top,#ffcc00,#ffd633);background-image: linear-gradient(to bottom,#ffcc00,#ffd633);background-repeat: repeat-x;filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffcc00',endColorstr='#ffffd633',GradientType=0);border-color: #ffd633 #ffd633 #e5b800;border-color: rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);*background-color: #ffd633;filter: progid:DXImageTransform.Microsoft.gradient(enabled = false);}
|
||||
.btn-yandex:hover,.btn-yandex:focus,.btn-yandex:active,.btn-yandex.active,.btn-yandex.disabled,.btn-yandex[disabled] {color: #ffffff;background-color: #ffd633;*background-color: #ffd119;}
|
||||
.btn-yandex:active,.btn-yandex.active {background-color: #ffcc00 ;}
|
@ -11,6 +11,9 @@
|
||||
<ipBad>Inkorrekte IP: </ipBad>
|
||||
<ipOK>Erlaubte IP(s) ist/sind </ipOK>
|
||||
<linkexpired>Link ist abgelaufen.</linkexpired>
|
||||
<multipleHeader>Mehrere Benutzer gefunden</multipleHeader>
|
||||
<multipleHelper>Es wurden mehrere Benutzer zu dem Login von %sp% gefunden. Bitte wählen einen aus</multipleHelper>
|
||||
<multipleHelperEndpoint>Im Regelfall muss eine App bei dem jeweiligen Service Provider angelegt werden. Beim Erstellen der App erhält man einen Key und Zugangstoken, die beide in Easy-WI hinterlegt werden müssen. In der App muss meistens der Endpunkt des SocialAuth definiert werden. Dieser ist bei Easy-Wi %url%</multipleHelperEndpoint>
|
||||
<nouser>Ein Benutzer mit diesem Namen, oder Email existiert nicht.</nouser>
|
||||
<password>Passwort</password>
|
||||
<passwordr>Passwort vergessen?</passwordr>
|
||||
|
@ -73,6 +73,9 @@
|
||||
<serverdata>Installierte Server</serverdata>
|
||||
<settings>Panel Einstellungen</settings>
|
||||
<shown>Ergebnisse je Seite</shown>
|
||||
<socialConnect>Verknüpfung herstellen mit</socialConnect>
|
||||
<socialRemove>Verknüpfung entfernen mit</socialRemove>
|
||||
<socialSignin>Einloggen mit</socialSignin>
|
||||
<stadt>Stadt</stadt>
|
||||
<str>Straße</str>
|
||||
<switch>Zum Benutzer wechseln</switch>
|
||||
|
@ -11,6 +11,9 @@
|
||||
<ipBad>Forkert IP: </ipBad>
|
||||
<ipOK>Tilladt IP'er </ipOK>
|
||||
<linkexpired>Link er udløbet.</linkexpired>
|
||||
<multipleHeader>Multiple users found</multipleHeader>
|
||||
<multipleHelper>Multiple users could be found connected to the login for %sp%. Please pick one.</multipleHelper>
|
||||
<multipleHelperEndpoint>Usually you will have to register an app at the service provider. During creating you will be provided with a key and access token. Both need to be entered at Easy-Wi. At the app you need to configure an endpoint. The endpoint for Easy-Wi is %url%</multipleHelperEndpoint>
|
||||
<nouser>En bruger med det indtastede navn eller email eksisterer ikke.</nouser>
|
||||
<password>Adgangskode</password>
|
||||
<passwordr>Adgangskode genopretning</passwordr>
|
||||
|
@ -73,6 +73,9 @@
|
||||
<serverdata>Installerede servere</serverdata>
|
||||
<settings>Panelindstillinger</settings>
|
||||
<shown>Resultater pr side</shown>
|
||||
<socialConnect>Connect with</socialConnect>
|
||||
<socialRemove>Remove connection with</socialRemove>
|
||||
<socialSignin>Sign in with</socialSignin>
|
||||
<stadt>By</stadt>
|
||||
<str>Gade</str>
|
||||
<switch>Skift til bruger</switch>
|
||||
|
@ -11,6 +11,9 @@
|
||||
<ipBad>Incorrect IP: </ipBad>
|
||||
<ipOK>Permitted IP(s) is/are </ipOK>
|
||||
<linkexpired>Link is expired.</linkexpired>
|
||||
<multipleHeader>Multiple users found</multipleHeader>
|
||||
<multipleHelper>Multiple users could be found connected to the login for %sp%. Please pick one.</multipleHelper>
|
||||
<multipleHelperEndpoint>Usually you will have to register an app at the service provider. During creating you will be provided with a key and access token. Both need to be entered at Easy-Wi. At the app you need to configure an endpoint. The endpoint for Easy-Wi is %url%</multipleHelperEndpoint>
|
||||
<nouser>A user with the entered name or email does not exist.</nouser>
|
||||
<password>Password</password>
|
||||
<passwordr>Passwort Recovery</passwordr>
|
||||
|
@ -73,6 +73,9 @@
|
||||
<serverdata>Installed Servers</serverdata>
|
||||
<settings>Panel Settings</settings>
|
||||
<shown>Results per page</shown>
|
||||
<socialConnect>Connect with</socialConnect>
|
||||
<socialRemove>Remove connection with</socialRemove>
|
||||
<socialSignin>Sign in with</socialSignin>
|
||||
<stadt>Town</stadt>
|
||||
<str>Street</str>
|
||||
<switch>Switch to user</switch>
|
||||
|
190
web/login.php
190
web/login.php
@ -193,11 +193,182 @@ if ($ui->st('w', 'get') == 'lo') {
|
||||
|
||||
} else {
|
||||
|
||||
if (!$ui->username('username', 255, 'post') and !$ui->ismail('username', 255, 'post') and !$ui->password('password', 255, 'post') and !isset($_SESSION['sessionid'])) {
|
||||
$serviceProvider = (string) $ui->w('serviceProvider', 255, 'get');
|
||||
|
||||
$include = 'login.tpl';
|
||||
if ($serviceProvider and file_exists(EASYWIDIR . '/third_party/hybridauth/Hybrid/Providers/' . $serviceProvider . '.php')) {
|
||||
$_SERVER = $ui->server;
|
||||
|
||||
$pageUrl = '';
|
||||
|
||||
$query = $sql->prepare("SELECT `pageurl`,`seo`,`registration` FROM `page_settings` WHERE `resellerid`=0 LIMIT 1");
|
||||
$query->execute();
|
||||
foreach ($query->fetchAll(PDO::FETCH_ASSOC) as $row) {
|
||||
$pageUrl = $row['pageurl'];
|
||||
$seo = $row['seo'];
|
||||
$registration = $row['registration'];
|
||||
}
|
||||
|
||||
$serviceProviderConfig = array(
|
||||
'base_url' => $pageUrl . '/login.php?endpoint=1',
|
||||
'debug_mode' => (isset($dbConnect['debug']) and $dbConnect['debug'] == 1) ? true : false,
|
||||
'debug_file' => EASYWIDIR . '/third_party/hybridauth/log/hybridauth.log',
|
||||
'providers' => array()
|
||||
);
|
||||
|
||||
$query = $sql->prepare("SELECT `serviceProviderID`,`filename`,`identifier`,`token` FROM `userdata_social_providers` WHERE `resellerID`=0 AND `active`='Y'");
|
||||
$query->execute();
|
||||
foreach ($query->fetchAll(PDO::FETCH_ASSOC) as $row) {
|
||||
$serviceProviderConfig['providers'][$row['filename']] = array(
|
||||
'internalID' => $row['serviceProviderID'],
|
||||
'enabled' => true,
|
||||
'keys' => array(
|
||||
'id' => $row['identifier'],
|
||||
'secret' => $row['token']
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($serviceProviderConfig['providers'][$serviceProvider]) and $ui->id('loginUserId', 10, 'get')) {
|
||||
|
||||
if (isset($_SESSION['loginUserAllowed'][$ui->id('loginUserId', 10, 'get')])) {
|
||||
|
||||
$query = $sql->prepare("SELECT `id`,`accounttype`,`cname`,`active`,`security`,`resellerid`,`mail`,`salt`,`externalID` FROM `userdata` WHERE `id`=? LIMIT 1");
|
||||
$query->execute(array($ui->id('loginUserId', 10, 'get')));
|
||||
foreach ($query->fetchAll(PDO::FETCH_ASSOC) as $row) {
|
||||
|
||||
$username = $row['cname'];
|
||||
$id = $row['id'];
|
||||
$active = $row['active'];
|
||||
$mail = $row['mail'];
|
||||
$externalID = $row['externalID'];
|
||||
$resellerid = $row['resellerid'];
|
||||
$accounttype = $row['accounttype'];
|
||||
|
||||
$passwordCorrect = true;
|
||||
}
|
||||
}
|
||||
|
||||
unset($_SESSION['loginUserAllowed']);
|
||||
|
||||
} else if (isset($serviceProviderConfig['providers'][$serviceProvider])) {
|
||||
|
||||
include(EASYWIDIR . '/third_party/hybridauth/Hybrid/Auth.php');
|
||||
|
||||
try{
|
||||
|
||||
$connectedUsers = array();
|
||||
|
||||
// initialize Hybrid_Auth with a given file
|
||||
$hybridauth = new Hybrid_Auth($serviceProviderConfig);
|
||||
|
||||
// try to authenticate with the selected provider
|
||||
$serviceProviderAdapter = $hybridauth->authenticate($serviceProvider);
|
||||
$userProfile = $serviceProviderAdapter->getUserProfile();
|
||||
$serviceProviderAdapter->logout();
|
||||
|
||||
// get all user for this identifier and service provider. User should be able to select the user he is going to logon to
|
||||
$serviceProviderID = $serviceProviderConfig['providers'][$serviceProvider]['internalID'];
|
||||
|
||||
if ((isset($user_id) or isset($admin_id)) and strlen($userProfile->identifier) > 0) {
|
||||
|
||||
$query = $sql->prepare("INSERT INTO `userdata_social_identities` (`userID`,`serviceProviderID`,`serviceUserID`,`resellerID`) VALUES (?,?,?,?)");
|
||||
$query->execute(array((isset($admin_id)) ? $admin_id : $user_id, $serviceProviderID, $userProfile->identifier, $reseller_id));
|
||||
|
||||
$redirectURL = (isset($admin_id)) ? $pageUrl . '/admin.php?w=su&added=' . $serviceProvider . '&r=su' : $pageUrl . '/userpanel.php?w=se&added=' . $serviceProvider . '&r=se';
|
||||
|
||||
redirect($redirectURL);
|
||||
|
||||
} else {
|
||||
|
||||
$query = $sql->prepare("SELECT u.`id`,u.`cname`,`mail`,CONCAT(u.`vname`,' ',u.`name`) AS `username` FROM `userdata_social_identities` AS s INNER JOIN `userdata` AS u ON u.`id`=s.`userID` WHERE s.`serviceProviderID`=? AND s.`serviceUserID`=? AND u.`active`='Y'");
|
||||
$query->execute(array($serviceProviderID, $userProfile->identifier));
|
||||
foreach ($query->fetchAll(PDO::FETCH_ASSOC) as $row) {
|
||||
|
||||
$username = trim($row['username']);
|
||||
$username = (strlen($username) > 0) ? $username : $row['cname'];
|
||||
|
||||
$connectedUsers[$row['id']] = $username . ' (' . $row['mail'] . ')';
|
||||
|
||||
}
|
||||
|
||||
$connectedUserCount = count($connectedUsers);
|
||||
|
||||
// no user has been found. Check if registration is allowed. If yes display registration form
|
||||
if ($connectedUserCount == 0) {
|
||||
|
||||
if (isset($registration) and in_array($registration, array('A', 'M', 'D'))) {
|
||||
|
||||
$page_sprache = getlanguagefile('page', $user_language, 0);
|
||||
|
||||
$_SESSION['serviceProviderData']['userProfile'] = (array) $userProfile;
|
||||
$_SESSION['serviceProviderData']['serviceProviderID'] = (string) $serviceProviderID;
|
||||
|
||||
$redirectURL = ($seo == 'Y') ? $pageUrl . '/' . $user_language . '/' . szrp($page_sprache->register) .'/' : $pageUrl . '/index.php?site=register';
|
||||
|
||||
redirect($redirectURL);
|
||||
}
|
||||
|
||||
// multiple active users are connected, let the user pick one
|
||||
} else if ($connectedUserCount > 1) {
|
||||
|
||||
$sprache->multipleHelper = str_replace('%sp%', $serviceProvider, $sprache->multipleHelper);
|
||||
|
||||
$_SESSION['loginUserAllowed'] = $connectedUsers;
|
||||
|
||||
$include = 'login_mutiple.tpl';
|
||||
|
||||
// exactly one user connected, login
|
||||
} else {
|
||||
|
||||
$query = $sql->prepare("SELECT `id`,`accounttype`,`cname`,`active`,`security`,`resellerid`,`mail`,`salt`,`externalID` FROM `userdata` WHERE `id`=? LIMIT 1");
|
||||
$query->execute(array(key($connectedUsers)));
|
||||
foreach ($query->fetchAll(PDO::FETCH_ASSOC) as $row) {
|
||||
|
||||
$username = $row['cname'];
|
||||
$id = $row['id'];
|
||||
$active = $row['active'];
|
||||
$mail = $row['mail'];
|
||||
$externalID = $row['externalID'];
|
||||
$resellerid = $row['resellerid'];
|
||||
$accounttype = $row['accounttype'];
|
||||
|
||||
$passwordCorrect = true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
catch( Exception $e ){
|
||||
$include = 'login.tpl';
|
||||
}
|
||||
|
||||
} else if ($ui->escaped('endpoint', 'get')) {
|
||||
|
||||
$_SERVER = $ui->server;
|
||||
include(EASYWIDIR . '/third_party/hybridauth/Hybrid/Auth.php');
|
||||
include(EASYWIDIR . '/third_party/hybridauth/Hybrid/Endpoint.php');
|
||||
|
||||
Hybrid_Endpoint::process();
|
||||
}
|
||||
|
||||
if (!isset($include) and !isset($passwordCorrect) and !$ui->username('username', 255, 'post') and !$ui->ismail('username', 255, 'post') and !$ui->password('password', 255, 'post') and !isset($_SESSION['sessionid'])) {
|
||||
|
||||
$serviceProviders = array();
|
||||
$query = $sql->prepare("SELECT `filename` FROM `userdata_social_providers` WHERE `resellerID`=0 AND `active`='Y'");
|
||||
$query->execute();
|
||||
foreach ($query->fetchAll(PDO::FETCH_ASSOC) as $row) {
|
||||
$serviceProviders[$row['filename']] = strtolower($row['filename']);
|
||||
}
|
||||
|
||||
if (count($serviceProviders) > 0) {
|
||||
$htmlExtraInformation['css'][] = '<link href="css/default/social_buttons.css" rel="stylesheet">';
|
||||
}
|
||||
|
||||
$include = 'login.tpl';
|
||||
|
||||
} else if (!isset($include) and (isset($passwordCorrect) or (($ui->username('username', 255, 'post') or $ui->ismail('username', 'post')) and $ui->password('password', 255, 'post') and !isset($_SESSION['sessionid'])))) {
|
||||
|
||||
} else if (($ui->username('username', 255, 'post') or $ui->ismail('username', 'post')) and $ui->password('password', 255, 'post') and !isset($_SESSION['sessionid'])) {
|
||||
$password = $ui->password('password', 255, 'post');
|
||||
|
||||
if (isset($ewCfg) and $ewCfg['captcha'] == 1) {
|
||||
@ -207,7 +378,7 @@ if ($ui->st('w', 'get') == 'lo') {
|
||||
|
||||
$query = $sql->prepare("SELECT `id` FROM `badips` WHERE `badip`=? LIMIT 1");
|
||||
$query->execute(array($loguserip));
|
||||
$rowcount = $query->rowcount();
|
||||
$rowcount = $query->rowCount();
|
||||
|
||||
$query=($rowcount==0) ? $sql->prepare("INSERT INTO `badips` (`bantime`,`failcount`,`reason`,`badip`) VALUES (?,'1','password',?)") : $sql->prepare("UPDATE `badips` SET `bantime`=?, `failcount`=`failcount`+1, `reason`='password' WHERE `badip`=? LIMIT 1");
|
||||
$query->execute(array($halfhour, $loguserip));
|
||||
@ -220,7 +391,7 @@ if ($ui->st('w', 'get') == 'lo') {
|
||||
$salt = '';
|
||||
|
||||
$query = $sql->prepare("SELECT `id`,`accounttype`,`cname`,`active`,`security`,`resellerid`,`mail`,`salt`,`externalID` FROM `userdata` WHERE `cname`=? OR `mail`=? ORDER BY `lastlogin` DESC LIMIT 1");
|
||||
$query->execute(array($ui->username('username', 255, 'post'),$ui->ismail('username', 'post')));
|
||||
$query->execute(array($ui->username('username', 255, 'post'), $ui->ismail('username', 'post')));
|
||||
foreach ($query->fetchAll(PDO::FETCH_ASSOC) as $row) {
|
||||
|
||||
$username = $row['cname'];
|
||||
@ -272,6 +443,7 @@ if ($ui->st('w', 'get') == 'lo') {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($sID) and isset($active) and $active == 'Y' and isset($passwordCorrect) and $passwordCorrect === false) {
|
||||
|
||||
$authLookupID = ($resellerid == $id) ? 0 : $resellerid;
|
||||
@ -335,7 +507,8 @@ if ($ui->st('w', 'get') == 'lo') {
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($active) and $active == 'Y' and isset($passwordCorrect) and $passwordCorrect) {
|
||||
if (isset($active, $id, $resellerid) and $active == 'Y' and isset($passwordCorrect) and $passwordCorrect) {
|
||||
|
||||
session_unset();
|
||||
session_destroy();
|
||||
session_start();
|
||||
@ -416,6 +589,7 @@ if ($ui->st('w', 'get') == 'lo') {
|
||||
redirect('userpanel.php');
|
||||
|
||||
} else if (isset($admin_id)) {
|
||||
|
||||
$folders = explode('/', $ui->server['SCRIPT_NAME']);
|
||||
$amount = count($folders) - 1;
|
||||
$i = 0;
|
||||
@ -463,10 +637,10 @@ if ($ui->st('w', 'get') == 'lo') {
|
||||
redirect('login.php?w=up&r=lo');
|
||||
}
|
||||
|
||||
} else if ($ui->escaped('username', 'post') and $ui->escaped('password', 'post')) {
|
||||
} else if (!isset($include) and $ui->escaped('username', 'post') and $ui->escaped('password', 'post')) {
|
||||
redirect('login.php?w=up&r=lo');
|
||||
|
||||
} else {
|
||||
} else if(!isset($include)) {
|
||||
redirect('login.php?w=lo');
|
||||
}
|
||||
}
|
||||
|
240
web/stuff/admin_social_provider.php
Normal file
240
web/stuff/admin_social_provider.php
Normal file
@ -0,0 +1,240 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* File: admin_social_provider.php.
|
||||
* Author: Ulrich Block
|
||||
* Date: 16.02.14
|
||||
* Contact: <ulrich.block@easy-wi.com>
|
||||
*
|
||||
* This file is part of Easy-WI.
|
||||
*
|
||||
* Easy-WI is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Easy-WI is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Easy-WI. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Diese Datei ist Teil von Easy-WI.
|
||||
*
|
||||
* Easy-WI ist Freie Software: Sie koennen es unter den Bedingungen
|
||||
* der GNU General Public License, wie von der Free Software Foundation,
|
||||
* Version 3 der Lizenz oder (nach Ihrer Wahl) jeder spaeteren
|
||||
* veroeffentlichten Version, weiterverbreiten und/oder modifizieren.
|
||||
*
|
||||
* Easy-WI wird in der Hoffnung, dass es nuetzlich sein wird, aber
|
||||
* OHNE JEDE GEWAEHELEISTUNG, bereitgestellt; sogar ohne die implizite
|
||||
* Gewaehrleistung der MARKTFAEHIGKEIT oder EIGNUNG FUER EINEN BESTIMMTEN ZWECK.
|
||||
* Siehe die GNU General Public License fuer weitere Details.
|
||||
*
|
||||
* Sie sollten eine Kopie der GNU General Public License zusammen mit diesem
|
||||
* Programm erhalten haben. Wenn nicht, siehe <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
if ((!isset($admin_id) or $main != 1) or (isset($admin_id) and !$pa['root'])) {
|
||||
header('Location: admin.php');
|
||||
die('No acces');
|
||||
}
|
||||
|
||||
$loguserid = $admin_id;
|
||||
$logusername = getusername($admin_id);
|
||||
$logusertype = 'admin';
|
||||
|
||||
if ($reseller_id == 0) {
|
||||
|
||||
$logreseller = 0;
|
||||
$logsubuser = 0;
|
||||
|
||||
} else {
|
||||
|
||||
$logsubuser = (isset($_SESSION['oldid'])) ? $_SESSION['oldid'] : 0;
|
||||
$logreseller = 0;
|
||||
}
|
||||
|
||||
$sprache = getlanguagefile('login', $user_language, $reseller_id);
|
||||
|
||||
// Define the ID variable which will be used at the form and SQLs
|
||||
$id = $ui->id('id', 10, 'get');
|
||||
$active = $ui->active('active', 'post');
|
||||
$name = $ui->w('name', 255, 'post');
|
||||
$keyID = $ui->escaped('keyID', 'post');
|
||||
$providerToken = $ui->escaped('providerToken', 'post');
|
||||
|
||||
|
||||
// At this point all variables are defined that can come from the user
|
||||
|
||||
// CSFR protection with hidden tokens. If token(true) returns false, we likely have an attack
|
||||
if ($ui->w('action',4, 'post') and !token(true)) {
|
||||
$template_file = $spracheResponse->token;
|
||||
|
||||
// Add and modify entries. Same validation can be used.
|
||||
} else if ($ui->st('d', 'get') == 'ad' or $ui->st('d', 'get') == 'md') {
|
||||
|
||||
// Error handling. Check if required attributes are set and can be validated
|
||||
$errors = array();
|
||||
|
||||
$serviceProviders = array();
|
||||
|
||||
foreach (scandir(EASYWIDIR . '/third_party/hybridauth/Hybrid/Providers/') as $sp) {
|
||||
if ($sp != '.' and $sp != '..') {
|
||||
$serviceProviders[] = substr($sp, 0 , (strlen($sp) - 4));
|
||||
}
|
||||
}
|
||||
|
||||
// Add or mod is opened
|
||||
if (!$ui->smallletters('action', 2, 'post')) {
|
||||
|
||||
$query = $sql->prepare("SELECT `pageurl` FROM `page_settings` WHERE `resellerid`=? LIMIT 1");
|
||||
$query->execute(array($resellerLockupID));
|
||||
|
||||
$sprache->multipleHelperEndpoint = str_replace('//login.php', '/login.php', str_replace('%url%', '<b>' . $query->fetchColumn() . '/login.php' . '</b>', $sprache->multipleHelperEndpoint));
|
||||
|
||||
// Gather data for adding if needed and define add template
|
||||
if ($ui->st('d', 'get') == 'ad') {
|
||||
|
||||
$template_file = 'admin_social_provider_add.tpl';
|
||||
|
||||
// Gather data for modding in case we have an ID and define mod template
|
||||
} else if ($ui->st('d', 'get') == 'md' and $id) {
|
||||
|
||||
$query = $sql->prepare("SELECT * FROM `userdata_social_providers` WHERE `serviceProviderID`=? AND `resellerID`=? LIMIT 1");
|
||||
$query->execute(array($id, $resellerLockupID));
|
||||
foreach ($query->fetchAll(PDO::FETCH_ASSOC) as $row) {
|
||||
$active = (string) $row['active'];
|
||||
$name = (string) $row['filename'];
|
||||
$keyID = (string) $row['identifier'];
|
||||
$providerToken = (string) $row['token'];
|
||||
}
|
||||
|
||||
// Check if database entry exists and if not display 404 page
|
||||
$template_file = ($query->rowCount() > 0) ? 'admin_social_provider_md.tpl' : 'admin_404.tpl';
|
||||
|
||||
// Show 404 if GET parameters did not add up or no ID was given with mod
|
||||
} else {
|
||||
$template_file = 'admin_404.tpl';
|
||||
}
|
||||
|
||||
// Form is submitted
|
||||
} else if ($ui->st('action', 'post') == 'md' or $ui->st('action', 'post') == 'ad') {
|
||||
|
||||
if (!$active) {
|
||||
$errors['active'] = $sprache->active;
|
||||
}
|
||||
|
||||
if (!$name or !in_array($name, $serviceProviders)) {
|
||||
|
||||
$errors['name'] = 'Social Auth Provider';
|
||||
|
||||
} else {
|
||||
|
||||
if ($ui->st('d', 'get') == 'ad') {
|
||||
|
||||
$query = $sql->prepare("SELECT 1 FROM `userdata_social_providers` WHERE `filename`=? AND `resellerID`=? LIMIT 1");
|
||||
$query->execute(array($name, $resellerLockupID));
|
||||
|
||||
} else {
|
||||
|
||||
$query = $sql->prepare("SELECT 1 FROM `userdata_social_providers` WHERE `filename`=? AND `serviceProviderID`!=? AND `resellerID`=? LIMIT 1");
|
||||
$query->execute(array($name, $id, $resellerLockupID));
|
||||
|
||||
}
|
||||
|
||||
if ($query->rowCount() > 0) {
|
||||
$errors['name'] = 'Social Auth Provider';
|
||||
}
|
||||
}
|
||||
|
||||
// Submitted values are OK
|
||||
if (count($errors) == 0) {
|
||||
|
||||
// Make the inserts or updates define the log entry and get the affected rows from insert
|
||||
if ($ui->st('action', 'post') == 'ad') {
|
||||
|
||||
$query = $sql->prepare("INSERT INTO `userdata_social_providers` (`filename`,`active`,`identifier`,`token`,`resellerID`) VALUES (?,?,?,?,?)");
|
||||
$query->execute(array($name, $active, $keyID, $providerToken, $resellerLockupID));
|
||||
$rowCount = $query->rowCount();
|
||||
$loguseraction = '%add% Social Provider ' . $name;
|
||||
|
||||
} else if ($ui->st('action', 'post') == 'md' and $id) {
|
||||
|
||||
$query = $sql->prepare("UPDATE `userdata_social_providers` SET `filename`=?,`active`=?,`identifier`=?,`token`=?WHERE `serviceProviderID`=? AND `resellerID`=? LIMIT 1");
|
||||
$query->execute(array($name, $active, $keyID, $providerToken, $id, $resellerLockupID));
|
||||
$rowCount = $query->rowCount();
|
||||
$loguseraction = '%mod% Social Provider ' . $name;
|
||||
}
|
||||
|
||||
// Check if a row was affected during insert or update
|
||||
if (isset($rowCount) and $rowCount > 0) {
|
||||
$insertlog->execute();
|
||||
$template_file = $spracheResponse->table_add;
|
||||
|
||||
// No update or insert failed
|
||||
} else {
|
||||
$template_file = $spracheResponse->error_table;
|
||||
}
|
||||
|
||||
// An error occurred during validation unset the redirect information and display the form again
|
||||
} else {
|
||||
unset($header, $text);
|
||||
$template_file = ($ui->st('d', 'get') == 'ad') ? 'admin_social_provider_add.tpl' : 'admin_social_provider_md.tpl';
|
||||
}
|
||||
}
|
||||
|
||||
// Remove entries in case we have an ID given with the GET request
|
||||
} else if ($ui->st('d', 'get') == 'dl' and $id) {
|
||||
|
||||
// Nothing submitted yet, display the delete form
|
||||
if (!$ui->st('action', 'post')) {
|
||||
|
||||
$query = $sql->prepare("SELECT `filename` FROM `userdata_social_providers` WHERE `serviceProviderID`=? AND `resellerID`=? LIMIT 1");
|
||||
$query->execute(array($id, $resellerLockupID));
|
||||
$name = $query->fetchColumn();
|
||||
|
||||
// Check if we could find an entry and if not display 404 page
|
||||
$template_file = ($query->rowCount() > 0) ? 'admin_social_provider_dl.tpl' : 'admin_404.tpl';
|
||||
|
||||
// User submitted remove the entry
|
||||
} else if ($ui->st('action', 'post') == 'dl') {
|
||||
|
||||
$query = $sql->prepare("DELETE FROM `userdata_social_providers` WHERE `serviceProviderID`=? AND `resellerID`=? LIMIT 1");
|
||||
$query->execute(array($id, $resellerLockupID));
|
||||
|
||||
// Check if a row was affected meaning an entry could be deleted. If yes add log entry and display success message
|
||||
if ($query->rowCount() > 0) {
|
||||
|
||||
$query = $sql->prepare("DELETE FROM `userdata_social_identities` WHERE `serviceProviderID`=? AND `resellerID`=? LIMIT 1");
|
||||
$query->execute(array($id, $resellerLockupID));
|
||||
|
||||
$template_file = $spracheResponse->table_del;
|
||||
$loguseraction = '%del% Social Provider ' . $name;
|
||||
$insertlog->execute();
|
||||
|
||||
// Nothing was deleted, display an error
|
||||
} else {
|
||||
$template_file = $spracheResponse->error_table;
|
||||
}
|
||||
|
||||
// GET Request did not add up. Display 404 error.
|
||||
} else {
|
||||
$template_file = 'admin_404.tpl';
|
||||
}
|
||||
|
||||
// List the available entries
|
||||
} else {
|
||||
|
||||
$table = array();
|
||||
|
||||
$query = $sql->prepare("SELECT `serviceProviderID`,`active`,`filename` FROM `userdata_social_providers` WHERE `resellerID`=?");
|
||||
$query->execute(array($resellerLockupID));
|
||||
foreach ($query->fetchAll(PDO::FETCH_ASSOC) as $row) {
|
||||
$table[] = array('id' => $row['serviceProviderID'], 'active' => $row['active'], 'name' => $row['filename']);
|
||||
}
|
||||
|
||||
$template_file = 'admin_social_provider_list.tpl';
|
||||
}
|
@ -40,14 +40,17 @@ include(EASYWIDIR . '/stuff/keyphrasefile.php');
|
||||
include(EASYWIDIR . '/third_party/password_compat/password.php');
|
||||
|
||||
if ($ui->st('w', 'get') == 'se') {
|
||||
|
||||
if ((!isset($user_id) or $main != 1) or (isset($user_id) and !$pa['usersettings'])) {
|
||||
header('Location: userpanel.php');
|
||||
die();
|
||||
}
|
||||
|
||||
$loguserid = $user_id;
|
||||
$logusername = getusername($user_id);
|
||||
$logusertype = 'user';
|
||||
$logreseller = 0;
|
||||
|
||||
if (isset($admin_id)) {
|
||||
$logsubuser = $admin_id;
|
||||
} else if (isset($subuser_id)) {
|
||||
@ -57,13 +60,16 @@ if ($ui->st('w', 'get') == 'se') {
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
if ((!isset($admin_id) or $main != 1)) {
|
||||
header('Location: admin.php');
|
||||
die();
|
||||
}
|
||||
|
||||
$loguserid = $admin_id;
|
||||
$logusername = getusername($admin_id);
|
||||
$logusertype = 'admin';
|
||||
|
||||
if ($reseller_id == 0) {
|
||||
$logreseller = 0;
|
||||
$logsubuser = 0;
|
||||
@ -72,9 +78,10 @@ if ($ui->st('w', 'get') == 'se') {
|
||||
$logreseller = 0;
|
||||
}
|
||||
}
|
||||
$sprache = getlanguagefile('user',$user_language,$reseller_id);
|
||||
|
||||
$lookUpID=($ui->st('w', 'get') == 'se') ? $user_id : $admin_id;
|
||||
$sprache = getlanguagefile('user', $user_language, $reseller_id);
|
||||
|
||||
$lookUpID = ($ui->st('w', 'get') == 'se') ? $user_id : $admin_id;
|
||||
|
||||
if ($ui->st('d', 'get') == 'pw') {
|
||||
|
||||
@ -101,7 +108,7 @@ if ($ui->st('d', 'get') == 'pw') {
|
||||
}
|
||||
|
||||
if (count($errors)>0) {
|
||||
$template_file = implode('<br />',$errors);
|
||||
$template_file = implode('<br />', $errors);
|
||||
} else {
|
||||
|
||||
$query = $sql->prepare("SELECT `cname` FROM `userdata` WHERE `id`=? AND `resellerid`=? LIMIT 1");
|
||||
@ -129,6 +136,16 @@ if ($ui->st('d', 'get') == 'pw') {
|
||||
} else {
|
||||
$template_file = 'userpanel_404.tpl';
|
||||
}
|
||||
} else if ($ui->w('spUser', 255, 'get') and $ui->id('spId', 10, 'get')) {
|
||||
|
||||
$query = $sql->prepare("DELETE FROM `userdata_social_identities` WHERE `userID`=? AND `serviceProviderID`=? AND `serviceUserID`=? AND `resellerID`=? LIMIT 1");
|
||||
$query->execute(array($lookUpID, $ui->id('spId', 10, 'get'), $ui->w('spUser', 255, 'get'), $reseller_id));
|
||||
|
||||
if ($query->rowCount() > 0) {
|
||||
$template_file = $spracheResponse->table_del;
|
||||
} else {
|
||||
$template_file = $spracheResponse->error_table;
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
@ -158,11 +175,40 @@ if ($ui->st('d', 'get') == 'pw') {
|
||||
$oldValues[$k] = $v;
|
||||
}
|
||||
}
|
||||
if ($ui->smallletters('action',2, 'post') == 'md' and isset($oldValues)){
|
||||
|
||||
if ($ui->smallletters('action', 2, 'post') != 'md' and $ui->w('added', 255, 'get')) {
|
||||
|
||||
$template_file = $spracheResponse->table_add;
|
||||
|
||||
} else if ($ui->smallletters('action', 2, 'post') != 'md') {
|
||||
|
||||
$serviceProviders = array();
|
||||
|
||||
$htmlExtraInformation['css'][] = '<link href="css/default/social_buttons.css" rel="stylesheet">';
|
||||
|
||||
$query = $sql->prepare("SELECT `serviceProviderID`,`filename` FROM `userdata_social_providers` WHERE `resellerID`=0 AND `active`='Y'");
|
||||
$query2 = $sql->prepare("SELECT `serviceUserID` FROM `userdata_social_identities` WHERE `serviceProviderID`=? AND `userID`=? LIMIT 1");
|
||||
|
||||
|
||||
$query->execute();
|
||||
foreach ($query->fetchAll(PDO::FETCH_ASSOC) as $row) {
|
||||
|
||||
$query2->execute(array($row['serviceProviderID'], $lookUpID));
|
||||
|
||||
$serviceProviders[] = array(
|
||||
'spId' => $row['serviceProviderID'],
|
||||
'sp' => $row['filename'],
|
||||
'spUserId' => $query2->fetchColumn()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if ($ui->smallletters('action', 2, 'post') == 'md' and isset($oldValues)) {
|
||||
|
||||
if ($ui->ismail('mail', 'post') and token(true)) {
|
||||
$mail_backup=($ui->active('mail_backup', 'post')) ? $ui->active('mail_backup', 'post') : 'N';
|
||||
$mail_serverdown=($ui->active('mail_serverdown', 'post')) ? $ui->active('mail_serverdown', 'post') : 'N';
|
||||
$mail_ticket=($ui->active('mail_ticket', 'post')) ? $ui->active('mail_ticket', 'post') : 'N';
|
||||
$mail_backup = ($ui->active('mail_backup', 'post')) ? $ui->active('mail_backup', 'post') : 'N';
|
||||
$mail_serverdown = ($ui->active('mail_serverdown', 'post')) ? $ui->active('mail_serverdown', 'post') : 'N';
|
||||
$mail_ticket = ($ui->active('mail_ticket', 'post')) ? $ui->active('mail_ticket', 'post') : 'N';
|
||||
$name = $ui->names('name', 30, 'post');
|
||||
$vname = $ui->names('vname', 30, 'post');
|
||||
$mail = $ui->ismail('mail', 'post');
|
||||
@ -172,15 +218,21 @@ if ($ui->st('d', 'get') == 'pw') {
|
||||
$cityn = $ui->isinteger('cityn', 'post');
|
||||
$street = $ui->names('street', 40, 'post');
|
||||
$streetn = $ui->streetNumber('streetn', 'post');
|
||||
|
||||
if (($ui->st('w', 'get') == 'se')) {
|
||||
|
||||
$query = $sql->prepare("UPDATE `userdata` SET `updateTime`=NOW(),`name`=?,`vname`=?,`mail`=?,`phone`=?,`handy`=?,`city`=?,`cityn`=?,`street`=?,`streetn`=?,`mail_backup`=?,`mail_serverdown`=?,`mail_ticket`=? WHERE `id`=? AND `resellerid`=? LIMIT 1");
|
||||
$query->execute(array($name,$vname,$mail,$phone,$handy,$city,$cityn,$street,$streetn,$mail_backup,$mail_serverdown,$mail_ticket,$lookUpID,$reseller_id));
|
||||
$query->execute(array($name, $vname, $mail, $phone, $handy, $city, $cityn, $street, $streetn, $mail_backup, $mail_serverdown, $mail_ticket, $lookUpID, $reseller_id));
|
||||
|
||||
} else {
|
||||
$mail_gsupdate=($ui->active('mail_gsupdate', 'post')) ? $ui->active('mail_gsupdate', 'post') : 'N';
|
||||
$mail_securitybreach=($ui->active('mail_securitybreach', 'post')) ? $ui->active('mail_securitybreach', 'post') : 'N';
|
||||
$mail_vserver=($ui->active('mail_vserver', 'post')) ? $ui->active('mail_vserver', 'post') : 'N';
|
||||
|
||||
$mail_gsupdate = ($ui->active('mail_gsupdate', 'post')) ? $ui->active('mail_gsupdate', 'post') : 'N';
|
||||
$mail_securitybreach = ($ui->active('mail_securitybreach', 'post')) ? $ui->active('mail_securitybreach', 'post') : 'N';
|
||||
$mail_vserver = ($ui->active('mail_vserver', 'post')) ? $ui->active('mail_vserver', 'post') : 'N';
|
||||
|
||||
$query = $sql->prepare("UPDATE `userdata` SET `updateTime`=NOW(),`name`=?,`vname`=?,`mail`=?,`phone`=?,`handy`=?,`city`=?,`cityn`=?,`street`=?,`streetn`=?,`mail_backup`=?,`mail_serverdown`=?,`mail_ticket`=?,`mail_gsupdate`=?,`mail_securitybreach`=?,`mail_vserver`=? WHERE `id`=? AND `resellerid`=? LIMIT 1");
|
||||
$query->execute(array($name,$vname,$mail,$phone,$handy,$city,$cityn,$street,$streetn,$mail_backup,$mail_serverdown,$mail_ticket,$mail_gsupdate,$mail_securitybreach,$mail_vserver,$lookUpID,$reseller_id));
|
||||
$query->execute(array($name, $vname, $mail, $phone, $handy, $city, $cityn, $street, $streetn, $mail_backup, $mail_serverdown, $mail_ticket, $mail_gsupdate, $mail_securitybreach, $mail_vserver, $lookUpID, $reseller_id));
|
||||
|
||||
}
|
||||
|
||||
if ($query->rowCount() > 0) {
|
||||
@ -193,18 +245,21 @@ if ($ui->st('d', 'get') == 'pw') {
|
||||
}
|
||||
|
||||
$query = $sql->prepare("INSERT INTO `userdata_value_log` (`userID`,`date`,`json`,`resellerID`) VALUES (?,NOW(),?,?)");
|
||||
$query->execute(array($lookUpID,json_encode($changed),$reseller_id));
|
||||
$query->execute(array($lookUpID, json_encode($changed), $reseller_id));
|
||||
|
||||
$template_file = $spracheResponse->table_add;
|
||||
$loguseraction="%mod% %user% $cname";
|
||||
$loguseraction = '%mod% %user% ' . $cname;
|
||||
$insertlog->execute();
|
||||
|
||||
} else {
|
||||
$template_file = $spracheResponse->error_table;
|
||||
}
|
||||
|
||||
} else {
|
||||
$template_file = (!token(true)) ? $spracheResponse->token : $sprache->error_mail;
|
||||
}
|
||||
} else {
|
||||
|
||||
} else if (!isset($template_file)) {
|
||||
$template_file = ($logusertype == 'user') ? 'userpanel_user_md.tpl' : 'admin_user_own_md.tpl';
|
||||
}
|
||||
}
|
@ -129,6 +129,7 @@ foreach ($query->fetchAll(PDO::FETCH_ASSOC) as $row) {
|
||||
|
||||
if ($reseller_id == 0) {
|
||||
$what_to_be_included_array['mo'] = 'admin_modules.php';
|
||||
$what_to_be_included_array['up'] = 'admin_social_provider.php';
|
||||
|
||||
if ($easywiModules['pn'] === true) {
|
||||
$what_to_be_included_array['ps'] = 'page_settings.php';
|
||||
|
@ -55,11 +55,19 @@ if (isset($page_active) and $page_active == 'Y') {
|
||||
$easywiModules = array('gs' => true, 'ip' => true, 'ea' => true, 'my' => true, 'ro' => true, 'ti' => true, 'le' => true, 'vo' => true);
|
||||
$customModules = array('gs' => array(), 'mo' => array(), 'my' => array(), 'ro' => array(), 'ti' => array(), 'us' => array(), 'vo' => array(), 'pa' => array());
|
||||
|
||||
$what_to_be_included_array = array('news' => 'page_news.php','contact' => 'page_contact.php',
|
||||
'page' => 'page_page.php','home' => 'page_page.php','about' => 'page_page.php','gallery' => 'page_page.php','sitemap' => 'page_page.php','search' => 'page_page.php',
|
||||
'tag' => 'page_tag.php','categories' => 'page_tag.php','downloads' => 'page_download.php',
|
||||
'protectioncheck' => 'protectioncheck.php',
|
||||
'register' => 'page_register.php'
|
||||
);
|
||||
|
||||
$query = $sql->prepare("SELECT * FROM `modules` WHERE `type` IN ('P','C')");
|
||||
$query2 = $sql->prepare("SELECT `text` FROM `translations` WHERE `type`='mo' AND `transID`=? AND `lang`=? LIMIT 1");
|
||||
$query->execute();
|
||||
foreach ($query->fetchAll(PDO::FETCH_ASSOC) as $row) {
|
||||
if ($row['active'] == 'Y' and $row['type'] == 'A' and is_file(EASYWIDIR . '/stuff/' . $row['file'])) {
|
||||
|
||||
if ($row['active'] == 'Y' and $row['type'] == 'P' and is_file(EASYWIDIR . '/stuff/' . $row['file'])) {
|
||||
$query2->execute(array($row['id'], $user_language));
|
||||
$name = $query2->fetchColumn();
|
||||
|
||||
@ -79,16 +87,10 @@ if (isset($page_active) and $page_active == 'Y') {
|
||||
}
|
||||
}
|
||||
|
||||
$what_to_be_included_array = array('news' => 'page_news.php','contact' => 'page_contact.php',
|
||||
'page' => 'page_page.php','home' => 'page_page.php','about' => 'page_page.php','gallery' => 'page_page.php','sitemap' => 'page_page.php','search' => 'page_page.php',
|
||||
'tag' => 'page_tag.php','categories' => 'page_tag.php','downloads' => 'page_download.php',
|
||||
'protectioncheck' => 'protectioncheck.php',
|
||||
'register' => 'page_register.php'
|
||||
);
|
||||
|
||||
if ($easywiModules['ip'] === true) {
|
||||
$what_to_be_included_array['imprint'] = 'imprint.php';
|
||||
}
|
||||
|
||||
if ($easywiModules['le'] === true) {
|
||||
$what_to_be_included_array['lendserver'] = 'lend.php';
|
||||
}
|
||||
@ -99,6 +101,7 @@ if (isset($page_active) and $page_active == 'Y') {
|
||||
$page_data->SetData('lendactiveGS', $row['activeGS']);
|
||||
$page_data->SetData('lendactiveVS', $row['activeVS']);
|
||||
}
|
||||
|
||||
$query = $sql->prepare("SELECT `active` FROM `modules` WHERE `id`=5 LIMIT 1");
|
||||
$query->execute();
|
||||
$lendActive = $query->fetchColumn();
|
||||
@ -192,7 +195,6 @@ if (isset($page_active) and $page_active == 'Y') {
|
||||
foreach ($query->fetchAll(PDO::FETCH_ASSOC) as $row) {
|
||||
if ($row['naviDisplay'] == 'Y') {
|
||||
$page_data->SetMenu($row['title'], $row['id'], $row['subpage'], $row['id']);
|
||||
|
||||
} else {
|
||||
$page_data->SetMenu($row['title'], $row['id'], $row['subpage'], $row['id'], false);
|
||||
}
|
||||
@ -215,37 +217,39 @@ if (isset($page_active) and $page_active == 'Y') {
|
||||
|
||||
if (isset($page_category)) {
|
||||
if ($page_category == szrp($gsprache->imprint)) {
|
||||
$s='imprint';
|
||||
$s = 'imprint';
|
||||
} else if ($page_category == szrp($page_sprache->contact)) {
|
||||
$s='contact';
|
||||
$s = 'contact';
|
||||
} else if ($page_category == szrp($gsprache->downloads)) {
|
||||
$s='downloads';
|
||||
$s = 'downloads';
|
||||
} else if ($page_category == szrp($page_sprache->protectioncheck)) {
|
||||
$s='protectioncheck';
|
||||
$s = 'protectioncheck';
|
||||
} else if ($page_category == szrp($page_sprache->tag)) {
|
||||
$s='tag';
|
||||
$s = 'tag';
|
||||
} else if ($page_category == szrp($page_sprache->categories)) {
|
||||
$s='categories';
|
||||
$s = 'categories';
|
||||
} else if ($page_category == szrp($page_sprache->about)) {
|
||||
$s='about';
|
||||
$s = 'about';
|
||||
} else if ($page_category == szrp($gsprache->lendserver)) {
|
||||
$s='lendserver';
|
||||
$s = 'lendserver';
|
||||
} else if ($page_category == szrp($gsprache->news)) {
|
||||
$s='news';
|
||||
$s = 'news';
|
||||
} else if ($page_category == szrp($page_sprache->sitemap)) {
|
||||
$s='sitemap';
|
||||
$s = 'sitemap';
|
||||
} else if ($page_category == szrp($page_sprache->search)) {
|
||||
$s='search';
|
||||
$s = 'search';
|
||||
} else if ($page_category == szrp($page_sprache->gallery)) {
|
||||
$s='gallery';
|
||||
$s = 'gallery';
|
||||
} else if ($page_category == szrp($page_sprache->sitemap)) {
|
||||
$s='sitemap';
|
||||
$s = 'sitemap';
|
||||
} else if ($page_category == szrp($page_sprache->search)) {
|
||||
$s='search';
|
||||
$s = 'search';
|
||||
} else if ($page_category == szrp($page_sprache->register)) {
|
||||
$s='register';
|
||||
$s = 'register';
|
||||
} else if (isset($page_data->pages_array['pages']) and in_array($page_category, $page_data->pages_array['pages'])) {
|
||||
$s='page';
|
||||
$s = 'page';
|
||||
} else if (isset($what_to_be_included_array[$page_category])) {
|
||||
$s = $page_category;
|
||||
}
|
||||
}
|
||||
|
||||
@ -254,11 +258,26 @@ if (isset($page_active) and $page_active == 'Y') {
|
||||
|
||||
} else if (isset($user_id)) {
|
||||
$page_lookupid = $user_id;
|
||||
} else {
|
||||
|
||||
$serviceProviders = array();
|
||||
|
||||
$query = $sql->prepare("SELECT `filename` FROM `userdata_social_providers` WHERE `resellerID`=0 AND `active`='Y'");
|
||||
$query->execute();
|
||||
foreach ($query->fetchAll(PDO::FETCH_ASSOC) as $row) {
|
||||
$serviceProviders[$row['filename']] = strtolower($row['filename']);
|
||||
}
|
||||
|
||||
if (count($serviceProviders) > 0) {
|
||||
$htmlExtraInformation['css'][] = '<link href="' . $page_data->pageurl . '/css/default/social_buttons.css" rel="stylesheet">';
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($page_lookupid)) {
|
||||
|
||||
$query = $sql->prepare("SELECT `cname`,`name`,`vname`,`lastlogin` FROM `userdata` WHERE `id`=? LIMIT 1");
|
||||
$query->execute(array($page_lookupid));
|
||||
|
||||
foreach ($query->fetchAll(PDO::FETCH_ASSOC) as $row) {
|
||||
$great_name = $row['name'];
|
||||
$great_vname = $row['vname'];
|
||||
@ -272,13 +291,20 @@ if (isset($page_active) and $page_active == 'Y') {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!isset($s) and !isset($page_category) and isset($page_default) and isid($page_default,19)) {
|
||||
|
||||
if (!isset($s) and !isset($page_category) and isset($page_default) and isid($page_default, 19)) {
|
||||
|
||||
$s = 'page';
|
||||
$default_page_id = $page_default;
|
||||
|
||||
} else if (!isset($s) and !isset($page_category) and isset($page_default)) {
|
||||
|
||||
$s = $page_default;
|
||||
|
||||
} else if (!isset($s) and isset($page_category) and $page_category != '' and $page_category != null) {
|
||||
|
||||
$s = 404;
|
||||
$throw404 = true;
|
||||
|
||||
}
|
||||
}
|
@ -103,16 +103,55 @@ if (isset($registration) and in_array($registration, array('A', 'M', 'D'))) {
|
||||
$selectlanguages = getlanguages($template_to_use);
|
||||
|
||||
// default values in case an input error appears so that the user only needs to enter false data
|
||||
$mail = $ui->ismail('mail', 'post');
|
||||
$password = $ui->password('password', 100, 'post');
|
||||
$passwordsecond = $ui->password('passwordsecond', 100, 'post');
|
||||
$name = $ui->names('name',255, 'post');
|
||||
$vname = $ui->names('vname',255, 'post');
|
||||
$vname = $ui->names('vname',255, 'post');
|
||||
$bday = date('Y-m-d', strtotime($ui->isDate('birthday', 'post')));
|
||||
$cname = $ui->username('cname', 255, 'post');
|
||||
if (!$ui->escaped('mail', 'post') and !$ui->escaped('password', 'post') and isset($_SESSION['serviceProviderData'])) {
|
||||
|
||||
$bdayShow = (isset($user_language) and $user_language == 'de') ? date('d.m.Y', strtotime($ui->isDate('birthday', 'post'))) : date('Y-m-d', strtotime($ui->isDate('birthday', 'post')));
|
||||
$streetn = '';
|
||||
$fax = '';
|
||||
$handy = '';
|
||||
$password = '';
|
||||
$passwordsecond = '';
|
||||
|
||||
$userProfile = $_SESSION['serviceProviderData']['userProfile'];
|
||||
|
||||
$displayNameSplit = preg_split("/\s/", $userProfile['displayName'], -1, PREG_SPLIT_NO_EMPTY);
|
||||
$vname = (strlen($userProfile['firstName']) == 0 and isset($displayNameSplit[0]) and strlen($displayNameSplit[0]) > 0) ? $displayNameSplit[0] : $userProfile['firstName'];
|
||||
$name = (strlen($userProfile['lastName']) == 0 and isset($displayNameSplit[1]) and strlen($displayNameSplit[1]) > 0) ? $displayNameSplit[1] : $userProfile['lastName'];
|
||||
$cname = str_replace(' ', '', $userProfile['displayName']);
|
||||
|
||||
$salutation = ($userProfile['gender'] == 'female') ? 2 : 1;
|
||||
|
||||
$bday = $userProfile['birthYear'] . '-' . $userProfile['birthMonth'] . '-' . $userProfile['birthDay'];
|
||||
$bdayShow = (isset($user_language) and $user_language == 'de') ? date('d.m.Y', strtotime($bday)) : date('Y-m-d', strtotime($bday));
|
||||
|
||||
$mail = $userProfile['email'];
|
||||
$flagmenu = $userProfile['language'];
|
||||
$phone = $userProfile['phone'];
|
||||
$city = $userProfile['city'];
|
||||
$cityn = $userProfile['zip'];
|
||||
$street = $userProfile['address'];
|
||||
|
||||
} else {
|
||||
|
||||
$mail = $ui->ismail('mail', 'post');
|
||||
$password = $ui->password('password', 100, 'post');
|
||||
$passwordsecond = $ui->password('passwordsecond', 100, 'post');
|
||||
$name = $ui->names('name',255, 'post');
|
||||
$vname = $ui->names('vname',255, 'post');
|
||||
$bday = date('Y-m-d', strtotime($ui->isDate('birthday', 'post')));
|
||||
$cname = $ui->username('cname', 255, 'post');
|
||||
$salutation = $ui->id('salutation', 1, 'post');
|
||||
$flagmenu = $ui->st('flagmenu', 'post');
|
||||
$phone = $ui->phone('phone', 50, 'post');
|
||||
$fax = $ui->phone('fax', 50, 'post');
|
||||
$handy = $ui->phone('handy', 50, 'post');
|
||||
$city = $ui->names('city', 50, 'post');
|
||||
$cityn = $ui->id('cityn', 6, 'post');
|
||||
$street = $ui->names('street', 50, 'post');
|
||||
$streetn = $ui->w('streetn', 6, 'post');
|
||||
|
||||
$bdayShow = (isset($user_language) and $user_language == 'de') ? date('d.m.Y', strtotime($ui->isDate('birthday', 'post'))) : date('Y-m-d', strtotime($ui->isDate('birthday', 'post')));
|
||||
|
||||
}
|
||||
|
||||
$query = $sql->prepare("SELECT `lang`,`text` FROM `translations` WHERE `type`='to'");
|
||||
$query->execute();
|
||||
@ -218,7 +257,7 @@ if (isset($registration) and in_array($registration, array('A', 'M', 'D'))) {
|
||||
|
||||
// insert data
|
||||
$query = $sql->prepare("INSERT INTO `userdata` (`accounttype`,`active`,`mail`,`token`,`creationTime`,`updateTime`,`salutation`,`country`,`name`,`vname`,`birthday`,`phone`,`fax`,`handy`,`city`,`cityn`,`street`,`streetn`) VALUES ('u','R',?,?,NOW(),NOW(),?,?,?,?,?,?,?,?,?,?,?,?)");
|
||||
$query->execute(array($mail, $activeHash, $ui->id('salutation', 1, 'post'), $ui->st('country', 'post'), $name, $vname, $bday, $ui->phone('phone', 50, 'post'), $ui->phone('fax', 50, 'post'), $ui->phone('handy', 50, 'post'), $ui->names('city', 50, 'post'), $ui->id('cityn', 6, 'post'), $ui->names('street', 50, 'post'), $ui->w('streetn', 6, 'post')));
|
||||
$query->execute(array($mail, $activeHash, $salutation, $flagmenu, $name, $vname, $bday, $phone, $fax, $handy, $city, $cityn, $street, $streetn));
|
||||
|
||||
$userID = $sql->lastInsertId();
|
||||
|
||||
@ -241,38 +280,72 @@ if (isset($registration) and in_array($registration, array('A', 'M', 'D'))) {
|
||||
$groupID = $query->fetchColumn();
|
||||
|
||||
$query = $sql->prepare("INSERT INTO `userdata_groups` (`userID`,`groupID`,`resellerID`) VALUES (?,?,0)");
|
||||
$query->execute(array($userID,$groupID));
|
||||
$query->execute(array($userID, $groupID));
|
||||
|
||||
// If is is in DB and mail could be send
|
||||
// If usergroup is in DB and mail could be send
|
||||
if ($query->rowCount() > 0) {
|
||||
if ($registration == 'A') {
|
||||
|
||||
if (isset($_SESSION['serviceProviderData'])) {
|
||||
|
||||
$query = $sql->prepare("INSERT INTO `userdata_social_identities` (`userID`,`serviceProviderID`,`serviceUserID`,`resellerID`) VALUES (?,?,?,0)");
|
||||
$query->execute(array($userID, $_SESSION['serviceProviderData']['serviceProviderID'], $_SESSION['serviceProviderData']['userProfile']['identifier']));
|
||||
|
||||
$directLogin = true;
|
||||
|
||||
} else if ($registration == 'A') {
|
||||
|
||||
$template_file = $page_sprache->registerAdmin;
|
||||
|
||||
} else if ($registration == 'M') {
|
||||
|
||||
$template_file = $page_sprache->registerMailSend;
|
||||
|
||||
$activationLink = $page_data->pages['register']['link'];
|
||||
$activationLink .= ($page_data->seo == 'Y') ? 'activate/' . $activeHash.'/' : '&activate=' . $activeHash;
|
||||
$activationLink .= ($page_data->seo == 'Y') ? 'activate/' . $activeHash . '/' : '&activate=' . $activeHash;
|
||||
|
||||
// send Mail
|
||||
sendmail('emailregister',$userID,'', $activationLink);
|
||||
|
||||
} else {
|
||||
$directLogin = true;
|
||||
}
|
||||
|
||||
if (isset($directLogin)) {
|
||||
|
||||
$query = $sql->prepare("UPDATE `userdata` SET `active`='Y',`token`=null,`updateTime`=NOW() WHERE `id`=? LIMIT 1");
|
||||
$query->execute(array($userID));
|
||||
|
||||
$_SESSION['userid'] = $userID;
|
||||
$_SESSION['resellerid'] = 0;
|
||||
$template_file = $page_sprache->registerAccountOK;
|
||||
|
||||
$header = '<meta http-equiv="refresh" content="3; URL=' . $page_data->pageurl . '/userpanel.php">';
|
||||
$text = $rsprache->refresh;
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
$error[] = $page_sprache->registerErrorUnknown;
|
||||
$token = md5(date('Y-d-m H:i:s u') . md5(mt_rand()));
|
||||
|
||||
$_SESSION['registerToken'] = $token;
|
||||
|
||||
$template_file = 'page_register.tpl';
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
} else if ($ui->escaped('email', 'post')) {
|
||||
|
||||
$template_file = $page_sprache->registerErrorBot;
|
||||
|
||||
} else {
|
||||
|
||||
$token = md5(date('Y-d-m H:i:s u').md5(mt_rand()));
|
||||
$_SESSION['registerToken'] = $token;
|
||||
$template_file = 'page_register.tpl';
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -1114,18 +1114,30 @@ $query = "CREATE TABLE IF NOT EXISTS `userdata` (
|
||||
`externalID` varchar(255) DEFAULT NULL,
|
||||
`sourceSystemID` varchar(255) NULL,
|
||||
`resellerid` int(10) unsigned DEFAULT 0,
|
||||
PRIMARY KEY (`id`),KEY(`resellerid`)
|
||||
PRIMARY KEY (`id`),KEY(`active`),KEY(`resellerid`)
|
||||
) ENGINE=InnoDB";
|
||||
$add = $sql->prepare($query);
|
||||
$add->execute();
|
||||
|
||||
#https://github.com/easy-wi/developer/issues/5
|
||||
$query = "CREATE TABLE IF NOT EXISTS `userdata_value_log` (
|
||||
#https://github.com/easy-wi/developer/issues/1
|
||||
$query = "CREATE TABLE IF NOT EXISTS `userdata_social_identities` (
|
||||
`userID` int(10) unsigned NOT NULL,
|
||||
`date` datetime NOT NULL,
|
||||
`json` text NOT NULL,
|
||||
`serviceProviderID` int(10) unsigned NOT NULL,
|
||||
`serviceUserID` varchar(255) DEFAULT NULL,
|
||||
`resellerID` int(10) unsigned DEFAULT 0,
|
||||
KEY (`userID`),KEY(`resellerID`)
|
||||
PRIMARY KEY (`userID`,`serviceProviderID`,`serviceUserID`),KEY(`resellerID`)
|
||||
) ENGINE=InnoDB";
|
||||
$add = $sql->prepare($query);
|
||||
$add->execute();
|
||||
|
||||
$query = "CREATE TABLE IF NOT EXISTS `userdata_social_providers` (
|
||||
`serviceProviderID` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`active` enum('Y','N') NOT NULL DEFAULT 'Y',
|
||||
`identifier` varchar(255) DEFAULT NULL,
|
||||
`token` varchar(255) DEFAULT NULL,
|
||||
`filename` varchar(255) DEFAULT NULL,
|
||||
`resellerID` int(10) unsigned DEFAULT 0,
|
||||
PRIMARY KEY (`serviceProviderID`),KEY(`resellerID`)
|
||||
) ENGINE=InnoDB";
|
||||
$add = $sql->prepare($query);
|
||||
$add->execute();
|
||||
@ -1170,6 +1182,17 @@ $query = "CREATE TABLE IF NOT EXISTS `userdata_groups` (
|
||||
$add = $sql->prepare($query);
|
||||
$add->execute();
|
||||
|
||||
#https://github.com/easy-wi/developer/issues/5
|
||||
$query = "CREATE TABLE IF NOT EXISTS `userdata_value_log` (
|
||||
`userID` int(10) unsigned NOT NULL,
|
||||
`date` datetime NOT NULL,
|
||||
`json` text NOT NULL,
|
||||
`resellerID` int(10) unsigned DEFAULT 0,
|
||||
KEY (`userID`),KEY(`resellerID`)
|
||||
) ENGINE=InnoDB";
|
||||
$add = $sql->prepare($query);
|
||||
$add->execute();
|
||||
|
||||
$query = "CREATE TABLE IF NOT EXISTS `usergroups` (
|
||||
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
`defaultgroup` enum('Y','N') DEFAULT 'N',
|
||||
|
@ -43,7 +43,8 @@ if (!isset($displayToUser) and (!isset($admin_id) or $main != 1 or $reseller_id
|
||||
die('No acces');
|
||||
}
|
||||
|
||||
$defined['addons'] = array('id' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
|
||||
$defined['addons'] = array(
|
||||
'id' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
|
||||
'active' => array("Type"=>"enum('Y','N')","Null"=>"NO","Key"=>"","Default"=>"N","Extra"=>""),
|
||||
'paddon' => array("Type"=>"enum('Y','N')","Null"=>"YES","Key"=>"","Default"=>"N","Extra"=>""),
|
||||
'addon' => array("Type"=>"varchar(15)","Null"=>"NO","Key"=>"","Default"=>"","Extra"=>""),
|
||||
@ -57,12 +58,14 @@ $defined['addons'] = array('id' => array("Type"=>"int(10) unsigned","Null"=>"NO"
|
||||
'resellerid' => array("Type"=>"int(10) unsigned","Null"=>"YES","Key"=>"MUL","Default"=>"0","Extra"=>"")
|
||||
);
|
||||
|
||||
$defined['addons_allowed'] = array('addon_id' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>""),
|
||||
$defined['addons_allowed'] = array(
|
||||
'addon_id' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>""),
|
||||
'servertype_id' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>""),
|
||||
'reseller_id' => array("Type"=>"int(10) unsigned","Null"=>"YES","Key"=>"MUL","Default"=>"0","Extra"=>"")
|
||||
);
|
||||
|
||||
$defined['addons_installed'] = array('id' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
|
||||
$defined['addons_installed'] = array(
|
||||
'id' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
|
||||
'userid' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"MUL","Default"=>"","Extra"=>""),
|
||||
'addonid' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"MUL","Default"=>"","Extra"=>""),
|
||||
'serverid' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"MUL","Default"=>"","Extra"=>""),
|
||||
@ -71,11 +74,13 @@ $defined['addons_installed'] = array('id' => array("Type"=>"int(10) unsigned","N
|
||||
'resellerid' => array("Type"=>"int(10) unsigned","Null"=>"YES","Key"=>"MUL","Default"=>"0","Extra"=>"")
|
||||
);
|
||||
|
||||
$defined['api_ips'] = array('ip' => array("Type"=>"varchar(15)","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>""),
|
||||
$defined['api_ips'] = array(
|
||||
'ip' => array("Type"=>"varchar(15)","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>""),
|
||||
'resellerID' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"0","Extra"=>"")
|
||||
);
|
||||
|
||||
$defined['api_settings'] = array('resellerID' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>""),
|
||||
$defined['api_settings'] = array(
|
||||
'resellerID' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>""),
|
||||
'userID' => array("Type"=>"int(10) unsigned","Null"=>"YES","Key"=>"MUL","Default"=>"","Extra"=>""),
|
||||
'active' => array("Type"=>"enum('Y','N')","Null"=>"NO","Key"=>"","Default"=>"N","Extra"=>""),
|
||||
'user' => array("Type"=>"varchar(255)","Null"=>"NO","Key"=>"","Default"=>"","Extra"=>""),
|
||||
@ -93,7 +98,8 @@ $defined['api_external_auth'] = array(
|
||||
'resellerID' => array("Type"=>"int(10) unsigned","Null"=>"YES","Key"=>"MUL","Default"=>"0","Extra"=>"")
|
||||
);
|
||||
|
||||
$defined['api_import'] = array('importID' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
|
||||
$defined['api_import'] = array(
|
||||
'importID' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
|
||||
'active' => array("Type"=>"enum('Y','N')","Null"=>"NO","Key"=>"","Default"=>"Y","Extra"=>""),
|
||||
'fetchUpdates' => array("Type"=>"enum('Y','N')","Null"=>"NO","Key"=>"","Default"=>"Y","Extra"=>""),
|
||||
'token' => array("Type"=>"varchar(255)","Null"=>"NO","Key"=>"","Default"=>"","Extra"=>""),
|
||||
@ -107,19 +113,22 @@ $defined['api_import'] = array('importID' => array("Type"=>"int(10) unsigned","N
|
||||
'resellerID' => array("Type"=>"int(10) unsigned","Null"=>"YES","Key"=>"MUL","Default"=>"0","Extra"=>"")
|
||||
);
|
||||
|
||||
$defined['badips'] = array('id' => array("Type"=>"bigint(19) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
|
||||
$defined['badips'] = array(
|
||||
'id' => array("Type"=>"bigint(19) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
|
||||
'badip' => array("Type"=>"varchar(15)","Null"=>"NO","Key"=>"","Default"=>"","Extra"=>""),
|
||||
'bantime' => array("Type"=>"datetime","Null"=>"NO","Key"=>"","Default"=>"","Extra"=>""),
|
||||
'failcount' => array("Type"=>"smallint(2) unsigned","Null"=>"YES","Key"=>"","Default"=>"0","Extra"=>""),
|
||||
'reason' => array("Type"=>"varchar(15)","Null"=>"NO","Key"=>"","Default"=>"","Extra"=>"")
|
||||
);
|
||||
|
||||
$defined['custom_columns'] = array('customID' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>""),
|
||||
$defined['custom_columns'] = array(
|
||||
'customID' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>""),
|
||||
'itemID' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>""),
|
||||
'var' => array("Type"=>"varchar(255)","Null"=>"NO","Key"=>"","Default"=>"","Extra"=>"")
|
||||
);
|
||||
|
||||
$defined['custom_columns_settings'] = array('customID' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
|
||||
$defined['custom_columns_settings'] = array(
|
||||
'customID' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
|
||||
'active' => array("Type"=>"enum('Y','N')","Null"=>"NO","Key"=>"","Default"=>"Y","Extra"=>""),
|
||||
'item' => array("Type"=>"enum('D','G','S','T','U','V')","Null"=>"NO","Key"=>"MUL","Default"=>"","Extra"=>""),
|
||||
'type' => array("Type"=>"enum('I','V')","Null"=>"NO","Key"=>"","Default"=>"","Extra"=>""),
|
||||
@ -127,7 +136,8 @@ $defined['custom_columns_settings'] = array('customID' => array("Type"=>"int(10)
|
||||
'name' => array("Type"=>"varchar(255)","Null"=>"NO","Key"=>"","Default"=>"","Extra"=>"")
|
||||
);
|
||||
|
||||
$defined['rootsDedicated'] = array('dedicatedID' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
|
||||
$defined['rootsDedicated'] = array(
|
||||
'dedicatedID' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
|
||||
'active' => array("Type"=>"enum('Y','N')","Null"=>"YES","Key"=>"","Default"=>"Y","Extra"=>""),
|
||||
'status' => array("Type"=>"smallint(1) unsigned","Null"=>"YES","Key"=>"","Default"=>"","Extra"=>""),
|
||||
'userID' => array("Type"=>"int(10) unsigned","Null"=>"YES","Key"=>"MUL","Default"=>"","Extra"=>""),
|
||||
@ -153,7 +163,8 @@ $defined['rootsDedicated'] = array('dedicatedID' => array("Type"=>"int(10) unsig
|
||||
'resellerID' => array("Type"=>"int(10) unsigned","Null"=>"YES","Key"=>"MUL","Default"=>"0","Extra"=>"")
|
||||
);
|
||||
|
||||
$defined['rootsDHCP'] = array('id' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
|
||||
$defined['rootsDHCP'] = array(
|
||||
'id' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
|
||||
'active' => array("Type"=>"enum('Y','N')","Null"=>"YES","Key"=>"","Default"=>"Y","Extra"=>""),
|
||||
'ip' => array("Type"=>"varchar(15)","Null"=>"YES","Key"=>"","Default"=>"","Extra"=>""),
|
||||
'port' => array("Type"=>"blob","Null"=>"YES","Key"=>"","Default"=>"","Extra"=>""),
|
||||
@ -178,7 +189,8 @@ $defined['rootsIP4'] = array(
|
||||
'resellerID' => array("Type"=>"int(10) unsigned","Null"=>"YES","Key"=>"MUL","Default"=>"0","Extra"=>"")
|
||||
);
|
||||
|
||||
$defined['rootsPXE'] = array('id' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
|
||||
$defined['rootsPXE'] = array(
|
||||
'id' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
|
||||
'active' => array("Type"=>"enum('Y','N')","Null"=>"YES","Key"=>"","Default"=>"Y","Extra"=>""),
|
||||
'ip' => array("Type"=>"varchar(15)","Null"=>"YES","Key"=>"","Default"=>"","Extra"=>""),
|
||||
'port' => array("Type"=>"blob","Null"=>"YES","Key"=>"","Default"=>"","Extra"=>""),
|
||||
@ -204,7 +216,8 @@ $defined['rootsSubnets'] = array(
|
||||
'vlanName' => array("Type"=>"varchar(255)","Null"=>"YES","Key"=>"","Default"=>"","Extra"=>"")
|
||||
);
|
||||
|
||||
$defined['eac'] = array('id' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
|
||||
$defined['eac'] = array(
|
||||
'id' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
|
||||
'active' => array("Type"=>"enum('Y','N')","Null"=>"YES","Key"=>"","Default"=>"N","Extra"=>""),
|
||||
'ip' => array("Type"=>"varchar(15)","Null"=>"YES","Key"=>"","Default"=>"","Extra"=>""),
|
||||
'port' => array("Type"=>"blob","Null"=>"YES","Key"=>"","Default"=>"","Extra"=>""),
|
||||
@ -230,13 +243,15 @@ $defined['eac'] = array('id' => array("Type"=>"int(10) unsigned","Null"=>"NO","K
|
||||
'resellerid' => array("Type"=>"int(10) unsigned","Null"=>"YES","Key"=>"MUL","Default"=>"0","Extra"=>"")
|
||||
);
|
||||
|
||||
$defined['easywi_version'] = array('id' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
|
||||
$defined['easywi_version'] = array(
|
||||
'id' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
|
||||
'version' => array("Type"=>"decimal(4,2)","Null"=>"NO","Key"=>"","Default"=>"3.30","Extra"=>""),
|
||||
'de' => array("Type"=>"text","Null"=>"YES","Key"=>"","Default"=>"","Extra"=>""),
|
||||
'en' => array("Type"=>"text","Null"=>"YES","Key"=>"","Default"=>"","Extra"=>"")
|
||||
);
|
||||
|
||||
$defined['feeds_news'] = array('newsID' => array("Type"=>"bigint(19) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
|
||||
$defined['feeds_news'] = array(
|
||||
'newsID' => array("Type"=>"bigint(19) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
|
||||
'feedID' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"MUL","Default"=>"0","Extra"=>""),
|
||||
'active' => array("Type"=>"enum('Y','N')","Null"=>"YES","Key"=>"","Default"=>"Y","Extra"=>""),
|
||||
'title' => array("Type"=>"varchar(255)","Null"=>"NO","Key"=>"","Default"=>"","Extra"=>""),
|
||||
@ -248,7 +263,8 @@ $defined['feeds_news'] = array('newsID' => array("Type"=>"bigint(19) unsigned","
|
||||
'resellerID' => array("Type"=>"int(10) unsigned","Null"=>"YES","Key"=>"MUL","Default"=>"0","Extra"=>"")
|
||||
);
|
||||
|
||||
$defined['feeds_settings'] = array('settingsID' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
|
||||
$defined['feeds_settings'] = array(
|
||||
'settingsID' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
|
||||
'active' => array("Type"=>"enum('Y','N')","Null"=>"YES","Key"=>"","Default"=>"Y","Extra"=>""),
|
||||
'merge' => array("Type"=>"enum('Y','N')","Null"=>"YES","Key"=>"","Default"=>"Y","Extra"=>""),
|
||||
'displayContent' => array("Type"=>"enum('Y','N')","Null"=>"YES","Key"=>"","Default"=>"N","Extra"=>""),
|
||||
@ -264,7 +280,8 @@ $defined['feeds_settings'] = array('settingsID' => array("Type"=>"int(10) unsign
|
||||
'resellerID' => array("Type"=>"int(10) unsigned","Null"=>"YES","Key"=>"MUL","Default"=>"0","Extra"=>"")
|
||||
);
|
||||
|
||||
$defined['feeds_url'] = array('feedID' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
|
||||
$defined['feeds_url'] = array(
|
||||
'feedID' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
|
||||
'active' => array("Type"=>"enum('Y','N')","Null"=>"YES","Key"=>"","Default"=>"Y","Extra"=>""),
|
||||
'twitter' => array("Type"=>"enum('Y','N')","Null"=>"YES","Key"=>"","Default"=>"N","Extra"=>""),
|
||||
'feedUrl' => array("Type"=>"varchar(255)","Null"=>"YES","Key"=>"","Default"=>"","Extra"=>""),
|
||||
@ -273,7 +290,8 @@ $defined['feeds_url'] = array('feedID' => array("Type"=>"int(10) unsigned","Null
|
||||
'resellerID' => array("Type"=>"int(10) unsigned","Null"=>"YES","Key"=>"MUL","Default"=>"0","Extra"=>"")
|
||||
);
|
||||
|
||||
$defined['gserver_file_templates'] = array('templateID' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
|
||||
$defined['gserver_file_templates'] = array(
|
||||
'templateID' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
|
||||
'userID' => array("Type"=>"int(10) unsigned","Null"=>"YES","Key"=>"MUL","Default"=>"","Extra"=>""),
|
||||
'servertype' => array("Type"=>"varchar(255)","Null"=>"YES","Key"=>"","Default"=>"","Extra"=>""),
|
||||
'name' => array("Type"=>"varchar(255)","Null"=>"NO","Key"=>"","Default"=>"","Extra"=>""),
|
||||
@ -281,7 +299,8 @@ $defined['gserver_file_templates'] = array('templateID' => array("Type"=>"int(10
|
||||
'resellerID' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"MUL","Default"=>"0","Extra"=>"")
|
||||
);
|
||||
|
||||
$defined['gserver_restarts'] = array('id' => array("Type"=>"bigint(19) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
|
||||
$defined['gserver_restarts'] = array(
|
||||
'id' => array("Type"=>"bigint(19) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
|
||||
'template' => array("Type"=>"smallint(1) unsigned","Null"=>"NO","Key"=>"","Default"=>"","Extra"=>""),
|
||||
'anticheat' => array("Type"=>"smallint(1) unsigned","Null"=>"YES","Key"=>"","Default"=>"1","Extra"=>""),
|
||||
'protected' => array("Type"=>"enum('Y','N')","Null"=>"YES","Key"=>"","Default"=>"N","Extra"=>""),
|
||||
@ -298,7 +317,8 @@ $defined['gserver_restarts'] = array('id' => array("Type"=>"bigint(19) unsigned"
|
||||
'resellerid' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"MUL","Default"=>"0","Extra"=>"")
|
||||
);
|
||||
|
||||
$defined['gsswitch'] = array('id' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
|
||||
$defined['gsswitch'] = array(
|
||||
'id' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
|
||||
'active' => array("Type"=>"enum('Y','N')","Null"=>"NO","Key"=>"","Default"=>"Y","Extra"=>""),
|
||||
'autoRestart' => array("Type"=>"enum('Y','N')","Null"=>"YES","Key"=>"","Default"=>"Y","Extra"=>""),
|
||||
'userid' => array("Type"=>"int(10) unsigned","Null"=>"YES","Key"=>"MUL","Default"=>"0","Extra"=>""),
|
||||
@ -345,13 +365,15 @@ $defined['gsswitch'] = array('id' => array("Type"=>"int(10) unsigned","Null"=>"N
|
||||
'resellerid' => array("Type"=>"int(10) unsigned","Null"=>"YES","Key"=>"MUL","Default"=>"0","Extra"=>"")
|
||||
);
|
||||
|
||||
$defined['imprints'] = array('id' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
|
||||
$defined['imprints'] = array(
|
||||
'id' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
|
||||
'language' => array("Type"=>"varchar(2)","Null"=>"NO","Key"=>"","Default"=>"","Extra"=>""),
|
||||
'imprint' => array("Type"=>"text","Null"=>"YES","Key"=>"","Default"=>"","Extra"=>""),
|
||||
'resellerid' => array("Type"=>"int(10) unsigned","Null"=>"YES","Key"=>"MUL","Default"=>"0","Extra"=>"")
|
||||
);
|
||||
|
||||
$defined['jobs'] = array('jobID' => array("Type"=>"bigint(19) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
|
||||
$defined['jobs'] = array(
|
||||
'jobID' => array("Type"=>"bigint(19) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
|
||||
'hostID' => array("Type"=>"int(10) unsigned","Null"=>"YES","Key"=>"MUL","Default"=>"0","Extra"=>""),
|
||||
'affectedID' => array("Type"=>"int(10) unsigned","Null"=>"YES","Key"=>"MUL","Default"=>"0","Extra"=>""),
|
||||
'userID' => array("Type"=>"int(10) unsigned","Null"=>"YES","Key"=>"MUL","Default"=>"0","Extra"=>""),
|
||||
@ -366,7 +388,8 @@ $defined['jobs'] = array('jobID' => array("Type"=>"bigint(19) unsigned","Null"=>
|
||||
'resellerID' => array("Type"=>"int(10) unsigned","Null"=>"YES","Key"=>"MUL","Default"=>"0","Extra"=>"")
|
||||
);
|
||||
|
||||
$defined['lendedserver'] = array('id' => array("Type"=>"bigint(19) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
|
||||
$defined['lendedserver'] = array(
|
||||
'id' => array("Type"=>"bigint(19) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
|
||||
'serverid' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"MUL","Default"=>"","Extra"=>""),
|
||||
'servertype' => array("Type"=>"varchar(1)","Null"=>"NO","Key"=>"","Default"=>"g","Extra"=>""),
|
||||
'rcon' => array("Type"=>"varchar(60)","Null"=>"YES","Key"=>"","Default"=>"","Extra"=>""),
|
||||
@ -379,7 +402,8 @@ $defined['lendedserver'] = array('id' => array("Type"=>"bigint(19) unsigned","Nu
|
||||
'resellerid' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"MUL","Default"=>"0","Extra"=>"")
|
||||
);
|
||||
|
||||
$defined['lendsettings'] = array('id' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
|
||||
$defined['lendsettings'] = array(
|
||||
'id' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
|
||||
'activeGS' => array("Type"=>"enum('A','R','B','N')","Null"=>"NO","Key"=>"","Default"=>"N","Extra"=>""),
|
||||
'activeVS' => array("Type"=>"enum('A','R','B','N')","Null"=>"NO","Key"=>"","Default"=>"N","Extra"=>""),
|
||||
'userGame' => array("Type"=>"enum('A','B','R')","Null"=>"NO","Key"=>"","Default"=>"B","Extra"=>""),
|
||||
@ -418,7 +442,8 @@ $defined['lendsettings'] = array('id' => array("Type"=>"int(10) unsigned","Null"
|
||||
'oldcheck' => array("Type"=>"datetime","Null"=>"NO","Key"=>"","Default"=>"","Extra"=>"")
|
||||
);
|
||||
|
||||
$defined['lendstats'] = array('lendDate' => array("Type"=>"datetime","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>""),
|
||||
$defined['lendstats'] = array(
|
||||
'lendDate' => array("Type"=>"datetime","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>""),
|
||||
'serverID' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>""),
|
||||
'serverType' => array("Type"=>"enum('v','g')","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>""),
|
||||
'lendtime' => array("Type"=>"smallint(3) unsigned","Null"=>"NO","Key"=>"","Default"=>"","Extra"=>""),
|
||||
@ -426,7 +451,8 @@ $defined['lendstats'] = array('lendDate' => array("Type"=>"datetime","Null"=>"NO
|
||||
'resellerID' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"MUL","Default"=>"","Extra"=>"")
|
||||
);
|
||||
|
||||
$defined['mail_log'] = array('id' => array("Type"=>"bigint(19) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
|
||||
$defined['mail_log'] = array(
|
||||
'id' => array("Type"=>"bigint(19) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
|
||||
'uid' => array("Type"=>"int(10) unsigned","Null"=>"YES","Key"=>"MUL","Default"=>"","Extra"=>""),
|
||||
'topic' => array("Type"=>"varchar(255)","Null"=>"NO","Key"=>"","Default"=>"","Extra"=>""),
|
||||
'date' => array("Type"=>"datetime","Null"=>"NO","Key"=>"","Default"=>"","Extra"=>""),
|
||||
@ -434,7 +460,8 @@ $defined['mail_log'] = array('id' => array("Type"=>"bigint(19) unsigned","Null"=
|
||||
);
|
||||
|
||||
#https://github.com/easy-wi/developer/issues/61 add module management
|
||||
$defined['modules'] = array('id' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
|
||||
$defined['modules'] = array(
|
||||
'id' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
|
||||
'get' => array("Type"=>"varchar(255)","Null"=>"NO","Key"=>"","Default"=>"","Extra"=>""),
|
||||
'file' => array("Type"=>"varchar(255)","Null"=>"NO","Key"=>"","Default"=>"","Extra"=>""),
|
||||
'sub' => array("Type"=>"varchar(2)","Null"=>"NO","Key"=>"","Default"=>"","Extra"=>""),
|
||||
@ -443,7 +470,8 @@ $defined['modules'] = array('id' => array("Type"=>"int(10) unsigned","Null"=>"NO
|
||||
);
|
||||
|
||||
#https://github.com/easy-wi/developer/issues/42 column description added
|
||||
$defined['mysql_external_dbs'] = array('id' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
|
||||
$defined['mysql_external_dbs'] = array(
|
||||
'id' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
|
||||
'active' => array("Type"=>"enum('Y','N')","Null"=>"YES","Key"=>"","Default"=>"Y","Extra"=>""),
|
||||
'sid' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"MUL","Default"=>"","Extra"=>""),
|
||||
'uid' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"MUL","Default"=>"","Extra"=>""),
|
||||
@ -462,7 +490,8 @@ $defined['mysql_external_dbs'] = array('id' => array("Type"=>"int(10) unsigned",
|
||||
'resellerid' => array("Type"=>"int(10) unsigned","Null"=>"YES","Key"=>"MUL","Default"=>"0","Extra"=>"")
|
||||
);
|
||||
|
||||
$defined['mysql_external_servers'] = array('id' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
|
||||
$defined['mysql_external_servers'] = array(
|
||||
'id' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
|
||||
'active' => array("Type"=>"enum('Y','N')","Null"=>"YES","Key"=>"","Default"=>"Y","Extra"=>""),
|
||||
'ip' => array("Type"=>"varchar(15)","Null"=>"NO","Key"=>"","Default"=>"","Extra"=>""),
|
||||
'port' => array("Type"=>"smallint(5) unsigned","Null"=>"YES","Key"=>"","Default"=>"3306","Extra"=>""),
|
||||
@ -477,7 +506,8 @@ $defined['mysql_external_servers'] = array('id' => array("Type"=>"int(10) unsign
|
||||
'resellerid' => array("Type"=>"int(10) unsigned","Null"=>"YES","Key"=>"MUL","Default"=>"0","Extra"=>"")
|
||||
);
|
||||
|
||||
$defined['page_comments'] = array('commentID' => array("Type"=>"bigint(19) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
|
||||
$defined['page_comments'] = array(
|
||||
'commentID' => array("Type"=>"bigint(19) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
|
||||
'pageTextID' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"MUL","Default"=>"","Extra"=>""),
|
||||
'replyTo' => array("Type"=>"bigint(19) unsigned","Null"=>"YES","Key"=>"MUL","Default"=>"","Extra"=>""),
|
||||
'date' => array("Type"=>"datetime","Null"=>"NO","Key"=>"","Default"=>"","Extra"=>""),
|
||||
@ -493,7 +523,8 @@ $defined['page_comments'] = array('commentID' => array("Type"=>"bigint(19) unsig
|
||||
'resellerID' => array("Type"=>"int(10) unsigned","Null"=>"YES","Key"=>"MUL","Default"=>"0","Extra"=>"")
|
||||
);
|
||||
|
||||
$defined['page_downloads'] = array('fileID' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
|
||||
$defined['page_downloads'] = array(
|
||||
'fileID' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
|
||||
'show' => array("Type"=>"enum('A','R','N','E')","Null"=>"YES","Key"=>"","Default"=>"E","Extra"=>""),
|
||||
'order' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"MUL","Default"=>"","Extra"=>""),
|
||||
'count' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"","Default"=>"","Extra"=>""),
|
||||
@ -504,14 +535,16 @@ $defined['page_downloads'] = array('fileID' => array("Type"=>"int(10) unsigned",
|
||||
'resellerID' => array("Type"=>"int(10) unsigned","Null"=>"YES","Key"=>"MUL","Default"=>"0","Extra"=>"")
|
||||
);
|
||||
|
||||
$defined['page_downloads_log'] = array('fileID' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"MUL","Default"=>"","Extra"=>""),
|
||||
$defined['page_downloads_log'] = array(
|
||||
'fileID' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"MUL","Default"=>"","Extra"=>""),
|
||||
'date' => array("Type"=>"datetime","Null"=>"YES","Key"=>"","Default"=>"","Extra"=>""),
|
||||
'ip' => array("Type"=>"varchar(15)","Null"=>"YES","Key"=>"","Default"=>"","Extra"=>""),
|
||||
'hostname' => array("Type"=>"varchar(255)","Null"=>"YES","Key"=>"","Default"=>"","Extra"=>""),
|
||||
'resellerID' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"MUL","Default"=>"","Extra"=>"")
|
||||
);
|
||||
|
||||
$defined['page_pages'] = array('id' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
|
||||
$defined['page_pages'] = array(
|
||||
'id' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
|
||||
'subpage' => array("Type"=>"int(10) unsigned","Null"=>"YES","Key"=>"MUL","Default"=>"","Extra"=>""),
|
||||
'released' => array("Type"=>"smallint(1) unsigned","Null"=>"YES","Key"=>"","Default"=>"1","Extra"=>""),
|
||||
'sort' => array("Type"=>"int(10) unsigned","Null"=>"YES","Key"=>"","Default"=>"","Extra"=>""),
|
||||
@ -525,7 +558,8 @@ $defined['page_pages'] = array('id' => array("Type"=>"int(10) unsigned","Null"=>
|
||||
'resellerid' => array("Type"=>"int(10) unsigned","Null"=>"YES","Key"=>"MUL","Default"=>"0","Extra"=>"")
|
||||
);
|
||||
|
||||
$defined['page_pages_text'] = array('id' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
|
||||
$defined['page_pages_text'] = array(
|
||||
'id' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
|
||||
'pageid' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"MUL","Default"=>"","Extra"=>""),
|
||||
'language' => array("Type"=>"varchar(2)","Null"=>"NO","Key"=>"","Default"=>"","Extra"=>""),
|
||||
'title' => array("Type"=>"varchar(255)","Null"=>"YES","Key"=>"","Default"=>"","Extra"=>""),
|
||||
@ -534,12 +568,14 @@ $defined['page_pages_text'] = array('id' => array("Type"=>"int(10) unsigned","Nu
|
||||
'resellerid' => array("Type"=>"int(10) unsigned","Null"=>"YES","Key"=>"MUL","Default"=>"0","Extra"=>"")
|
||||
);
|
||||
|
||||
$defined['page_register_questions'] = array('id' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
|
||||
$defined['page_register_questions'] = array(
|
||||
'id' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
|
||||
'question' => array("Type"=>"varchar(255)","Null"=>"YES","Key"=>"","Default"=>"","Extra"=>""),
|
||||
'answer' => array("Type"=>"varchar(255)","Null"=>"YES","Key"=>"","Default"=>"","Extra"=>"")
|
||||
);
|
||||
|
||||
$defined['page_settings'] = array('id' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
|
||||
$defined['page_settings'] = array(
|
||||
'id' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
|
||||
'seo' => array("Type"=>"enum('Y','N')","Null"=>"YES","Key"=>"","Default"=>"N","Extra"=>""),
|
||||
'rssfeed' => array("Type"=>"enum('Y','N')","Null"=>"YES","Key"=>"","Default"=>"Y","Extra"=>""),
|
||||
'rssfeed_fulltext' => array("Type"=>"enum('Y','N')","Null"=>"YES","Key"=>"","Default"=>"Y","Extra"=>""),
|
||||
@ -566,7 +602,8 @@ $defined['page_settings'] = array('id' => array("Type"=>"int(10) unsigned","Null
|
||||
'resellerid' => array("Type"=>"int(10) unsigned","Null"=>"YES","Key"=>"MUL","Default"=>"0","Extra"=>"")
|
||||
);
|
||||
|
||||
$defined['page_terms'] = array('id' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
|
||||
$defined['page_terms'] = array(
|
||||
'id' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
|
||||
'language' => array("Type"=>"varchar(2)","Null"=>"NO","Key"=>"","Default"=>"","Extra"=>""),
|
||||
'name' => array("Type"=>"varchar(255)","Null"=>"YES","Key"=>"","Default"=>"","Extra"=>""),
|
||||
'search_name' => array("Type"=>"varchar(255)","Null"=>"YES","Key"=>"","Default"=>"","Extra"=>""),
|
||||
@ -576,13 +613,15 @@ $defined['page_terms'] = array('id' => array("Type"=>"int(10) unsigned","Null"=>
|
||||
'resellerid' => array("Type"=>"int(10) unsigned","Null"=>"YES","Key"=>"MUL","Default"=>"0","Extra"=>"")
|
||||
);
|
||||
|
||||
$defined['page_terms_used'] = array('page_id' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"0","Extra"=>""),
|
||||
$defined['page_terms_used'] = array(
|
||||
'page_id' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"0","Extra"=>""),
|
||||
'term_id' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"0","Extra"=>""),
|
||||
'language_id' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"0","Extra"=>""),
|
||||
'resellerid' => array("Type"=>"int(10) unsigned","Null"=>"YES","Key"=>"MUL","Default"=>"0","Extra"=>"")
|
||||
);
|
||||
|
||||
$defined['resellerdata'] = array('id' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
|
||||
$defined['resellerdata'] = array(
|
||||
'id' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
|
||||
'useractive' => array("Type"=>"enum('Y','N')","Null"=>"NO","Key"=>"","Default"=>"Y","Extra"=>""),
|
||||
'ips' => array("Type"=>"text","Null"=>"YES","Key"=>"","Default"=>"","Extra"=>""),
|
||||
'maxuser' => array("Type"=>"int(10) unsigned","Null"=>"YES","Key"=>"","Default"=>"","Extra"=>""),
|
||||
@ -596,7 +635,8 @@ $defined['resellerdata'] = array('id' => array("Type"=>"int(10) unsigned","Null"
|
||||
'resellersid' => array("Type"=>"int(10) unsigned","Null"=>"YES","Key"=>"MUL","Default"=>"","Extra"=>"")
|
||||
);
|
||||
|
||||
$defined['resellerimages'] = array('id' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
|
||||
$defined['resellerimages'] = array(
|
||||
'id' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
|
||||
'active' => array("Type"=>"enum('Y','N')","Null"=>"NO","Key"=>"","Default"=>"Y","Extra"=>""),
|
||||
'distro' => array("Type"=>"varchar(50)","Null"=>"NO","Key"=>"","Default"=>"","Extra"=>""),
|
||||
'description' => array("Type"=>"varchar(255)","Null"=>"NO","Key"=>"","Default"=>"","Extra"=>""),
|
||||
@ -604,7 +644,8 @@ $defined['resellerimages'] = array('id' => array("Type"=>"int(10) unsigned","Nul
|
||||
'pxelinux' => array("Type"=>"text","Null"=>"YES","Key"=>"","Default"=>"","Extra"=>"")
|
||||
);
|
||||
|
||||
$defined['rserverdata'] = array('id' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
|
||||
$defined['rserverdata'] = array(
|
||||
'id' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
|
||||
'active' => array("Type"=>"enum('Y','N')","Null"=>"NO","Key"=>"","Default"=>"Y","Extra"=>""),
|
||||
'hyperthreading' => array("Type"=>"enum('Y','N')","Null"=>"YES","Key"=>"","Default"=>"N","Extra"=>""),
|
||||
'cores' => array("Type"=>"smallint(3) unsigned","Null"=>"YES","Key"=>"","Default"=>"4","Extra"=>""),
|
||||
@ -635,7 +676,8 @@ $defined['rserverdata'] = array('id' => array("Type"=>"int(10) unsigned","Null"=
|
||||
'resellerid' => array("Type"=>"int(10) unsigned","Null"=>"YES","Key"=>"MUL","Default"=>"0","Extra"=>"")
|
||||
);
|
||||
|
||||
$defined['rservermasterg'] = array('id' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
|
||||
$defined['rservermasterg'] = array(
|
||||
'id' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
|
||||
'serverid' => array("Type"=>"varchar(11)","Null"=>"NO","Key"=>"","Default"=>"","Extra"=>""),
|
||||
'servertypeid' => array("Type"=>"int(10) unsigned","Null"=>"YES","Key"=>"MUL","Default"=>"","Extra"=>""),
|
||||
'localVersion' => array("Type"=>"varchar(255)","Null"=>"YES","Key"=>"","Default"=>"","Extra"=>""),
|
||||
@ -645,7 +687,8 @@ $defined['rservermasterg'] = array('id' => array("Type"=>"int(10) unsigned","Nul
|
||||
'resellerid' => array("Type"=>"int(10) unsigned","Null"=>"YES","Key"=>"MUL","Default"=>"0","Extra"=>"")
|
||||
);
|
||||
|
||||
$defined['serverlist'] = array('id' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
|
||||
$defined['serverlist'] = array(
|
||||
'id' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
|
||||
'switchID' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"MUL","Default"=>"","Extra"=>""),
|
||||
'servertype' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"MUL","Default"=>"","Extra"=>""),
|
||||
'anticheat' => array("Type"=>"smallint(1) unsigned","Null"=>"YES","Key"=>"","Default"=>"1","Extra"=>""),
|
||||
@ -671,7 +714,8 @@ $defined['serverlist'] = array('id' => array("Type"=>"int(10) unsigned","Null"=>
|
||||
'uploaddir' => array("Type"=>"blob","Null"=>"YES","Key"=>"","Default"=>"","Extra"=>""),
|
||||
'resellerid' => array("Type"=>"int(10) unsigned","Null"=>"YES","Key"=>"MUL","Default"=>"0","Extra"=>"")
|
||||
);
|
||||
$defined['servertypes'] = array('id' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
|
||||
$defined['servertypes'] = array(
|
||||
'id' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
|
||||
'steamgame' => array("Type"=>"enum('Y','N','S')","Null"=>"NO","Key"=>"","Default"=>"Y","Extra"=>""),
|
||||
'appID' => array("Type"=>"int(10) unsigned","Null"=>"YES","Key"=>"MUL","Default"=>"","Extra"=>""),
|
||||
'steamVersion' => array("Type"=>"varchar(255)","Null"=>"YES","Key"=>"","Default"=>"","Extra"=>""),
|
||||
@ -712,7 +756,8 @@ $defined['servertypes'] = array('id' => array("Type"=>"int(10) unsigned","Null"=
|
||||
'resellerid' => array("Type"=>"int(10) unsigned","Null"=>"YES","Key"=>"MUL","Default"=>"0","Extra"=>"")
|
||||
);
|
||||
|
||||
$defined['settings'] = array('id' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
|
||||
$defined['settings'] = array(
|
||||
'id' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
|
||||
'version' => array("Type"=>"decimal(4,2)","Null"=>"YES","Key"=>"","Default"=>"4.30","Extra"=>""),
|
||||
'releasenotesDE' => array("Type"=>"int(11) unsigned","Null"=>"YES","Key"=>"","Default"=>"","Extra"=>""),
|
||||
'releasenotesEN' => array("Type"=>"int(11) unsigned","Null"=>"YES","Key"=>"","Default"=>"","Extra"=>""),
|
||||
@ -771,7 +816,8 @@ $defined['settings'] = array('id' => array("Type"=>"int(10) unsigned","Null"=>"N
|
||||
'resellerid' => array("Type"=>"int(10) unsigned","Null"=>"YES","Key"=>"MUL","Default"=>"0","Extra"=>"")
|
||||
);
|
||||
|
||||
$defined['tickets'] = array('id' => array("Type"=>"bigint(19) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
|
||||
$defined['tickets'] = array(
|
||||
'id' => array("Type"=>"bigint(19) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
|
||||
'writedate' => array("Type"=>"datetime","Null"=>"YES","Key"=>"","Default"=>"","Extra"=>""),
|
||||
'topic' => array("Type"=>"varchar(30)","Null"=>"YES","Key"=>"","Default"=>"","Extra"=>""),
|
||||
'userid' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"MUL","Default"=>"","Extra"=>""),
|
||||
@ -784,21 +830,24 @@ $defined['tickets'] = array('id' => array("Type"=>"bigint(19) unsigned","Null"=>
|
||||
'resellerid' => array("Type"=>"int(11) unsigned","Null"=>"YES","Key"=>"","Default"=>"0","Extra"=>"")
|
||||
);
|
||||
|
||||
$defined['tickets_text'] = array('ticketID' => array("Type"=>"bigint(19) unsigned","Null"=>"YES","Key"=>"MUL","Default"=>"","Extra"=>""),
|
||||
$defined['tickets_text'] = array(
|
||||
'ticketID' => array("Type"=>"bigint(19) unsigned","Null"=>"YES","Key"=>"MUL","Default"=>"","Extra"=>""),
|
||||
'writeDate' => array("Type"=>"datetime","Null"=>"YES","Key"=>"","Default"=>"","Extra"=>""),
|
||||
'userID' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"MUL","Default"=>"","Extra"=>""),
|
||||
'message' => array("Type"=>"text","Null"=>"YES","Key"=>"","Default"=>"","Extra"=>""),
|
||||
'resellerID' => array("Type"=>"int(11) unsigned","Null"=>"YES","Key"=>"","Default"=>"0","Extra"=>"")
|
||||
);
|
||||
|
||||
$defined['ticket_topics'] = array('id' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
|
||||
$defined['ticket_topics'] = array(
|
||||
'id' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
|
||||
'topic' => array("Type"=>"varchar(30)","Null"=>"NO","Key"=>"","Default"=>"","Extra"=>""),
|
||||
'maintopic' => array("Type"=>"int(10) unsigned","Null"=>"YES","Key"=>"","Default"=>"","Extra"=>""),
|
||||
'priority' => array("Type"=>"smallint(1) unsigned","Null"=>"YES","Key"=>"","Default"=>"","Extra"=>""),
|
||||
'resellerid' => array("Type"=>"int(10) unsigned","Null"=>"YES","Key"=>"MUL","Default"=>"0","Extra"=>"")
|
||||
);
|
||||
|
||||
$defined['traffic_data'] = array('id' => array("Type"=>"bigint(19) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
|
||||
$defined['traffic_data'] = array(
|
||||
'id' => array("Type"=>"bigint(19) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
|
||||
'serverid' => array("Type"=>"bigint(19) unsigned","Null"=>"YES","Key"=>"MUL","Default"=>"","Extra"=>""),
|
||||
'ip' => array("Type"=>"varchar(15)","Null"=>"YES","Key"=>"","Default"=>"","Extra"=>""),
|
||||
'in' => array("Type"=>"bigint(19) unsigned","Null"=>"YES","Key"=>"","Default"=>"0","Extra"=>""),
|
||||
@ -808,7 +857,8 @@ $defined['traffic_data'] = array('id' => array("Type"=>"bigint(19) unsigned","Nu
|
||||
'resellerid' => array("Type"=>"bigint(19) unsigned","Null"=>"YES","Key"=>"MUL","Default"=>"0","Extra"=>"")
|
||||
);
|
||||
|
||||
$defined['traffic_data_day'] = array('id' => array("Type"=>"bigint(19) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
|
||||
$defined['traffic_data_day'] = array(
|
||||
'id' => array("Type"=>"bigint(19) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
|
||||
'serverid' => array("Type"=>"bigint(19) unsigned","Null"=>"YES","Key"=>"MUL","Default"=>"","Extra"=>""),
|
||||
'ip' => array("Type"=>"varchar(15)","Null"=>"YES","Key"=>"","Default"=>"","Extra"=>""),
|
||||
'in' => array("Type"=>"bigint(19) unsigned","Null"=>"YES","Key"=>"","Default"=>"0","Extra"=>""),
|
||||
@ -818,7 +868,8 @@ $defined['traffic_data_day'] = array('id' => array("Type"=>"bigint(19) unsigned"
|
||||
'resellerid' => array("Type"=>"bigint(19) unsigned","Null"=>"YES","Key"=>"MUL","Default"=>"0","Extra"=>"")
|
||||
);
|
||||
|
||||
$defined['traffic_settings'] = array('id' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
|
||||
$defined['traffic_settings'] = array(
|
||||
'id' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
|
||||
'type' => array("Type"=>"varchar(30)","Null"=>"NO","Key"=>"","Default"=>"mysql","Extra"=>""),
|
||||
'statip' => array("Type"=>"varchar(50)","Null"=>"YES","Key"=>"","Default"=>"","Extra"=>""),
|
||||
'dbname' => array("Type"=>"blob","Null"=>"YES","Key"=>"","Default"=>"","Extra"=>""),
|
||||
@ -853,17 +904,19 @@ $defined['traffic_settings'] = array('id' => array("Type"=>"int(10) unsigned","N
|
||||
'line_colour_3' => array("Type"=>"smallint(3) unsigned","Null"=>"YES","Key"=>"","Default"=>"220","Extra"=>"")
|
||||
);
|
||||
|
||||
$defined['translations'] = array('type' => array("Type"=>"varchar(2)","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>""),
|
||||
$defined['translations'] = array(
|
||||
'type' => array("Type"=>"varchar(2)","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>""),
|
||||
'lang' => array("Type"=>"varchar(2)","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>""),
|
||||
'transID' => array("Type"=>"varchar(255)","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>""),
|
||||
'resellerID' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"0","Extra"=>""),
|
||||
'text' => array("Type"=>"text","Null"=>"YES","Key"=>"","Default"=>"","Extra"=>"")
|
||||
);
|
||||
|
||||
$defined['userdata'] = array('id' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
|
||||
$defined['userdata'] = array(
|
||||
'id' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
|
||||
'creationTime' => array("Type"=>"datetime","Null"=>"YES","Key"=>"","Default"=>"","Extra"=>""),
|
||||
'updateTime' => array("Type"=>"datetime","Null"=>"YES","Key"=>"","Default"=>"","Extra"=>""),
|
||||
'active' => array("Type"=>"enum('Y','N','R')","Null"=>"NO","Key"=>"","Default"=>"Y","Extra"=>""),
|
||||
'active' => array("Type"=>"enum('Y','N','R')","Null"=>"NO","Key"=>"MUL","Default"=>"Y","Extra"=>""),
|
||||
'salutation' => array("Type"=>"int(1)","Null"=>"YES","Key"=>"","Default"=>"","Extra"=>""),
|
||||
'cname' => array("Type"=>"varchar(255)","Null"=>"NO","Key"=>"","Default"=>"","Extra"=>""),
|
||||
'security' => array("Type"=>"varchar(255)","Null"=>"YES","Key"=>"","Default"=>"","Extra"=>""),
|
||||
@ -899,15 +952,26 @@ $defined['userdata'] = array('id' => array("Type"=>"int(10) unsigned","Null"=>"N
|
||||
'resellerid' => array("Type"=>"int(10) unsigned","Null"=>"YES","Key"=>"MUL","Default"=>"0","Extra"=>"")
|
||||
);
|
||||
|
||||
#https://github.com/easy-wi/developer/issues/5
|
||||
$defined['userdata_value_log'] = array('userID' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"MUL","Default"=>"","Extra"=>""),
|
||||
'date' => array("Type"=>"datetime","Null"=>"NO","Key"=>"","Default"=>"","Extra"=>""),
|
||||
'json' => array("Type"=>"text","Null"=>"NO","Key"=>"","Default"=>"","Extra"=>""),
|
||||
'resellerID' => array("Type"=>"int(10) unsigned","Null"=>"YES","Key"=>"MUL","Default"=>"0","Extra"=>"")
|
||||
#https://github.com/easy-wi/developer/issues/1
|
||||
$defined['userdata_social_identities'] = array(
|
||||
'userID' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>""),
|
||||
'serviceProviderID' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>""),
|
||||
'serviceUserID' => array("Type"=>"varchar(255)","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>""),
|
||||
'resellerID' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"MUL","Default"=>"0","Extra"=>"")
|
||||
);
|
||||
|
||||
$defined['userdata_social_providers'] = array(
|
||||
'serviceProviderID' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
|
||||
'active' => array("Type"=>"enum('Y','N')","Null"=>"NO","Key"=>"","Default"=>"Y","Extra"=>""),
|
||||
'identifier' => array("Type"=>"varchar(255)","Null"=>"NO","Key"=>"","Default"=>"","Extra"=>""),
|
||||
'token' => array("Type"=>"varchar(255)","Null"=>"NO","Key"=>"","Default"=>"","Extra"=>""),
|
||||
'filename' => array("Type"=>"varchar(255)","Null"=>"NO","Key"=>"","Default"=>"","Extra"=>""),
|
||||
'resellerID' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"MUL","Default"=>"0","Extra"=>"")
|
||||
);
|
||||
|
||||
#https://github.com/easy-wi/developer/issues/2
|
||||
$defined['userdata_substitutes'] = array('sID' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
|
||||
$defined['userdata_substitutes'] = array(
|
||||
'sID' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
|
||||
'userID' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>""),
|
||||
'active' => array("Type"=>"enum('Y','N')","Null"=>"NO","Key"=>"","Default"=>"Y","Extra"=>""),
|
||||
'loginName' => array("Type"=>"varchar(255)","Null"=>"NO","Key"=>"MUL","Default"=>"","Extra"=>""),
|
||||
@ -922,18 +986,30 @@ $defined['userdata_substitutes'] = array('sID' => array("Type"=>"int(10) unsigne
|
||||
'sourceSystemID' => array("Type"=>"varchar(255)","Null"=>"YES","Key"=>"","Default"=>"","Extra"=>""),
|
||||
'resellerID' => array("Type"=>"int(10) unsigned","Null"=>"YES","Key"=>"MUL","Default"=>"0","Extra"=>"")
|
||||
);
|
||||
$defined['userdata_substitutes_servers'] = array('sID' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>""),
|
||||
|
||||
$defined['userdata_substitutes_servers'] = array(
|
||||
'sID' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>""),
|
||||
'oType' => array("Type"=>"varchar(2)","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>""),
|
||||
'oID' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>""),
|
||||
'resellerID' => array("Type"=>"int(10) unsigned","Null"=>"YES","Key"=>"MUL","Default"=>"0","Extra"=>"")
|
||||
);
|
||||
|
||||
$defined['userdata_groups'] = array('userID' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>""),
|
||||
$defined['userdata_groups'] = array(
|
||||
'userID' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>""),
|
||||
'groupID' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>""),
|
||||
'resellerID' => array("Type"=>"int(10) unsigned","Null"=>"YES","Key"=>"MUL","Default"=>"0","Extra"=>"")
|
||||
);
|
||||
|
||||
$defined['usergroups'] = array('id' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
|
||||
#https://github.com/easy-wi/developer/issues/5
|
||||
$defined['userdata_value_log'] = array(
|
||||
'userID' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"MUL","Default"=>"","Extra"=>""),
|
||||
'date' => array("Type"=>"datetime","Null"=>"NO","Key"=>"","Default"=>"","Extra"=>""),
|
||||
'json' => array("Type"=>"text","Null"=>"NO","Key"=>"","Default"=>"","Extra"=>""),
|
||||
'resellerID' => array("Type"=>"int(10) unsigned","Null"=>"YES","Key"=>"MUL","Default"=>"0","Extra"=>"")
|
||||
);
|
||||
|
||||
$defined['usergroups'] = array(
|
||||
'id' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
|
||||
'defaultgroup' => array("Type"=>"enum('Y','N')","Null"=>"NO","Key"=>"","Default"=>"N","Extra"=>""),
|
||||
'active' => array("Type"=>"enum('Y','N')","Null"=>"YES","Key"=>"","Default"=>"Y","Extra"=>""),
|
||||
'name' => array("Type"=>"varchar(255)","Null"=>"YES","Key"=>"","Default"=>"","Extra"=>""),
|
||||
@ -994,7 +1070,8 @@ $defined['usergroups'] = array('id' => array("Type"=>"int(10) unsigned","Null"=>
|
||||
'resellerid' => array("Type"=>"int(10) unsigned","Null"=>"YES","Key"=>"MUL","Default"=>"0","Extra"=>"")
|
||||
);
|
||||
|
||||
$defined['userlog'] = array('id' => array("Type"=>"bigint(19) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
|
||||
$defined['userlog'] = array(
|
||||
'id' => array("Type"=>"bigint(19) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
|
||||
'userid' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"MUL","Default"=>"","Extra"=>""),
|
||||
'subuser' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"MUL","Default"=>"","Extra"=>""),
|
||||
'reseller' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"MUL","Default"=>"","Extra"=>""),
|
||||
@ -1007,7 +1084,8 @@ $defined['userlog'] = array('id' => array("Type"=>"bigint(19) unsigned","Null"=>
|
||||
'resellerid' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"MUL","Default"=>"","Extra"=>"")
|
||||
);
|
||||
|
||||
$defined['userpermissions'] = array('id' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
|
||||
$defined['userpermissions'] = array(
|
||||
'id' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
|
||||
'userid' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"MUL","Default"=>"","Extra"=>""),
|
||||
'root' => array("Type"=>"enum('Y','N')","Null"=>"YES","Key"=>"","Default"=>"N","Extra"=>""),
|
||||
'miniroot' => array("Type"=>"enum('Y','N')","Null"=>"YES","Key"=>"","Default"=>"N","Extra"=>""),
|
||||
@ -1063,7 +1141,8 @@ $defined['userpermissions'] = array('id' => array("Type"=>"int(10) unsigned","Nu
|
||||
'resellerid' => array("Type"=>"int(10) unsigned","Null"=>"YES","Key"=>"MUL","Default"=>"0","Extra"=>"")
|
||||
);
|
||||
|
||||
$defined['virtualcontainer'] = array('id' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
|
||||
$defined['virtualcontainer'] = array(
|
||||
'id' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
|
||||
'imageid' => array("Type"=>"int(10) unsigned","Null"=>"YES","Key"=>"MUL","Default"=>"","Extra"=>""),
|
||||
'userid' => array("Type"=>"int(10) unsigned","Null"=>"YES","Key"=>"MUL","Default"=>"","Extra"=>""),
|
||||
'hostid' => array("Type"=>"int(10) unsigned","Null"=>"YES","Key"=>"MUL","Default"=>"","Extra"=>""),
|
||||
@ -1090,7 +1169,8 @@ $defined['virtualcontainer'] = array('id' => array("Type"=>"int(10) unsigned","N
|
||||
'resellerid' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"MUL","Default"=>"0","Extra"=>"")
|
||||
);
|
||||
|
||||
$defined['virtualhosts'] = array('id' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
|
||||
$defined['virtualhosts'] = array(
|
||||
'id' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
|
||||
'active' => array("Type"=>"enum('Y','N')","Null"=>"NO","Key"=>"","Default"=>"Y","Extra"=>""),
|
||||
'esxi' => array("Type"=>"enum('Y','N')","Null"=>"YES","Key"=>"","Default"=>"N","Extra"=>""),
|
||||
'ip' => array("Type"=>"varchar(15)","Null"=>"NO","Key"=>"","Default"=>"","Extra"=>""),
|
||||
@ -1113,7 +1193,8 @@ $defined['virtualhosts'] = array('id' => array("Type"=>"int(10) unsigned","Null"
|
||||
'resellerid' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"MUL","Default"=>"0","Extra"=>"")
|
||||
);
|
||||
|
||||
$defined['voice_dns'] = array('dnsID' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
|
||||
$defined['voice_dns'] = array(
|
||||
'dnsID' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
|
||||
'active' => array("Type"=>"enum('Y','N')","Null"=>"YES","Key"=>"","Default"=>"Y","Extra"=>""),
|
||||
'dns' => array("Type"=>"varchar(255)","Null"=>"YES","Key"=>"","Default"=>"","Extra"=>""),
|
||||
'ip' => array("Type"=>"varchar(15)","Null"=>"YES","Key"=>"","Default"=>"","Extra"=>""),
|
||||
@ -1126,7 +1207,8 @@ $defined['voice_dns'] = array('dnsID' => array("Type"=>"int(10) unsigned","Null"
|
||||
);
|
||||
|
||||
// https://github.com/easy-wi/developer/issues/36 managedServer,managedForID added
|
||||
$defined['voice_masterserver'] = array('id' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
|
||||
$defined['voice_masterserver'] = array(
|
||||
'id' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
|
||||
'active' => array("Type"=>"enum('Y','N')","Null"=>"YES","Key"=>"","Default"=>"Y","Extra"=>""),
|
||||
'type' => array("Type"=>"varchar(30)","Null"=>"NO","Key"=>"","Default"=>"ts3","Extra"=>""),
|
||||
'usedns' => array("Type"=>"enum('Y','N')","Null"=>"YES","Key"=>"","Default"=>"Y","Extra"=>""),
|
||||
@ -1167,7 +1249,8 @@ $defined['voice_masterserver'] = array('id' => array("Type"=>"int(10) unsigned",
|
||||
'resellerid' => array("Type"=>"int(10) unsigned","Null"=>"YES","Key"=>"MUL","Default"=>"0","Extra"=>"")
|
||||
);
|
||||
|
||||
$defined['voice_server'] = array('id' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
|
||||
$defined['voice_server'] = array(
|
||||
'id' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
|
||||
'active' => array("Type"=>"enum('Y','N')","Null"=>"YES","Key"=>"","Default"=>"Y","Extra"=>""),
|
||||
'autoRestart' => array("Type"=>"enum('Y','N')","Null"=>"YES","Key"=>"","Default"=>"Y","Extra"=>""),
|
||||
'backup' => array("Type"=>"enum('Y','N')","Null"=>"YES","Key"=>"","Default"=>"Y","Extra"=>""),
|
||||
@ -1209,7 +1292,8 @@ $defined['voice_server'] = array('id' => array("Type"=>"int(10) unsigned","Null"
|
||||
'resellerid' => array("Type"=>"int(10) unsigned","Null"=>"YES","Key"=>"MUL","Default"=>"0","Extra"=>"")
|
||||
);
|
||||
|
||||
$defined['voice_server_backup'] = array('id' => array("Type"=>"bigint(19) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
|
||||
$defined['voice_server_backup'] = array(
|
||||
'id' => array("Type"=>"bigint(19) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
|
||||
'sid' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"MUL","Default"=>"","Extra"=>""),
|
||||
'uid' => array("Type"=>"int(10) unsigned","Null"=>"YES","Key"=>"MUL","Default"=>"","Extra"=>""),
|
||||
'name' => array("Type"=>"varchar(50)","Null"=>"YES","Key"=>"","Default"=>"","Extra"=>""),
|
||||
@ -1219,7 +1303,8 @@ $defined['voice_server_backup'] = array('id' => array("Type"=>"bigint(19) unsign
|
||||
'resellerid' => array("Type"=>"int(10) unsigned","Null"=>"YES","Key"=>"MUL","Default"=>"0","Extra"=>"")
|
||||
);
|
||||
|
||||
$defined['voice_server_stats'] = array('sid' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>""),
|
||||
$defined['voice_server_stats'] = array(
|
||||
'sid' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>""),
|
||||
'date' => array("Type"=>"datetime","Null"=>"NO","Key"=>"PRI","Default"=>"0000-00-00 00:00:00","Extra"=>""),
|
||||
'mid' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"MUL","Default"=>"","Extra"=>""),
|
||||
'installed' => array("Type"=>"decimal(6,2) unsigned","Null"=>"NO","Key"=>"","Default"=>"","Extra"=>""),
|
||||
@ -1230,7 +1315,8 @@ $defined['voice_server_stats'] = array('sid' => array("Type"=>"int(10) unsigned"
|
||||
'resellerid' => array("Type"=>"int(10) unsigned","Null"=>"YES","Key"=>"MUL","Default"=>"0","Extra"=>"")
|
||||
);
|
||||
|
||||
$defined['voice_server_stats_hours'] = array('sid' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>""),
|
||||
$defined['voice_server_stats_hours'] = array(
|
||||
'sid' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>""),
|
||||
'date' => array("Type"=>"datetime","Null"=>"NO","Key"=>"PRI","Default"=>"0000-00-00 00:00:00","Extra"=>""),
|
||||
'mid' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"MUL","Default"=>"","Extra"=>""),
|
||||
'installed' => array("Type"=>"decimal(6,2) unsigned","Null"=>"NO","Key"=>"","Default"=>"","Extra"=>""),
|
||||
@ -1241,7 +1327,8 @@ $defined['voice_server_stats_hours'] = array('sid' => array("Type"=>"int(10) uns
|
||||
'resellerid' => array("Type"=>"int(10) unsigned","Null"=>"YES","Key"=>"MUL","Default"=>"0","Extra"=>"")
|
||||
);
|
||||
|
||||
$defined['voice_stats_settings'] = array('id' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
|
||||
$defined['voice_stats_settings'] = array(
|
||||
'id' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
|
||||
'text_colour_1' => array("Type"=>"smallint(3) unsigned","Null"=>"YES","Key"=>"","Default"=>"0","Extra"=>""),
|
||||
'text_colour_2' => array("Type"=>"smallint(3) unsigned","Null"=>"YES","Key"=>"","Default"=>"0","Extra"=>""),
|
||||
'text_colour_3' => array("Type"=>"smallint(3) unsigned","Null"=>"YES","Key"=>"","Default"=>"0","Extra"=>""),
|
||||
@ -1263,7 +1350,8 @@ $defined['voice_stats_settings'] = array('id' => array("Type"=>"int(10) unsigned
|
||||
'resellerid' => array("Type"=>"int(10) unsigned","Null"=>"YES","Key"=>"MUL","Default"=>"0","Extra"=>"")
|
||||
);
|
||||
|
||||
$defined['voice_tsdns'] = array('id' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
|
||||
$defined['voice_tsdns'] = array(
|
||||
'id' => array("Type"=>"int(10) unsigned","Null"=>"NO","Key"=>"PRI","Default"=>"","Extra"=>"auto_increment"),
|
||||
'active' => array("Type"=>"enum('Y','N')","Null"=>"YES","Key"=>"","Default"=>"Y","Extra"=>""),
|
||||
'defaultdns' => array("Type"=>"varchar(255)","Null"=>"YES","Key"=>"","Default"=>"","Extra"=>""),
|
||||
'rootid' => array("Type"=>"int(10) unsigned","Null"=>"YES","Key"=>"MUL","Default"=>"","Extra"=>""),
|
||||
|
@ -239,7 +239,7 @@
|
||||
<div class="accordion-heading">
|
||||
<a class="accordion-toggle" data-toggle="collapse" data-parent="#accordionMenu" href="#collapseSeven"><i class="fa fa-users fa-fw"></i> <?php echo $gsprache->user;?></a>
|
||||
</div>
|
||||
<div id="collapseSeven" class="accordion-body collapse <?php if(in_array($ui->smallletters('w',255,'get'),array('us','ug')) or isset($customModules['us'][$ui->smallletters('w',255,'get')])) echo 'in';?>">
|
||||
<div id="collapseSeven" class="accordion-body collapse <?php if(in_array($ui->smallletters('w',255,'get'),array('up','us','ug')) or isset($customModules['us'][$ui->smallletters('w',255,'get')])) echo 'in';?>">
|
||||
<div class="accordion-inner">
|
||||
<ul class="nav nav-pills nav-stacked">
|
||||
<?php if($pa['user'] or $pa['user_users']) { ?>
|
||||
@ -248,6 +248,9 @@
|
||||
<?php if($pa['userGroups']) { ?>
|
||||
<li <?php if($ui->smallletters('w',255,'get')=='ug') echo 'class="active"';?>><a href="admin.php?w=ug"><?php echo $gsprache->groups;?></a></li>
|
||||
<?php } ?>
|
||||
<?php if($pa['root'] and $reseller_id==0) { ?>
|
||||
<li <?php if($ui->smallletters('w',255,'get')=='up') echo 'class="active"';?>><a href="admin.php?w=up">Social Auth Provider</a></li>
|
||||
<?php } ?>
|
||||
<?php foreach ($customModules['us'] as $k => $v) { echo '<li '; echo ($ui->smallletters('w',255,'get')==$k) ? 'class="active"' : ''; echo '><a href="admin.php?w='.$k.'">'.$v.'</a></li>'; }; ?>
|
||||
</ul>
|
||||
</div>
|
||||
|
62
web/template/default/admin_social_provider_add.tpl
Normal file
62
web/template/default/admin_social_provider_add.tpl
Normal file
@ -0,0 +1,62 @@
|
||||
<div class="row-fluid">
|
||||
<div class="span12">
|
||||
<ul class="breadcrumb">
|
||||
<li><a href="admin.php">Home</a> <span class="divider">/</span></li>
|
||||
<li><a href="admin.php?w=up">Social Auth Provider</a> <span class="divider">/</span></li>
|
||||
<li class="active"><?php echo $gsprache->add?></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<?php if (count($errors)>0){ ?>
|
||||
<div class="alert alert-error">
|
||||
<button type="button" class="close" data-dismiss="alert">×</button>
|
||||
<h4>Error(s)</h4>
|
||||
<?php echo implode(', ',$errors);?>
|
||||
</div>
|
||||
<?php }?>
|
||||
<div class="row-fluid">
|
||||
<div class="alert alert-info"><button type="button" class="close" data-dismiss="alert">×</button><?php echo $sprache->multipleHelperEndpoint; ?></div>
|
||||
<div class="span6">
|
||||
<form class="form-horizontal" action="admin.php?w=up&d=ad&r=up" onsubmit="return confirm('<?php echo $gsprache->sure; ?>');" method="post">
|
||||
<input type="hidden" name="token" value="<?php echo token();?>">
|
||||
<input type="hidden" name="action" value="ad">
|
||||
<div class="control-group">
|
||||
<label class="control-label<?php if(isset($errors['active'])) echo ' error';?>" for="inputActive"><?php echo $gsprache->active;?></label>
|
||||
<div class="controls">
|
||||
<select id="inputActive" name="active">
|
||||
<option value="Y"><?php echo $gsprache->yes;?></option>
|
||||
<option value="N" <?php if($active=='N') echo 'selected="selected"';?>><?php echo $gsprache->no;?></option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label<?php if(isset($errors['name'])) echo ' error';?>" for="inputName">Social Auth Provider</label>
|
||||
<div class="controls">
|
||||
<select id="inputName" name="name">
|
||||
<?php foreach($serviceProviders as $sp){ ?>
|
||||
<option<?php if($sp == $name) echo ' selected="selected"';?>><?php echo $sp;?></option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group<?php if(isset($errors['keyID'])) echo ' error';?>">
|
||||
<label class="control-label" for="inputKeyID">ID/Key</label>
|
||||
<div class="controls">
|
||||
<input id="inputKeyID" type="text" name="keyID" value="<?php echo $keyID;?>">
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group<?php if(isset($errors['providerToken'])) echo ' error';?>">
|
||||
<label class="control-label" for="inputToken">Token</label>
|
||||
<div class="controls">
|
||||
<input id="inputToken" type="text" name="providerToken" value="<?php echo $providerToken;?>">
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group pull-left">
|
||||
<label class="control-label" for="inputEdit"></label>
|
||||
<div class="controls">
|
||||
<button class="btn btn-primary" id="inputEdit" type="submit"><i class="icon-plus-sign icon-white"></i> <?php echo $gsprache->add;?></button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
32
web/template/default/admin_social_provider_dl.tpl
Normal file
32
web/template/default/admin_social_provider_dl.tpl
Normal file
@ -0,0 +1,32 @@
|
||||
<div class="row-fluid">
|
||||
<div class="span12">
|
||||
<ul class="breadcrumb">
|
||||
<li><a href="admin.php">Home</a> <span class="divider">/</span></li>
|
||||
<li><a href="admin.php?w=up">Social Auth Provider</a> <span class="divider">/</span></li>
|
||||
<li><?php echo $gsprache->del?> <span class="divider">/</span></li>
|
||||
<li class="active"><?php echo $name?></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row-fluid">
|
||||
<div class="span6">
|
||||
<dl class="dl-horizontal">
|
||||
<dt>Service Provider</dt>
|
||||
<dd><?php echo $name;?></dd>
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row-fluid">
|
||||
<div class="span6">
|
||||
<form class="form-horizontal" action="admin.php?w=up&d=dl&id=<?php echo $id;?>&r=up" onsubmit="return confirm('<?php echo $gsprache->sure; ?>');" method="post">
|
||||
<input type="hidden" name="token" value="<?php echo token();?>">
|
||||
<input type="hidden" name="action" value="dl">
|
||||
<div class="control-group pull-left">
|
||||
<label class="control-label" for="inputEdit"></label>
|
||||
<div class="controls">
|
||||
<button class="btn btn-danger pull-left" id="inputEdit" type="submit"><i class="fa fa-trash-o"></i> <?php echo $gsprache->del;?></button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
38
web/template/default/admin_social_provider_list.tpl
Normal file
38
web/template/default/admin_social_provider_list.tpl
Normal file
@ -0,0 +1,38 @@
|
||||
<div class="row-fluid">
|
||||
<div class="span12">
|
||||
<ul class="breadcrumb">
|
||||
<li><a href="admin.php">Home</a> <span class="divider">/</span></li>
|
||||
<li class="active">Social Auth Provider</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row-fluid">
|
||||
<div class="span6">
|
||||
Social Auth Provider <a href="admin.php?w=up&d=ad"<span class="btn btn-primary btn-mini"><i class="icon-white icon-plus-sign"></i></span></a>
|
||||
</div>
|
||||
</div>
|
||||
<hr>
|
||||
<div class="row-fluid">
|
||||
<div class="span11">
|
||||
<table class="table table-bordered table-hover table-striped footable">
|
||||
<thead>
|
||||
<tr>
|
||||
<th data-class="expand">Service Provider</th>
|
||||
<th data-hide="phone,tablet"><?php echo $gsprache->status;?></th>
|
||||
<th class="span1"><?php echo $gsprache->del;?></a></th>
|
||||
<th class="span1"><?php echo $gsprache->mod;?></a></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($table as $table_row) { ?>
|
||||
<tr>
|
||||
<td><?php echo $table_row['name'];?></a></td>
|
||||
<td><i class="<?php if($table_row['active']=='Y') echo 'icon-ok'; else echo 'icon-ban-circle';?>"></i></td>
|
||||
<td class="span1"><a href="admin.php?w=up&d=dl&id=<?php echo $table_row['id'];?>" ><span class="btn btn-mini btn-danger"><i class="fa fa-trash-o"></i></span></a></td>
|
||||
<td class="span1"><a href="admin.php?w=up&d=md&id=<?php echo $table_row['id'];?>" ><span class="btn btn-mini btn-primary"><i class="icon-white icon-edit"></i></span></a></td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
63
web/template/default/admin_social_provider_md.tpl
Normal file
63
web/template/default/admin_social_provider_md.tpl
Normal file
@ -0,0 +1,63 @@
|
||||
<div class="row-fluid">
|
||||
<div class="span12">
|
||||
<ul class="breadcrumb">
|
||||
<li><a href="admin.php">Home</a> <span class="divider">/</span></li>
|
||||
<li><a href="admin.php?w=up">Social Auth Provider</a> <span class="divider">/</span></li>
|
||||
<li><?php echo $gsprache->mod?> <span class="divider">/</span></li>
|
||||
<li class="active"><?php echo $name?></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<?php if (count($errors)>0){ ?>
|
||||
<div class="alert alert-error">
|
||||
<button type="button" class="close" data-dismiss="alert">×</button>
|
||||
<h4>Error(s)</h4>
|
||||
<?php echo implode(', ',$errors);?>
|
||||
</div>
|
||||
<?php }?>
|
||||
<div class="row-fluid">
|
||||
<div class="alert alert-info"><button type="button" class="close" data-dismiss="alert">×</button><?php echo $sprache->multipleHelperEndpoint; ?></div>
|
||||
<div class="span6">
|
||||
<form class="form-horizontal" action="admin.php?w=up&d=md&id=<?php echo $id;?>&r=up" onsubmit="return confirm('<?php echo $gsprache->sure; ?>');" method="post">
|
||||
<input type="hidden" name="token" value="<?php echo token();?>">
|
||||
<input type="hidden" name="action" value="md">
|
||||
<div class="control-group<?php if(isset($errors['active'])) echo ' error';?>">
|
||||
<label class="control-label" for="inputActive"><?php echo $gsprache->active;?></label>
|
||||
<div class="controls">
|
||||
<select id="inputActive" name="active">
|
||||
<option value="Y"><?php echo $gsprache->yes;?></option>
|
||||
<option value="N" <?php if($active=='N') echo 'selected="selected"';?>><?php echo $gsprache->no;?></option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group<?php if(isset($errors['name'])) echo ' error';?>">
|
||||
<label class="control-label" for="inputName">Social Auth Provider</label>
|
||||
<div class="controls">
|
||||
<select id="inputName" name="name">
|
||||
<?php foreach($serviceProviders as $sp){ ?>
|
||||
<option<?php if($sp == $name) echo ' selected="selected"';?>><?php echo $sp;?></option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group<?php if(isset($errors['keyID'])) echo ' error';?>">
|
||||
<label class="control-label" for="inputKeyID">ID/Key</label>
|
||||
<div class="controls">
|
||||
<input id="inputKeyID" type="text" name="keyID" value="<?php echo $keyID;?>">
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group<?php if(isset($errors['providerToken'])) echo ' error';?>">
|
||||
<label class="control-label" for="inputToken">Token</label>
|
||||
<div class="controls">
|
||||
<input id="inputToken" type="text" name="providerToken" value="<?php echo $providerToken;?>">
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group pull-left">
|
||||
<label class="control-label" for="inputEdit"></label>
|
||||
<div class="controls">
|
||||
<button class="btn btn-primary" id="inputEdit" type="submit"><i class="icon-edit icon-white"></i> <?php echo $gsprache->mod;?></button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
@ -11,6 +11,60 @@
|
||||
<div class="span11">
|
||||
<form class="form-horizontal" action="admin.php?w=su&r=su" onsubmit="return confirm('<?php echo $gsprache->sure;?>');" method="post">
|
||||
<input type="hidden" name="token" value="<?php echo token();?>">
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="mail_backup"><?php echo $sprache->mail_backup;?></label>
|
||||
<div class="controls">
|
||||
<input id="mail_backup" type="checkbox" name="mail_backup" value="Y" <?php if ($mail_backup=="Y") echo 'checked="checked"'; ?>>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="mail_serverdown"><?php echo $sprache->mail_serverdown;?></label>
|
||||
<div class="controls">
|
||||
<input id="mail_serverdown" type="checkbox" name="mail_serverdown" value="Y" <?php if ($mail_serverdown=="Y") echo 'checked="checked"'; ?>>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="mail_ticket"><?php echo $sprache->mail_ticket;?></label>
|
||||
<div class="controls">
|
||||
<input id="mail_ticket" type="checkbox" name="mail_ticket" value="Y" <?php if ($mail_ticket=="Y") echo 'checked="checked"'; ?>>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="inputMailUpdate"><?php echo $sprache->mail_gsupdate;?></label>
|
||||
<div class="controls">
|
||||
<input id="inputMailUpdate" type="checkbox" name="mail_gsupdate" value="Y" <?php if ($mail_gsupdate=="Y") echo 'checked="checked"'; ?>>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="inputMailSecurity"><?php echo $sprache->mail_securitybreach;?></label>
|
||||
<div class="controls">
|
||||
<input id="inputMailSecurity" type="checkbox" name="mail_securitybreach" value="Y" <?php if ($mail_securitybreach=="Y") echo 'checked="checked"'; ?>>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="inputMailVserver"><?php echo $sprache->mail_vserver;?></label>
|
||||
<div class="controls">
|
||||
<input id="inputMailVserver" type="checkbox" name="mail_vserver" value="Y" <?php if ($mail_vserver=="Y") echo 'checked="checked"'; ?>>
|
||||
</div>
|
||||
</div>
|
||||
<hr>
|
||||
<?php foreach($serviceProviders as $sp){ ?>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="sp<?php echo $sp['sp'];?>"><?php echo $sp['sp'];?></label>
|
||||
<div class="controls">
|
||||
<?php if (strlen($sp['spUserId'])==0){ ?>
|
||||
<a class="btn btn-block btn-social btn-<?php echo strtolower($sp['sp']);?> span10" href="login.php?serviceProvider=<?php echo $sp['sp'];?>" id="sp<?php echo $sp['sp'];?>">
|
||||
<i class="fa fa-<?php echo strtolower($sp['sp']);?>"></i> <?php echo $sprache->socialConnect.' '.$sp['sp'];?>
|
||||
</a>
|
||||
<?php } else { ?>
|
||||
<a class="btn btn-block btn-social btn-<?php echo strtolower($sp['sp']);?> span10" href="admin.php?w=su&spUser=<?php echo $sp['spUserId'];?>&spId=<?php echo $sp['spId'];?>&r=su" id="sp<?php echo $sp['sp'];?>">
|
||||
<i class="fa fa-<?php echo strtolower($sp['sp']);?>"></i> <?php echo $sprache->socialRemove.' '.$sp['sp'];?>
|
||||
</a>
|
||||
<?php } ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<?php if(count($serviceProviders) > 0 ) echo '<hr>';?>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="fname"><?php echo $sprache->fname;?></label>
|
||||
<div class="controls">
|
||||
@ -65,42 +119,6 @@
|
||||
<input class="span10" id="streetn" type="text" name="streetn" value="<?php echo $streetn;?>">
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="mail_backup"><?php echo $sprache->mail_backup;?></label>
|
||||
<div class="controls">
|
||||
<input id="mail_backup" type="checkbox" name="mail_backup" value="Y" <?php if ($mail_backup=="Y") echo 'checked="checked"'; ?>>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="mail_serverdown"><?php echo $sprache->mail_serverdown;?></label>
|
||||
<div class="controls">
|
||||
<input id="mail_serverdown" type="checkbox" name="mail_serverdown" value="Y" <?php if ($mail_serverdown=="Y") echo 'checked="checked"'; ?>>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="mail_ticket"><?php echo $sprache->mail_ticket;?></label>
|
||||
<div class="controls">
|
||||
<input id="mail_ticket" type="checkbox" name="mail_ticket" value="Y" <?php if ($mail_ticket=="Y") echo 'checked="checked"'; ?>>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="inputMailUpdate"><?php echo $sprache->mail_gsupdate;?></label>
|
||||
<div class="controls">
|
||||
<input id="inputMailUpdate" type="checkbox" name="mail_gsupdate" value="Y" <?php if ($mail_gsupdate=="Y") echo 'checked="checked"'; ?>>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="inputMailSecurity"><?php echo $sprache->mail_securitybreach;?></label>
|
||||
<div class="controls">
|
||||
<input id="inputMailSecurity" type="checkbox" name="mail_securitybreach" value="Y" <?php if ($mail_securitybreach=="Y") echo 'checked="checked"'; ?>>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="inputMailVserver"><?php echo $sprache->mail_vserver;?></label>
|
||||
<div class="controls">
|
||||
<input id="inputMailVserver" type="checkbox" name="mail_vserver" value="Y" <?php if ($mail_vserver=="Y") echo 'checked="checked"'; ?>>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="inputEdit"></label>
|
||||
<div class="controls">
|
||||
|
@ -11,11 +11,12 @@
|
||||
<meta name="author" content="">
|
||||
<link href="//netdna.bootstrapcdn.com/bootstrap/2.3.2/css/bootstrap.min.css" rel="stylesheet">
|
||||
<link href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
|
||||
<?php echo implode('',$htmlExtraInformation['css']);?>
|
||||
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" ></script>
|
||||
<script src="//netdna.bootstrapcdn.com/bootstrap/2.3.2/js/bootstrap.min.js"></script>
|
||||
<style type="text/css">
|
||||
body { padding-top: 40px;padding-bottom: 40px;background-color: #f5f5f5;}
|
||||
.form-signin { max-width: 300px;padding: 19px 29px 29px;margin: 0 auto 20px;background-color: #fff;border: 1px solid #e5e5e5;-webkit-border-radius: 5px;-moz-border-radius: 5px;border-radius: 5px;-webkit-box-shadow: 0 1px 2px rgba(0,0,0,.05); -moz-box-shadow: 0 1px 2px rgba(0,0,0,.05);box-shadow: 0 1px 2px rgba(0,0,0,.05);}
|
||||
.form-signin { max-width: <?php echo (count($serviceProviders)==0) ? '300px':'450px';?>;padding: 19px 29px 29px;margin: 0 auto 20px;background-color: #fff;border: 1px solid #e5e5e5;-webkit-border-radius: 5px;-moz-border-radius: 5px;border-radius: 5px;-webkit-box-shadow: 0 1px 2px rgba(0,0,0,.05); -moz-box-shadow: 0 1px 2px rgba(0,0,0,.05);box-shadow: 0 1px 2px rgba(0,0,0,.05);}
|
||||
.form-signin .form-signin-heading,
|
||||
.form-signin .checkbox { margin-bottom: 10px;}
|
||||
.checkbox { margin-bottom: 10px;text-align: right;}
|
||||
@ -26,8 +27,9 @@
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
<?php echo implode('',$htmlExtraInformation['js']);?>
|
||||
</head>
|
||||
<body>
|
||||
<body <?php echo implode(' ',$htmlExtraInformation['body']);?>>
|
||||
<div class="container">
|
||||
<form class="form-signin" action="login.php" method="post">
|
||||
<?php if (isset($sus)) { ?>
|
||||
@ -38,49 +40,54 @@
|
||||
<?php } else { ?>
|
||||
<h2 class="form-signin-heading"><?php echo $sprache->heading;?></h2>
|
||||
<?php if(isset($header)) echo '<div class="alert">'.$text.'</div>'; ?>
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<label class="control-label" for="inputUser"></label>
|
||||
<div class="input-prepend">
|
||||
<span class="add-on"><i class="icon-user"></i></span>
|
||||
<input name="username" id="inputUser" type="text" class="input-block-level" placeholder="<?php echo $sprache->user;?>" required >
|
||||
<div class="row-fluid">
|
||||
<div class="span6">
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<label class="control-label" for="inputUser"></label>
|
||||
<div class="input-prepend">
|
||||
<span class="add-on"><i class="icon-user"></i></span>
|
||||
<input name="username" id="inputUser" type="text" class="input-block-level" placeholder="<?php echo $sprache->user;?>" required >
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<label class="control-label" for="inputPassword"></label>
|
||||
<div class="input-prepend">
|
||||
<span class="add-on"><i class="icon-lock"></i></span>
|
||||
<input name="password" id="inputPassword" type="password" class="input-block-level" placeholder="<?php echo $sprache->password;?>" required >
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<label class="control-label" for="inputPassword"></label>
|
||||
<div class="input-prepend">
|
||||
<span class="add-on"><i class="icon-lock"></i></span>
|
||||
<input name="password" id="inputPassword" type="password" class="input-block-level" placeholder="<?php echo $sprache->password;?>" required >
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php if ($ewCfg['captcha']==1) { ?>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="inputCaptcha"></label>
|
||||
<div class="controls">
|
||||
<div class="input-prepend">
|
||||
<span class="add-on"><img src="images.php" alt="Captcha" /></span>
|
||||
<input name="captcha" id="inputCaptcha" type="text" class="input-block-level" placeholder="Captcha" pattern="^[\w]{4}$" required >
|
||||
<?php if ($ewCfg['captcha']==1) { ?>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="inputCaptcha"></label>
|
||||
<div class="controls">
|
||||
<div class="input-prepend">
|
||||
<span class="add-on"><img src="images.php" alt="Captcha" /></span>
|
||||
<input name="captcha" id="inputCaptcha" type="text" class="input-block-level" placeholder="Captcha" pattern="^[\w]{4}$" required >
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<div class="hide" aria-hidden="true">
|
||||
<input type="text" name="email">
|
||||
</div>
|
||||
<div class="row-fluid pull-left">
|
||||
<a class="btn" href="login.php?w=pr" >Lost PW</a>
|
||||
<button class="btn btn-primary">Login</button>
|
||||
</div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
<div class="span6">
|
||||
<?php foreach($serviceProviders as $k=>$css){ ?>
|
||||
<a class="btn btn-block btn-social btn-<?php echo $css;?>" href="login.php?serviceProvider=<?php echo $k;?>">
|
||||
<i class="fa fa-<?php echo $css;?>"></i> Sign in with <?php echo $k;?>
|
||||
</a>
|
||||
<?php } ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<div class="hide" aria-hidden="true">
|
||||
<input type="text" name="email">
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<button class="btn btn-large btn-primary" type="submit">Login</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group checkbox">
|
||||
<div class="controls">
|
||||
<a href="login.php?w=pr" ><?php echo $sprache->passwordr ;?></a>
|
||||
</div>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<hr>
|
||||
<div>
|
||||
© <a href="https://easy-wi.com" target="_blank" title="free gameserver, voiceserver, dedicated and virtualserver webinterface easy-wi.com">Easy-WI.com</a> 2011 - <?php echo date('Y'); ?>
|
||||
|
47
web/template/default/login_mutiple.tpl
Normal file
47
web/template/default/login_mutiple.tpl
Normal file
@ -0,0 +1,47 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<?php if(isset($header)) echo $header; ?>
|
||||
<title><?php if(isset($title)) echo $title; ?></title>
|
||||
<link rel="shortcut icon" href="images/favicon.png" type="image/png" />
|
||||
<meta name="robots" content="noindex" />
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta name="description" content="">
|
||||
<meta name="author" content="">
|
||||
<link href="//netdna.bootstrapcdn.com/bootstrap/2.3.2/css/bootstrap.min.css" rel="stylesheet">
|
||||
<link href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
|
||||
<?php echo implode('',$htmlExtraInformation['css']);?>
|
||||
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" ></script>
|
||||
<script src="//netdna.bootstrapcdn.com/bootstrap/2.3.2/js/bootstrap.min.js"></script>
|
||||
<style type="text/css">
|
||||
body { padding-top: 40px;padding-bottom: 40px;background-color: #f5f5f5;}
|
||||
.form-signin { max-width: 500px;padding: 19px 29px 29px;margin: 0 auto 20px;background-color: #fff;border: 1px solid #e5e5e5;-webkit-border-radius: 5px;-moz-border-radius: 5px;border-radius: 5px;-webkit-box-shadow: 0 1px 2px rgba(0,0,0,.05); -moz-box-shadow: 0 1px 2px rgba(0,0,0,.05);box-shadow: 0 1px 2px rgba(0,0,0,.05);}
|
||||
.form-signin .form-signin-heading { margin-bottom: 10px;}
|
||||
</style>
|
||||
<!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
<?php echo implode('',$htmlExtraInformation['js']);?>
|
||||
</head>
|
||||
<body <?php echo implode(' ',$htmlExtraInformation['body']);?>>
|
||||
<div class="container">
|
||||
<div class="form-signin">
|
||||
<h2 class="form-signin-heading"><?php echo $sprache->multipleHeader; ?></h2>
|
||||
<div class="alert alert-info"><button type="button" class="close" data-dismiss="alert">×</button><?php echo $sprache->multipleHelper; ?></div>
|
||||
<div class="row-fluid">
|
||||
<ul class="nav nav-tabs nav-stacked">
|
||||
<?php foreach($connectedUsers as $k=>$v){ ?>
|
||||
<li><a href="login.php?serviceProvider=<?php echo $serviceProvider;?>&loginUserId=<?php echo $k;?>"><?php echo $v;?></a></li>
|
||||
<?php }?>
|
||||
</ul>
|
||||
</div>
|
||||
<hr>
|
||||
<div>
|
||||
© <a href="https://easy-wi.com" target="_blank" title="free gameserver, voiceserver, dedicated and virtualserver webinterface easy-wi.com">Easy-WI.com</a> 2011 - <?php echo date('Y'); ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -20,6 +20,7 @@
|
||||
<script src="//netdna.bootstrapcdn.com/bootstrap/2.3.2/js/bootstrap.min.js"></script>
|
||||
|
||||
<script src="<?php echo $page_data->pageurl;?>/js/default/footable.js" type="text/javascript"></script>
|
||||
<script src="<?php echo $page_data->pageurl;?>/js/default/main.js" type="text/javascript"></script>
|
||||
<?php echo implode('',$htmlExtraInformation['js']);?>
|
||||
|
||||
<?php if(isset($page_feeds)) echo $page_feeds; ?>
|
||||
@ -28,6 +29,7 @@
|
||||
<!--[if lt IE 9]>
|
||||
<script src="//html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
<script type="text/javascript">window.onDomReady(onReady); function onReady() { SwitchShowHideRows('init_ready');}</script>
|
||||
<script type="text/javascript">$(function() { $('table').footable();});</script>
|
||||
</head>
|
||||
<body <?php echo implode(' ',$htmlExtraInformation['body']);?>>
|
||||
@ -58,7 +60,7 @@
|
||||
<ul class="dropdown-menu">
|
||||
<li><a href="#"><?php echo $gsprache->last.'<br />'.$great_last;?></a></li>
|
||||
<li class="divider"></li>
|
||||
<li><a href="<?php echo (isset($admin_id)) ? $page_data->pageurl.'/admin.php' : $page_data->url.'/userpanel.php';?>"><i class="fa fa-sign-in fa-fw"></i> Backend</a></li>
|
||||
<li><a href="<?php echo (isset($admin_id)) ? $page_data->pageurl.'/admin.php' : $page_data->pageurl.'/userpanel.php';?>"><i class="fa fa-sign-in fa-fw"></i> Backend</a></li>
|
||||
<li class="divider"></li>
|
||||
<?php if ($support_phonenumber!="") echo '<li><a href="#"><i class="fa fa-phone fa-fw"></i> '.$gsprache->hotline.": ".$support_phonenumber.'</a></li>';?>
|
||||
<li class="divider"></li>
|
||||
@ -87,43 +89,59 @@
|
||||
<h3 id="myModalLabel">Login</h3>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<label class="control-label" for="inputUser"></label>
|
||||
<div class="input-prepend">
|
||||
<span class="add-on"><i class="icon-user"></i></span>
|
||||
<input name="username" id="inputUser" type="text" class="input-block-level" placeholder="User/Email" required >
|
||||
<div class="row-fluid">
|
||||
<div class="span6">
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<label class="control-label" for="inputUser"></label>
|
||||
<div class="input-prepend">
|
||||
<span class="add-on"><i class="icon-user"></i></span>
|
||||
<input name="username" id="inputUser" type="text" class="input-block-level" placeholder="User/Email" required >
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<label class="control-label" for="inputPassword"></label>
|
||||
<div class="input-prepend">
|
||||
<span class="add-on"><i class="icon-lock"></i></span>
|
||||
<input name="password" id="inputPassword" type="password" class="input-block-level" placeholder="Password" required >
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php if ($ewCfg['captcha']==1) { ?>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="inputCaptcha"></label>
|
||||
<div class="controls">
|
||||
<div class="input-prepend">
|
||||
<span class="add-on"><img src="images.php" alt="Captcha" /></span>
|
||||
<input name="captcha" id="inputCaptcha" type="text" class="input-block-level" placeholder="Captcha" pattern="^[\w]{4}$" required >
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="hide">
|
||||
<label><input type="text" name="email"></label>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="inputLogin"></label>
|
||||
<div class="controls">
|
||||
<button id="inputLogin" class="btn btn-primary pull-left">Login</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<label class="control-label" for="inputPassword"></label>
|
||||
<div class="input-prepend">
|
||||
<span class="add-on"><i class="icon-lock"></i></span>
|
||||
<input name="password" id="inputPassword" type="password" class="input-block-level" placeholder="Password" required >
|
||||
</div>
|
||||
<div class="span6">
|
||||
<?php foreach($serviceProviders as $k=>$css){ ?>
|
||||
<a class="btn btn-block btn-social btn-<?php echo $css;?>" href="login.php?serviceProvider=<?php echo $k;?>">
|
||||
<i class="fa fa-<?php echo $css;?>"></i> Sign in with <?php echo $k;?>
|
||||
</a>
|
||||
<?php } ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php if ($ewCfg['captcha']==1) { ?>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="inputCaptcha"></label>
|
||||
<div class="controls">
|
||||
<div class="input-prepend">
|
||||
<span class="add-on"><img src="images.php" alt="Captcha" /></span>
|
||||
<input name="captcha" id="inputCaptcha" type="text" class="input-block-level" placeholder="Captcha" pattern="^[\w]{4}$" required >
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="hide">
|
||||
<label><input type="text" name="email"></label>
|
||||
</div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<a class="btn pull-left btn-info" href="<?php echo $page_data->pages['register']['link'];?>"><?php echo $page_data->pages['register']['linkname'];?></a>
|
||||
<a class="btn pull-left" href="<?php echo $page_data->pageurl;?>/login.php?w=pr" >Lost PW</a>
|
||||
<button class="btn btn-primary pull-right">Login</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
@ -43,7 +43,7 @@
|
||||
<div class="controls">
|
||||
<select id="inputSalutation" name="salutation">
|
||||
<option value="1"><?php echo $langObject->salutation2;?></option>
|
||||
<option value="2"><?php echo $langObject->salutation3;?></option>
|
||||
<option value="2"<?php if($salutation==2) echo ' selected="selected"';?>><?php echo $langObject->salutation3;?></option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
@ -52,7 +52,7 @@
|
||||
<div class="controls">
|
||||
<select id="inputCountry" name="flagmenu">
|
||||
<?php foreach ($selectlanguages as $la) { ?>
|
||||
<option value="<?php echo $la;?>"><?php echo $la;?></option>
|
||||
<option value="<?php echo $la;?>"<?php if($la==$flagmenu) echo ' selected="selected"';?>><?php echo $la;?></option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</div>
|
||||
@ -78,43 +78,43 @@
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="inputTel"><?php echo $langObject->tel;?></label>
|
||||
<div class="controls">
|
||||
<input id="inputTel" type="tel" name="phone" value="">
|
||||
<input id="inputTel" type="tel" name="phone" value="<?php echo $phone;?>">
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="inputFax">Fax</label>
|
||||
<div class="controls">
|
||||
<input id="inputFax" type="tel" name="fax" value="">
|
||||
<input id="inputFax" type="tel" name="fax" value="<?php echo $fax;?>">
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="inputHandy"><?php echo $langObject->han;?></label>
|
||||
<div class="controls">
|
||||
<input id="inputHandy" type="tel" name="handy" value="">
|
||||
<input id="inputHandy" type="tel" name="handy" value="<?php echo $handy;?>">
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="inputCity"><?php echo $langObject->stadt;?></label>
|
||||
<div class="controls">
|
||||
<input id="inputCity" type="text" name="city" value="">
|
||||
<input id="inputCity" type="text" name="city" value="<?php echo $city;?>">
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="inputCityn"><?php echo $langObject->plz;?></label>
|
||||
<div class="controls">
|
||||
<input id="inputCityn" type="text" name="cityn" value="">
|
||||
<input id="inputCityn" type="text" name="cityn" value="<?php echo $cityn;?>">
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="inputStreet"><?php echo $langObject->str;?></label>
|
||||
<div class="controls">
|
||||
<input id="inputStreet" type="text" name="street" value="">
|
||||
<input id="inputStreet" type="text" name="street" value="<?php echo $street;?>">
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="inputHnum"><?php echo $langObject->hnum;?></label>
|
||||
<div class="controls">
|
||||
<input id="inputHnum" type="text" name="streetn" value="">
|
||||
<input id="inputHnum" type="text" name="streetn" value="<?php echo $streetn;?>">
|
||||
</div>
|
||||
</div>
|
||||
<?php if(isset($tou)) { ?>
|
||||
|
@ -17,6 +17,24 @@
|
||||
<input id="mail_backup" type="checkbox" name="mail_backup" value="Y" <?php if ($mail_backup=="Y") echo 'checked="checked"'; ?>>
|
||||
</div>
|
||||
</div>
|
||||
<hr>
|
||||
<?php foreach($serviceProviders as $sp){ ?>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="sp<?php echo $sp['sp'];?>"><?php echo $sp['sp'];?></label>
|
||||
<div class="controls">
|
||||
<?php if (strlen($sp['spUserId'])==0){ ?>
|
||||
<a class="btn btn-block btn-social btn-<?php echo strtolower($sp['sp']);?> span10" href="login.php?serviceProvider=<?php echo $sp['sp'];?>" id="sp<?php echo $sp['sp'];?>">
|
||||
<i class="fa fa-<?php echo strtolower($sp['sp']);?>"></i> <?php echo $sprache->socialConnect.' '.$sp['sp'];?>
|
||||
</a>
|
||||
<?php } else { ?>
|
||||
<a class="btn btn-block btn-social btn-<?php echo strtolower($sp['sp']);?> span10" href="userpanel.php?w=se&spUser=<?php echo $sp['spUserId'];?>&spId=<?php echo $sp['spId'];?>&r=se" id="sp<?php echo $sp['sp'];?>">
|
||||
<i class="fa fa-<?php echo strtolower($sp['sp']);?>"></i> <?php echo $sprache->socialRemove.' '.$sp['sp'];?>
|
||||
</a>
|
||||
<?php } ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<?php if(count($serviceProviders) > 0 ) echo '<hr>';?>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="mail_serverdown"><?php echo $sprache->mail_serverdown;?></label>
|
||||
<div class="controls">
|
||||
|
406
web/third_party/hybridauth/Hybrid/Auth.php
vendored
Normal file
406
web/third_party/hybridauth/Hybrid/Auth.php
vendored
Normal file
@ -0,0 +1,406 @@
|
||||
<?php
|
||||
/*!
|
||||
* HybridAuth
|
||||
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
|
||||
* (c) 2009-2012, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
|
||||
*/
|
||||
|
||||
/**
|
||||
* Hybrid_Auth class
|
||||
*
|
||||
* Hybrid_Auth class provide a simple way to authenticate users via OpenID and OAuth.
|
||||
*
|
||||
* Generally, Hybrid_Auth is the only class you should instanciate and use throughout your application.
|
||||
*/
|
||||
class Hybrid_Auth
|
||||
{
|
||||
public static $version = "2.1.2";
|
||||
|
||||
public static $config = array();
|
||||
|
||||
public static $store = NULL;
|
||||
|
||||
public static $error = NULL;
|
||||
|
||||
public static $logger = NULL;
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Try to start a new session of none then initialize Hybrid_Auth
|
||||
*
|
||||
* Hybrid_Auth constructor will require either a valid config array or
|
||||
* a path for a configuration file as parameter. To know more please
|
||||
* refer to the Configuration section:
|
||||
* http://hybridauth.sourceforge.net/userguide/Configuration.html
|
||||
*/
|
||||
function __construct( $config )
|
||||
{
|
||||
Hybrid_Auth::initialize( $config );
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Try to initialize Hybrid_Auth with given $config hash or file
|
||||
*/
|
||||
public static function initialize( $config )
|
||||
{
|
||||
if( ! is_array( $config ) && ! file_exists( $config ) ){
|
||||
throw new Exception( "Hybriauth config does not exist on the given path.", 1 );
|
||||
}
|
||||
|
||||
if( ! is_array( $config ) ){
|
||||
$config = include $config;
|
||||
}
|
||||
|
||||
// build some need'd paths
|
||||
$config["path_base"] = realpath( dirname( __FILE__ ) ) . "/";
|
||||
$config["path_libraries"] = $config["path_base"] . "thirdparty/";
|
||||
$config["path_resources"] = $config["path_base"] . "resources/";
|
||||
$config["path_providers"] = $config["path_base"] . "Providers/";
|
||||
|
||||
// reset debug mode
|
||||
if( ! isset( $config["debug_mode"] ) ){
|
||||
$config["debug_mode"] = false;
|
||||
$config["debug_file"] = null;
|
||||
}
|
||||
|
||||
# load hybridauth required files, a autoload is on the way...
|
||||
require_once $config["path_base"] . "Error.php";
|
||||
require_once $config["path_base"] . "Logger.php";
|
||||
|
||||
require_once $config["path_base"] . "Storage.php";
|
||||
|
||||
require_once $config["path_base"] . "Provider_Adapter.php";
|
||||
|
||||
require_once $config["path_base"] . "Provider_Model.php";
|
||||
require_once $config["path_base"] . "Provider_Model_OpenID.php";
|
||||
require_once $config["path_base"] . "Provider_Model_OAuth1.php";
|
||||
require_once $config["path_base"] . "Provider_Model_OAuth2.php";
|
||||
|
||||
require_once $config["path_base"] . "User.php";
|
||||
require_once $config["path_base"] . "User_Profile.php";
|
||||
require_once $config["path_base"] . "User_Contact.php";
|
||||
require_once $config["path_base"] . "User_Activity.php";
|
||||
|
||||
// hash given config
|
||||
Hybrid_Auth::$config = $config;
|
||||
|
||||
// instace of log mng
|
||||
Hybrid_Auth::$logger = new Hybrid_Logger();
|
||||
|
||||
// instace of errors mng
|
||||
Hybrid_Auth::$error = new Hybrid_Error();
|
||||
|
||||
// start session storage mng
|
||||
Hybrid_Auth::$store = new Hybrid_Storage();
|
||||
|
||||
Hybrid_Logger::info( "Enter Hybrid_Auth::initialize()");
|
||||
Hybrid_Logger::info( "Hybrid_Auth::initialize(). PHP version: " . PHP_VERSION );
|
||||
Hybrid_Logger::info( "Hybrid_Auth::initialize(). Hybrid_Auth version: " . Hybrid_Auth::$version );
|
||||
Hybrid_Logger::info( "Hybrid_Auth::initialize(). Hybrid_Auth called from: " . Hybrid_Auth::getCurrentUrl() );
|
||||
|
||||
// PHP Curl extension [http://www.php.net/manual/en/intro.curl.php]
|
||||
if ( ! function_exists('curl_init') ) {
|
||||
Hybrid_Logger::error('Hybridauth Library needs the CURL PHP extension.');
|
||||
throw new Exception('Hybridauth Library needs the CURL PHP extension.');
|
||||
}
|
||||
|
||||
// PHP JSON extension [http://php.net/manual/en/book.json.php]
|
||||
if ( ! function_exists('json_decode') ) {
|
||||
Hybrid_Logger::error('Hybridauth Library needs the JSON PHP extension.');
|
||||
throw new Exception('Hybridauth Library needs the JSON PHP extension.');
|
||||
}
|
||||
|
||||
// session.name
|
||||
if( session_name() != "PHPSESSID" ){
|
||||
Hybrid_Logger::info('PHP session.name diff from default PHPSESSID. http://php.net/manual/en/session.configuration.php#ini.session.name.');
|
||||
}
|
||||
|
||||
// safe_mode is on
|
||||
if( ini_get('safe_mode') ){
|
||||
Hybrid_Logger::info('PHP safe_mode is on. http://php.net/safe-mode.');
|
||||
}
|
||||
|
||||
// open basedir is on
|
||||
if( ini_get('open_basedir') ){
|
||||
Hybrid_Logger::info('PHP open_basedir is on. http://php.net/open-basedir.');
|
||||
}
|
||||
|
||||
Hybrid_Logger::debug( "Hybrid_Auth initialize. dump used config: ", serialize( $config ) );
|
||||
Hybrid_Logger::debug( "Hybrid_Auth initialize. dump current session: ", Hybrid_Auth::storage()->getSessionData() );
|
||||
Hybrid_Logger::info( "Hybrid_Auth initialize: check if any error is stored on the endpoint..." );
|
||||
|
||||
if( Hybrid_Error::hasError() ){
|
||||
$m = Hybrid_Error::getErrorMessage();
|
||||
$c = Hybrid_Error::getErrorCode();
|
||||
$p = Hybrid_Error::getErrorPrevious();
|
||||
|
||||
Hybrid_Logger::error( "Hybrid_Auth initialize: A stored Error found, Throw an new Exception and delete it from the store: Error#$c, '$m'" );
|
||||
|
||||
Hybrid_Error::clearError();
|
||||
|
||||
// try to provide the previous if any
|
||||
// Exception::getPrevious (PHP 5 >= 5.3.0) http://php.net/manual/en/exception.getprevious.php
|
||||
if ( version_compare( PHP_VERSION, '5.3.0', '>=' ) && ($p instanceof Exception) ) {
|
||||
throw new Exception( $m, $c, $p );
|
||||
}
|
||||
else{
|
||||
throw new Exception( $m, $c );
|
||||
}
|
||||
}
|
||||
|
||||
Hybrid_Logger::info( "Hybrid_Auth initialize: no error found. initialization succeed." );
|
||||
|
||||
// Endof initialize
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Hybrid storage system accessor
|
||||
*
|
||||
* Users sessions are stored using HybridAuth storage system ( HybridAuth 2.0 handle PHP Session only) and can be acessed directly by
|
||||
* Hybrid_Auth::storage()->get($key) to retrieves the data for the given key, or calling
|
||||
* Hybrid_Auth::storage()->set($key, $value) to store the key => $value set.
|
||||
*/
|
||||
public static function storage()
|
||||
{
|
||||
return Hybrid_Auth::$store;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Get hybridauth session data.
|
||||
*/
|
||||
function getSessionData()
|
||||
{
|
||||
return Hybrid_Auth::storage()->getSessionData();
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* restore hybridauth session data.
|
||||
*/
|
||||
function restoreSessionData( $sessiondata = NULL )
|
||||
{
|
||||
Hybrid_Auth::storage()->restoreSessionData( $sessiondata );
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Try to authenticate the user with a given provider.
|
||||
*
|
||||
* If the user is already connected we just return and instance of provider adapter,
|
||||
* ELSE, try to authenticate and authorize the user with the provider.
|
||||
*
|
||||
* $params is generally an array with required info in order for this provider and HybridAuth to work,
|
||||
* like :
|
||||
* hauth_return_to: URL to call back after authentication is done
|
||||
* openid_identifier: The OpenID identity provider identifier
|
||||
* google_service: can be "Users" for Google user accounts service or "Apps" for Google hosted Apps
|
||||
*/
|
||||
public static function authenticate( $providerId, $params = NULL )
|
||||
{
|
||||
Hybrid_Logger::info( "Enter Hybrid_Auth::authenticate( $providerId )" );
|
||||
|
||||
// if user not connected to $providerId then try setup a new adapter and start the login process for this provider
|
||||
if( ! Hybrid_Auth::storage()->get( "hauth_session.$providerId.is_logged_in" ) ){
|
||||
Hybrid_Logger::info( "Hybrid_Auth::authenticate( $providerId ), User not connected to the provider. Try to authenticate.." );
|
||||
|
||||
$provider_adapter = Hybrid_Auth::setup( $providerId, $params );
|
||||
|
||||
$provider_adapter->login();
|
||||
}
|
||||
|
||||
// else, then return the adapter instance for the given provider
|
||||
else{
|
||||
Hybrid_Logger::info( "Hybrid_Auth::authenticate( $providerId ), User is already connected to this provider. Return the adapter instance." );
|
||||
|
||||
return Hybrid_Auth::getAdapter( $providerId );
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Return the adapter instance for an authenticated provider
|
||||
*/
|
||||
public static function getAdapter( $providerId = NULL )
|
||||
{
|
||||
Hybrid_Logger::info( "Enter Hybrid_Auth::getAdapter( $providerId )" );
|
||||
|
||||
return Hybrid_Auth::setup( $providerId );
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Setup an adapter for a given provider
|
||||
*/
|
||||
public static function setup( $providerId, $params = NULL )
|
||||
{
|
||||
Hybrid_Logger::debug( "Enter Hybrid_Auth::setup( $providerId )", $params );
|
||||
|
||||
if( ! $params ){
|
||||
$params = Hybrid_Auth::storage()->get( "hauth_session.$providerId.id_provider_params" );
|
||||
|
||||
Hybrid_Logger::debug( "Hybrid_Auth::setup( $providerId ), no params given. Trying to get the sotred for this provider.", $params );
|
||||
}
|
||||
|
||||
if( ! $params ){
|
||||
$params = ARRAY();
|
||||
|
||||
Hybrid_Logger::info( "Hybrid_Auth::setup( $providerId ), no stored params found for this provider. Initialize a new one for new session" );
|
||||
}
|
||||
|
||||
if( ! isset( $params["hauth_return_to"] ) ){
|
||||
$params["hauth_return_to"] = Hybrid_Auth::getCurrentUrl();
|
||||
}
|
||||
|
||||
Hybrid_Logger::debug( "Hybrid_Auth::setup( $providerId ). HybridAuth Callback URL set to: ", $params["hauth_return_to"] );
|
||||
|
||||
# instantiate a new IDProvider Adapter
|
||||
$provider = new Hybrid_Provider_Adapter();
|
||||
|
||||
$provider->factory( $providerId, $params );
|
||||
|
||||
return $provider;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Check if the current user is connected to a given provider
|
||||
*/
|
||||
public static function isConnectedWith( $providerId )
|
||||
{
|
||||
return (bool) Hybrid_Auth::storage()->get( "hauth_session.{$providerId}.is_logged_in" );
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Return array listing all authenticated providers
|
||||
*/
|
||||
public static function getConnectedProviders()
|
||||
{
|
||||
$idps = array();
|
||||
|
||||
foreach( Hybrid_Auth::$config["providers"] as $idpid => $params ){
|
||||
if( Hybrid_Auth::isConnectedWith( $idpid ) ){
|
||||
$idps[] = $idpid;
|
||||
}
|
||||
}
|
||||
|
||||
return $idps;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Return array listing all enabled providers as well as a flag if you are connected.
|
||||
*/
|
||||
public static function getProviders()
|
||||
{
|
||||
$idps = array();
|
||||
|
||||
foreach( Hybrid_Auth::$config["providers"] as $idpid => $params ){
|
||||
if($params['enabled']) {
|
||||
$idps[$idpid] = array( 'connected' => false );
|
||||
|
||||
if( Hybrid_Auth::isConnectedWith( $idpid ) ){
|
||||
$idps[$idpid]['connected'] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $idps;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* A generic function to logout all connected provider at once
|
||||
*/
|
||||
public static function logoutAllProviders()
|
||||
{
|
||||
$idps = Hybrid_Auth::getConnectedProviders();
|
||||
|
||||
foreach( $idps as $idp ){
|
||||
$adapter = Hybrid_Auth::getAdapter( $idp );
|
||||
|
||||
$adapter->logout();
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Utility function, redirect to a given URL with php header or using javascript location.href
|
||||
*/
|
||||
public static function redirect( $url, $mode = "PHP" )
|
||||
{
|
||||
Hybrid_Logger::info( "Enter Hybrid_Auth::redirect( $url, $mode )" );
|
||||
|
||||
if( $mode == "PHP" ){
|
||||
header( "Location: $url" ) ;
|
||||
}
|
||||
elseif( $mode == "JS" ){
|
||||
echo '<html>';
|
||||
echo '<head>';
|
||||
echo '<script type="text/javascript">';
|
||||
echo 'function redirect(){ window.top.location.href="' . $url . '"; }';
|
||||
echo '</script>';
|
||||
echo '</head>';
|
||||
echo '<body onload="redirect()">';
|
||||
echo 'Redirecting, please wait...';
|
||||
echo '</body>';
|
||||
echo '</html>';
|
||||
}
|
||||
|
||||
die();
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Utility function, return the current url. TRUE to get $_SERVER['REQUEST_URI'], FALSE for $_SERVER['PHP_SELF']
|
||||
*/
|
||||
public static function getCurrentUrl( $request_uri = true )
|
||||
{
|
||||
if(
|
||||
isset( $_SERVER['HTTPS'] ) && ( $_SERVER['HTTPS'] == 'on' || $_SERVER['HTTPS'] == 1 )
|
||||
|| isset( $_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https'
|
||||
){
|
||||
$protocol = 'https://';
|
||||
}
|
||||
else {
|
||||
$protocol = 'http://';
|
||||
}
|
||||
|
||||
$url = $protocol . $_SERVER['HTTP_HOST'];
|
||||
|
||||
// use port if non default
|
||||
if( isset( $_SERVER['SERVER_PORT'] ) && strpos( $url, ':'.$_SERVER['SERVER_PORT'] ) === FALSE ) {
|
||||
$url .= ($protocol === 'http://' && $_SERVER['SERVER_PORT'] != 80 && !isset( $_SERVER['HTTP_X_FORWARDED_PROTO']))
|
||||
|| ($protocol === 'https://' && $_SERVER['SERVER_PORT'] != 443 && !isset( $_SERVER['HTTP_X_FORWARDED_PROTO']))
|
||||
? ':' . $_SERVER['SERVER_PORT']
|
||||
: '';
|
||||
}
|
||||
|
||||
if( $request_uri ){
|
||||
$url .= $_SERVER['REQUEST_URI'];
|
||||
}
|
||||
else{
|
||||
$url .= $_SERVER['PHP_SELF'];
|
||||
}
|
||||
|
||||
// return current url
|
||||
return $url;
|
||||
}
|
||||
}
|
217
web/third_party/hybridauth/Hybrid/Endpoint.php
vendored
Normal file
217
web/third_party/hybridauth/Hybrid/Endpoint.php
vendored
Normal file
@ -0,0 +1,217 @@
|
||||
<?php
|
||||
/*!
|
||||
* HybridAuth
|
||||
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
|
||||
* (c) 2009-2012, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
|
||||
*/
|
||||
|
||||
/**
|
||||
* Hybrid_Endpoint class
|
||||
*
|
||||
* Hybrid_Endpoint class provides a simple way to handle the OpenID and OAuth endpoint.
|
||||
*/
|
||||
class Hybrid_Endpoint {
|
||||
public static $request = NULL;
|
||||
public static $initDone = FALSE;
|
||||
|
||||
/**
|
||||
* Process the current request
|
||||
*
|
||||
* $request - The current request parameters. Leave as NULL to default to use $_REQUEST.
|
||||
*/
|
||||
public static function process( $request = NULL )
|
||||
{
|
||||
// Setup request variable
|
||||
Hybrid_Endpoint::$request = $request;
|
||||
|
||||
if ( is_null(Hybrid_Endpoint::$request) ){
|
||||
// Fix a strange behavior when some provider call back ha endpoint
|
||||
// with /index.php?hauth.done={provider}?{args}...
|
||||
// >here we need to recreate the $_REQUEST
|
||||
if ( strrpos( $_SERVER["QUERY_STRING"], '?' ) ) {
|
||||
$_SERVER["QUERY_STRING"] = str_replace( "?", "&", $_SERVER["QUERY_STRING"] );
|
||||
|
||||
parse_str( $_SERVER["QUERY_STRING"], $_REQUEST );
|
||||
}
|
||||
|
||||
Hybrid_Endpoint::$request = $_REQUEST;
|
||||
}
|
||||
|
||||
// If openid_policy requested, we return our policy document
|
||||
if ( isset( Hybrid_Endpoint::$request["get"] ) && Hybrid_Endpoint::$request["get"] == "openid_policy" ) {
|
||||
Hybrid_Endpoint::processOpenidPolicy();
|
||||
}
|
||||
|
||||
// If openid_xrds requested, we return our XRDS document
|
||||
if ( isset( Hybrid_Endpoint::$request["get"] ) && Hybrid_Endpoint::$request["get"] == "openid_xrds" ) {
|
||||
Hybrid_Endpoint::processOpenidXRDS();
|
||||
}
|
||||
|
||||
// If we get a hauth.start
|
||||
if ( isset( Hybrid_Endpoint::$request["hauth_start"] ) && Hybrid_Endpoint::$request["hauth_start"] ) {
|
||||
Hybrid_Endpoint::processAuthStart();
|
||||
}
|
||||
// Else if hauth.done
|
||||
elseif ( isset( Hybrid_Endpoint::$request["hauth_done"] ) && Hybrid_Endpoint::$request["hauth_done"] ) {
|
||||
Hybrid_Endpoint::processAuthDone();
|
||||
}
|
||||
// Else we advertise our XRDS document, something supposed to be done from the Realm URL page
|
||||
else {
|
||||
Hybrid_Endpoint::processOpenidRealm();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Process OpenID policy request
|
||||
*/
|
||||
public static function processOpenidPolicy()
|
||||
{
|
||||
$output = file_get_contents( dirname(__FILE__) . "/resources/openid_policy.html" );
|
||||
print $output;
|
||||
die();
|
||||
}
|
||||
|
||||
/**
|
||||
* Process OpenID XRDS request
|
||||
*/
|
||||
public static function processOpenidXRDS()
|
||||
{
|
||||
header("Content-Type: application/xrds+xml");
|
||||
|
||||
$output = str_replace
|
||||
(
|
||||
"{RETURN_TO_URL}",
|
||||
str_replace(
|
||||
array("<", ">", "\"", "'", "&"), array("<", ">", """, "'", "&"),
|
||||
Hybrid_Auth::getCurrentUrl( false )
|
||||
),
|
||||
file_get_contents( dirname(__FILE__) . "/resources/openid_xrds.xml" )
|
||||
);
|
||||
print $output;
|
||||
die();
|
||||
}
|
||||
|
||||
/**
|
||||
* Process OpenID realm request
|
||||
*/
|
||||
public static function processOpenidRealm()
|
||||
{
|
||||
$output = str_replace
|
||||
(
|
||||
"{X_XRDS_LOCATION}",
|
||||
htmlentities( Hybrid_Auth::getCurrentUrl( false ), ENT_QUOTES, 'UTF-8' ) . "?get=openid_xrds&v=" . Hybrid_Auth::$version,
|
||||
file_get_contents( dirname(__FILE__) . "/resources/openid_realm.html" )
|
||||
);
|
||||
print $output;
|
||||
die();
|
||||
}
|
||||
|
||||
/**
|
||||
* define:endpoint step 3.
|
||||
*/
|
||||
public static function processAuthStart()
|
||||
{
|
||||
Hybrid_Endpoint::authInit();
|
||||
|
||||
$provider_id = trim( strip_tags( Hybrid_Endpoint::$request["hauth_start"] ) );
|
||||
|
||||
# check if page accessed directly
|
||||
if( ! Hybrid_Auth::storage()->get( "hauth_session.$provider_id.hauth_endpoint" ) ) {
|
||||
Hybrid_Logger::error( "Endpoint: hauth_endpoint parameter is not defined on hauth_start, halt login process!" );
|
||||
|
||||
header( "HTTP/1.0 404 Not Found" );
|
||||
die( "You cannot access this page directly." );
|
||||
}
|
||||
|
||||
# define:hybrid.endpoint.php step 2.
|
||||
$hauth = Hybrid_Auth::setup( $provider_id );
|
||||
|
||||
# if REQUESTed hauth_idprovider is wrong, session not created, etc.
|
||||
if( ! $hauth ) {
|
||||
Hybrid_Logger::error( "Endpoint: Invalid parameter on hauth_start!" );
|
||||
|
||||
header( "HTTP/1.0 404 Not Found" );
|
||||
die( "Invalid parameter! Please return to the login page and try again." );
|
||||
}
|
||||
|
||||
try {
|
||||
Hybrid_Logger::info( "Endpoint: call adapter [{$provider_id}] loginBegin()" );
|
||||
|
||||
$hauth->adapter->loginBegin();
|
||||
}
|
||||
catch ( Exception $e ) {
|
||||
Hybrid_Logger::error( "Exception:" . $e->getMessage(), $e );
|
||||
Hybrid_Error::setError( $e->getMessage(), $e->getCode(), $e->getTraceAsString(), $e );
|
||||
|
||||
$hauth->returnToCallbackUrl();
|
||||
}
|
||||
|
||||
die();
|
||||
}
|
||||
|
||||
/**
|
||||
* define:endpoint step 3.1 and 3.2
|
||||
*/
|
||||
public static function processAuthDone()
|
||||
{
|
||||
Hybrid_Endpoint::authInit();
|
||||
|
||||
$provider_id = trim( strip_tags( Hybrid_Endpoint::$request["hauth_done"] ) );
|
||||
|
||||
$hauth = Hybrid_Auth::setup( $provider_id );
|
||||
|
||||
if( ! $hauth ) {
|
||||
Hybrid_Logger::error( "Endpoint: Invalid parameter on hauth_done!" );
|
||||
|
||||
$hauth->adapter->setUserUnconnected();
|
||||
|
||||
header("HTTP/1.0 404 Not Found");
|
||||
die( "Invalid parameter! Please return to the login page and try again." );
|
||||
}
|
||||
|
||||
try {
|
||||
Hybrid_Logger::info( "Endpoint: call adapter [{$provider_id}] loginFinish() " );
|
||||
|
||||
$hauth->adapter->loginFinish();
|
||||
}
|
||||
catch( Exception $e ){
|
||||
Hybrid_Logger::error( "Exception:" . $e->getMessage(), $e );
|
||||
Hybrid_Error::setError( $e->getMessage(), $e->getCode(), $e->getTraceAsString(), $e );
|
||||
|
||||
$hauth->adapter->setUserUnconnected();
|
||||
}
|
||||
|
||||
Hybrid_Logger::info( "Endpoint: job done. retrun to callback url." );
|
||||
|
||||
$hauth->returnToCallbackUrl();
|
||||
die();
|
||||
}
|
||||
|
||||
public static function authInit()
|
||||
{
|
||||
if ( ! Hybrid_Endpoint::$initDone) {
|
||||
Hybrid_Endpoint::$initDone = TRUE;
|
||||
|
||||
# Init Hybrid_Auth
|
||||
try {
|
||||
require_once realpath( dirname( __FILE__ ) ) . "/Storage.php";
|
||||
|
||||
$storage = new Hybrid_Storage();
|
||||
|
||||
// Check if Hybrid_Auth session already exist
|
||||
if ( ! $storage->config( "CONFIG" ) ) {
|
||||
header( "HTTP/1.0 404 Not Found" );
|
||||
die( "You cannot access this page directly." );
|
||||
}
|
||||
|
||||
Hybrid_Auth::initialize( $storage->config( "CONFIG" ) );
|
||||
}
|
||||
catch ( Exception $e ){
|
||||
Hybrid_Logger::error( "Endpoint: Error while trying to init Hybrid_Auth" );
|
||||
|
||||
header( "HTTP/1.0 404 Not Found" );
|
||||
die( "Oophs. Error!" );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
84
web/third_party/hybridauth/Hybrid/Error.php
vendored
Normal file
84
web/third_party/hybridauth/Hybrid/Error.php
vendored
Normal file
@ -0,0 +1,84 @@
|
||||
<?php
|
||||
/*!
|
||||
* HybridAuth
|
||||
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
|
||||
* (c) 2009-2012, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
|
||||
*/
|
||||
|
||||
/**
|
||||
* Errors manager
|
||||
*
|
||||
* HybridAuth errors are stored in Hybrid::storage() and not displayed directly to the end user
|
||||
*/
|
||||
class Hybrid_Error
|
||||
{
|
||||
/**
|
||||
* store error in session
|
||||
*/
|
||||
public static function setError( $message, $code = NULL, $trace = NULL, $previous = NULL )
|
||||
{
|
||||
Hybrid_Logger::info( "Enter Hybrid_Error::setError( $message )" );
|
||||
|
||||
Hybrid_Auth::storage()->set( "hauth_session.error.status" , 1 );
|
||||
Hybrid_Auth::storage()->set( "hauth_session.error.message" , $message );
|
||||
Hybrid_Auth::storage()->set( "hauth_session.error.code" , $code );
|
||||
Hybrid_Auth::storage()->set( "hauth_session.error.trace" , $trace );
|
||||
Hybrid_Auth::storage()->set( "hauth_session.error.previous", $previous );
|
||||
}
|
||||
|
||||
/**
|
||||
* clear the last error
|
||||
*/
|
||||
public static function clearError()
|
||||
{
|
||||
Hybrid_Logger::info( "Enter Hybrid_Error::clearError()" );
|
||||
|
||||
Hybrid_Auth::storage()->delete( "hauth_session.error.status" );
|
||||
Hybrid_Auth::storage()->delete( "hauth_session.error.message" );
|
||||
Hybrid_Auth::storage()->delete( "hauth_session.error.code" );
|
||||
Hybrid_Auth::storage()->delete( "hauth_session.error.trace" );
|
||||
Hybrid_Auth::storage()->delete( "hauth_session.error.previous" );
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if there is a an error.
|
||||
*
|
||||
* @return boolean True if there is an error.
|
||||
*/
|
||||
public static function hasError()
|
||||
{
|
||||
return (bool) Hybrid_Auth::storage()->get( "hauth_session.error.status" );
|
||||
}
|
||||
|
||||
/**
|
||||
* return error message
|
||||
*/
|
||||
public static function getErrorMessage()
|
||||
{
|
||||
return Hybrid_Auth::storage()->get( "hauth_session.error.message" );
|
||||
}
|
||||
|
||||
/**
|
||||
* return error code
|
||||
*/
|
||||
public static function getErrorCode()
|
||||
{
|
||||
return Hybrid_Auth::storage()->get( "hauth_session.error.code" );
|
||||
}
|
||||
|
||||
/**
|
||||
* return string detailled error backtrace as string.
|
||||
*/
|
||||
public static function getErrorTrace()
|
||||
{
|
||||
return Hybrid_Auth::storage()->get( "hauth_session.error.trace" );
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string detailled error backtrace as string.
|
||||
*/
|
||||
public static function getErrorPrevious()
|
||||
{
|
||||
return Hybrid_Auth::storage()->get( "hauth_session.error.previous" );
|
||||
}
|
||||
}
|
68
web/third_party/hybridauth/Hybrid/Logger.php
vendored
Normal file
68
web/third_party/hybridauth/Hybrid/Logger.php
vendored
Normal file
@ -0,0 +1,68 @@
|
||||
<?php
|
||||
/*!
|
||||
* HybridAuth
|
||||
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
|
||||
* (c) 2009-2012, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
|
||||
*/
|
||||
|
||||
/**
|
||||
* Debugging and Logging manager
|
||||
*/
|
||||
class Hybrid_Logger
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
// if debug mode is set to true, then check for the writable log file
|
||||
if ( Hybrid_Auth::$config["debug_mode"] ){
|
||||
if ( ! file_exists( Hybrid_Auth::$config["debug_file"] ) ){
|
||||
throw new Exception( "'debug_mode' is set to 'true', but the file " . Hybrid_Auth::$config['debug_file'] . " in 'debug_file' does not exit.", 1 );
|
||||
}
|
||||
|
||||
if ( ! is_writable( Hybrid_Auth::$config["debug_file"] ) ){
|
||||
throw new Exception( "'debug_mode' is set to 'true', but the given log file path 'debug_file' is not a writable file.", 1 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function debug( $message, $object = NULL )
|
||||
{
|
||||
if( Hybrid_Auth::$config["debug_mode"] ){
|
||||
$datetime = new DateTime();
|
||||
$datetime = $datetime->format(DATE_ATOM);
|
||||
|
||||
file_put_contents(
|
||||
Hybrid_Auth::$config["debug_file"],
|
||||
"DEBUG -- " . $_SERVER['REMOTE_ADDR'] . " -- " . $datetime . " -- " . $message . " -- " . print_r($object, true) . "\n",
|
||||
FILE_APPEND
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public static function info( $message )
|
||||
{
|
||||
if( Hybrid_Auth::$config["debug_mode"] ){
|
||||
$datetime = new DateTime();
|
||||
$datetime = $datetime->format(DATE_ATOM);
|
||||
|
||||
file_put_contents(
|
||||
Hybrid_Auth::$config["debug_file"],
|
||||
"INFO -- " . $_SERVER['REMOTE_ADDR'] . " -- " . $datetime . " -- " . $message . "\n",
|
||||
FILE_APPEND
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public static function error($message, $object = NULL)
|
||||
{
|
||||
if( Hybrid_Auth::$config["debug_mode"] ){
|
||||
$datetime = new DateTime();
|
||||
$datetime = $datetime->format(DATE_ATOM);
|
||||
|
||||
file_put_contents(
|
||||
Hybrid_Auth::$config["debug_file"],
|
||||
"ERROR -- " . $_SERVER['REMOTE_ADDR'] . " -- " . $datetime . " -- " . $message . " -- " . print_r($object, true) . "\n",
|
||||
FILE_APPEND
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
283
web/third_party/hybridauth/Hybrid/Provider_Adapter.php
vendored
Normal file
283
web/third_party/hybridauth/Hybrid/Provider_Adapter.php
vendored
Normal file
@ -0,0 +1,283 @@
|
||||
<?php
|
||||
/*!
|
||||
* HybridAuth
|
||||
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
|
||||
* (c) 2009-2012, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
|
||||
*/
|
||||
|
||||
/**
|
||||
* Hybrid_Provider_Adapter is the basic class which Hybrid_Auth will use
|
||||
* to connect users to a given provider.
|
||||
*
|
||||
* Basically Hybrid_Provider_Adapterwill create a bridge from your php
|
||||
* application to the provider api.
|
||||
*
|
||||
* Hybrid_Auth will automatically load Hybrid_Provider_Adapter and create
|
||||
* an instance of it for each authenticated provider.
|
||||
*/
|
||||
class Hybrid_Provider_Adapter
|
||||
{
|
||||
/* Provider ID (or unique name) */
|
||||
public $id = NULL ;
|
||||
|
||||
/* Provider adapter specific config */
|
||||
public $config = NULL ;
|
||||
|
||||
/* Provider adapter extra parameters */
|
||||
public $params = NULL ;
|
||||
|
||||
/* Provider adapter wrapper path */
|
||||
public $wrapper = NULL ;
|
||||
|
||||
/* Provider adapter instance */
|
||||
public $adapter = NULL ;
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* create a new adapter switch IDp name or ID
|
||||
*
|
||||
* @param string $id The id or name of the IDp
|
||||
* @param array $params (optional) required parameters by the adapter
|
||||
*/
|
||||
function factory( $id, $params = NULL )
|
||||
{
|
||||
Hybrid_Logger::info( "Enter Hybrid_Provider_Adapter::factory( $id )" );
|
||||
|
||||
# init the adapter config and params
|
||||
$this->id = $id;
|
||||
$this->params = $params;
|
||||
$this->id = $this->getProviderCiId( $this->id );
|
||||
$this->config = $this->getConfigById( $this->id );
|
||||
|
||||
# check the IDp id
|
||||
if( ! $this->id ){
|
||||
throw new Exception( "No provider ID specified.", 2 );
|
||||
}
|
||||
|
||||
# check the IDp config
|
||||
if( ! $this->config ){
|
||||
throw new Exception( "Unknown Provider ID, check your configuration file.", 3 );
|
||||
}
|
||||
|
||||
# check the IDp adapter is enabled
|
||||
if( ! $this->config["enabled"] ){
|
||||
throw new Exception( "The provider '{$this->id}' is not enabled.", 3 );
|
||||
}
|
||||
|
||||
# include the adapter wrapper
|
||||
if( isset( $this->config["wrapper"] ) && is_array( $this->config["wrapper"] ) ){
|
||||
require_once $this->config["wrapper"]["path"];
|
||||
|
||||
if( ! class_exists( $this->config["wrapper"]["class"] ) ){
|
||||
throw new Exception( "Unable to load the adapter class.", 3 );
|
||||
}
|
||||
|
||||
$this->wrapper = $this->config["wrapper"]["class"];
|
||||
}
|
||||
else{
|
||||
require_once Hybrid_Auth::$config["path_providers"] . $this->id . ".php" ;
|
||||
|
||||
$this->wrapper = "Hybrid_Providers_" . $this->id;
|
||||
}
|
||||
|
||||
# create the adapter instance, and pass the current params and config
|
||||
$this->adapter = new $this->wrapper( $this->id, $this->config, $this->params );
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Hybrid_Provider_Adapter::login(), prepare the user session and the authentication request
|
||||
* for index.php
|
||||
*/
|
||||
function login()
|
||||
{
|
||||
Hybrid_Logger::info( "Enter Hybrid_Provider_Adapter::login( {$this->id} ) " );
|
||||
|
||||
if( ! $this->adapter ){
|
||||
throw new Exception( "Hybrid_Provider_Adapter::login() should not directly used." );
|
||||
}
|
||||
|
||||
// clear all unneeded params
|
||||
foreach( Hybrid_Auth::$config["providers"] as $idpid => $params ){
|
||||
Hybrid_Auth::storage()->delete( "hauth_session.{$idpid}.hauth_return_to" );
|
||||
Hybrid_Auth::storage()->delete( "hauth_session.{$idpid}.hauth_endpoint" );
|
||||
Hybrid_Auth::storage()->delete( "hauth_session.{$idpid}.id_provider_params" );
|
||||
}
|
||||
|
||||
// make a fresh start
|
||||
$this->logout();
|
||||
|
||||
# get hybridauth base url
|
||||
$HYBRID_AUTH_URL_BASE = Hybrid_Auth::$config["base_url"];
|
||||
|
||||
# we make use of session_id() as storage hash to identify the current user
|
||||
# using session_regenerate_id() will be a problem, but ..
|
||||
$this->params["hauth_token"] = session_id();
|
||||
|
||||
# set request timestamp
|
||||
$this->params["hauth_time"] = time();
|
||||
|
||||
# for default HybridAuth endpoint url hauth_login_start_url
|
||||
# auth.start required the IDp ID
|
||||
# auth.time optional login request timestamp
|
||||
$this->params["login_start"] = $HYBRID_AUTH_URL_BASE . ( strpos( $HYBRID_AUTH_URL_BASE, '?' ) ? '&' : '?' ) . "hauth.start={$this->id}&hauth.time={$this->params["hauth_time"]}";
|
||||
|
||||
# for default HybridAuth endpoint url hauth_login_done_url
|
||||
# auth.done required the IDp ID
|
||||
$this->params["login_done"] = $HYBRID_AUTH_URL_BASE . ( strpos( $HYBRID_AUTH_URL_BASE, '?' ) ? '&' : '?' ) . "hauth.done={$this->id}";
|
||||
|
||||
Hybrid_Auth::storage()->set( "hauth_session.{$this->id}.hauth_return_to" , $this->params["hauth_return_to"] );
|
||||
Hybrid_Auth::storage()->set( "hauth_session.{$this->id}.hauth_endpoint" , $this->params["login_done"] );
|
||||
Hybrid_Auth::storage()->set( "hauth_session.{$this->id}.id_provider_params" , $this->params );
|
||||
|
||||
// store config to be used by the end point
|
||||
Hybrid_Auth::storage()->config( "CONFIG", Hybrid_Auth::$config );
|
||||
|
||||
// move on
|
||||
Hybrid_Logger::debug( "Hybrid_Provider_Adapter::login( {$this->id} ), redirect the user to login_start URL." );
|
||||
|
||||
Hybrid_Auth::redirect( $this->params["login_start"] );
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* let hybridauth forget all about the user for the current provider
|
||||
*/
|
||||
function logout()
|
||||
{
|
||||
$this->adapter->logout();
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* return true if the user is connected to the current provider
|
||||
*/
|
||||
public function isUserConnected()
|
||||
{
|
||||
return $this->adapter->isUserConnected();
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* handle :
|
||||
* getUserProfile()
|
||||
* getUserContacts()
|
||||
* getUserActivity()
|
||||
* setUserStatus()
|
||||
*/
|
||||
public function __call( $name, $arguments )
|
||||
{
|
||||
Hybrid_Logger::info( "Enter Hybrid_Provider_Adapter::$name(), Provider: {$this->id}" );
|
||||
|
||||
if ( ! $this->isUserConnected() ){
|
||||
throw new Exception( "User not connected to the provider {$this->id}.", 7 );
|
||||
}
|
||||
|
||||
if ( ! method_exists( $this->adapter, $name ) ){
|
||||
throw new Exception( "Call to undefined function Hybrid_Providers_{$this->id}::$name()." );
|
||||
}
|
||||
|
||||
if( count( $arguments ) ){
|
||||
return $this->adapter->$name( $arguments[0] );
|
||||
}
|
||||
else{
|
||||
return $this->adapter->$name();
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* If the user is connected, then return the access_token and access_token_secret
|
||||
* if the provider api use oauth
|
||||
*/
|
||||
public function getAccessToken()
|
||||
{
|
||||
if( ! $this->adapter->isUserConnected() ){
|
||||
Hybrid_Logger::error( "User not connected to the provider." );
|
||||
|
||||
throw new Exception( "User not connected to the provider.", 7 );
|
||||
}
|
||||
|
||||
return
|
||||
ARRAY(
|
||||
"access_token" => $this->adapter->token( "access_token" ) , // OAuth access token
|
||||
"access_token_secret" => $this->adapter->token( "access_token_secret" ), // OAuth access token secret
|
||||
"refresh_token" => $this->adapter->token( "refresh_token" ) , // OAuth refresh token
|
||||
"expires_in" => $this->adapter->token( "expires_in" ) , // OPTIONAL. The duration in seconds of the access token lifetime
|
||||
"expires_at" => $this->adapter->token( "expires_at" ) , // OPTIONAL. Timestamp when the access_token expire. if not provided by the social api, then it should be calculated: expires_at = now + expires_in
|
||||
);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Naive getter of the current connected IDp API client
|
||||
*/
|
||||
function api()
|
||||
{
|
||||
if( ! $this->adapter->isUserConnected() ){
|
||||
Hybrid_Logger::error( "User not connected to the provider." );
|
||||
|
||||
throw new Exception( "User not connected to the provider.", 7 );
|
||||
}
|
||||
|
||||
return $this->adapter->api;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* redirect the user to hauth_return_to (the callback url)
|
||||
*/
|
||||
function returnToCallbackUrl()
|
||||
{
|
||||
// get the stored callback url
|
||||
$callback_url = Hybrid_Auth::storage()->get( "hauth_session.{$this->id}.hauth_return_to" );
|
||||
|
||||
// remove some unneed'd stored data
|
||||
Hybrid_Auth::storage()->delete( "hauth_session.{$this->id}.hauth_return_to" );
|
||||
Hybrid_Auth::storage()->delete( "hauth_session.{$this->id}.hauth_endpoint" );
|
||||
Hybrid_Auth::storage()->delete( "hauth_session.{$this->id}.id_provider_params" );
|
||||
|
||||
// back to home
|
||||
Hybrid_Auth::redirect( $callback_url );
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* return the provider config by id
|
||||
*/
|
||||
function getConfigById( $id )
|
||||
{
|
||||
if( isset( Hybrid_Auth::$config["providers"][$id] ) ){
|
||||
return Hybrid_Auth::$config["providers"][$id];
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* return the provider config by id; insensitive
|
||||
*/
|
||||
function getProviderCiId( $id )
|
||||
{
|
||||
foreach( Hybrid_Auth::$config["providers"] as $idpid => $params ){
|
||||
if( strtolower( $idpid ) == strtolower( $id ) ){
|
||||
return $idpid;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
}
|
231
web/third_party/hybridauth/Hybrid/Provider_Model.php
vendored
Normal file
231
web/third_party/hybridauth/Hybrid/Provider_Model.php
vendored
Normal file
@ -0,0 +1,231 @@
|
||||
<?php
|
||||
/*!
|
||||
* HybridAuth
|
||||
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
|
||||
* (c) 2009-2012, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
|
||||
*/
|
||||
|
||||
/**
|
||||
* Hybrid_Provider_Model provide a common interface for supported IDps on HybridAuth.
|
||||
*
|
||||
* Basically, each provider adapter has to define at least 4 methods:
|
||||
* Hybrid_Providers_{provider_name}::initialize()
|
||||
* Hybrid_Providers_{provider_name}::loginBegin()
|
||||
* Hybrid_Providers_{provider_name}::loginFinish()
|
||||
* Hybrid_Providers_{provider_name}::getUserProfile()
|
||||
*
|
||||
* HybridAuth also come with three others models
|
||||
* Class Hybrid_Provider_Model_OpenID for providers that uses the OpenID 1 and 2 protocol.
|
||||
* Class Hybrid_Provider_Model_OAuth1 for providers that uses the OAuth 1 protocol.
|
||||
* Class Hybrid_Provider_Model_OAuth2 for providers that uses the OAuth 2 protocol.
|
||||
*/
|
||||
abstract class Hybrid_Provider_Model
|
||||
{
|
||||
/* IDp ID (or unique name) */
|
||||
public $providerId = NULL;
|
||||
|
||||
/* specific provider adapter config */
|
||||
public $config = NULL;
|
||||
|
||||
/* provider extra parameters */
|
||||
public $params = NULL;
|
||||
|
||||
/* Endpoint URL for that provider */
|
||||
public $endpoint = NULL;
|
||||
|
||||
/* Hybrid_User obj, represents the current loggedin user */
|
||||
public $user = NULL;
|
||||
|
||||
/* the provider api client (optional) */
|
||||
public $api = NULL;
|
||||
|
||||
/**
|
||||
* common providers adapter constructor
|
||||
*/
|
||||
function __construct( $providerId, $config, $params = NULL )
|
||||
{
|
||||
# init the IDp adapter parameters, get them from the cache if possible
|
||||
if( ! $params ){
|
||||
$this->params = Hybrid_Auth::storage()->get( "hauth_session.$providerId.id_provider_params" );
|
||||
}
|
||||
else{
|
||||
$this->params = $params;
|
||||
}
|
||||
|
||||
// idp id
|
||||
$this->providerId = $providerId;
|
||||
|
||||
// set HybridAuth endpoint for this provider
|
||||
$this->endpoint = Hybrid_Auth::storage()->get( "hauth_session.$providerId.hauth_endpoint" );
|
||||
|
||||
// idp config
|
||||
$this->config = $config;
|
||||
|
||||
// new user instance
|
||||
$this->user = new Hybrid_User();
|
||||
$this->user->providerId = $providerId;
|
||||
|
||||
// initialize the current provider adapter
|
||||
$this->initialize();
|
||||
|
||||
Hybrid_Logger::debug( "Hybrid_Provider_Model::__construct( $providerId ) initialized. dump current adapter instance: ", serialize( $this ) );
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* IDp wrappers initializer
|
||||
*
|
||||
* The main job of wrappers initializer is to performs (depend on the IDp api client it self):
|
||||
* - include some libs nedded by this provider,
|
||||
* - check IDp key and secret,
|
||||
* - set some needed parameters (stored in $this->params) by this IDp api client
|
||||
* - create and setup an instance of the IDp api client on $this->api
|
||||
*/
|
||||
abstract protected function initialize();
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* begin login
|
||||
*/
|
||||
abstract protected function loginBegin();
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* finish login
|
||||
*/
|
||||
abstract protected function loginFinish();
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* generic logout, just erase current provider adapter stored data to let Hybrid_Auth all forget about it
|
||||
*/
|
||||
function logout()
|
||||
{
|
||||
Hybrid_Logger::info( "Enter [{$this->providerId}]::logout()" );
|
||||
|
||||
$this->clearTokens();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* grab the user profile from the IDp api client
|
||||
*/
|
||||
function getUserProfile()
|
||||
{
|
||||
Hybrid_Logger::error( "HybridAuth do not provide users contats list for {$this->providerId} yet." );
|
||||
|
||||
throw new Exception( "Provider does not support this feature.", 8 );
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* load the current logged in user contacts list from the IDp api client
|
||||
*/
|
||||
function getUserContacts()
|
||||
{
|
||||
Hybrid_Logger::error( "HybridAuth do not provide users contats list for {$this->providerId} yet." );
|
||||
|
||||
throw new Exception( "Provider does not support this feature.", 8 );
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* return the user activity stream
|
||||
*/
|
||||
function getUserActivity( $stream )
|
||||
{
|
||||
Hybrid_Logger::error( "HybridAuth do not provide user's activity stream for {$this->providerId} yet." );
|
||||
|
||||
throw new Exception( "Provider does not support this feature.", 8 );
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* return the user activity stream
|
||||
*/
|
||||
function setUserStatus( $status )
|
||||
{
|
||||
Hybrid_Logger::error( "HybridAuth do not provide user's activity stream for {$this->providerId} yet." );
|
||||
|
||||
throw new Exception( "Provider does not support this feature.", 8 );
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* return true if the user is connected to the current provider
|
||||
*/
|
||||
public function isUserConnected()
|
||||
{
|
||||
return (bool) Hybrid_Auth::storage()->get( "hauth_session.{$this->providerId}.is_logged_in" );
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* set user to connected
|
||||
*/
|
||||
public function setUserConnected()
|
||||
{
|
||||
Hybrid_Logger::info( "Enter [{$this->providerId}]::setUserConnected()" );
|
||||
|
||||
Hybrid_Auth::storage()->set( "hauth_session.{$this->providerId}.is_logged_in", 1 );
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* set user to unconnected
|
||||
*/
|
||||
public function setUserUnconnected()
|
||||
{
|
||||
Hybrid_Logger::info( "Enter [{$this->providerId}]::setUserUnconnected()" );
|
||||
|
||||
Hybrid_Auth::storage()->set( "hauth_session.{$this->providerId}.is_logged_in", 0 );
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* get or set a token
|
||||
*/
|
||||
public function token( $token, $value = NULL )
|
||||
{
|
||||
if( $value === NULL ){
|
||||
return Hybrid_Auth::storage()->get( "hauth_session.{$this->providerId}.token.$token" );
|
||||
}
|
||||
else{
|
||||
Hybrid_Auth::storage()->set( "hauth_session.{$this->providerId}.token.$token", $value );
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* delete a stored token
|
||||
*/
|
||||
public function deleteToken( $token )
|
||||
{
|
||||
Hybrid_Auth::storage()->delete( "hauth_session.{$this->providerId}.token.$token" );
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* clear all existen tokens for this provider
|
||||
*/
|
||||
public function clearTokens()
|
||||
{
|
||||
Hybrid_Auth::storage()->deleteMatch( "hauth_session.{$this->providerId}." );
|
||||
}
|
||||
}
|
161
web/third_party/hybridauth/Hybrid/Provider_Model_OAuth1.php
vendored
Normal file
161
web/third_party/hybridauth/Hybrid/Provider_Model_OAuth1.php
vendored
Normal file
@ -0,0 +1,161 @@
|
||||
<?php
|
||||
/*!
|
||||
* HybridAuth
|
||||
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
|
||||
* (c) 2009-2012, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
|
||||
*/
|
||||
|
||||
/**
|
||||
* To implement an OAuth 1 based service provider, Hybrid_Provider_Model_OAuth1
|
||||
* can be used to save the hassle of the authentication flow.
|
||||
*
|
||||
* Each class that inherit from Hybrid_Provider_Model_OAuth1 have to implemenent
|
||||
* at least 2 methods:
|
||||
* Hybrid_Providers_{provider_name}::initialize() to setup the provider api end-points urls
|
||||
* Hybrid_Providers_{provider_name}::getUserProfile() to grab the user profile
|
||||
*
|
||||
* Hybrid_Provider_Model_OAuth1 use OAuth1Client v0.1 which can be found on
|
||||
* Hybrid/thirdparty/OAuth/OAuth1Client.php
|
||||
*/
|
||||
class Hybrid_Provider_Model_OAuth1 extends Hybrid_Provider_Model
|
||||
{
|
||||
public $request_tokens_raw = null; // request_tokens as recived from provider
|
||||
public $access_tokens_raw = null; // access_tokens as recived from provider
|
||||
|
||||
/**
|
||||
* try to get the error message from provider api
|
||||
*/
|
||||
function errorMessageByStatus( $code = null ) {
|
||||
$http_status_codes = ARRAY(
|
||||
200 => "OK: Success!",
|
||||
304 => "Not Modified: There was no new data to return.",
|
||||
400 => "Bad Request: The request was invalid.",
|
||||
401 => "Unauthorized.",
|
||||
403 => "Forbidden: The request is understood, but it has been refused.",
|
||||
404 => "Not Found: The URI requested is invalid or the resource requested does not exists.",
|
||||
406 => "Not Acceptable.",
|
||||
500 => "Internal Server Error: Something is broken.",
|
||||
502 => "Bad Gateway.",
|
||||
503 => "Service Unavailable."
|
||||
);
|
||||
|
||||
if( ! $code && $this->api )
|
||||
$code = $this->api->http_code;
|
||||
|
||||
if( isset( $http_status_codes[ $code ] ) )
|
||||
return $code . " " . $http_status_codes[ $code ];
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* adapter initializer
|
||||
*/
|
||||
function initialize()
|
||||
{
|
||||
// 1 - check application credentials
|
||||
if ( ! $this->config["keys"]["id"] || ! $this->config["keys"]["secret"] ){
|
||||
throw new Exception( "Your application key and secret are required in order to connect to {$this->providerId}.", 4 );
|
||||
}
|
||||
|
||||
// 2 - include OAuth lib and client
|
||||
require_once Hybrid_Auth::$config["path_libraries"] . "OAuth/OAuth.php";
|
||||
require_once Hybrid_Auth::$config["path_libraries"] . "OAuth/OAuth1Client.php";
|
||||
|
||||
// 3.1 - setup access_token if any stored
|
||||
if( $this->token( "access_token" ) ){
|
||||
$this->api = new OAuth1Client(
|
||||
$this->config["keys"]["id"], $this->config["keys"]["secret"],
|
||||
$this->token( "access_token" ), $this->token( "access_token_secret" )
|
||||
);
|
||||
}
|
||||
|
||||
// 3.2 - setup request_token if any stored, in order to exchange with an access token
|
||||
elseif( $this->token( "request_token" ) ){
|
||||
$this->api = new OAuth1Client(
|
||||
$this->config["keys"]["id"], $this->config["keys"]["secret"],
|
||||
$this->token( "request_token" ), $this->token( "request_token_secret" )
|
||||
);
|
||||
}
|
||||
|
||||
// 3.3 - instanciate OAuth client with client credentials
|
||||
else{
|
||||
$this->api = new OAuth1Client( $this->config["keys"]["id"], $this->config["keys"]["secret"] );
|
||||
}
|
||||
|
||||
// Set curl proxy if exist
|
||||
if( isset( Hybrid_Auth::$config["proxy"] ) ){
|
||||
$this->api->curl_proxy = Hybrid_Auth::$config["proxy"];
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* begin login step
|
||||
*/
|
||||
function loginBegin()
|
||||
{
|
||||
$tokens = $this->api->requestToken( $this->endpoint );
|
||||
|
||||
// request tokens as recived from provider
|
||||
$this->request_tokens_raw = $tokens;
|
||||
|
||||
// check the last HTTP status code returned
|
||||
if ( $this->api->http_code != 200 ){
|
||||
throw new Exception( "Authentication failed! {$this->providerId} returned an error. " . $this->errorMessageByStatus( $this->api->http_code ), 5 );
|
||||
}
|
||||
|
||||
if ( ! isset( $tokens["oauth_token"] ) ){
|
||||
throw new Exception( "Authentication failed! {$this->providerId} returned an invalid oauth token.", 5 );
|
||||
}
|
||||
|
||||
$this->token( "request_token" , $tokens["oauth_token"] );
|
||||
$this->token( "request_token_secret", $tokens["oauth_token_secret"] );
|
||||
|
||||
# redirect the user to the provider authentication url
|
||||
Hybrid_Auth::redirect( $this->api->authorizeUrl( $tokens ) );
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* finish login step
|
||||
*/
|
||||
function loginFinish()
|
||||
{
|
||||
$oauth_token = (array_key_exists('oauth_token',$_REQUEST))?$_REQUEST['oauth_token']:"";
|
||||
$oauth_verifier = (array_key_exists('oauth_verifier',$_REQUEST))?$_REQUEST['oauth_verifier']:"";
|
||||
|
||||
if ( ! $oauth_token || ! $oauth_verifier ){
|
||||
throw new Exception( "Authentication failed! {$this->providerId} returned an invalid oauth verifier.", 5 );
|
||||
}
|
||||
|
||||
// request an access token
|
||||
$tokens = $this->api->accessToken( $oauth_verifier );
|
||||
|
||||
// access tokens as recived from provider
|
||||
$this->access_tokens_raw = $tokens;
|
||||
|
||||
// check the last HTTP status code returned
|
||||
if ( $this->api->http_code != 200 ){
|
||||
throw new Exception( "Authentication failed! {$this->providerId} returned an error. " . $this->errorMessageByStatus( $this->api->http_code ), 5 );
|
||||
}
|
||||
|
||||
// we should have an access_token, or else, something has gone wrong
|
||||
if ( ! isset( $tokens["oauth_token"] ) ){
|
||||
throw new Exception( "Authentication failed! {$this->providerId} returned an invalid access token.", 5 );
|
||||
}
|
||||
|
||||
// we no more need to store requet tokens
|
||||
$this->deleteToken( "request_token" );
|
||||
$this->deleteToken( "request_token_secret" );
|
||||
|
||||
// sotre access_token for later user
|
||||
$this->token( "access_token" , $tokens['oauth_token'] );
|
||||
$this->token( "access_token_secret" , $tokens['oauth_token_secret'] );
|
||||
|
||||
// set user as logged in to the current provider
|
||||
$this->setUserConnected();
|
||||
}
|
||||
}
|
176
web/third_party/hybridauth/Hybrid/Provider_Model_OAuth2.php
vendored
Normal file
176
web/third_party/hybridauth/Hybrid/Provider_Model_OAuth2.php
vendored
Normal file
@ -0,0 +1,176 @@
|
||||
<?php
|
||||
/*!
|
||||
* HybridAuth
|
||||
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
|
||||
* (c) 2009-2012, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
|
||||
*/
|
||||
|
||||
/**
|
||||
* To implement an OAuth 2 based service provider, Hybrid_Provider_Model_OAuth2
|
||||
* can be used to save the hassle of the authentication flow.
|
||||
*
|
||||
* Each class that inherit from Hybrid_Provider_Model_OAuth2 have to implemenent
|
||||
* at least 2 methods:
|
||||
* Hybrid_Providers_{provider_name}::initialize() to setup the provider api end-points urls
|
||||
* Hybrid_Providers_{provider_name}::getUserProfile() to grab the user profile
|
||||
*
|
||||
* Hybrid_Provider_Model_OAuth2 use OAuth2Client v0.1 which can be found on
|
||||
* Hybrid/thirdparty/OAuth/OAuth2Client.php
|
||||
*/
|
||||
class Hybrid_Provider_Model_OAuth2 extends Hybrid_Provider_Model
|
||||
{
|
||||
// default permissions
|
||||
public $scope = "";
|
||||
|
||||
/**
|
||||
* try to get the error message from provider api
|
||||
*/
|
||||
function errorMessageByStatus( $code = null ) {
|
||||
$http_status_codes = ARRAY(
|
||||
200 => "OK: Success!",
|
||||
304 => "Not Modified: There was no new data to return.",
|
||||
400 => "Bad Request: The request was invalid.",
|
||||
401 => "Unauthorized.",
|
||||
403 => "Forbidden: The request is understood, but it has been refused.",
|
||||
404 => "Not Found: The URI requested is invalid or the resource requested does not exists.",
|
||||
406 => "Not Acceptable.",
|
||||
500 => "Internal Server Error: Something is broken.",
|
||||
502 => "Bad Gateway.",
|
||||
503 => "Service Unavailable."
|
||||
);
|
||||
|
||||
if( ! $code && $this->api )
|
||||
$code = $this->api->http_code;
|
||||
|
||||
if( isset( $http_status_codes[ $code ] ) )
|
||||
return $code . " " . $http_status_codes[ $code ];
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* adapter initializer
|
||||
*/
|
||||
function initialize()
|
||||
{
|
||||
if ( ! $this->config["keys"]["id"] || ! $this->config["keys"]["secret"] ){
|
||||
throw new Exception( "Your application id and secret are required in order to connect to {$this->providerId}.", 4 );
|
||||
}
|
||||
|
||||
// override requested scope
|
||||
if( isset( $this->config["scope"] ) && ! empty( $this->config["scope"] ) ){
|
||||
$this->scope = $this->config["scope"];
|
||||
}
|
||||
|
||||
// include OAuth2 client
|
||||
require_once Hybrid_Auth::$config["path_libraries"] . "OAuth/OAuth2Client.php";
|
||||
|
||||
// create a new OAuth2 client instance
|
||||
$this->api = new OAuth2Client( $this->config["keys"]["id"], $this->config["keys"]["secret"], $this->endpoint );
|
||||
|
||||
// If we have an access token, set it
|
||||
if( $this->token( "access_token" ) ){
|
||||
$this->api->access_token = $this->token( "access_token" );
|
||||
$this->api->refresh_token = $this->token( "refresh_token" );
|
||||
$this->api->access_token_expires_in = $this->token( "expires_in" );
|
||||
$this->api->access_token_expires_at = $this->token( "expires_at" );
|
||||
}
|
||||
|
||||
// Set curl proxy if exist
|
||||
if( isset( Hybrid_Auth::$config["proxy"] ) ){
|
||||
$this->api->curl_proxy = Hybrid_Auth::$config["proxy"];
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* begin login step
|
||||
*/
|
||||
function loginBegin()
|
||||
{
|
||||
// redirect the user to the provider authentication url
|
||||
Hybrid_Auth::redirect( $this->api->authorizeUrl( array( "scope" => $this->scope ) ) );
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* finish login step
|
||||
*/
|
||||
function loginFinish()
|
||||
{
|
||||
$error = (array_key_exists('error',$_REQUEST))?$_REQUEST['error']:"";
|
||||
|
||||
// check for errors
|
||||
if ( $error ){
|
||||
throw new Exception( "Authentication failed! {$this->providerId} returned an error: $error", 5 );
|
||||
}
|
||||
|
||||
// try to authenicate user
|
||||
$code = (array_key_exists('code',$_REQUEST))?$_REQUEST['code']:"";
|
||||
|
||||
try{
|
||||
$this->api->authenticate( $code );
|
||||
}
|
||||
catch( Exception $e ){
|
||||
throw new Exception( "User profile request failed! {$this->providerId} returned an error: $e", 6 );
|
||||
}
|
||||
|
||||
// check if authenticated
|
||||
if ( ! $this->api->access_token ){
|
||||
throw new Exception( "Authentication failed! {$this->providerId} returned an invalid access token.", 5 );
|
||||
}
|
||||
|
||||
// store tokens
|
||||
$this->token( "access_token" , $this->api->access_token );
|
||||
$this->token( "refresh_token", $this->api->refresh_token );
|
||||
$this->token( "expires_in" , $this->api->access_token_expires_in );
|
||||
$this->token( "expires_at" , $this->api->access_token_expires_at );
|
||||
|
||||
// set user connected locally
|
||||
$this->setUserConnected();
|
||||
}
|
||||
|
||||
function refreshToken()
|
||||
{
|
||||
// have an access token?
|
||||
if( $this->api->access_token ){
|
||||
|
||||
// have to refresh?
|
||||
if( $this->api->refresh_token && $this->api->access_token_expires_at ){
|
||||
|
||||
// expired?
|
||||
if( $this->api->access_token_expires_at <= time() ){
|
||||
$response = $this->api->refreshToken( array( "refresh_token" => $this->api->refresh_token ) );
|
||||
|
||||
if( ! isset( $response->access_token ) || ! $response->access_token ){
|
||||
// set the user as disconnected at this point and throw an exception
|
||||
$this->setUserUnconnected();
|
||||
|
||||
throw new Exception( "The Authorization Service has return an invalid response while requesting a new access token. " . (string) $response->error );
|
||||
}
|
||||
|
||||
// set new access_token
|
||||
$this->api->access_token = $response->access_token;
|
||||
|
||||
if( isset( $response->refresh_token ) )
|
||||
$this->api->refresh_token = $response->refresh_token;
|
||||
|
||||
if( isset( $response->expires_in ) ){
|
||||
$this->api->access_token_expires_in = $response->expires_in;
|
||||
|
||||
// even given by some idp, we should calculate this
|
||||
$this->api->access_token_expires_at = time() + $response->expires_in;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// re store tokens
|
||||
$this->token( "access_token" , $this->api->access_token );
|
||||
$this->token( "refresh_token", $this->api->refresh_token );
|
||||
$this->token( "expires_in" , $this->api->access_token_expires_in );
|
||||
$this->token( "expires_at" , $this->api->access_token_expires_at );
|
||||
}
|
||||
}
|
||||
}
|
172
web/third_party/hybridauth/Hybrid/Provider_Model_OpenID.php
vendored
Normal file
172
web/third_party/hybridauth/Hybrid/Provider_Model_OpenID.php
vendored
Normal file
@ -0,0 +1,172 @@
|
||||
<?php
|
||||
/*!
|
||||
* HybridAuth
|
||||
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
|
||||
* (c) 2009-2012, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
|
||||
*/
|
||||
|
||||
/**
|
||||
* To implement an OpenID based service provider, Hybrid_Provider_Model_OpenID
|
||||
* can be used to save the hassle of the authentication flow.
|
||||
*
|
||||
* Each class that inherit from Hybrid_Provider_Model_OAuth2 have only to define
|
||||
* the provider identifier : <code>public $openidIdentifier = ""; </code>
|
||||
*
|
||||
* Hybrid_Provider_Model_OpenID use LightOpenID lib which can be found on
|
||||
* Hybrid/thirdparty/OpenID/LightOpenID.php
|
||||
*/
|
||||
class Hybrid_Provider_Model_OpenID extends Hybrid_Provider_Model
|
||||
{
|
||||
/* Openid provider identifier */
|
||||
public $openidIdentifier = "";
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* adapter initializer
|
||||
*/
|
||||
function initialize()
|
||||
{
|
||||
if( isset( $this->params["openid_identifier"] ) ){
|
||||
$this->openidIdentifier = $this->params["openid_identifier"];
|
||||
}
|
||||
|
||||
// include LightOpenID lib
|
||||
require_once Hybrid_Auth::$config["path_libraries"] . "OpenID/LightOpenID.php";
|
||||
|
||||
// An error was occurring when proxy wasn't set. Not sure where proxy was meant to be set/initialized.
|
||||
Hybrid_Auth::$config['proxy'] = isset(Hybrid_Auth::$config['proxy'])?Hybrid_Auth::$config['proxy']:'';
|
||||
|
||||
$this->api = new LightOpenID( parse_url( Hybrid_Auth::$config["base_url"], PHP_URL_HOST), Hybrid_Auth::$config["proxy"] );
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* begin login step
|
||||
*/
|
||||
function loginBegin()
|
||||
{
|
||||
if( empty( $this->openidIdentifier ) ){
|
||||
throw new Exception( "OpenID adapter require the identity provider identifier 'openid_identifier' as an extra parameter.", 4 );
|
||||
}
|
||||
|
||||
$this->api->identity = $this->openidIdentifier;
|
||||
$this->api->returnUrl = $this->endpoint;
|
||||
$this->api->required = ARRAY(
|
||||
'namePerson/first' ,
|
||||
'namePerson/last' ,
|
||||
'namePerson/friendly' ,
|
||||
'namePerson' ,
|
||||
|
||||
'contact/email' ,
|
||||
|
||||
'birthDate' ,
|
||||
'birthDate/birthDay' ,
|
||||
'birthDate/birthMonth' ,
|
||||
'birthDate/birthYear' ,
|
||||
|
||||
'person/gender' ,
|
||||
'pref/language' ,
|
||||
|
||||
'contact/postalCode/home',
|
||||
'contact/city/home' ,
|
||||
'contact/country/home' ,
|
||||
|
||||
'media/image/default' ,
|
||||
);
|
||||
|
||||
# redirect the user to the provider authentication url
|
||||
Hybrid_Auth::redirect( $this->api->authUrl() );
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* finish login step
|
||||
*/
|
||||
function loginFinish()
|
||||
{
|
||||
# if user don't garant acess of their data to your site, halt with an Exception
|
||||
if( $this->api->mode == 'cancel'){
|
||||
throw new Exception( "Authentication failed! User has canceled authentication!", 5 );
|
||||
}
|
||||
|
||||
# if something goes wrong
|
||||
if( ! $this->api->validate() ){
|
||||
throw new Exception( "Authentication failed. Invalid request recived!", 5 );
|
||||
}
|
||||
|
||||
# fetch recived user data
|
||||
$response = $this->api->getAttributes();
|
||||
|
||||
# sotre the user profile
|
||||
$this->user->profile->identifier = $this->api->identity;
|
||||
|
||||
$this->user->profile->firstName = (array_key_exists("namePerson/first",$response))?$response["namePerson/first"]:"";
|
||||
$this->user->profile->lastName = (array_key_exists("namePerson/last",$response))?$response["namePerson/last"]:"";
|
||||
$this->user->profile->displayName = (array_key_exists("namePerson",$response))?$response["namePerson"]:"";
|
||||
$this->user->profile->email = (array_key_exists("contact/email",$response))?$response["contact/email"]:"";
|
||||
$this->user->profile->language = (array_key_exists("pref/language",$response))?$response["pref/language"]:"";
|
||||
$this->user->profile->country = (array_key_exists("contact/country/home",$response))?$response["contact/country/home"]:"";
|
||||
$this->user->profile->zip = (array_key_exists("contact/postalCode/home",$response))?$response["contact/postalCode/home"]:"";
|
||||
$this->user->profile->gender = (array_key_exists("person/gender",$response))?$response["person/gender"]:"";
|
||||
$this->user->profile->photoURL = (array_key_exists("media/image/default",$response))?$response["media/image/default"]:"";
|
||||
|
||||
$this->user->profile->birthDay = (array_key_exists("birthDate/birthDay",$response))?$response["birthDate/birthDay"]:"";
|
||||
$this->user->profile->birthMonth = (array_key_exists("birthDate/birthMonth",$response))?$response["birthDate/birthMonth"]:"";
|
||||
$this->user->profile->birthYear = (array_key_exists("birthDate/birthDate",$response))?$response["birthDate/birthDate"]:"";
|
||||
|
||||
if( ! $this->user->profile->displayName ) {
|
||||
$this->user->profile->displayName = trim( $this->user->profile->lastName . " " . $this->user->profile->firstName );
|
||||
}
|
||||
|
||||
if( isset( $response['namePerson/friendly'] ) && ! empty( $response['namePerson/friendly'] ) && ! $this->user->profile->displayName ) {
|
||||
$this->user->profile->displayName = (array_key_exists("namePerson/friendly",$response))?$response["namePerson/friendly"]:"" ;
|
||||
}
|
||||
|
||||
if( isset( $response['birthDate'] ) && ! empty( $response['birthDate'] ) && ! $this->user->profile->birthDay ) {
|
||||
list( $birthday_year, $birthday_month, $birthday_day ) = (array_key_exists('birthDate',$response))?$response['birthDate']:"";
|
||||
|
||||
$this->user->profile->birthDay = (int) $birthday_day;
|
||||
$this->user->profile->birthMonth = (int) $birthday_month;
|
||||
$this->user->profile->birthYear = (int) $birthday_year;
|
||||
}
|
||||
|
||||
if( ! $this->user->profile->displayName ){
|
||||
$this->user->profile->displayName = trim( $this->user->profile->firstName . " " . $this->user->profile->lastName );
|
||||
}
|
||||
|
||||
if( $this->user->profile->gender == "f" ){
|
||||
$this->user->profile->gender = "female";
|
||||
}
|
||||
|
||||
if( $this->user->profile->gender == "m" ){
|
||||
$this->user->profile->gender = "male";
|
||||
}
|
||||
|
||||
// set user as logged in
|
||||
$this->setUserConnected();
|
||||
|
||||
// with openid providers we get the user profile only once, so store it
|
||||
Hybrid_Auth::storage()->set( "hauth_session.{$this->providerId}.user", $this->user );
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* load the user profile from the IDp api client
|
||||
*/
|
||||
function getUserProfile()
|
||||
{
|
||||
// try to get the user profile from stored data
|
||||
$this->user = Hybrid_Auth::storage()->get( "hauth_session.{$this->providerId}.user" ) ;
|
||||
|
||||
// if not found
|
||||
if ( ! is_object( $this->user ) ){
|
||||
throw new Exception( "User profile request failed! User is not connected to {$this->providerId} or his session has expired.", 6 );
|
||||
}
|
||||
|
||||
return $this->user->profile;
|
||||
}
|
||||
}
|
271
web/third_party/hybridauth/Hybrid/Providers/Facebook.php
vendored
Normal file
271
web/third_party/hybridauth/Hybrid/Providers/Facebook.php
vendored
Normal file
@ -0,0 +1,271 @@
|
||||
<?php
|
||||
/*!
|
||||
* HybridAuth
|
||||
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
|
||||
* (c) 2009-2012, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
|
||||
*/
|
||||
|
||||
/**
|
||||
* Hybrid_Providers_Facebook provider adapter based on OAuth2 protocol
|
||||
*
|
||||
* Hybrid_Providers_Facebook use the Facebook PHP SDK created by Facebook
|
||||
*
|
||||
* http://hybridauth.sourceforge.net/userguide/IDProvider_info_Facebook.html
|
||||
*/
|
||||
class Hybrid_Providers_Facebook extends Hybrid_Provider_Model
|
||||
{
|
||||
// default permissions, and alot of them. You can change them from the configuration by setting the scope to what you want/need
|
||||
public $scope = "email, user_about_me, user_birthday, user_hometown, user_website, read_stream, offline_access, publish_stream, read_friendlists";
|
||||
|
||||
/**
|
||||
* IDp wrappers initializer
|
||||
*/
|
||||
function initialize()
|
||||
{
|
||||
if ( ! $this->config["keys"]["id"] || ! $this->config["keys"]["secret"] ){
|
||||
throw new Exception( "Your application id and secret are required in order to connect to {$this->providerId}.", 4 );
|
||||
}
|
||||
|
||||
if ( ! class_exists('FacebookApiException', false) ) {
|
||||
require_once Hybrid_Auth::$config["path_libraries"] . "Facebook/base_facebook.php";
|
||||
require_once Hybrid_Auth::$config["path_libraries"] . "Facebook/facebook.php";
|
||||
}
|
||||
|
||||
if ( isset ( Hybrid_Auth::$config["proxy"] ) ) {
|
||||
BaseFacebook::$CURL_OPTS[CURLOPT_PROXY] = Hybrid_Auth::$config["proxy"];
|
||||
}
|
||||
|
||||
$this->api = new Facebook( ARRAY( 'appId' => $this->config["keys"]["id"], 'secret' => $this->config["keys"]["secret"] ) );
|
||||
|
||||
if ( $this->token("access_token") ) {
|
||||
$this->api->setAccessToken( $this->token("access_token") );
|
||||
$this->api->setExtendedAccessToken();
|
||||
$access_token = $this->api->getAccessToken();
|
||||
|
||||
if( $access_token ){
|
||||
$this->token("access_token", $access_token );
|
||||
$this->api->setAccessToken( $access_token );
|
||||
}
|
||||
|
||||
$this->api->setAccessToken( $this->token("access_token") );
|
||||
}
|
||||
|
||||
$this->api->getUser();
|
||||
}
|
||||
|
||||
/**
|
||||
* begin login step
|
||||
*
|
||||
* simply call Facebook::require_login().
|
||||
*/
|
||||
function loginBegin()
|
||||
{
|
||||
$parameters = array("scope" => $this->scope, "redirect_uri" => $this->endpoint, "display" => "page");
|
||||
$optionals = array("scope", "redirect_uri", "display");
|
||||
|
||||
foreach ($optionals as $parameter){
|
||||
if( isset( $this->config[$parameter] ) && ! empty( $this->config[$parameter] ) ){
|
||||
$parameters[$parameter] = $this->config[$parameter];
|
||||
}
|
||||
}
|
||||
|
||||
// get the login url
|
||||
$url = $this->api->getLoginUrl( $parameters );
|
||||
|
||||
// redirect to facebook
|
||||
Hybrid_Auth::redirect( $url );
|
||||
}
|
||||
|
||||
/**
|
||||
* finish login step
|
||||
*/
|
||||
function loginFinish()
|
||||
{
|
||||
// in case we get error_reason=user_denied&error=access_denied
|
||||
if ( isset( $_REQUEST['error'] ) && $_REQUEST['error'] == "access_denied" ){
|
||||
throw new Exception( "Authentication failed! The user denied your request.", 5 );
|
||||
}
|
||||
|
||||
// try to get the UID of the connected user from fb, should be > 0
|
||||
if ( ! $this->api->getUser() ){
|
||||
throw new Exception( "Authentication failed! {$this->providerId} returned an invalid user id.", 5 );
|
||||
}
|
||||
|
||||
// set user as logged in
|
||||
$this->setUserConnected();
|
||||
|
||||
// store facebook access token
|
||||
$this->token( "access_token", $this->api->getAccessToken() );
|
||||
}
|
||||
|
||||
/**
|
||||
* logout
|
||||
*/
|
||||
function logout()
|
||||
{
|
||||
$this->api->destroySession();
|
||||
|
||||
parent::logout();
|
||||
}
|
||||
|
||||
/**
|
||||
* load the user profile from the IDp api client
|
||||
*/
|
||||
function getUserProfile()
|
||||
{
|
||||
// request user profile from fb api
|
||||
try{
|
||||
$data = $this->api->api('/me');
|
||||
}
|
||||
catch( FacebookApiException $e ){
|
||||
throw new Exception( "User profile request failed! {$this->providerId} returned an error: $e", 6 );
|
||||
}
|
||||
|
||||
// if the provider identifier is not recived, we assume the auth has failed
|
||||
if ( ! isset( $data["id"] ) ){
|
||||
throw new Exception( "User profile request failed! {$this->providerId} api returned an invalid response.", 6 );
|
||||
}
|
||||
|
||||
# store the user profile.
|
||||
$this->user->profile->identifier = (array_key_exists('id',$data))?$data['id']:"";
|
||||
$this->user->profile->displayName = (array_key_exists('name',$data))?$data['name']:"";
|
||||
$this->user->profile->firstName = (array_key_exists('first_name',$data))?$data['first_name']:"";
|
||||
$this->user->profile->lastName = (array_key_exists('last_name',$data))?$data['last_name']:"";
|
||||
$this->user->profile->photoURL = "https://graph.facebook.com/" . $this->user->profile->identifier . "/picture?width=150&height=150";
|
||||
$this->user->profile->profileURL = (array_key_exists('link',$data))?$data['link']:"";
|
||||
$this->user->profile->webSiteURL = (array_key_exists('website',$data))?$data['website']:"";
|
||||
$this->user->profile->gender = (array_key_exists('gender',$data))?$data['gender']:"";
|
||||
$this->user->profile->description = (array_key_exists('bio',$data))?$data['bio']:"";
|
||||
$this->user->profile->email = (array_key_exists('email',$data))?$data['email']:"";
|
||||
$this->user->profile->emailVerified = (array_key_exists('email',$data))?$data['email']:"";
|
||||
$this->user->profile->region = (array_key_exists("hometown",$data)&&array_key_exists("name",$data['hometown']))?$data['hometown']["name"]:"";
|
||||
|
||||
if( array_key_exists('birthday',$data) ) {
|
||||
list($birthday_month, $birthday_day, $birthday_year) = explode( "/", $data['birthday'] );
|
||||
|
||||
$this->user->profile->birthDay = (int) $birthday_day;
|
||||
$this->user->profile->birthMonth = (int) $birthday_month;
|
||||
$this->user->profile->birthYear = (int) $birthday_year;
|
||||
}
|
||||
|
||||
return $this->user->profile;
|
||||
}
|
||||
|
||||
/**
|
||||
* load the user contacts
|
||||
*/
|
||||
function getUserContacts()
|
||||
{
|
||||
try{
|
||||
$response = $this->api->api('/me/friends');
|
||||
}
|
||||
catch( FacebookApiException $e ){
|
||||
throw new Exception( "User contacts request failed! {$this->providerId} returned an error: $e" );
|
||||
}
|
||||
|
||||
if( ! $response || ! count( $response["data"] ) ){
|
||||
return ARRAY();
|
||||
}
|
||||
|
||||
$contacts = ARRAY();
|
||||
|
||||
foreach( $response["data"] as $item ){
|
||||
$uc = new Hybrid_User_Contact();
|
||||
|
||||
$uc->identifier = (array_key_exists("id",$item))?$item["id"]:"";
|
||||
$uc->displayName = (array_key_exists("name",$item))?$item["name"]:"";
|
||||
$uc->profileURL = "https://www.facebook.com/profile.php?id=" . $uc->identifier;
|
||||
$uc->photoURL = "https://graph.facebook.com/" . $uc->identifier . "/picture?width=150&height=150";
|
||||
|
||||
$contacts[] = $uc;
|
||||
}
|
||||
|
||||
return $contacts;
|
||||
}
|
||||
|
||||
/**
|
||||
* update user status
|
||||
*/
|
||||
function setUserStatus( $status )
|
||||
{
|
||||
$parameters = array();
|
||||
|
||||
if( is_array( $status ) ){
|
||||
$parameters = $status;
|
||||
}
|
||||
else{
|
||||
$parameters["message"] = $status;
|
||||
}
|
||||
|
||||
try{
|
||||
$response = $this->api->api( "/me/feed", "post", $parameters );
|
||||
}
|
||||
catch( FacebookApiException $e ){
|
||||
throw new Exception( "Update user status failed! {$this->providerId} returned an error: $e" );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* load the user latest activity
|
||||
* - timeline : all the stream
|
||||
* - me : the user activity only
|
||||
*/
|
||||
function getUserActivity( $stream )
|
||||
{
|
||||
try{
|
||||
if( $stream == "me" ){
|
||||
$response = $this->api->api( '/me/feed' );
|
||||
}
|
||||
else{
|
||||
$response = $this->api->api('/me/home');
|
||||
}
|
||||
}
|
||||
catch( FacebookApiException $e ){
|
||||
throw new Exception( "User activity stream request failed! {$this->providerId} returned an error: $e" );
|
||||
}
|
||||
|
||||
if( ! $response || ! count( $response['data'] ) ){
|
||||
return ARRAY();
|
||||
}
|
||||
|
||||
$activities = ARRAY();
|
||||
|
||||
foreach( $response['data'] as $item ){
|
||||
if( $stream == "me" && $item["from"]["id"] != $this->api->getUser() ){
|
||||
continue;
|
||||
}
|
||||
|
||||
$ua = new Hybrid_User_Activity();
|
||||
|
||||
$ua->id = (array_key_exists("id",$item))?$item["id"]:"";
|
||||
$ua->date = (array_key_exists("created_time",$item))?strtotime($item["created_time"]):"";
|
||||
|
||||
if( $item["type"] == "video" ){
|
||||
$ua->text = (array_key_exists("link",$item))?$item["link"]:"";
|
||||
}
|
||||
|
||||
if( $item["type"] == "link" ){
|
||||
$ua->text = (array_key_exists("link",$item))?$item["link"]:"";
|
||||
}
|
||||
|
||||
if( empty( $ua->text ) && isset( $item["story"] ) ){
|
||||
$ua->text = (array_key_exists("link",$item))?$item["link"]:"";
|
||||
}
|
||||
|
||||
if( empty( $ua->text ) && isset( $item["message"] ) ){
|
||||
$ua->text = (array_key_exists("message",$item))?$item["message"]:"";
|
||||
}
|
||||
|
||||
if( ! empty( $ua->text ) ){
|
||||
$ua->user->identifier = (array_key_exists("id",$item["from"]))?$item["from"]["id"]:"";
|
||||
$ua->user->displayName = (array_key_exists("name",$item["from"]))?$item["from"]["name"]:"";
|
||||
$ua->user->profileURL = "https://www.facebook.com/profile.php?id=" . $ua->user->identifier;
|
||||
$ua->user->photoURL = "https://graph.facebook.com/" . $ua->user->identifier . "/picture?type=square";
|
||||
|
||||
$activities[] = $ua;
|
||||
}
|
||||
}
|
||||
|
||||
return $activities;
|
||||
}
|
||||
}
|
56
web/third_party/hybridauth/Hybrid/Providers/GitHub.php
vendored
Normal file
56
web/third_party/hybridauth/Hybrid/Providers/GitHub.php
vendored
Normal file
@ -0,0 +1,56 @@
|
||||
<?php
|
||||
/*!
|
||||
* HybridAuth
|
||||
* http://hybridauth.sourceforge.net | https://github.com/hybridauth/hybridauth
|
||||
* (c) 2009-2011 HybridAuth authors | hybridauth.sourceforge.net/licenses.html
|
||||
*/
|
||||
|
||||
/**
|
||||
* Hybrid_Providers_GitHub
|
||||
*/
|
||||
class Hybrid_Providers_GitHub extends Hybrid_Provider_Model_OAuth2
|
||||
{
|
||||
// default permissions
|
||||
// (no scope) => public read-only access (includes public user profile info, public repo info, and gists).
|
||||
public $scope = "";
|
||||
|
||||
/**
|
||||
* IDp wrappers initializer
|
||||
*/
|
||||
function initialize()
|
||||
{
|
||||
parent::initialize();
|
||||
|
||||
// Provider api end-points
|
||||
$this->api->api_base_url = "https://api.github.com/";
|
||||
$this->api->authorize_url = "https://github.com/login/oauth/authorize";
|
||||
$this->api->token_url = "https://github.com/login/oauth/access_token";
|
||||
}
|
||||
|
||||
/**
|
||||
* load the user profile from the IDp api client
|
||||
*/
|
||||
function getUserProfile()
|
||||
{
|
||||
$data = $this->api->api( "user" );
|
||||
|
||||
if ( ! isset( $data->id ) ){
|
||||
throw new Exception( "User profile request failed! {$this->providerId} returned an invalid response.", 6 );
|
||||
}
|
||||
|
||||
$this->user->profile->identifier = @ $data->id;
|
||||
$this->user->profile->displayName = @ $data->name;
|
||||
$this->user->profile->description = @ $data->bio;
|
||||
$this->user->profile->photoURL = @ $data->avatar_url;
|
||||
$this->user->profile->profileURL = @ $data->html_url;
|
||||
$this->user->profile->email = @ $data->email;
|
||||
$this->user->profile->webSiteURL = @ $data->blog;
|
||||
$this->user->profile->region = @ $data->location;
|
||||
|
||||
if( ! $this->user->profile->displayName ){
|
||||
$this->user->profile->displayName = @ $data->login;
|
||||
}
|
||||
|
||||
return $this->user->profile;
|
||||
}
|
||||
}
|
119
web/third_party/hybridauth/Hybrid/Providers/Google.php
vendored
Normal file
119
web/third_party/hybridauth/Hybrid/Providers/Google.php
vendored
Normal file
@ -0,0 +1,119 @@
|
||||
<?php
|
||||
/*!
|
||||
* HybridAuth
|
||||
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
|
||||
* (c) 2009-2012, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
|
||||
*/
|
||||
|
||||
/**
|
||||
* Hybrid_Providers_Google provider adapter based on OAuth2 protocol
|
||||
*
|
||||
* http://hybridauth.sourceforge.net/userguide/IDProvider_info_Google.html
|
||||
*/
|
||||
class Hybrid_Providers_Google extends Hybrid_Provider_Model_OAuth2
|
||||
{
|
||||
// default permissions
|
||||
public $scope = "https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email https://www.google.com/m8/feeds/";
|
||||
|
||||
/**
|
||||
* IDp wrappers initializer
|
||||
*/
|
||||
function initialize()
|
||||
{
|
||||
parent::initialize();
|
||||
|
||||
// Provider api end-points
|
||||
$this->api->authorize_url = "https://accounts.google.com/o/oauth2/auth";
|
||||
$this->api->token_url = "https://accounts.google.com/o/oauth2/token";
|
||||
$this->api->token_info_url = "https://www.googleapis.com/oauth2/v1/tokeninfo";
|
||||
}
|
||||
|
||||
/**
|
||||
* begin login step
|
||||
*/
|
||||
function loginBegin()
|
||||
{
|
||||
$parameters = array("scope" => $this->scope, "access_type" => "offline");
|
||||
$optionals = array("scope", "access_type", "redirect_uri", "approval_prompt", "hd");
|
||||
|
||||
foreach ($optionals as $parameter){
|
||||
if( isset( $this->config[$parameter] ) && ! empty( $this->config[$parameter] ) ){
|
||||
$parameters[$parameter] = $this->config[$parameter];
|
||||
}
|
||||
}
|
||||
|
||||
Hybrid_Auth::redirect( $this->api->authorizeUrl( $parameters ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* load the user profile from the IDp api client
|
||||
*/
|
||||
function getUserProfile()
|
||||
{
|
||||
// refresh tokens if needed
|
||||
$this->refreshToken();
|
||||
|
||||
// ask google api for user infos
|
||||
$response = $this->api->api( "https://www.googleapis.com/oauth2/v1/userinfo" );
|
||||
|
||||
if ( ! isset( $response->id ) || isset( $response->error ) ){
|
||||
throw new Exception( "User profile request failed! {$this->providerId} returned an invalid response.", 6 );
|
||||
}
|
||||
|
||||
$this->user->profile->identifier = (property_exists($response,'id'))?$response->id:"";
|
||||
$this->user->profile->firstName = (property_exists($response,'given_name'))?$response->given_name:"";
|
||||
$this->user->profile->lastName = (property_exists($response,'family_name'))?$response->family_name:"";
|
||||
$this->user->profile->displayName = (property_exists($response,'name'))?$response->name:"";
|
||||
$this->user->profile->photoURL = (property_exists($response,'picture'))?$response->picture:"";
|
||||
$this->user->profile->profileURL = "https://profiles.google.com/" . $this->user->profile->identifier;
|
||||
$this->user->profile->gender = (property_exists($response,'gender'))?$response->gender:"";
|
||||
$this->user->profile->email = (property_exists($response,'email'))?$response->email:"";
|
||||
$this->user->profile->emailVerified = (property_exists($response,'email'))?$response->email:"";
|
||||
$this->user->profile->language = (property_exists($response,'locale'))?$response->locale:"";
|
||||
|
||||
if( property_exists($response,'birthday') ){
|
||||
list($birthday_year, $birthday_month, $birthday_day) = explode( '-', $response->birthday );
|
||||
|
||||
$this->user->profile->birthDay = (int) $birthday_day;
|
||||
$this->user->profile->birthMonth = (int) $birthday_month;
|
||||
$this->user->profile->birthYear = (int) $birthday_year;
|
||||
}
|
||||
|
||||
return $this->user->profile;
|
||||
}
|
||||
|
||||
/**
|
||||
* load the user (Gmail) contacts
|
||||
* ..toComplete
|
||||
*/
|
||||
function getUserContacts()
|
||||
{
|
||||
// refresh tokens if needed
|
||||
$this->refreshToken();
|
||||
|
||||
if( ! isset( $this->config['contacts_param'] ) ){
|
||||
$this->config['contacts_param'] = array( "max-results" => 500 );
|
||||
}
|
||||
|
||||
$response = $this->api->api( "https://www.google.com/m8/feeds/contacts/default/full?"
|
||||
. http_build_query( array_merge( array('alt' => 'json'), $this->config['contacts_param'] ) ) );
|
||||
|
||||
if( ! $response ){
|
||||
return ARRAY();
|
||||
}
|
||||
|
||||
$contacts = ARRAY();
|
||||
|
||||
foreach( $response->feed->entry as $idx => $entry ){
|
||||
$uc = new Hybrid_User_Contact();
|
||||
|
||||
$uc->email = isset($entry->{'gd$email'}[0]->address) ? (string) $entry->{'gd$email'}[0]->address : '';
|
||||
$uc->displayName = isset($entry->title->{'$t'}) ? (string) $entry->title->{'$t'} : '';
|
||||
$uc->identifier = $uc->email;
|
||||
|
||||
$contacts[] = $uc;
|
||||
}
|
||||
|
||||
return $contacts;
|
||||
}
|
||||
}
|
252
web/third_party/hybridauth/Hybrid/Providers/LinkedIn.php
vendored
Normal file
252
web/third_party/hybridauth/Hybrid/Providers/LinkedIn.php
vendored
Normal file
@ -0,0 +1,252 @@
|
||||
<?php
|
||||
/*!
|
||||
* HybridAuth
|
||||
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
|
||||
* (c) 2009-2012, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
|
||||
*/
|
||||
|
||||
/**
|
||||
* Hybrid_Providers_LinkedIn provider adapter based on OAuth1 protocol
|
||||
*
|
||||
* Hybrid_Providers_LinkedIn use linkedinPHP library created by fiftyMission Inc.
|
||||
*
|
||||
* http://hybridauth.sourceforge.net/userguide/IDProvider_info_LinkedIn.html
|
||||
*/
|
||||
class Hybrid_Providers_LinkedIn extends Hybrid_Provider_Model
|
||||
{
|
||||
/**
|
||||
* IDp wrappers initializer
|
||||
*/
|
||||
function initialize()
|
||||
{
|
||||
if ( ! $this->config["keys"]["id"] || ! $this->config["keys"]["secret"] ){
|
||||
throw new Exception( "Your application key and secret are required in order to connect to {$this->providerId}.", 4 );
|
||||
}
|
||||
|
||||
require_once Hybrid_Auth::$config["path_libraries"] . "OAuth/OAuth.php";
|
||||
require_once Hybrid_Auth::$config["path_libraries"] . "LinkedIn/LinkedIn.php";
|
||||
|
||||
$this->api = new LinkedIn( array( 'appKey' => $this->config["keys"]["id"], 'appSecret' => $this->config["keys"]["secret"], 'callbackUrl' => $this->endpoint ) );
|
||||
|
||||
if( $this->token( "access_token_linkedin" ) ){
|
||||
$this->api->setTokenAccess( $this->token( "access_token_linkedin" ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* begin login step
|
||||
*/
|
||||
function loginBegin()
|
||||
{
|
||||
// send a request for a LinkedIn access token
|
||||
$response = $this->api->retrieveTokenRequest();
|
||||
|
||||
if( isset( $response['success'] ) && $response['success'] === TRUE ){
|
||||
$this->token( "oauth_token", $response['linkedin']['oauth_token'] );
|
||||
$this->token( "oauth_token_secret", $response['linkedin']['oauth_token_secret'] );
|
||||
|
||||
# redirect user to LinkedIn authorisation web page
|
||||
Hybrid_Auth::redirect( LINKEDIN::_URL_AUTH . $response['linkedin']['oauth_token'] );
|
||||
}
|
||||
else{
|
||||
throw new Exception( "Authentication failed! {$this->providerId} returned an invalid Token.", 5 );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* finish login step
|
||||
*/
|
||||
function loginFinish()
|
||||
{
|
||||
$oauth_token = $_REQUEST['oauth_token'];
|
||||
$oauth_verifier = $_REQUEST['oauth_verifier'];
|
||||
|
||||
if ( ! $oauth_verifier ){
|
||||
throw new Exception( "Authentication failed! {$this->providerId} returned an invalid Token.", 5 );
|
||||
}
|
||||
|
||||
$response = $this->api->retrieveTokenAccess( $oauth_token, $this->token( "oauth_token_secret" ), $oauth_verifier );
|
||||
|
||||
if( isset( $response['success'] ) && $response['success'] === TRUE ){
|
||||
$this->deleteToken( "oauth_token" );
|
||||
$this->deleteToken( "oauth_token_secret" );
|
||||
|
||||
$this->token( "access_token_linkedin", $response['linkedin'] );
|
||||
$this->token( "access_token" , $response['linkedin']['oauth_token'] );
|
||||
$this->token( "access_token_secret" , $response['linkedin']['oauth_token_secret'] );
|
||||
|
||||
// set user as logged in
|
||||
$this->setUserConnected();
|
||||
}
|
||||
else{
|
||||
throw new Exception( "Authentication failed! {$this->providerId} returned an invalid Token.", 5 );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* load the user profile from the IDp api client
|
||||
*/
|
||||
function getUserProfile()
|
||||
{
|
||||
try{
|
||||
// http://developer.linkedin.com/docs/DOC-1061
|
||||
$response = $this->api->profile('~:(id,first-name,last-name,public-profile-url,picture-url,email-address,date-of-birth,phone-numbers,summary)');
|
||||
}
|
||||
catch( LinkedInException $e ){
|
||||
throw new Exception( "User profile request failed! {$this->providerId} returned an error: $e", 6 );
|
||||
}
|
||||
|
||||
if( isset( $response['success'] ) && $response['success'] === TRUE ){
|
||||
$data = @ new SimpleXMLElement( $response['linkedin'] );
|
||||
|
||||
if ( ! is_object( $data ) ){
|
||||
throw new Exception( "User profile request failed! {$this->providerId} returned an invalid xml data.", 6 );
|
||||
}
|
||||
|
||||
$this->user->profile->identifier = (string) $data->{'id'};
|
||||
$this->user->profile->firstName = (string) $data->{'first-name'};
|
||||
$this->user->profile->lastName = (string) $data->{'last-name'};
|
||||
$this->user->profile->displayName = trim( $this->user->profile->firstName . " " . $this->user->profile->lastName );
|
||||
|
||||
$this->user->profile->email = (string) $data->{'email-address'};
|
||||
$this->user->profile->emailVerified = (string) $data->{'email-address'};
|
||||
|
||||
$this->user->profile->photoURL = (string) $data->{'picture-url'};
|
||||
$this->user->profile->profileURL = (string) $data->{'public-profile-url'};
|
||||
$this->user->profile->description = (string) $data->{'summary'};
|
||||
|
||||
if( $data->{'phone-numbers'} && $data->{'phone-numbers'}->{'phone-number'} ){
|
||||
$this->user->profile->phone = (string) $data->{'phone-numbers'}->{'phone-number'}->{'phone-number'};
|
||||
}
|
||||
else{
|
||||
$this->user->profile->phone = null;
|
||||
}
|
||||
|
||||
if( $data->{'date-of-birth'} ){
|
||||
$this->user->profile->birthDay = (string) $data->{'date-of-birth'}->day;
|
||||
$this->user->profile->birthMonth = (string) $data->{'date-of-birth'}->month;
|
||||
$this->user->profile->birthYear = (string) $data->{'date-of-birth'}->year;
|
||||
}
|
||||
|
||||
return $this->user->profile;
|
||||
}
|
||||
else{
|
||||
throw new Exception( "User profile request failed! {$this->providerId} returned an invalid response.", 6 );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* load the user contacts
|
||||
*/
|
||||
function getUserContacts()
|
||||
{
|
||||
try{
|
||||
$response = $this->api->profile('~/connections:(id,first-name,last-name,picture-url,public-profile-url,summary)');
|
||||
}
|
||||
catch( LinkedInException $e ){
|
||||
throw new Exception( "User contacts request failed! {$this->providerId} returned an error: $e" );
|
||||
}
|
||||
|
||||
if( ! $response || ! $response['success'] ){
|
||||
return ARRAY();
|
||||
}
|
||||
|
||||
$connections = new SimpleXMLElement( $response['linkedin'] );
|
||||
|
||||
$contacts = ARRAY();
|
||||
|
||||
foreach( $connections->person as $connection ) {
|
||||
$uc = new Hybrid_User_Contact();
|
||||
|
||||
$uc->identifier = (string) $connection->id;
|
||||
$uc->displayName = (string) $connection->{'last-name'} . " " . $connection->{'first-name'};
|
||||
$uc->profileURL = (string) $connection->{'public-profile-url'};
|
||||
$uc->photoURL = (string) $connection->{'picture-url'};
|
||||
$uc->description = (string) $connection->{'summary'};
|
||||
|
||||
$contacts[] = $uc;
|
||||
}
|
||||
|
||||
return $contacts;
|
||||
}
|
||||
|
||||
/**
|
||||
* update user status
|
||||
*/
|
||||
function setUserStatus( $status )
|
||||
{
|
||||
$parameters = array();
|
||||
$private = true; // share with your connections only
|
||||
|
||||
if( is_array( $status ) ){
|
||||
if( isset( $status[0] ) && ! empty( $status[0] ) ) $parameters["title"] = $status[0]; // post title
|
||||
if( isset( $status[1] ) && ! empty( $status[1] ) ) $parameters["comment"] = $status[1]; // post comment
|
||||
if( isset( $status[2] ) && ! empty( $status[2] ) ) $parameters["submitted-url"] = $status[2]; // post url
|
||||
if( isset( $status[3] ) && ! empty( $status[3] ) ) $parameters["submitted-image-url"] = $status[3]; // post picture url
|
||||
if( isset( $status[4] ) && ! empty( $status[4] ) ) $private = $status[4]; // true or false
|
||||
}
|
||||
else{
|
||||
$parameters["comment"] = $status;
|
||||
}
|
||||
|
||||
try{
|
||||
$response = $this->api->share( 'new', $parameters, $private );
|
||||
}
|
||||
catch( LinkedInException $e ){
|
||||
throw new Exception( "Update user status update failed! {$this->providerId} returned an error: $e" );
|
||||
}
|
||||
|
||||
if ( ! $response || ! $response['success'] )
|
||||
{
|
||||
throw new Exception( "Update user status update failed! {$this->providerId} returned an error." );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* load the user latest activity
|
||||
* - timeline : all the stream
|
||||
* - me : the user activity only
|
||||
*/
|
||||
function getUserActivity( $stream )
|
||||
{
|
||||
try{
|
||||
if( $stream == "me" ){
|
||||
$response = $this->api->updates( '?type=SHAR&scope=self&count=25' );
|
||||
}
|
||||
else{
|
||||
$response = $this->api->updates( '?type=SHAR&count=25' );
|
||||
}
|
||||
}
|
||||
catch( LinkedInException $e ){
|
||||
throw new Exception( "User activity stream request failed! {$this->providerId} returned an error: $e" );
|
||||
}
|
||||
|
||||
if( ! $response || ! $response['success'] ){
|
||||
return ARRAY();
|
||||
}
|
||||
|
||||
$updates = new SimpleXMLElement( $response['linkedin'] );
|
||||
|
||||
$activities = ARRAY();
|
||||
|
||||
foreach( $updates->update as $update ) {
|
||||
$person = $update->{'update-content'}->person;
|
||||
$share = $update->{'update-content'}->person->{'current-share'};
|
||||
|
||||
$ua = new Hybrid_User_Activity();
|
||||
|
||||
$ua->id = (string) $update->id;
|
||||
$ua->date = (string) $update->timestamp;
|
||||
$ua->text = (string) $share->{'comment'};
|
||||
|
||||
$ua->user->identifier = (string) $person->id;
|
||||
$ua->user->displayName = (string) $person->{'first-name'} . ' ' . $person->{'last-name'};
|
||||
$ua->user->profileURL = (string) $person->{'site-standard-profile-request'}->url;
|
||||
$ua->user->photoURL = NULL;
|
||||
|
||||
$activities[] = $ua;
|
||||
}
|
||||
|
||||
return $activities;
|
||||
}
|
||||
}
|
106
web/third_party/hybridauth/Hybrid/Providers/Live.php
vendored
Normal file
106
web/third_party/hybridauth/Hybrid/Providers/Live.php
vendored
Normal file
@ -0,0 +1,106 @@
|
||||
<?php
|
||||
/*!
|
||||
* HybridAuth
|
||||
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
|
||||
* (c) 2009-2012, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
|
||||
*/
|
||||
|
||||
/**
|
||||
* Windows Live OAuth2 Class
|
||||
*
|
||||
* @package HybridAuth providers package
|
||||
* @author Lukasz Koprowski <azram19@gmail.com>
|
||||
* @version 0.2
|
||||
* @license BSD License
|
||||
*/
|
||||
|
||||
/**
|
||||
* Hybrid_Providers_Live - Windows Live provider adapter based on OAuth2 protocol
|
||||
*/
|
||||
class Hybrid_Providers_Live extends Hybrid_Provider_Model_OAuth2
|
||||
{
|
||||
// default permissions
|
||||
public $scope = "wl.basic wl.emails wl.signin wl.share wl.birthday";
|
||||
|
||||
|
||||
/**
|
||||
* IDp wrappers initializer
|
||||
*/
|
||||
function initialize()
|
||||
{
|
||||
parent::initialize();
|
||||
|
||||
// Provider api end-points
|
||||
$this->api->api_base_url = 'https://apis.live.net/v5.0/';
|
||||
$this->api->authorize_url = 'https://login.live.com/oauth20_authorize.srf';
|
||||
$this->api->token_url = 'https://login.live.com/oauth20_token.srf';
|
||||
|
||||
$this->api->curl_authenticate_method = "GET";
|
||||
}
|
||||
|
||||
/**
|
||||
* grab the user profile from the api client
|
||||
*/
|
||||
function getUserProfile()
|
||||
{
|
||||
$data = $this->api->get( "me" );
|
||||
|
||||
if ( ! isset( $data->id ) ){
|
||||
throw new Exception( "User profile request failed! {$this->providerId} returned an invalide response.", 6 );
|
||||
}
|
||||
|
||||
$this->user->profile->identifier = (property_exists($data,'id'))?$data->id:"";
|
||||
$this->user->profile->firstName = (property_exists($data,'first_name'))?$data->first_name:"";
|
||||
$this->user->profile->lastName = (property_exists($data,'last_name'))?$data->last_name:"";
|
||||
$this->user->profile->displayName = (property_exists($data,'name'))?trim( $data->name ):"";
|
||||
$this->user->profile->gender = (property_exists($data,'gender'))?$data->gender:"";
|
||||
|
||||
//wl.basic
|
||||
$this->user->profile->profileURL = (property_exists($data,'link'))?$data->link:"";
|
||||
|
||||
//wl.emails
|
||||
$this->user->profile->email = (property_exists($data,'emails'))?$data->emails->account:"";
|
||||
$this->user->profile->emailVerified = (property_exists($data,'emails'))?$data->emails->account:"";
|
||||
|
||||
//wl.birthday
|
||||
$this->user->profile->birthDay = (property_exists($data,'birth_day'))?$data->birth_day:"";
|
||||
$this->user->profile->birthMonth = (property_exists($data,'birth_month'))?$data->birth_month:"";
|
||||
$this->user->profile->birthYear = (property_exists($data,'birth_year'))?$data->birth_year:"";
|
||||
|
||||
return $this->user->profile;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* load the current logged in user contacts list from the IDp api client
|
||||
*/
|
||||
|
||||
/* Windows Live api does not support retrieval of email addresses (only hashes :/) */
|
||||
function getUserContacts()
|
||||
{
|
||||
$response = $this->api->get( 'me/contacts' );
|
||||
|
||||
if ( $this->api->http_code != 200 )
|
||||
{
|
||||
throw new Exception( 'User contacts request failed! ' . $this->providerId . ' returned an error: ' . $this->errorMessageByStatus( $this->api->http_code ) );
|
||||
}
|
||||
|
||||
if ( ! $response->data && ( $response->error != 0 ) )
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
$contacts = array();
|
||||
|
||||
foreach( $response->data as $item ) {
|
||||
$uc = new Hybrid_User_Contact();
|
||||
|
||||
$uc->identifier = (property_exists($item,'id'))?$item->id:"";
|
||||
$uc->displayName = (property_exists($item,'name'))?$item->name:"";
|
||||
|
||||
$contacts[] = $uc;
|
||||
}
|
||||
|
||||
return $contacts;
|
||||
}
|
||||
}
|
63
web/third_party/hybridauth/Hybrid/Providers/Mailru.php
vendored
Normal file
63
web/third_party/hybridauth/Hybrid/Providers/Mailru.php
vendored
Normal file
@ -0,0 +1,63 @@
|
||||
<?php
|
||||
/*!
|
||||
* HybridAuth
|
||||
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
|
||||
* (c) 2009-2012, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
|
||||
*
|
||||
* Provider writed by xbreaker | https://github.com/xbreaker/hybridauth
|
||||
*/
|
||||
|
||||
/**
|
||||
* Hybrid_Providers_Mailru provider adapter based on OAuth2 protocol
|
||||
*
|
||||
*/
|
||||
class Hybrid_Providers_Mailru extends Hybrid_Provider_Model_OAuth2
|
||||
{
|
||||
/**
|
||||
* IDp wrappers initializer
|
||||
*/
|
||||
function initialize()
|
||||
{
|
||||
parent::initialize();
|
||||
|
||||
// Provider apis end-points
|
||||
$this->api->api_base_url = "http://www.appsmail.ru/platform/api";
|
||||
$this->api->authorize_url = "https://connect.mail.ru/oauth/authorize";
|
||||
$this->api->token_url = "https://connect.mail.ru/oauth/token";
|
||||
$this->api->sign_token_name = "session_key";
|
||||
}
|
||||
|
||||
/**
|
||||
* load the user profile from the IDp api client
|
||||
*/
|
||||
function getUserProfile()
|
||||
{
|
||||
$sig = md5( "client_id=" . $this->api->client_id . "format=jsonmethod=users.getInfosecure=1session_key=". $this->api->access_token . $this->api->client_secret );
|
||||
$response = $this->api->api( "?format=json&client_id=" . $this->api->client_id . "&method=users.getInfo&secure=1&sig=" .$sig);
|
||||
if ( ! isset( $response[0]->uid ) ){
|
||||
throw new Exception( "User profile request failed! {$this->providerId} returned an invalid response.", 6 );
|
||||
}
|
||||
|
||||
$response = $response[0];
|
||||
|
||||
$this->user->profile->identifier = (property_exists($response,'uid'))?$response->uid:"";
|
||||
$this->user->profile->firstName = (property_exists($response,'first_name'))?$response->first_name:"";
|
||||
$this->user->profile->lastName = (property_exists($response,'last_name'))?$response->last_name:"";
|
||||
$this->user->profile->displayName = (property_exists($response,'nick'))?$response->nick:"";
|
||||
$this->user->profile->photoURL = (property_exists($response,'pic'))?$response->pic:"";
|
||||
$this->user->profile->profileURL = (property_exists($response,'link'))?$response->link:"";
|
||||
$this->user->profile->gender = (property_exists($response,'sex'))?$response->sex:"";
|
||||
$this->user->profile->email = (property_exists($response,'email'))?$response->email:"";
|
||||
$this->user->profile->emailVerified = (property_exists($response,'email'))?$response->email:"";
|
||||
|
||||
if( property_exists($response,'birthday') ){
|
||||
list($birthday_day, $birthday_month, $birthday_year) = explode( '.', $response->birthday );
|
||||
|
||||
$this->user->profile->birthDay = (int) $birthday_day;
|
||||
$this->user->profile->birthMonth = (int) $birthday_month;
|
||||
$this->user->profile->birthYear = (int) $birthday_year;
|
||||
}
|
||||
|
||||
return $this->user->profile;
|
||||
}
|
||||
}
|
15
web/third_party/hybridauth/Hybrid/Providers/OpenID.php
vendored
Normal file
15
web/third_party/hybridauth/Hybrid/Providers/OpenID.php
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
/*!
|
||||
* HybridAuth
|
||||
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
|
||||
* (c) 2009-2012, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
|
||||
*/
|
||||
|
||||
/**
|
||||
* Hybrid_Providers_OpenID provider adapter for any idp openid based
|
||||
*
|
||||
* http://hybridauth.sourceforge.net/userguide/IDProvider_info_OpenID.html
|
||||
*/
|
||||
class Hybrid_Providers_OpenID extends Hybrid_Provider_Model_OpenID
|
||||
{
|
||||
}
|
55
web/third_party/hybridauth/Hybrid/Providers/Steam.php
vendored
Normal file
55
web/third_party/hybridauth/Hybrid/Providers/Steam.php
vendored
Normal file
@ -0,0 +1,55 @@
|
||||
<?php
|
||||
/*!
|
||||
* HybridAuth
|
||||
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
|
||||
* (c) 2009-2012, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
|
||||
*/
|
||||
|
||||
/**
|
||||
* Hybrid_Providers_Steam provider adapter based on OpenID protocol
|
||||
*
|
||||
* http://hybridauth.sourceforge.net/userguide/IDProvider_info_Steam.html
|
||||
*/
|
||||
class Hybrid_Providers_Steam extends Hybrid_Provider_Model_OpenID
|
||||
{
|
||||
var $openidIdentifier = "http://steamcommunity.com/openid";
|
||||
|
||||
/**
|
||||
* finish login step
|
||||
*/
|
||||
function loginFinish()
|
||||
{
|
||||
parent::loginFinish();
|
||||
|
||||
$uid = str_replace( "http://steamcommunity.com/openid/id/", "", $this->user->profile->identifier );
|
||||
|
||||
if( $uid ){
|
||||
$data = @ file_get_contents( "http://steamcommunity.com/profiles/$uid/?xml=1" );
|
||||
|
||||
$data = @ new SimpleXMLElement( $data );
|
||||
|
||||
if ( ! is_object( $data ) ){
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->user->profile->displayName = (string) $data->{'steamID'};
|
||||
$this->user->profile->photoURL = (string) $data->{'avatarMedium'};
|
||||
$this->user->profile->description = (string) $data->{'summary'};
|
||||
|
||||
$realname = (string) $data->{'realname'};
|
||||
|
||||
if( $realname ){
|
||||
$this->user->profile->displayName = $realname;
|
||||
}
|
||||
|
||||
$customURL = (string) $data->{'customURL'};
|
||||
|
||||
if( $customURL ){
|
||||
$this->user->profile->profileURL = "http://steamcommunity.com/id/$customURL/";
|
||||
}
|
||||
|
||||
// restore the user profile
|
||||
Hybrid_Auth::storage()->set( "hauth_session.{$this->providerId}.user", $this->user );
|
||||
}
|
||||
}
|
||||
}
|
73
web/third_party/hybridauth/Hybrid/Providers/TwitchTV.php
vendored
Normal file
73
web/third_party/hybridauth/Hybrid/Providers/TwitchTV.php
vendored
Normal file
@ -0,0 +1,73 @@
|
||||
<?php
|
||||
/*!
|
||||
* HybridAuth
|
||||
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
|
||||
* (c) 2009-2012, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
|
||||
*/
|
||||
|
||||
/**
|
||||
* Hybrid_Providers_TwitchTV provider adapter based on OAuth2 protocol
|
||||
*
|
||||
* http://hybridauth.sourceforge.net/userguide/IDProvider_info_TwitchTV.html
|
||||
*/
|
||||
class Hybrid_Providers_TwitchTV extends Hybrid_Provider_Model_OAuth2
|
||||
{
|
||||
// default permissions
|
||||
public $scope = "user_read channel_read";
|
||||
|
||||
/**
|
||||
* IDp wrappers initializer
|
||||
*/
|
||||
function initialize()
|
||||
{
|
||||
parent::initialize();
|
||||
|
||||
// Provider apis end-points
|
||||
$this->api->api_base_url = "https://api.twitch.tv/kraken/";
|
||||
$this->api->authorize_url = "https://api.twitch.tv/kraken/oauth2/authorize";
|
||||
$this->api->token_url = "https://api.twitch.tv/kraken/oauth2/token";
|
||||
|
||||
$this->api->sign_token_name = "oauth_token";
|
||||
}
|
||||
|
||||
/**
|
||||
* begin login step
|
||||
*/
|
||||
function loginBegin()
|
||||
{
|
||||
$parameters = array( "scope" => $this->scope );
|
||||
$optionals = array( "scope" );
|
||||
|
||||
foreach ($optionals as $parameter){
|
||||
if( isset( $this->config[$parameter] ) && ! empty( $this->config[$parameter] ) ){
|
||||
$parameters[$parameter] = $this->config[$parameter];
|
||||
}
|
||||
}
|
||||
|
||||
Hybrid_Auth::redirect( $this->api->authorizeUrl( $parameters ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* load the user profile from the IDp api client
|
||||
*/
|
||||
function getUserProfile()
|
||||
{
|
||||
$data = $this->api->api( "user" );
|
||||
|
||||
if ( ! isset( $data->name ) ){
|
||||
throw new Exception( "User profile request failed! {$this->providerId} returned an invalid response.", 6 );
|
||||
}
|
||||
|
||||
$this->user->profile->identifier = $data->_id;
|
||||
$this->user->profile->displayName = $data->display_name;
|
||||
$this->user->profile->photoURL = $data->logo;
|
||||
$this->user->profile->profileURL = "http://www.twitch.tv/" . $data->name;
|
||||
$this->user->profile->email = $data->email;
|
||||
|
||||
if( ! $this->user->profile->displayName ){
|
||||
$this->user->profile->displayName = $data->name;
|
||||
}
|
||||
|
||||
return $this->user->profile;
|
||||
}
|
||||
}
|
204
web/third_party/hybridauth/Hybrid/Providers/Twitter.php
vendored
Normal file
204
web/third_party/hybridauth/Hybrid/Providers/Twitter.php
vendored
Normal file
@ -0,0 +1,204 @@
|
||||
<?php
|
||||
/*!
|
||||
* HybridAuth
|
||||
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
|
||||
* (c) 2009-2012, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
|
||||
*/
|
||||
|
||||
/**
|
||||
* Hybrid_Providers_Twitter provider adapter based on OAuth1 protocol
|
||||
*/
|
||||
class Hybrid_Providers_Twitter extends Hybrid_Provider_Model_OAuth1
|
||||
{
|
||||
/**
|
||||
* IDp wrappers initializer
|
||||
*/
|
||||
function initialize()
|
||||
{
|
||||
parent::initialize();
|
||||
|
||||
// Provider api end-points
|
||||
$this->api->api_base_url = "https://api.twitter.com/1.1/";
|
||||
$this->api->authorize_url = "https://api.twitter.com/oauth/authenticate";
|
||||
$this->api->request_token_url = "https://api.twitter.com/oauth/request_token";
|
||||
$this->api->access_token_url = "https://api.twitter.com/oauth/access_token";
|
||||
|
||||
if ( isset( $this->config['api_version'] ) && $this->config['api_version'] ){
|
||||
$this->api->api_base_url = "https://api.twitter.com/{$this->config['api_version']}/";
|
||||
}
|
||||
|
||||
if ( isset( $this->config['authorize'] ) && $this->config['authorize'] ){
|
||||
$this->api->authorize_url = "https://api.twitter.com/oauth/authorize";
|
||||
}
|
||||
|
||||
$this->api->curl_auth_header = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* begin login step
|
||||
*/
|
||||
function loginBegin()
|
||||
{
|
||||
$tokens = $this->api->requestToken( $this->endpoint );
|
||||
|
||||
// request tokens as recived from provider
|
||||
$this->request_tokens_raw = $tokens;
|
||||
|
||||
// check the last HTTP status code returned
|
||||
if ( $this->api->http_code != 200 ){
|
||||
throw new Exception( "Authentification failed! {$this->providerId} returned an error. " . $this->errorMessageByStatus( $this->api->http_code ), 5 );
|
||||
}
|
||||
|
||||
if ( ! isset( $tokens["oauth_token"] ) ){
|
||||
throw new Exception( "Authentification failed! {$this->providerId} returned an invalid oauth token.", 5 );
|
||||
}
|
||||
|
||||
$this->token( "request_token" , $tokens["oauth_token"] );
|
||||
$this->token( "request_token_secret", $tokens["oauth_token_secret"] );
|
||||
|
||||
// redirect the user to the provider authentication url with force_login
|
||||
if ( isset( $this->config['force_login'] ) && $this->config['force_login'] ){
|
||||
Hybrid_Auth::redirect( $this->api->authorizeUrl( $tokens, array( 'force_login' => true ) ) );
|
||||
}
|
||||
|
||||
// else, redirect the user to the provider authentication url
|
||||
Hybrid_Auth::redirect( $this->api->authorizeUrl( $tokens ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* load the user profile from the IDp api client
|
||||
*/
|
||||
function getUserProfile()
|
||||
{
|
||||
$response = $this->api->get( 'account/verify_credentials.json' );
|
||||
|
||||
// check the last HTTP status code returned
|
||||
if ( $this->api->http_code != 200 ){
|
||||
throw new Exception( "User profile request failed! {$this->providerId} returned an error. " . $this->errorMessageByStatus( $this->api->http_code ), 6 );
|
||||
}
|
||||
|
||||
if ( ! is_object( $response ) || ! isset( $response->id ) ){
|
||||
throw new Exception( "User profile request failed! {$this->providerId} api returned an invalid response.", 6 );
|
||||
}
|
||||
|
||||
# store the user profile.
|
||||
$this->user->profile->identifier = (property_exists($response,'id'))?$response->id:"";
|
||||
$this->user->profile->displayName = (property_exists($response,'screen_name'))?$response->screen_name:"";
|
||||
$this->user->profile->description = (property_exists($response,'description'))?$response->description:"";
|
||||
$this->user->profile->firstName = (property_exists($response,'name'))?$response->name:"";
|
||||
$this->user->profile->photoURL = (property_exists($response,'profile_image_url'))?$response->profile_image_url:"";
|
||||
$this->user->profile->profileURL = (property_exists($response,'screen_name'))?("http://twitter.com/".$response->screen_name):"";
|
||||
$this->user->profile->webSiteURL = (property_exists($response,'url'))?$response->url:"";
|
||||
$this->user->profile->region = (property_exists($response,'location'))?$response->location:"";
|
||||
|
||||
return $this->user->profile;
|
||||
}
|
||||
|
||||
/**
|
||||
* load the user contacts
|
||||
*/
|
||||
function getUserContacts()
|
||||
{
|
||||
$parameters = array( 'cursor' => '-1' );
|
||||
$response = $this->api->get( 'friends/ids.json', $parameters );
|
||||
|
||||
// check the last HTTP status code returned
|
||||
if ( $this->api->http_code != 200 ){
|
||||
throw new Exception( "User contacts request failed! {$this->providerId} returned an error. " . $this->errorMessageByStatus( $this->api->http_code ) );
|
||||
}
|
||||
|
||||
if( ! $response || ! count( $response->ids ) ){
|
||||
return ARRAY();
|
||||
}
|
||||
|
||||
// 75 id per time should be okey
|
||||
$contactsids = array_chunk ( $response->ids, 75 );
|
||||
|
||||
$contacts = ARRAY();
|
||||
|
||||
foreach( $contactsids as $chunk ){
|
||||
$parameters = array( 'user_id' => implode( ",", $chunk ) );
|
||||
$response = $this->api->get( 'users/lookup.json', $parameters );
|
||||
|
||||
// check the last HTTP status code returned
|
||||
if ( $this->api->http_code != 200 ){
|
||||
throw new Exception( "User contacts request failed! {$this->providerId} returned an error. " . $this->errorMessageByStatus( $this->api->http_code ) );
|
||||
}
|
||||
|
||||
if( $response && count( $response ) ){
|
||||
foreach( $response as $item ){
|
||||
$uc = new Hybrid_User_Contact();
|
||||
|
||||
$uc->identifier = (property_exists($item,'id'))?$item->id:"";
|
||||
$uc->displayName = (property_exists($item,'name'))?$item->name:"";
|
||||
$uc->profileURL = (property_exists($item,'screen_name'))?("http://twitter.com/".$item->screen_name):"";
|
||||
$uc->photoURL = (property_exists($item,'profile_image_url'))?$item->profile_image_url:"";
|
||||
$uc->description = (property_exists($item,'description'))?$item->description:"";
|
||||
|
||||
$contacts[] = $uc;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $contacts;
|
||||
}
|
||||
|
||||
/**
|
||||
* update user status
|
||||
*/
|
||||
function setUserStatus( $status )
|
||||
{
|
||||
$parameters = array( 'status' => $status );
|
||||
$response = $this->api->post( 'statuses/update.json', $parameters );
|
||||
|
||||
// check the last HTTP status code returned
|
||||
if ( $this->api->http_code != 200 ){
|
||||
throw new Exception( "Update user status failed! {$this->providerId} returned an error. " . $this->errorMessageByStatus( $this->api->http_code ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* load the user latest activity
|
||||
* - timeline : all the stream
|
||||
* - me : the user activity only
|
||||
*
|
||||
* by default return the timeline
|
||||
*/
|
||||
function getUserActivity( $stream )
|
||||
{
|
||||
if( $stream == "me" ){
|
||||
$response = $this->api->get( 'statuses/user_timeline.json' );
|
||||
}
|
||||
else{
|
||||
$response = $this->api->get( 'statuses/home_timeline.json' );
|
||||
}
|
||||
|
||||
// check the last HTTP status code returned
|
||||
if ( $this->api->http_code != 200 ){
|
||||
throw new Exception( "User activity stream request failed! {$this->providerId} returned an error. " . $this->errorMessageByStatus( $this->api->http_code ) );
|
||||
}
|
||||
|
||||
if( ! $response ){
|
||||
return ARRAY();
|
||||
}
|
||||
|
||||
$activities = ARRAY();
|
||||
|
||||
foreach( $response as $item ){
|
||||
$ua = new Hybrid_User_Activity();
|
||||
|
||||
$ua->id = (property_exists($item,'id'))?$item->id:"";
|
||||
$ua->date = (property_exists($item,'created_at'))?strtotime($item->created_at):"";
|
||||
$ua->text = (property_exists($item,'text'))?$item->text:"";
|
||||
|
||||
$ua->user->identifier = (property_exists($item->user,'id'))?$item->user->id:"";
|
||||
$ua->user->displayName = (property_exists($item->user,'name'))?$item->user->name:"";
|
||||
$ua->user->profileURL = (property_exists($item->user,'screen_name'))?("http://twitter.com/".$item->user->screen_name):"";
|
||||
$ua->user->photoURL = (property_exists($item->user,'profile_image_url'))?$item->user->profile_image_url:"";
|
||||
|
||||
$activities[] = $ua;
|
||||
}
|
||||
|
||||
return $activities;
|
||||
}
|
||||
}
|
309
web/third_party/hybridauth/Hybrid/Providers/XING.php
vendored
Normal file
309
web/third_party/hybridauth/Hybrid/Providers/XING.php
vendored
Normal file
@ -0,0 +1,309 @@
|
||||
<?php
|
||||
/*!
|
||||
* HybridAuth
|
||||
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
|
||||
* (c) 2009-2012, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
|
||||
*/
|
||||
|
||||
/**
|
||||
* XING.com Provider
|
||||
*
|
||||
* @author Fabian Beiner <mail@fabian-beiner.de>
|
||||
* @version 1.0.1
|
||||
*/
|
||||
class Hybrid_Providers_XING extends Hybrid_Provider_Model_OAuth1 {
|
||||
/**
|
||||
* Initialize.
|
||||
*/
|
||||
function initialize() {
|
||||
if (!$this->config['keys']['id'] || !$this->config['keys']['secret']) {
|
||||
throw new Exception('You need a consumer key and secret to connect to ' . $this->providerId . '.');
|
||||
}
|
||||
|
||||
parent::initialize();
|
||||
|
||||
// XING API endpoints.
|
||||
$this->api->api_base_url = 'https://api.xing.com/v1/';
|
||||
$this->api->authorize_url = 'https://api.xing.com/v1/authorize';
|
||||
$this->api->request_token_url = 'https://api.xing.com/v1/request_token';
|
||||
$this->api->access_token_url = 'https://api.xing.com/v1/access_token';
|
||||
|
||||
// Currently there is only version "v1" available.
|
||||
if (isset($this->config['api_version']) && $this->config['api_version']) {
|
||||
$this->api->api_base_url = 'https://api.xing.com/' . $this->config['api_version'] . '/';
|
||||
}
|
||||
|
||||
// We don't need them.
|
||||
$this->api->curl_auth_header = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Begin logging in.
|
||||
*/
|
||||
function loginBegin() {
|
||||
// Handle the request token.
|
||||
$aToken = $this->api->requestToken($this->endpoint);
|
||||
$this->request_tokens_raw = $aToken;
|
||||
|
||||
// The HTTP status code needs to be 201. If it's not, something is wrong.
|
||||
if ($this->api->http_code !== 201) {
|
||||
throw new Exception('Authentication failed! ' . $this->providerId . ' returned an error: ' . $this->errorMessageByStatus($this->api->http_code) . '.');
|
||||
}
|
||||
|
||||
// If we don't have an OAuth token by now, something is ABSOLUTELY wrong.
|
||||
if (!isset($aToken['oauth_token'])) {
|
||||
throw new Exception('Authentication failed! ' . $this->providerId . ' returned an invalid OAuth token.');
|
||||
}
|
||||
|
||||
$this->token('request_token' , $aToken['oauth_token']);
|
||||
$this->token('request_token_secret', $aToken['oauth_token_secret']);
|
||||
|
||||
// Redirect to the XING authorization URL.
|
||||
Hybrid_Auth::redirect($this->api->authorizeUrl($aToken));
|
||||
}
|
||||
|
||||
/**
|
||||
* Finish logging in.
|
||||
*/
|
||||
function loginFinish() {
|
||||
$sToken = (isset($_REQUEST['oauth_token'])) ? $_REQUEST['oauth_token'] : '';
|
||||
$sVerifier = (isset($_REQUEST['oauth_verifier'])) ? $_REQUEST['oauth_verifier'] : '';
|
||||
|
||||
if (!$sToken || !$sVerifier) {
|
||||
throw new Exception('Authentication failed! ' . $this->providerId . ' returned an invalid OAuth token/verifier.');
|
||||
}
|
||||
|
||||
// Handle the access token.
|
||||
$aToken = $this->api->accessToken($sVerifier);
|
||||
$this->access_tokens_raw = $aToken;
|
||||
|
||||
// You know the deal, don't you? :)
|
||||
if ($this->api->http_code !== 201) {
|
||||
throw new Exception('Authentication failed! ' . $this->providerId . ' returned an error: ' . $this->errorMessageByStatus($this->api->http_code) . '.');
|
||||
}
|
||||
|
||||
// If we don't have an OAuth token by now, something is ABSOLUTELY wrong.
|
||||
if (!isset($aToken['oauth_token'])) {
|
||||
throw new Exception('Authentication failed! ' . $this->providerId . ' returned an invalid OAuth token.');
|
||||
}
|
||||
|
||||
// Delete the request tokens, as we don't need them anymore.
|
||||
$this->deleteToken('request_token');
|
||||
$this->deleteToken('request_token_secret');
|
||||
|
||||
// But store the access tokens for later usage.
|
||||
$this->token('access_token', $aToken['oauth_token']);
|
||||
$this->token('access_token_secret', $aToken['oauth_token_secret']);
|
||||
|
||||
// Connection established!
|
||||
$this->setUserConnected();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the profile of the user who has granted access.
|
||||
*
|
||||
* @see https://dev.xing.com/docs/get/users/me
|
||||
*/
|
||||
function getUserProfile() {
|
||||
$oResponse = $this->api->get('users/me');
|
||||
|
||||
// The HTTP status code needs to be 200 here. If it's not, something is wrong.
|
||||
if ($this->api->http_code !== 200) {
|
||||
throw new Exception('Profile request failed! ' . $this->providerId . ' API returned an error: ' . $this->errorMessageByStatus($this->api->http_code) . '.');
|
||||
}
|
||||
|
||||
// We should have an object by now.
|
||||
if (!is_object($oResponse)) {
|
||||
throw new Exception('Profile request failed! ' . $this->providerId . ' API returned an error: invalid response.');
|
||||
}
|
||||
|
||||
// Redefine the object.
|
||||
$oResponse = $oResponse->users[0];
|
||||
|
||||
/**
|
||||
* Handle the profile data.
|
||||
*
|
||||
* @see http://hybridauth.sourceforge.net/userguide/Profile_Data_User_Profile.html
|
||||
*/
|
||||
$this->user->profile->identifier = (property_exists($oResponse, 'id')) ? $oResponse->id : '';
|
||||
$this->user->profile->profileURL = (property_exists($oResponse, 'permalink')) ? $oResponse->permalink : '';
|
||||
$this->user->profile->displayName = (property_exists($oResponse, 'display_name')) ? $oResponse->display_name : '';
|
||||
$this->user->profile->description = (property_exists($oResponse, 'interests')) ? $oResponse->interests : ''; // Not really a "description, but anyways …
|
||||
$this->user->profile->firstName = (property_exists($oResponse, 'first_name')) ? $oResponse->first_name : '';
|
||||
$this->user->profile->lastName = (property_exists($oResponse, 'last_name')) ? $oResponse->last_name : '';
|
||||
$this->user->profile->gender = (property_exists($oResponse, 'gender')) ? $oResponse->gender : '';
|
||||
$this->user->profile->emailVerified = (property_exists($oResponse, 'active_email')) ? $oResponse->active_email : '';
|
||||
|
||||
// My own priority: Homepage, blog, other, something else.
|
||||
if (property_exists($oResponse, 'web_profiles')) {
|
||||
$this->user->profile->webSiteURL = (property_exists($oResponse->web_profiles, 'homepage')) ? $oResponse->web_profiles->homepage[0] : null;
|
||||
if (null === $this->user->profile->webSiteURL) {
|
||||
$this->user->profile->webSiteURL = (property_exists($oResponse->web_profiles, 'blog')) ? $oResponse->web_profiles->blog[0] : null;
|
||||
}
|
||||
if (null === $this->user->profile->webSiteURL) {
|
||||
$this->user->profile->webSiteURL = (property_exists($oResponse->web_profiles, 'other')) ? $oResponse->web_profiles->other[0] : null;
|
||||
}
|
||||
// Just use *anything*!
|
||||
if (null === $this->user->profile->webSiteURL) {
|
||||
foreach ($oResponse->web_profiles as $aUrl) {
|
||||
$this->user->profile->webSiteURL = $aUrl[0];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// We use the largest picture available.
|
||||
if (property_exists($oResponse, 'photo_urls') && property_exists($oResponse->photo_urls, 'large')) {
|
||||
$this->user->profile->photoURL = (property_exists($oResponse->photo_urls, 'large')) ? $oResponse->photo_urls->large : '';
|
||||
}
|
||||
|
||||
// Try to get the native language first.
|
||||
if (property_exists($oResponse, 'languages')) {
|
||||
foreach ($oResponse->languages as $sLanguage => $sSkill) {
|
||||
$this->user->profile->language = strtoupper($sLanguage);
|
||||
if ($sSkill == 'NATIVE') {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Age stuff.
|
||||
if (property_exists($oResponse, 'birth_date')) {
|
||||
$this->user->profile->age = floor((time() - strtotime($oResponse->birth_date->year . '-' . $oResponse->birth_date->month . '-' . $oResponse->birth_date->day)) / 31556926);
|
||||
$this->user->profile->birthDay = $oResponse->birth_date->day;
|
||||
$this->user->profile->birthMonth = $oResponse->birth_date->month;
|
||||
$this->user->profile->birthYear = $oResponse->birth_date->year;
|
||||
}
|
||||
|
||||
// As XING is a business network, users are more likely to be interested in the business address.
|
||||
$oAddress = (property_exists($oResponse, 'business_address')) ? $oResponse->business_address : null;
|
||||
if (null === $oAddress && property_exists($oResponse, 'private_address')) {
|
||||
$oAddress = $oResponse->private_address;
|
||||
}
|
||||
if (null !== $oAddress) {
|
||||
$this->user->profile->phone = (property_exists($oAddress, 'phone')) ? $oAddress->phone : '';
|
||||
$this->user->profile->address = (property_exists($oAddress, 'street')) ? $oAddress->street : '';
|
||||
$this->user->profile->country = (property_exists($oAddress, 'country')) ? $oAddress->country : '';
|
||||
$this->user->profile->region = (property_exists($oAddress, 'province')) ? $oAddress->province : '';
|
||||
$this->user->profile->city = (property_exists($oAddress, 'city')) ? $oAddress->city : '';
|
||||
$this->user->profile->zip = (property_exists($oAddress, 'zip_code')) ? $oAddress->zip_code : '';
|
||||
$this->user->profile->email = (property_exists($oAddress, 'email')) ? $oAddress->email : '';
|
||||
if (null === $this->user->profile->language) {
|
||||
$this->user->profile->language = (property_exists($oAddress, 'country')) ? $oAddress->country : '';
|
||||
}
|
||||
// The following two are actually not part of the normalized user profile structure used by HybridAuth...
|
||||
$this->user->profile->mobile = (property_exists($oAddress, 'mobile_phone')) ? $oAddress->mobile_phone : '';
|
||||
$this->user->profile->fax = (property_exists($oAddress, 'fax')) ? $oAddress->fax : '';
|
||||
}
|
||||
|
||||
return $this->user->profile;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the user status.
|
||||
*
|
||||
* @see http://hybridauth.sourceforge.net/userguide/Profile_Data_User_Status.html
|
||||
*/
|
||||
function setUserStatus($sMessage) {
|
||||
$aParameters = array(
|
||||
'oauth_token' => $this->token('access_token')
|
||||
,'id' => 'me'
|
||||
);
|
||||
|
||||
// German network, there will probably be Umlauts somewhere. :)
|
||||
mb_internal_encoding('UTF-8');
|
||||
|
||||
if (!is_string($sMessage) || $sMessage == '') {
|
||||
throw new Exception('The passed parameter needs to be a string.');
|
||||
}
|
||||
|
||||
// Check if the message is <= 420 characters.
|
||||
if (strlen($sMessage) >= 420) {
|
||||
$aParameters['message'] = mb_substr($sMessage, 0, 419) . '…';
|
||||
}
|
||||
else {
|
||||
$aParameters['message'] = $sMessage;
|
||||
}
|
||||
|
||||
try {
|
||||
$oResponse = $this->api->post('users/' . $aParameters['id'] . '/status_message', $aParameters);
|
||||
if ($this->api->http_code === 201) {
|
||||
return true;
|
||||
}
|
||||
elseif ($this->api->http_code === 403) {
|
||||
throw new Exception('Something went wrong. ' . $this->providerId . ' denied the access.');
|
||||
}
|
||||
elseif ($this->api->http_code === 404) {
|
||||
throw new Exception('The user "' . $aParameters['id'] . '" was not found.');
|
||||
}
|
||||
return false;
|
||||
}
|
||||
catch(Exception $e) {
|
||||
throw new Exception('Could not update the status. ' . $this->providerId . ' returned an error: ' . $e . '.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load user contacts.
|
||||
*
|
||||
* @see http://hybridauth.sourceforge.net/userguide/Profile_Data_User_Contacts.html
|
||||
*/
|
||||
function getUserContacts() {
|
||||
try {
|
||||
$oResponse = $this->api->get('users/me/contacts?limit=100&user_fields=id,display_name,permalink,web_profiles,photo_urls,display_name,interests,active_email&offset=0');
|
||||
$oTotal = $oResponse->contacts->users;
|
||||
$iTotal = $oResponse->contacts->total;
|
||||
|
||||
for ($i = 100; $i <= $iTotal; $i = $i + 100) {
|
||||
$oResponse = $this->api->get('users/me/contacts?limit=100&user_fields=id,display_name,permalink,web_profiles,photo_urls,display_name,interests,active_email&offset=' . $i);
|
||||
$oTotal = array_merge($oTotal, $oResponse->contacts->users);
|
||||
}
|
||||
}
|
||||
catch(Exception $e) {
|
||||
throw new Exception('Could not fetch contacts. ' . $this->providerId . ' returned an error: ' . $e . '.');
|
||||
}
|
||||
|
||||
// Return empty array if there are no contacts.
|
||||
if (count($oTotal) == 0) {
|
||||
return array();
|
||||
}
|
||||
|
||||
// Create the contacts array.
|
||||
$aContacts = array();
|
||||
foreach($oTotal as $aTitle) {
|
||||
$oContact = new Hybrid_User_Contact();
|
||||
$oContact->identifier = (property_exists($aTitle, 'id')) ? $aTitle->id : '';
|
||||
$oContact->profileURL = (property_exists($aTitle, 'permalink')) ? $aTitle->permalink : '';
|
||||
$oContact->displayName = (property_exists($aTitle, 'display_name')) ? $aTitle->display_name : '';
|
||||
$oContact->description = (property_exists($aTitle, 'interests')) ? $aTitle->interests : '';
|
||||
$oContact->email = (property_exists($aTitle, 'active_email')) ? $aTitle->active_email : '';
|
||||
|
||||
// My own priority: Homepage, blog, other, something else.
|
||||
if (property_exists($aTitle, 'web_profiles')) {
|
||||
$oContact->webSiteURL = (property_exists($aTitle->web_profiles, 'homepage')) ? $aTitle->web_profiles->homepage[0] : null;
|
||||
if (null === $oContact->webSiteURL) {
|
||||
$oContact->webSiteURL = (property_exists($aTitle->web_profiles, 'blog')) ? $aTitle->web_profiles->blog[0] : null;
|
||||
}
|
||||
if (null === $oContact->webSiteURL) {
|
||||
$oContact->webSiteURL = (property_exists($aTitle->web_profiles, 'other')) ? $aTitle->web_profiles->other[0] : null;
|
||||
}
|
||||
// Just use *anything*!
|
||||
if (null === $oContact->webSiteURL) {
|
||||
foreach ($aTitle->web_profiles as $aUrl) {
|
||||
$oContact->webSiteURL = $aUrl[0];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// We use the largest picture available.
|
||||
if (property_exists($aTitle, 'photo_urls') && property_exists($aTitle->photo_urls, 'large')) {
|
||||
$oContact->photoURL = (property_exists($aTitle->photo_urls, 'large')) ? $aTitle->photo_urls->large : '';
|
||||
}
|
||||
|
||||
$aContacts[] = $oContact;
|
||||
}
|
||||
|
||||
return $aContacts;
|
||||
}
|
||||
}
|
61
web/third_party/hybridauth/Hybrid/Providers/Yandex.php
vendored
Normal file
61
web/third_party/hybridauth/Hybrid/Providers/Yandex.php
vendored
Normal file
@ -0,0 +1,61 @@
|
||||
<?php
|
||||
/*!
|
||||
* HybridAuth
|
||||
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
|
||||
* (c) 2009-2012, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
|
||||
*
|
||||
* Provider writed by xbreaker | https://github.com/xbreaker/hybridauth
|
||||
*/
|
||||
|
||||
/**
|
||||
* Hybrid_Providers_Yandex provider adapter based on OAuth2 protocol
|
||||
*
|
||||
*/
|
||||
class Hybrid_Providers_Yandex extends Hybrid_Provider_Model_OAuth2
|
||||
{
|
||||
/**
|
||||
* IDp wrappers initializer
|
||||
*/
|
||||
function initialize()
|
||||
{
|
||||
parent::initialize();
|
||||
|
||||
// Provider apis end-points
|
||||
$this->api->api_base_url = "https://login.yandex.ru/info";
|
||||
$this->api->authorize_url = "https://oauth.yandex.ru/authorize";
|
||||
$this->api->token_url = "https://oauth.yandex.ru/token";
|
||||
|
||||
$this->api->sign_token_name = "oauth_token";
|
||||
}
|
||||
|
||||
/**
|
||||
* load the user profile from the IDp api client
|
||||
*/
|
||||
function getUserProfile()
|
||||
{
|
||||
$response = $this->api->api( "?format=json" );
|
||||
if ( ! isset( $response->id ) ){
|
||||
throw new Exception( "User profile request failed! {$this->providerId} returned an invalid response.", 6 );
|
||||
}
|
||||
|
||||
$this->user->profile->identifier = (property_exists($response,'id'))?$response->id:"";
|
||||
$this->user->profile->firstName = (property_exists($response,'real_name'))?$response->real_name:"";
|
||||
$this->user->profile->lastName = (property_exists($response,'family_name'))?$response->family_name:"";
|
||||
$this->user->profile->displayName = (property_exists($response,'display_name'))?$response->display_name:"";
|
||||
$this->user->profile->photoURL = 'http://upics.yandex.net/'. $this->user->profile->identifier .'/normal';
|
||||
$this->user->profile->profileURL = "";
|
||||
$this->user->profile->gender = (property_exists($response,'sex'))?$response->sex:"";
|
||||
$this->user->profile->email = (property_exists($response,'default_email'))?$response->default_email:"";
|
||||
$this->user->profile->emailVerified = (property_exists($response,'default_email'))?$response->default_email:"";
|
||||
|
||||
if( property_exists($response,'birthday') ){
|
||||
list($birthday_year, $birthday_month, $birthday_day) = explode( '-', $response->birthday );
|
||||
|
||||
$this->user->profile->birthDay = (int) $birthday_day;
|
||||
$this->user->profile->birthMonth = (int) $birthday_month;
|
||||
$this->user->profile->birthYear = (int) $birthday_year;
|
||||
}
|
||||
|
||||
return $this->user->profile;
|
||||
}
|
||||
}
|
102
web/third_party/hybridauth/Hybrid/Storage.php
vendored
Normal file
102
web/third_party/hybridauth/Hybrid/Storage.php
vendored
Normal file
@ -0,0 +1,102 @@
|
||||
<?php
|
||||
/*!
|
||||
* HybridAuth
|
||||
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
|
||||
* (c) 2009-2012, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
|
||||
*/
|
||||
|
||||
/**
|
||||
* HybridAuth storage manager
|
||||
*/
|
||||
class Hybrid_Storage
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
if ( ! session_id() ){
|
||||
if( ! session_start() ){
|
||||
throw new Exception( "Hybridauth requires the use of 'session_start()' at the start of your script, which appears to be disabled.", 1 );
|
||||
}
|
||||
}
|
||||
|
||||
$this->config( "php_session_id", session_id() );
|
||||
$this->config( "version", Hybrid_Auth::$version );
|
||||
}
|
||||
|
||||
public function config($key, $value=null)
|
||||
{
|
||||
$key = strtolower( $key );
|
||||
|
||||
if( $value ){
|
||||
$_SESSION["HA::CONFIG"][$key] = serialize( $value );
|
||||
}
|
||||
elseif( isset( $_SESSION["HA::CONFIG"][$key] ) ){
|
||||
return unserialize( $_SESSION["HA::CONFIG"][$key] );
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
public function get($key)
|
||||
{
|
||||
$key = strtolower( $key );
|
||||
|
||||
if( isset( $_SESSION["HA::STORE"], $_SESSION["HA::STORE"][$key] ) ){
|
||||
return unserialize( $_SESSION["HA::STORE"][$key] );
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
public function set( $key, $value )
|
||||
{
|
||||
$key = strtolower( $key );
|
||||
|
||||
$_SESSION["HA::STORE"][$key] = serialize( $value );
|
||||
}
|
||||
|
||||
function clear()
|
||||
{
|
||||
$_SESSION["HA::STORE"] = ARRAY();
|
||||
}
|
||||
|
||||
function delete($key)
|
||||
{
|
||||
$key = strtolower( $key );
|
||||
|
||||
if( isset( $_SESSION["HA::STORE"], $_SESSION["HA::STORE"][$key] ) ){
|
||||
$f = $_SESSION['HA::STORE'];
|
||||
unset($f[$key]);
|
||||
$_SESSION["HA::STORE"] = $f;
|
||||
}
|
||||
}
|
||||
|
||||
function deleteMatch($key)
|
||||
{
|
||||
$key = strtolower( $key );
|
||||
|
||||
if( isset( $_SESSION["HA::STORE"] ) && count( $_SESSION["HA::STORE"] ) ) {
|
||||
$f = $_SESSION['HA::STORE'];
|
||||
foreach( $f as $k => $v ){
|
||||
if( strstr( $k, $key ) ){
|
||||
unset( $f[ $k ] );
|
||||
}
|
||||
}
|
||||
$_SESSION["HA::STORE"] = $f;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function getSessionData()
|
||||
{
|
||||
if( isset( $_SESSION["HA::STORE"] ) ){
|
||||
return serialize( $_SESSION["HA::STORE"] );
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
function restoreSessionData( $sessiondata = NULL )
|
||||
{
|
||||
$_SESSION["HA::STORE"] = unserialize( $sessiondata );
|
||||
}
|
||||
}
|
31
web/third_party/hybridauth/Hybrid/User.php
vendored
Normal file
31
web/third_party/hybridauth/Hybrid/User.php
vendored
Normal file
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
/*!
|
||||
* HybridAuth
|
||||
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
|
||||
* (c) 2009-2012, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
|
||||
*/
|
||||
|
||||
/**
|
||||
* The Hybrid_User class represents the current loggedin user
|
||||
*/
|
||||
class Hybrid_User
|
||||
{
|
||||
/* The ID (name) of the connected provider */
|
||||
public $providerId = NULL;
|
||||
|
||||
/* timestamp connection to the provider */
|
||||
public $timestamp = NULL;
|
||||
|
||||
/* user profile, containts the list of fields available in the normalized user profile structure used by HybridAuth. */
|
||||
public $profile = NULL;
|
||||
|
||||
/**
|
||||
* inisialize the user object,
|
||||
*/
|
||||
function __construct()
|
||||
{
|
||||
$this->timestamp = time();
|
||||
|
||||
$this->profile = new Hybrid_User_Profile();
|
||||
}
|
||||
}
|
39
web/third_party/hybridauth/Hybrid/User_Activity.php
vendored
Normal file
39
web/third_party/hybridauth/Hybrid/User_Activity.php
vendored
Normal file
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
/*!
|
||||
* HybridAuth
|
||||
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
|
||||
* (c) 2009-2012, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
|
||||
*/
|
||||
|
||||
/**
|
||||
* Hybrid_User_Activity
|
||||
*
|
||||
* used to provider the connected user activity stream on a standardized structure across supported social apis.
|
||||
*
|
||||
* http://hybridauth.sourceforge.net/userguide/Profile_Data_User_Activity.html
|
||||
*/
|
||||
class Hybrid_User_Activity
|
||||
{
|
||||
/* activity id on the provider side, usually given as integer */
|
||||
public $id = NULL;
|
||||
|
||||
/* activity date of creation */
|
||||
public $date = NULL;
|
||||
|
||||
/* activity content as a string */
|
||||
public $text = NULL;
|
||||
|
||||
/* user who created the activity */
|
||||
public $user = NULL;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->user = new stdClass();
|
||||
|
||||
// typically, we should have a few information about the user who created the event from social apis
|
||||
$this->user->identifier = NULL;
|
||||
$this->user->displayName = NULL;
|
||||
$this->user->profileURL = NULL;
|
||||
$this->user->photoURL = NULL;
|
||||
}
|
||||
}
|
37
web/third_party/hybridauth/Hybrid/User_Contact.php
vendored
Normal file
37
web/third_party/hybridauth/Hybrid/User_Contact.php
vendored
Normal file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
/*!
|
||||
* HybridAuth
|
||||
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
|
||||
* (c) 2009-2012, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
|
||||
*/
|
||||
|
||||
/**
|
||||
* Hybrid_User_Contact
|
||||
*
|
||||
* used to provider the connected user contacts list on a standardized structure across supported social apis.
|
||||
*
|
||||
* http://hybridauth.sourceforge.net/userguide/Profile_Data_User_Contacts.html
|
||||
*/
|
||||
class Hybrid_User_Contact
|
||||
{
|
||||
/* The Unique contact user ID */
|
||||
public $identifier = NULL;
|
||||
|
||||
/* User website, blog, web page */
|
||||
public $webSiteURL = NULL;
|
||||
|
||||
/* URL link to profile page on the IDp web site */
|
||||
public $profileURL = NULL;
|
||||
|
||||
/* URL link to user photo or avatar */
|
||||
public $photoURL = NULL;
|
||||
|
||||
/* User dispalyName provided by the IDp or a concatenation of first and last name */
|
||||
public $displayName = NULL;
|
||||
|
||||
/* A short about_me */
|
||||
public $description = NULL;
|
||||
|
||||
/* User email. Not all of IDp garant access to the user email */
|
||||
public $email = NULL;
|
||||
}
|
84
web/third_party/hybridauth/Hybrid/User_Profile.php
vendored
Normal file
84
web/third_party/hybridauth/Hybrid/User_Profile.php
vendored
Normal file
@ -0,0 +1,84 @@
|
||||
<?php
|
||||
/*!
|
||||
* HybridAuth
|
||||
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
|
||||
* (c) 2009-2012, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
|
||||
*/
|
||||
|
||||
/**
|
||||
* Hybrid_User_Profile object represents the current logged in user profile.
|
||||
* The list of fields available in the normalized user profile structure used by HybridAuth.
|
||||
*
|
||||
* The Hybrid_User_Profile object is populated with as much information about the user as
|
||||
* HybridAuth was able to pull from the given API or authentication provider.
|
||||
*
|
||||
* http://hybridauth.sourceforge.net/userguide/Profile_Data_User_Profile.html
|
||||
*/
|
||||
class Hybrid_User_Profile
|
||||
{
|
||||
/* The Unique user's ID on the connected provider */
|
||||
public $identifier = NULL;
|
||||
|
||||
/* User website, blog, web page */
|
||||
public $webSiteURL = NULL;
|
||||
|
||||
/* URL link to profile page on the IDp web site */
|
||||
public $profileURL = NULL;
|
||||
|
||||
/* URL link to user photo or avatar */
|
||||
public $photoURL = NULL;
|
||||
|
||||
/* User dispalyName provided by the IDp or a concatenation of first and last name. */
|
||||
public $displayName = NULL;
|
||||
|
||||
/* A short about_me */
|
||||
public $description = NULL;
|
||||
|
||||
/* User's first name */
|
||||
public $firstName = NULL;
|
||||
|
||||
/* User's last name */
|
||||
public $lastName = NULL;
|
||||
|
||||
/* male or female */
|
||||
public $gender = NULL;
|
||||
|
||||
/* language */
|
||||
public $language = NULL;
|
||||
|
||||
/* User age, we dont calculate it. we return it as is if the IDp provide it. */
|
||||
public $age = NULL;
|
||||
|
||||
/* User birth Day */
|
||||
public $birthDay = NULL;
|
||||
|
||||
/* User birth Month */
|
||||
public $birthMonth = NULL;
|
||||
|
||||
/* User birth Year */
|
||||
public $birthYear = NULL;
|
||||
|
||||
/* User email. Note: not all of IDp garant access to the user email */
|
||||
public $email = NULL;
|
||||
|
||||
/* Verified user email. Note: not all of IDp garant access to verified user email */
|
||||
public $emailVerified = NULL;
|
||||
|
||||
/* phone number */
|
||||
public $phone = NULL;
|
||||
|
||||
/* complete user address */
|
||||
public $address = NULL;
|
||||
|
||||
/* user country */
|
||||
public $country = NULL;
|
||||
|
||||
/* region */
|
||||
public $region = NULL;
|
||||
|
||||
/** city */
|
||||
public $city = NULL;
|
||||
|
||||
/* Postal code */
|
||||
public $zip = NULL;
|
||||
}
|
10
web/third_party/hybridauth/Hybrid/index.html
vendored
Normal file
10
web/third_party/hybridauth/Hybrid/index.html
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>403 Forbidden</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p>Directory access is forbidden.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
72
web/third_party/hybridauth/Hybrid/resources/config.php.tpl
vendored
Normal file
72
web/third_party/hybridauth/Hybrid/resources/config.php.tpl
vendored
Normal file
@ -0,0 +1,72 @@
|
||||
<?php
|
||||
/*!
|
||||
* HybridAuth
|
||||
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
|
||||
* (c) 2009-2012, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
|
||||
*/
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
// HybridAuth Config file: http://hybridauth.sourceforge.net/userguide/Configuration.html
|
||||
// ----------------------------------------------------------------------------------------
|
||||
|
||||
return
|
||||
array(
|
||||
"base_url" => "#GLOBAL_HYBRID_AUTH_URL_BASE#",
|
||||
|
||||
"providers" => array (
|
||||
// openid providers
|
||||
"OpenID" => array (
|
||||
"enabled" => #OPENID_ADAPTER_STATUS#
|
||||
),
|
||||
|
||||
"AOL" => array (
|
||||
"enabled" => #AOL_ADAPTER_STATUS#
|
||||
),
|
||||
|
||||
"Yahoo" => array (
|
||||
"enabled" => #YAHOO_ADAPTER_STATUS#,
|
||||
"keys" => array ( "id" => "#YAHOO_APPLICATION_APP_ID#", "secret" => "#YAHOO_APPLICATION_SECRET#" )
|
||||
),
|
||||
|
||||
"Google" => array (
|
||||
"enabled" => #GOOGLE_ADAPTER_STATUS#,
|
||||
"keys" => array ( "id" => "#GOOGLE_APPLICATION_APP_ID#", "secret" => "#GOOGLE_APPLICATION_SECRET#" )
|
||||
),
|
||||
|
||||
"Facebook" => array (
|
||||
"enabled" => #FACEBOOK_ADAPTER_STATUS#,
|
||||
"keys" => array ( "id" => "#FACEBOOK_APPLICATION_APP_ID#", "secret" => "#FACEBOOK_APPLICATION_SECRET#" )
|
||||
),
|
||||
|
||||
"Twitter" => array (
|
||||
"enabled" => #TWITTER_ADAPTER_STATUS#,
|
||||
"keys" => array ( "key" => "#TWITTER_APPLICATION_KEY#", "secret" => "#TWITTER_APPLICATION_SECRET#" )
|
||||
),
|
||||
|
||||
// windows live
|
||||
"Live" => array (
|
||||
"enabled" => #LIVE_ADAPTER_STATUS#,
|
||||
"keys" => array ( "id" => "#LIVE_APPLICATION_APP_ID#", "secret" => "#LIVE_APPLICATION_SECRET#" )
|
||||
),
|
||||
|
||||
"MySpace" => array (
|
||||
"enabled" => #MYSPACE_ADAPTER_STATUS#,
|
||||
"keys" => array ( "key" => "#MYSPACE_APPLICATION_KEY#", "secret" => "#MYSPACE_APPLICATION_SECRET#" )
|
||||
),
|
||||
|
||||
"LinkedIn" => array (
|
||||
"enabled" => #LINKEDIN_ADAPTER_STATUS#,
|
||||
"keys" => array ( "key" => "#LINKEDIN_APPLICATION_KEY#", "secret" => "#LINKEDIN_APPLICATION_SECRET#" )
|
||||
),
|
||||
|
||||
"Foursquare" => array (
|
||||
"enabled" => #FOURSQUARE_ADAPTER_STATUS#,
|
||||
"keys" => array ( "id" => "#FOURSQUARE_APPLICATION_APP_ID#", "secret" => "#FOURSQUARE_APPLICATION_SECRET#" )
|
||||
),
|
||||
),
|
||||
|
||||
// if you want to enable logging, set 'debug_mode' to true then provide a writable file by the web server on "debug_file"
|
||||
"debug_mode" => false,
|
||||
|
||||
"debug_file" => ""
|
||||
);
|
10
web/third_party/hybridauth/Hybrid/resources/index.html
vendored
Normal file
10
web/third_party/hybridauth/Hybrid/resources/index.html
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>403 Forbidden</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p>Directory access is forbidden.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
10
web/third_party/hybridauth/Hybrid/resources/openid_policy.html
vendored
Normal file
10
web/third_party/hybridauth/Hybrid/resources/openid_policy.html
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>OpenID Policy</title>
|
||||
</head>
|
||||
<body>
|
||||
<!--
|
||||
Set here your OpenID Policy,
|
||||
-->
|
||||
</body>
|
||||
</html>
|
13
web/third_party/hybridauth/Hybrid/resources/openid_realm.html
vendored
Normal file
13
web/third_party/hybridauth/Hybrid/resources/openid_realm.html
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>HybridAuth Endpoint</title>
|
||||
<meta name="robots" content="NOINDEX, NOFOLLOW">
|
||||
<meta http-equiv="X-XRDS-Location" content="{X_XRDS_LOCATION}" />
|
||||
</head>
|
||||
<body>
|
||||
<h3 style="margin-bottom: 2px;">HybridAuth</h3>
|
||||
Open Source Social Sign On PHP Library.
|
||||
<br />
|
||||
<a href="http://hybridauth.sourceforge.net/" style="color:green;text-decoration:none;">hybridauth.sourceforge.net/</a>
|
||||
</body>
|
||||
</html>
|
12
web/third_party/hybridauth/Hybrid/resources/openid_xrds.xml
vendored
Normal file
12
web/third_party/hybridauth/Hybrid/resources/openid_xrds.xml
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<xrds:XRDS
|
||||
xmlns:xrds="xri://$xrds"
|
||||
xmlns:openid="http://openid.net/xmlns/1.0"
|
||||
xmlns="xri://$xrd*($v*2.0)">
|
||||
<XRD>
|
||||
<Service priority="1">
|
||||
<Type>http://specs.openid.net/auth/2.0/return_to</Type>
|
||||
<URI>{RETURN_TO_URL}</URI>
|
||||
</Service>
|
||||
</XRD>
|
||||
</xrds:XRDS>
|
1436
web/third_party/hybridauth/Hybrid/thirdparty/Facebook/base_facebook.php
vendored
Normal file
1436
web/third_party/hybridauth/Hybrid/thirdparty/Facebook/base_facebook.php
vendored
Normal file
File diff suppressed because it is too large
Load Diff
160
web/third_party/hybridauth/Hybrid/thirdparty/Facebook/facebook.php
vendored
Normal file
160
web/third_party/hybridauth/Hybrid/thirdparty/Facebook/facebook.php
vendored
Normal file
@ -0,0 +1,160 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2011 Facebook, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License. You may obtain
|
||||
* a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
require_once "base_facebook.php";
|
||||
|
||||
/**
|
||||
* Extends the BaseFacebook class with the intent of using
|
||||
* PHP sessions to store user ids and access tokens.
|
||||
*/
|
||||
class Facebook extends BaseFacebook
|
||||
{
|
||||
const FBSS_COOKIE_NAME = 'fbss';
|
||||
|
||||
// We can set this to a high number because the main session
|
||||
// expiration will trump this.
|
||||
const FBSS_COOKIE_EXPIRE = 31556926; // 1 year
|
||||
|
||||
// Stores the shared session ID if one is set.
|
||||
protected $sharedSessionID;
|
||||
|
||||
/**
|
||||
* Identical to the parent constructor, except that
|
||||
* we start a PHP session to store the user ID and
|
||||
* access token if during the course of execution
|
||||
* we discover them.
|
||||
*
|
||||
* @param Array $config the application configuration. Additionally
|
||||
* accepts "sharedSession" as a boolean to turn on a secondary
|
||||
* cookie for environments with a shared session (that is, your app
|
||||
* shares the domain with other apps).
|
||||
* @see BaseFacebook::__construct in facebook.php
|
||||
*/
|
||||
public function __construct($config) {
|
||||
if (!session_id()) {
|
||||
session_start();
|
||||
}
|
||||
parent::__construct($config);
|
||||
if (!empty($config['sharedSession'])) {
|
||||
$this->initSharedSession();
|
||||
}
|
||||
}
|
||||
|
||||
protected static $kSupportedKeys =
|
||||
array('state', 'code', 'access_token', 'user_id');
|
||||
|
||||
protected function initSharedSession() {
|
||||
$cookie_name = $this->getSharedSessionCookieName();
|
||||
if (isset($_COOKIE[$cookie_name])) {
|
||||
$data = $this->parseSignedRequest($_COOKIE[$cookie_name]);
|
||||
if ($data && !empty($data['domain']) &&
|
||||
self::isAllowedDomain($this->getHttpHost(), $data['domain'])) {
|
||||
// good case
|
||||
$this->sharedSessionID = $data['id'];
|
||||
return;
|
||||
}
|
||||
// ignoring potentially unreachable data
|
||||
}
|
||||
// evil/corrupt/missing case
|
||||
$base_domain = $this->getBaseDomain();
|
||||
$this->sharedSessionID = md5(uniqid(mt_rand(), true));
|
||||
$cookie_value = $this->makeSignedRequest(
|
||||
array(
|
||||
'domain' => $base_domain,
|
||||
'id' => $this->sharedSessionID,
|
||||
)
|
||||
);
|
||||
$_COOKIE[$cookie_name] = $cookie_value;
|
||||
if (!headers_sent()) {
|
||||
$expire = time() + self::FBSS_COOKIE_EXPIRE;
|
||||
setcookie($cookie_name, $cookie_value, $expire, '/', '.'.$base_domain);
|
||||
} else {
|
||||
// @codeCoverageIgnoreStart
|
||||
self::errorLog(
|
||||
'Shared session ID cookie could not be set! You must ensure you '.
|
||||
'create the Facebook instance before headers have been sent. This '.
|
||||
'will cause authentication issues after the first request.'
|
||||
);
|
||||
// @codeCoverageIgnoreEnd
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides the implementations of the inherited abstract
|
||||
* methods. The implementation uses PHP sessions to maintain
|
||||
* a store for authorization codes, user ids, CSRF states, and
|
||||
* access tokens.
|
||||
*/
|
||||
protected function setPersistentData($key, $value) {
|
||||
if (!in_array($key, self::$kSupportedKeys)) {
|
||||
self::errorLog('Unsupported key passed to setPersistentData.');
|
||||
return;
|
||||
}
|
||||
|
||||
$session_var_name = $this->constructSessionVariableName($key);
|
||||
$_SESSION[$session_var_name] = $value;
|
||||
}
|
||||
|
||||
protected function getPersistentData($key, $default = false) {
|
||||
if (!in_array($key, self::$kSupportedKeys)) {
|
||||
self::errorLog('Unsupported key passed to getPersistentData.');
|
||||
return $default;
|
||||
}
|
||||
|
||||
$session_var_name = $this->constructSessionVariableName($key);
|
||||
return isset($_SESSION[$session_var_name]) ?
|
||||
$_SESSION[$session_var_name] : $default;
|
||||
}
|
||||
|
||||
protected function clearPersistentData($key) {
|
||||
if (!in_array($key, self::$kSupportedKeys)) {
|
||||
self::errorLog('Unsupported key passed to clearPersistentData.');
|
||||
return;
|
||||
}
|
||||
|
||||
$session_var_name = $this->constructSessionVariableName($key);
|
||||
unset($_SESSION[$session_var_name]);
|
||||
}
|
||||
|
||||
protected function clearAllPersistentData() {
|
||||
foreach (self::$kSupportedKeys as $key) {
|
||||
$this->clearPersistentData($key);
|
||||
}
|
||||
if ($this->sharedSessionID) {
|
||||
$this->deleteSharedSessionCookie();
|
||||
}
|
||||
}
|
||||
|
||||
protected function deleteSharedSessionCookie() {
|
||||
$cookie_name = $this->getSharedSessionCookieName();
|
||||
unset($_COOKIE[$cookie_name]);
|
||||
$base_domain = $this->getBaseDomain();
|
||||
setcookie($cookie_name, '', 1, '/', '.'.$base_domain);
|
||||
}
|
||||
|
||||
protected function getSharedSessionCookieName() {
|
||||
return self::FBSS_COOKIE_NAME . '_' . $this->getAppId();
|
||||
}
|
||||
|
||||
protected function constructSessionVariableName($key) {
|
||||
$parts = array('fb', $this->getAppId(), $key);
|
||||
if ($this->sharedSessionID) {
|
||||
array_unshift($parts, $this->sharedSessionID);
|
||||
}
|
||||
return implode('_', $parts);
|
||||
}
|
||||
}
|
3920
web/third_party/hybridauth/Hybrid/thirdparty/Facebook/fb_ca_chain_bundle.crt
vendored
Normal file
3920
web/third_party/hybridauth/Hybrid/thirdparty/Facebook/fb_ca_chain_bundle.crt
vendored
Normal file
File diff suppressed because it is too large
Load Diff
2639
web/third_party/hybridauth/Hybrid/thirdparty/LinkedIn/LinkedIn.php
vendored
Normal file
2639
web/third_party/hybridauth/Hybrid/thirdparty/LinkedIn/LinkedIn.php
vendored
Normal file
File diff suppressed because it is too large
Load Diff
897
web/third_party/hybridauth/Hybrid/thirdparty/OAuth/OAuth.php
vendored
Normal file
897
web/third_party/hybridauth/Hybrid/thirdparty/OAuth/OAuth.php
vendored
Normal file
@ -0,0 +1,897 @@
|
||||
<?php
|
||||
// http://oauth.googlecode.com/svn/code/php/OAuth.php
|
||||
// rev 1261, Mar 29, 2011 morten.fangel
|
||||
// modified on Dec 29, 2019 to remove OAuth PECL conflict
|
||||
|
||||
// vim: foldmethod=marker
|
||||
|
||||
/* Generic exception class
|
||||
*/
|
||||
class OAuthExceptionPHP extends Exception {
|
||||
// pass
|
||||
}
|
||||
|
||||
class OAuthConsumer {
|
||||
public $key;
|
||||
public $secret;
|
||||
|
||||
function __construct($key, $secret, $callback_url=NULL) {
|
||||
$this->key = $key;
|
||||
$this->secret = $secret;
|
||||
$this->callback_url = $callback_url;
|
||||
}
|
||||
|
||||
function __toString() {
|
||||
return "OAuthConsumer[key=$this->key,secret=$this->secret]";
|
||||
}
|
||||
}
|
||||
|
||||
class OAuthToken {
|
||||
// access tokens and request tokens
|
||||
public $key;
|
||||
public $secret;
|
||||
|
||||
/**
|
||||
* key = the token
|
||||
* secret = the token secret
|
||||
*/
|
||||
function __construct($key, $secret) {
|
||||
$this->key = $key;
|
||||
$this->secret = $secret;
|
||||
}
|
||||
|
||||
/**
|
||||
* generates the basic string serialization of a token that a server
|
||||
* would respond to request_token and access_token calls with
|
||||
*/
|
||||
function to_string() {
|
||||
return "oauth_token=" .
|
||||
OAuthUtil::urlencode_rfc3986($this->key) .
|
||||
"&oauth_token_secret=" .
|
||||
OAuthUtil::urlencode_rfc3986($this->secret);
|
||||
}
|
||||
|
||||
function __toString() {
|
||||
return $this->to_string();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A class for implementing a Signature Method
|
||||
* See section 9 ("Signing Requests") in the spec
|
||||
*/
|
||||
abstract class OAuthSignatureMethod {
|
||||
/**
|
||||
* Needs to return the name of the Signature Method (ie HMAC-SHA1)
|
||||
* @return string
|
||||
*/
|
||||
abstract public function get_name();
|
||||
|
||||
/**
|
||||
* Build up the signature
|
||||
* NOTE: The output of this function MUST NOT be urlencoded.
|
||||
* the encoding is handled in OAuthRequest when the final
|
||||
* request is serialized
|
||||
* @param OAuthRequest $request
|
||||
* @param OAuthConsumer $consumer
|
||||
* @param OAuthToken $token
|
||||
* @return string
|
||||
*/
|
||||
abstract public function build_signature($request, $consumer, $token);
|
||||
|
||||
/**
|
||||
* Verifies that a given signature is correct
|
||||
* @param OAuthRequest $request
|
||||
* @param OAuthConsumer $consumer
|
||||
* @param OAuthToken $token
|
||||
* @param string $signature
|
||||
* @return bool
|
||||
*/
|
||||
public function check_signature($request, $consumer, $token, $signature) {
|
||||
$built = $this->build_signature($request, $consumer, $token);
|
||||
|
||||
// Check for zero length, although unlikely here
|
||||
if (strlen($built) == 0 || strlen($signature) == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (strlen($built) != strlen($signature)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Avoid a timing leak with a (hopefully) time insensitive compare
|
||||
$result = 0;
|
||||
for ($i = 0; $i < strlen($signature); $i++) {
|
||||
$result |= ord($built{$i}) ^ ord($signature{$i});
|
||||
}
|
||||
|
||||
return $result == 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The HMAC-SHA1 signature method uses the HMAC-SHA1 signature algorithm as defined in [RFC2104]
|
||||
* where the Signature Base String is the text and the key is the concatenated values (each first
|
||||
* encoded per Parameter Encoding) of the Consumer Secret and Token Secret, separated by an '&'
|
||||
* character (ASCII code 38) even if empty.
|
||||
* - Chapter 9.2 ("HMAC-SHA1")
|
||||
*/
|
||||
class OAuthSignatureMethod_HMAC_SHA1 extends OAuthSignatureMethod {
|
||||
function get_name() {
|
||||
return "HMAC-SHA1";
|
||||
}
|
||||
|
||||
public function build_signature($request, $consumer, $token) {
|
||||
$base_string = $request->get_signature_base_string();
|
||||
$request->base_string = $base_string;
|
||||
|
||||
$key_parts = array(
|
||||
$consumer->secret,
|
||||
($token) ? $token->secret : ""
|
||||
);
|
||||
|
||||
$key_parts = OAuthUtil::urlencode_rfc3986($key_parts);
|
||||
$key = implode('&', $key_parts);
|
||||
|
||||
return base64_encode(hash_hmac('sha1', $base_string, $key, true));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The PLAINTEXT method does not provide any security protection and SHOULD only be used
|
||||
* over a secure channel such as HTTPS. It does not use the Signature Base String.
|
||||
* - Chapter 9.4 ("PLAINTEXT")
|
||||
*/
|
||||
class OAuthSignatureMethod_PLAINTEXT extends OAuthSignatureMethod {
|
||||
public function get_name() {
|
||||
return "PLAINTEXT";
|
||||
}
|
||||
|
||||
/**
|
||||
* oauth_signature is set to the concatenated encoded values of the Consumer Secret and
|
||||
* Token Secret, separated by a '&' character (ASCII code 38), even if either secret is
|
||||
* empty. The result MUST be encoded again.
|
||||
* - Chapter 9.4.1 ("Generating Signatures")
|
||||
*
|
||||
* Please note that the second encoding MUST NOT happen in the SignatureMethod, as
|
||||
* OAuthRequest handles this!
|
||||
*/
|
||||
public function build_signature($request, $consumer, $token) {
|
||||
$key_parts = array(
|
||||
$consumer->secret,
|
||||
($token) ? $token->secret : ""
|
||||
);
|
||||
|
||||
$key_parts = OAuthUtil::urlencode_rfc3986($key_parts);
|
||||
$key = implode('&', $key_parts);
|
||||
$request->base_string = $key;
|
||||
|
||||
return $key;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The RSA-SHA1 signature method uses the RSASSA-PKCS1-v1_5 signature algorithm as defined in
|
||||
* [RFC3447] section 8.2 (more simply known as PKCS#1), using SHA-1 as the hash function for
|
||||
* EMSA-PKCS1-v1_5. It is assumed that the Consumer has provided its RSA public key in a
|
||||
* verified way to the Service Provider, in a manner which is beyond the scope of this
|
||||
* specification.
|
||||
* - Chapter 9.3 ("RSA-SHA1")
|
||||
*/
|
||||
abstract class OAuthSignatureMethod_RSA_SHA1 extends OAuthSignatureMethod {
|
||||
public function get_name() {
|
||||
return "RSA-SHA1";
|
||||
}
|
||||
|
||||
// Up to the SP to implement this lookup of keys. Possible ideas are:
|
||||
// (1) do a lookup in a table of trusted certs keyed off of consumer
|
||||
// (2) fetch via http using a url provided by the requester
|
||||
// (3) some sort of specific discovery code based on request
|
||||
//
|
||||
// Either way should return a string representation of the certificate
|
||||
protected abstract function fetch_public_cert(&$request);
|
||||
|
||||
// Up to the SP to implement this lookup of keys. Possible ideas are:
|
||||
// (1) do a lookup in a table of trusted certs keyed off of consumer
|
||||
//
|
||||
// Either way should return a string representation of the certificate
|
||||
protected abstract function fetch_private_cert(&$request);
|
||||
|
||||
public function build_signature($request, $consumer, $token) {
|
||||
$base_string = $request->get_signature_base_string();
|
||||
$request->base_string = $base_string;
|
||||
|
||||
// Fetch the private key cert based on the request
|
||||
$cert = $this->fetch_private_cert($request);
|
||||
|
||||
// Pull the private key ID from the certificate
|
||||
$privatekeyid = openssl_get_privatekey($cert);
|
||||
|
||||
// Sign using the key
|
||||
$ok = openssl_sign($base_string, $signature, $privatekeyid);
|
||||
|
||||
// Release the key resource
|
||||
openssl_free_key($privatekeyid);
|
||||
|
||||
return base64_encode($signature);
|
||||
}
|
||||
|
||||
public function check_signature($request, $consumer, $token, $signature) {
|
||||
$decoded_sig = base64_decode($signature);
|
||||
|
||||
$base_string = $request->get_signature_base_string();
|
||||
|
||||
// Fetch the public key cert based on the request
|
||||
$cert = $this->fetch_public_cert($request);
|
||||
|
||||
// Pull the public key ID from the certificate
|
||||
$publickeyid = openssl_get_publickey($cert);
|
||||
|
||||
// Check the computed signature against the one passed in the query
|
||||
$ok = openssl_verify($base_string, $decoded_sig, $publickeyid);
|
||||
|
||||
// Release the key resource
|
||||
openssl_free_key($publickeyid);
|
||||
|
||||
return $ok == 1;
|
||||
}
|
||||
}
|
||||
|
||||
class OAuthRequest {
|
||||
protected $parameters;
|
||||
protected $http_method;
|
||||
protected $http_url;
|
||||
// for debug purposes
|
||||
public $base_string;
|
||||
public static $version = '1.0';
|
||||
public static $POST_INPUT = 'php://input';
|
||||
|
||||
function __construct($http_method, $http_url, $parameters=NULL) {
|
||||
$parameters = ($parameters) ? $parameters : array();
|
||||
$parameters = array_merge( OAuthUtil::parse_parameters(parse_url($http_url, PHP_URL_QUERY)), $parameters);
|
||||
$this->parameters = $parameters;
|
||||
$this->http_method = $http_method;
|
||||
$this->http_url = $http_url;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* attempt to build up a request from what was passed to the server
|
||||
*/
|
||||
public static function from_request($http_method=NULL, $http_url=NULL, $parameters=NULL) {
|
||||
$scheme = (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != "on")
|
||||
? 'http'
|
||||
: 'https';
|
||||
$http_url = ($http_url) ? $http_url : $scheme .
|
||||
'://' . $_SERVER['SERVER_NAME'] .
|
||||
':' .
|
||||
$_SERVER['SERVER_PORT'] .
|
||||
$_SERVER['REQUEST_URI'];
|
||||
$http_method = ($http_method) ? $http_method : $_SERVER['REQUEST_METHOD'];
|
||||
|
||||
// We weren't handed any parameters, so let's find the ones relevant to
|
||||
// this request.
|
||||
// If you run XML-RPC or similar you should use this to provide your own
|
||||
// parsed parameter-list
|
||||
if (!$parameters) {
|
||||
// Find request headers
|
||||
$request_headers = OAuthUtil::get_headers();
|
||||
|
||||
// Parse the query-string to find GET parameters
|
||||
$parameters = OAuthUtil::parse_parameters($_SERVER['QUERY_STRING']);
|
||||
|
||||
// It's a POST request of the proper content-type, so parse POST
|
||||
// parameters and add those overriding any duplicates from GET
|
||||
if ($http_method == "POST"
|
||||
&& isset($request_headers['Content-Type'])
|
||||
&& strstr($request_headers['Content-Type'],
|
||||
'application/x-www-form-urlencoded')
|
||||
) {
|
||||
$post_data = OAuthUtil::parse_parameters(
|
||||
file_get_contents(self::$POST_INPUT)
|
||||
);
|
||||
$parameters = array_merge($parameters, $post_data);
|
||||
}
|
||||
|
||||
// We have a Authorization-header with OAuth data. Parse the header
|
||||
// and add those overriding any duplicates from GET or POST
|
||||
if (isset($request_headers['Authorization']) && substr($request_headers['Authorization'], 0, 6) == 'OAuth ') {
|
||||
$header_parameters = OAuthUtil::split_header(
|
||||
$request_headers['Authorization']
|
||||
);
|
||||
$parameters = array_merge($parameters, $header_parameters);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return new OAuthRequest($http_method, $http_url, $parameters);
|
||||
}
|
||||
|
||||
/**
|
||||
* pretty much a helper function to set up the request
|
||||
*/
|
||||
public static function from_consumer_and_token($consumer, $token, $http_method, $http_url, $parameters=NULL) {
|
||||
$parameters = ($parameters) ? $parameters : array();
|
||||
$defaults = array("oauth_version" => OAuthRequest::$version,
|
||||
"oauth_nonce" => OAuthRequest::generate_nonce(),
|
||||
"oauth_timestamp" => OAuthRequest::generate_timestamp(),
|
||||
"oauth_consumer_key" => $consumer->key);
|
||||
if ($token)
|
||||
$defaults['oauth_token'] = $token->key;
|
||||
|
||||
$parameters = array_merge($defaults, $parameters);
|
||||
|
||||
return new OAuthRequest($http_method, $http_url, $parameters);
|
||||
}
|
||||
|
||||
public function set_parameter($name, $value, $allow_duplicates = true) {
|
||||
if ($allow_duplicates && isset($this->parameters[$name])) {
|
||||
// We have already added parameter(s) with this name, so add to the list
|
||||
if (is_scalar($this->parameters[$name])) {
|
||||
// This is the first duplicate, so transform scalar (string)
|
||||
// into an array so we can add the duplicates
|
||||
$this->parameters[$name] = array($this->parameters[$name]);
|
||||
}
|
||||
|
||||
$this->parameters[$name][] = $value;
|
||||
} else {
|
||||
$this->parameters[$name] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
public function get_parameter($name) {
|
||||
return isset($this->parameters[$name]) ? $this->parameters[$name] : null;
|
||||
}
|
||||
|
||||
public function get_parameters() {
|
||||
return $this->parameters;
|
||||
}
|
||||
|
||||
public function unset_parameter($name) {
|
||||
unset($this->parameters[$name]);
|
||||
}
|
||||
|
||||
/**
|
||||
* The request parameters, sorted and concatenated into a normalized string.
|
||||
* @return string
|
||||
*/
|
||||
public function get_signable_parameters() {
|
||||
// Grab all parameters
|
||||
$params = $this->parameters;
|
||||
|
||||
// Remove oauth_signature if present
|
||||
// Ref: Spec: 9.1.1 ("The oauth_signature parameter MUST be excluded.")
|
||||
if (isset($params['oauth_signature'])) {
|
||||
unset($params['oauth_signature']);
|
||||
}
|
||||
|
||||
return OAuthUtil::build_http_query($params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the base string of this request
|
||||
*
|
||||
* The base string defined as the method, the url
|
||||
* and the parameters (normalized), each urlencoded
|
||||
* and the concated with &.
|
||||
*/
|
||||
public function get_signature_base_string() {
|
||||
$parts = array(
|
||||
$this->get_normalized_http_method(),
|
||||
$this->get_normalized_http_url(),
|
||||
$this->get_signable_parameters()
|
||||
);
|
||||
|
||||
$parts = OAuthUtil::urlencode_rfc3986($parts);
|
||||
|
||||
return implode('&', $parts);
|
||||
}
|
||||
|
||||
/**
|
||||
* just uppercases the http method
|
||||
*/
|
||||
public function get_normalized_http_method() {
|
||||
return strtoupper($this->http_method);
|
||||
}
|
||||
|
||||
/**
|
||||
* parses the url and rebuilds it to be
|
||||
* scheme://host/path
|
||||
*/
|
||||
public function get_normalized_http_url() {
|
||||
$parts = parse_url($this->http_url);
|
||||
|
||||
$scheme = (isset($parts['scheme'])) ? $parts['scheme'] : 'http';
|
||||
$port = (isset($parts['port'])) ? $parts['port'] : (($scheme == 'https') ? '443' : '80');
|
||||
$host = (isset($parts['host'])) ? strtolower($parts['host']) : '';
|
||||
$path = (isset($parts['path'])) ? $parts['path'] : '';
|
||||
|
||||
if (($scheme == 'https' && $port != '443')
|
||||
|| ($scheme == 'http' && $port != '80')) {
|
||||
$host = "$host:$port";
|
||||
}
|
||||
return "$scheme://$host$path";
|
||||
}
|
||||
|
||||
/**
|
||||
* builds a url usable for a GET request
|
||||
*/
|
||||
public function to_url() {
|
||||
$post_data = $this->to_postdata();
|
||||
$out = $this->get_normalized_http_url();
|
||||
if ($post_data) {
|
||||
$out .= '?'.$post_data;
|
||||
}
|
||||
return $out;
|
||||
}
|
||||
|
||||
/**
|
||||
* builds the data one would send in a POST request
|
||||
*/
|
||||
public function to_postdata() {
|
||||
return OAuthUtil::build_http_query($this->parameters);
|
||||
}
|
||||
|
||||
/**
|
||||
* builds the Authorization: header
|
||||
*/
|
||||
public function to_header($realm=null) {
|
||||
$first = true;
|
||||
if($realm) {
|
||||
$out = 'Authorization: OAuth realm="' . OAuthUtil::urlencode_rfc3986($realm) . '"';
|
||||
$first = false;
|
||||
} else
|
||||
$out = 'Authorization: OAuth';
|
||||
|
||||
$total = array();
|
||||
foreach ($this->parameters as $k => $v) {
|
||||
if (substr($k, 0, 5) != "oauth") continue;
|
||||
if (is_array($v)) {
|
||||
throw new OAuthExceptionPHP('Arrays not supported in headers');
|
||||
}
|
||||
$out .= ($first) ? ' ' : ',';
|
||||
$out .= OAuthUtil::urlencode_rfc3986($k) .
|
||||
'="' .
|
||||
OAuthUtil::urlencode_rfc3986($v) .
|
||||
'"';
|
||||
$first = false;
|
||||
}
|
||||
return $out;
|
||||
}
|
||||
|
||||
public function __toString() {
|
||||
return $this->to_url();
|
||||
}
|
||||
|
||||
|
||||
public function sign_request($signature_method, $consumer, $token) {
|
||||
$this->set_parameter(
|
||||
"oauth_signature_method",
|
||||
$signature_method->get_name(),
|
||||
false
|
||||
);
|
||||
$signature = $this->build_signature($signature_method, $consumer, $token);
|
||||
$this->set_parameter("oauth_signature", $signature, false);
|
||||
}
|
||||
|
||||
public function build_signature($signature_method, $consumer, $token) {
|
||||
$signature = $signature_method->build_signature($this, $consumer, $token);
|
||||
return $signature;
|
||||
}
|
||||
|
||||
/**
|
||||
* util function: current timestamp
|
||||
*/
|
||||
private static function generate_timestamp() {
|
||||
return time();
|
||||
}
|
||||
|
||||
/**
|
||||
* util function: current nonce
|
||||
*/
|
||||
private static function generate_nonce() {
|
||||
$mt = microtime();
|
||||
$rand = mt_rand();
|
||||
|
||||
return md5($mt . $rand); // md5s look nicer than numbers
|
||||
}
|
||||
}
|
||||
|
||||
class OAuthServer {
|
||||
protected $timestamp_threshold = 300; // in seconds, five minutes
|
||||
protected $version = '1.0'; // hi blaine
|
||||
protected $signature_methods = array();
|
||||
|
||||
protected $data_store;
|
||||
|
||||
function __construct($data_store) {
|
||||
$this->data_store = $data_store;
|
||||
}
|
||||
|
||||
public function add_signature_method($signature_method) {
|
||||
$this->signature_methods[$signature_method->get_name()] =
|
||||
$signature_method;
|
||||
}
|
||||
|
||||
// high level functions
|
||||
|
||||
/**
|
||||
* process a request_token request
|
||||
* returns the request token on success
|
||||
*/
|
||||
public function fetch_request_token(&$request) {
|
||||
$this->get_version($request);
|
||||
|
||||
$consumer = $this->get_consumer($request);
|
||||
|
||||
// no token required for the initial token request
|
||||
$token = NULL;
|
||||
|
||||
$this->check_signature($request, $consumer, $token);
|
||||
|
||||
// Rev A change
|
||||
$callback = $request->get_parameter('oauth_callback');
|
||||
$new_token = $this->data_store->new_request_token($consumer, $callback);
|
||||
|
||||
return $new_token;
|
||||
}
|
||||
|
||||
/**
|
||||
* process an access_token request
|
||||
* returns the access token on success
|
||||
*/
|
||||
public function fetch_access_token(&$request) {
|
||||
$this->get_version($request);
|
||||
|
||||
$consumer = $this->get_consumer($request);
|
||||
|
||||
// requires authorized request token
|
||||
$token = $this->get_token($request, $consumer, "request");
|
||||
|
||||
$this->check_signature($request, $consumer, $token);
|
||||
|
||||
// Rev A change
|
||||
$verifier = $request->get_parameter('oauth_verifier');
|
||||
$new_token = $this->data_store->new_access_token($token, $consumer, $verifier);
|
||||
|
||||
return $new_token;
|
||||
}
|
||||
|
||||
/**
|
||||
* verify an api call, checks all the parameters
|
||||
*/
|
||||
public function verify_request(&$request) {
|
||||
$this->get_version($request);
|
||||
$consumer = $this->get_consumer($request);
|
||||
$token = $this->get_token($request, $consumer, "access");
|
||||
$this->check_signature($request, $consumer, $token);
|
||||
return array($consumer, $token);
|
||||
}
|
||||
|
||||
// Internals from here
|
||||
/**
|
||||
* version 1
|
||||
*/
|
||||
private function get_version(&$request) {
|
||||
$version = $request->get_parameter("oauth_version");
|
||||
if (!$version) {
|
||||
// Service Providers MUST assume the protocol version to be 1.0 if this parameter is not present.
|
||||
// Chapter 7.0 ("Accessing Protected Ressources")
|
||||
$version = '1.0';
|
||||
}
|
||||
if ($version !== $this->version) {
|
||||
throw new OAuthExceptionPHP("OAuth version '$version' not supported");
|
||||
}
|
||||
return $version;
|
||||
}
|
||||
|
||||
/**
|
||||
* figure out the signature with some defaults
|
||||
*/
|
||||
private function get_signature_method($request) {
|
||||
$signature_method = $request instanceof OAuthRequest
|
||||
? $request->get_parameter("oauth_signature_method")
|
||||
: NULL;
|
||||
|
||||
if (!$signature_method) {
|
||||
// According to chapter 7 ("Accessing Protected Ressources") the signature-method
|
||||
// parameter is required, and we can't just fallback to PLAINTEXT
|
||||
throw new OAuthExceptionPHP('No signature method parameter. This parameter is required');
|
||||
}
|
||||
|
||||
if (!in_array($signature_method,
|
||||
array_keys($this->signature_methods))) {
|
||||
throw new OAuthExceptionPHP(
|
||||
"Signature method '$signature_method' not supported " .
|
||||
"try one of the following: " .
|
||||
implode(", ", array_keys($this->signature_methods))
|
||||
);
|
||||
}
|
||||
return $this->signature_methods[$signature_method];
|
||||
}
|
||||
|
||||
/**
|
||||
* try to find the consumer for the provided request's consumer key
|
||||
*/
|
||||
private function get_consumer($request) {
|
||||
$consumer_key = $request instanceof OAuthRequest
|
||||
? $request->get_parameter("oauth_consumer_key")
|
||||
: NULL;
|
||||
|
||||
if (!$consumer_key) {
|
||||
throw new OAuthExceptionPHP("Invalid consumer key");
|
||||
}
|
||||
|
||||
$consumer = $this->data_store->lookup_consumer($consumer_key);
|
||||
if (!$consumer) {
|
||||
throw new OAuthExceptionPHP("Invalid consumer");
|
||||
}
|
||||
|
||||
return $consumer;
|
||||
}
|
||||
|
||||
/**
|
||||
* try to find the token for the provided request's token key
|
||||
*/
|
||||
private function get_token($request, $consumer, $token_type="access") {
|
||||
$token_field = $request instanceof OAuthRequest
|
||||
? $request->get_parameter('oauth_token')
|
||||
: NULL;
|
||||
|
||||
$token = $this->data_store->lookup_token(
|
||||
$consumer, $token_type, $token_field
|
||||
);
|
||||
if (!$token) {
|
||||
throw new OAuthExceptionPHP("Invalid $token_type token: $token_field");
|
||||
}
|
||||
return $token;
|
||||
}
|
||||
|
||||
/**
|
||||
* all-in-one function to check the signature on a request
|
||||
* should guess the signature method appropriately
|
||||
*/
|
||||
private function check_signature($request, $consumer, $token) {
|
||||
// this should probably be in a different method
|
||||
$timestamp = $request instanceof OAuthRequest
|
||||
? $request->get_parameter('oauth_timestamp')
|
||||
: NULL;
|
||||
$nonce = $request instanceof OAuthRequest
|
||||
? $request->get_parameter('oauth_nonce')
|
||||
: NULL;
|
||||
|
||||
$this->check_timestamp($timestamp);
|
||||
$this->check_nonce($consumer, $token, $nonce, $timestamp);
|
||||
|
||||
$signature_method = $this->get_signature_method($request);
|
||||
|
||||
$signature = $request->get_parameter('oauth_signature');
|
||||
$valid_sig = $signature_method->check_signature(
|
||||
$request,
|
||||
$consumer,
|
||||
$token,
|
||||
$signature
|
||||
);
|
||||
|
||||
if (!$valid_sig) {
|
||||
throw new OAuthExceptionPHP("Invalid signature");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* check that the timestamp is new enough
|
||||
*/
|
||||
private function check_timestamp($timestamp) {
|
||||
if( ! $timestamp )
|
||||
throw new OAuthExceptionPHP(
|
||||
'Missing timestamp parameter. The parameter is required'
|
||||
);
|
||||
|
||||
// verify that timestamp is recentish
|
||||
$now = time();
|
||||
if (abs($now - $timestamp) > $this->timestamp_threshold) {
|
||||
throw new OAuthExceptionPHP(
|
||||
"Expired timestamp, yours $timestamp, ours $now"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* check that the nonce is not repeated
|
||||
*/
|
||||
private function check_nonce($consumer, $token, $nonce, $timestamp) {
|
||||
if( ! $nonce )
|
||||
throw new OAuthExceptionPHP(
|
||||
'Missing nonce parameter. The parameter is required'
|
||||
);
|
||||
|
||||
// verify that the nonce is uniqueish
|
||||
$found = $this->data_store->lookup_nonce(
|
||||
$consumer,
|
||||
$token,
|
||||
$nonce,
|
||||
$timestamp
|
||||
);
|
||||
if ($found) {
|
||||
throw new OAuthExceptionPHP("Nonce already used: $nonce");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class OAuthDataStore {
|
||||
function lookup_consumer($consumer_key) {
|
||||
// implement me
|
||||
}
|
||||
|
||||
function lookup_token($consumer, $token_type, $token) {
|
||||
// implement me
|
||||
}
|
||||
|
||||
function lookup_nonce($consumer, $token, $nonce, $timestamp) {
|
||||
// implement me
|
||||
}
|
||||
|
||||
function new_request_token($consumer, $callback = null) {
|
||||
// return a new token attached to this consumer
|
||||
}
|
||||
|
||||
function new_access_token($token, $consumer, $verifier = null) {
|
||||
// return a new access token attached to this consumer
|
||||
// for the user associated with this token if the request token
|
||||
// is authorized
|
||||
// should also invalidate the request token
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class OAuthUtil {
|
||||
public static function urlencode_rfc3986($input) {
|
||||
if (is_array($input)) {
|
||||
return array_map(array('OAuthUtil', 'urlencode_rfc3986'), $input);
|
||||
} else if (is_scalar($input)) {
|
||||
return str_replace(
|
||||
'+',
|
||||
' ',
|
||||
str_replace('%7E', '~', rawurlencode($input))
|
||||
);
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// This decode function isn't taking into consideration the above
|
||||
// modifications to the encoding process. However, this method doesn't
|
||||
// seem to be used anywhere so leaving it as is.
|
||||
public static function urldecode_rfc3986($string) {
|
||||
return urldecode($string);
|
||||
}
|
||||
|
||||
// Utility function for turning the Authorization: header into
|
||||
// parameters, has to do some unescaping
|
||||
// Can filter out any non-oauth parameters if needed (default behaviour)
|
||||
// May 28th, 2010 - method updated to tjerk.meesters for a speed improvement.
|
||||
// see http://code.google.com/p/oauth/issues/detail?id=163
|
||||
public static function split_header($header, $only_allow_oauth_parameters = true) {
|
||||
$params = array();
|
||||
if (preg_match_all('/('.($only_allow_oauth_parameters ? 'oauth_' : '').'[a-z_-]*)=(:?"([^"]*)"|([^,]*))/', $header, $matches)) {
|
||||
foreach ($matches[1] as $i => $h) {
|
||||
$params[$h] = OAuthUtil::urldecode_rfc3986(empty($matches[3][$i]) ? $matches[4][$i] : $matches[3][$i]);
|
||||
}
|
||||
if (isset($params['realm'])) {
|
||||
unset($params['realm']);
|
||||
}
|
||||
}
|
||||
return $params;
|
||||
}
|
||||
|
||||
// helper to try to sort out headers for people who aren't running apache
|
||||
public static function get_headers() {
|
||||
if (function_exists('apache_request_headers')) {
|
||||
// we need this to get the actual Authorization: header
|
||||
// because apache tends to tell us it doesn't exist
|
||||
$headers = apache_request_headers();
|
||||
|
||||
// sanitize the output of apache_request_headers because
|
||||
// we always want the keys to be Cased-Like-This and arh()
|
||||
// returns the headers in the same case as they are in the
|
||||
// request
|
||||
$out = array();
|
||||
foreach ($headers AS $key => $value) {
|
||||
$key = str_replace(
|
||||
" ",
|
||||
"-",
|
||||
ucwords(strtolower(str_replace("-", " ", $key)))
|
||||
);
|
||||
$out[$key] = $value;
|
||||
}
|
||||
} else {
|
||||
// otherwise we don't have apache and are just going to have to hope
|
||||
// that $_SERVER actually contains what we need
|
||||
$out = array();
|
||||
if( isset($_SERVER['CONTENT_TYPE']) )
|
||||
$out['Content-Type'] = $_SERVER['CONTENT_TYPE'];
|
||||
if( isset($_ENV['CONTENT_TYPE']) )
|
||||
$out['Content-Type'] = $_ENV['CONTENT_TYPE'];
|
||||
|
||||
foreach ($_SERVER as $key => $value) {
|
||||
if (substr($key, 0, 5) == "HTTP_") {
|
||||
// this is chaos, basically it is just there to capitalize the first
|
||||
// letter of every word that is not an initial HTTP and strip HTTP
|
||||
// code from przemek
|
||||
$key = str_replace(
|
||||
" ",
|
||||
"-",
|
||||
ucwords(strtolower(str_replace("_", " ", substr($key, 5))))
|
||||
);
|
||||
$out[$key] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $out;
|
||||
}
|
||||
|
||||
// This function takes a input like a=b&a=c&d=e and returns the parsed
|
||||
// parameters like this
|
||||
// array('a' => array('b','c'), 'd' => 'e')
|
||||
public static function parse_parameters( $input ) {
|
||||
if (!isset($input) || !$input) return array();
|
||||
|
||||
$pairs = explode('&', $input);
|
||||
|
||||
$parsed_parameters = array();
|
||||
foreach ($pairs as $pair) {
|
||||
$split = explode('=', $pair, 2);
|
||||
$parameter = OAuthUtil::urldecode_rfc3986($split[0]);
|
||||
$value = isset($split[1]) ? OAuthUtil::urldecode_rfc3986($split[1]) : '';
|
||||
|
||||
if (isset($parsed_parameters[$parameter])) {
|
||||
// We have already recieved parameter(s) with this name, so add to the list
|
||||
// of parameters with this name
|
||||
|
||||
if (is_scalar($parsed_parameters[$parameter])) {
|
||||
// This is the first duplicate, so transform scalar (string) into an array
|
||||
// so we can add the duplicates
|
||||
$parsed_parameters[$parameter] = array($parsed_parameters[$parameter]);
|
||||
}
|
||||
|
||||
$parsed_parameters[$parameter][] = $value;
|
||||
} else {
|
||||
$parsed_parameters[$parameter] = $value;
|
||||
}
|
||||
}
|
||||
return $parsed_parameters;
|
||||
}
|
||||
|
||||
public static function build_http_query($params) {
|
||||
if (!$params) return '';
|
||||
|
||||
// Urlencode both keys and values
|
||||
$keys = OAuthUtil::urlencode_rfc3986(array_keys($params));
|
||||
$values = OAuthUtil::urlencode_rfc3986(array_values($params));
|
||||
$params = array_combine($keys, $values);
|
||||
|
||||
// Parameters are sorted by name, using lexicographical byte value ordering.
|
||||
// Ref: Spec: 9.1.1 (1)
|
||||
uksort($params, 'strcmp');
|
||||
|
||||
$pairs = array();
|
||||
foreach ($params as $parameter => $value) {
|
||||
if (is_array($value)) {
|
||||
// If two or more parameters share the same name, they are sorted by their value
|
||||
// Ref: Spec: 9.1.1 (1)
|
||||
// June 12th, 2010 - changed to sort because of issue 164 by hidetaka
|
||||
sort($value, SORT_STRING);
|
||||
foreach ($value as $duplicate_value) {
|
||||
$pairs[] = $parameter . '=' . $duplicate_value;
|
||||
}
|
||||
} else {
|
||||
$pairs[] = $parameter . '=' . $value;
|
||||
}
|
||||
}
|
||||
// For each parameter, the name is separated from the corresponding value by an '=' character (ASCII code 61)
|
||||
// Each name-value pair is separated by an '&' character (ASCII code 38)
|
||||
return implode('&', $pairs);
|
||||
}
|
||||
}
|
229
web/third_party/hybridauth/Hybrid/thirdparty/OAuth/OAuth1Client.php
vendored
Normal file
229
web/third_party/hybridauth/Hybrid/thirdparty/OAuth/OAuth1Client.php
vendored
Normal file
@ -0,0 +1,229 @@
|
||||
<?php
|
||||
/*!
|
||||
* HybridAuth
|
||||
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
|
||||
* (c) 2009-2012, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
|
||||
*/
|
||||
|
||||
// A service client for the OAuth 1/1.0a flow.
|
||||
// v0.1
|
||||
class OAuth1Client{
|
||||
public $api_base_url = "";
|
||||
public $authorize_url = "";
|
||||
public $authenticate_url = "";
|
||||
public $request_token_url = "";
|
||||
public $access_token_url = "";
|
||||
|
||||
public $request_token_method = "GET";
|
||||
public $access_token_method = "GET";
|
||||
|
||||
public $redirect_uri = "";
|
||||
|
||||
public $decode_json = true;
|
||||
public $curl_time_out = 30;
|
||||
public $curl_connect_time_out = 30;
|
||||
public $curl_ssl_verifypeer = false;
|
||||
public $curl_auth_header = true;
|
||||
public $curl_useragent = "OAuth/1 Simple PHP Client v0.1; HybridAuth http://hybridauth.sourceforge.net/";
|
||||
public $curl_proxy = null;
|
||||
|
||||
//--
|
||||
|
||||
public $http_code = "";
|
||||
public $http_info = "";
|
||||
|
||||
/**
|
||||
* OAuth client constructor
|
||||
*/
|
||||
function __construct( $consumer_key, $consumer_secret, $oauth_token = null, $oauth_token_secret = null )
|
||||
{
|
||||
$this->sha1_method = new OAuthSignatureMethod_HMAC_SHA1();
|
||||
$this->consumer = new OAuthConsumer( $consumer_key, $consumer_secret );
|
||||
$this->token = null;
|
||||
|
||||
if ( $oauth_token && $oauth_token_secret ){
|
||||
$this->token = new OAuthConsumer( $oauth_token, $oauth_token_secret );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build authorize url
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function authorizeUrl( $token, $extras =array() )
|
||||
{
|
||||
if ( is_array( $token ) ){
|
||||
$token = $token['oauth_token'];
|
||||
}
|
||||
|
||||
$parameters = array( "oauth_token" => $token );
|
||||
|
||||
if( count($extras) )
|
||||
foreach( $extras as $k=>$v )
|
||||
$parameters[$k] = $v;
|
||||
|
||||
return $this->authorize_url . "?" . http_build_query( $parameters );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a request_token from provider
|
||||
*
|
||||
* @return array a key/value array containing oauth_token and oauth_token_secret
|
||||
*/
|
||||
function requestToken( $callback = null )
|
||||
{
|
||||
$parameters = array();
|
||||
|
||||
if ( $callback ) {
|
||||
$this->redirect_uri = $parameters['oauth_callback'] = $callback;
|
||||
}
|
||||
|
||||
$request = $this->signedRequest( $this->request_token_url, $this->request_token_method, $parameters );
|
||||
$token = OAuthUtil::parse_parameters( $request );
|
||||
$this->token = new OAuthConsumer( $token['oauth_token'], $token['oauth_token_secret'] );
|
||||
|
||||
return $token;
|
||||
}
|
||||
|
||||
/**
|
||||
* Exchange the request token and secret for an access token and secret, to sign API calls.
|
||||
*
|
||||
* @return array array('oauth_token' => the access token, 'oauth_token_secret' => the access secret)
|
||||
*/
|
||||
function accessToken( $oauth_verifier = false, $oauth_token = false )
|
||||
{
|
||||
$parameters = array();
|
||||
|
||||
// 1.0a
|
||||
if ( $oauth_verifier ) {
|
||||
$parameters['oauth_verifier'] = $oauth_verifier;
|
||||
}
|
||||
|
||||
$request = $this->signedRequest( $this->access_token_url, $this->access_token_method, $parameters );
|
||||
$token = OAuthUtil::parse_parameters( $request );
|
||||
$this->token = new OAuthConsumer( $token['oauth_token'], $token['oauth_token_secret'] );
|
||||
|
||||
return $token;
|
||||
}
|
||||
|
||||
/**
|
||||
* GET wrappwer for provider apis request
|
||||
*/
|
||||
function get($url, $parameters = array())
|
||||
{
|
||||
return $this->api($url, 'GET', $parameters);
|
||||
}
|
||||
|
||||
/**
|
||||
* POST wreapper for provider apis request
|
||||
*/
|
||||
function post($url, $parameters = array())
|
||||
{
|
||||
return $this->api($url, 'POST', $parameters);
|
||||
}
|
||||
|
||||
/**
|
||||
* Format and sign an oauth for provider api
|
||||
*/
|
||||
function api( $url, $method = 'GET', $parameters = array() )
|
||||
{
|
||||
if ( strrpos($url, 'http://') !== 0 && strrpos($url, 'https://') !== 0 ) {
|
||||
$url = $this->api_base_url . $url;
|
||||
}
|
||||
|
||||
$response = $this->signedRequest( $url, $method, $parameters );
|
||||
|
||||
if( $this->decode_json ){
|
||||
$response = json_decode( $response );
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make signed request
|
||||
*/
|
||||
function signedRequest( $url, $method, $parameters )
|
||||
{
|
||||
$request = OAuthRequest::from_consumer_and_token($this->consumer, $this->token, $method, $url, $parameters);
|
||||
$request->sign_request($this->sha1_method, $this->consumer, $this->token);
|
||||
switch ($method) {
|
||||
case 'GET': return $this->request( $request->to_url(), 'GET' );
|
||||
default : return $this->request( $request->get_normalized_http_url(), $method, $request->to_postdata(), $request->to_header() ) ;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Make http request
|
||||
*/
|
||||
function request( $url, $method, $postfields = NULL, $auth_header = null )
|
||||
{
|
||||
Hybrid_Logger::info( "Enter OAuth1Client::request( $method, $url )" );
|
||||
Hybrid_Logger::debug( "OAuth1Client::request(). dump post fields: ", serialize( $postfields ) );
|
||||
|
||||
$this->http_info = array();
|
||||
$ci = curl_init();
|
||||
|
||||
/* Curl settings */
|
||||
curl_setopt( $ci, CURLOPT_USERAGENT , $this->curl_useragent );
|
||||
curl_setopt( $ci, CURLOPT_CONNECTTIMEOUT, $this->curl_connect_time_out );
|
||||
curl_setopt( $ci, CURLOPT_TIMEOUT , $this->curl_time_out );
|
||||
curl_setopt( $ci, CURLOPT_RETURNTRANSFER, TRUE );
|
||||
curl_setopt( $ci, CURLOPT_HTTPHEADER , array('Expect:') );
|
||||
curl_setopt( $ci, CURLOPT_SSL_VERIFYPEER, $this->curl_ssl_verifypeer );
|
||||
curl_setopt( $ci, CURLOPT_HEADERFUNCTION, array($this, 'getHeader') );
|
||||
curl_setopt( $ci, CURLOPT_HEADER , FALSE );
|
||||
|
||||
if($this->curl_proxy){
|
||||
curl_setopt( $ci, CURLOPT_PROXY , $this->curl_proxy);
|
||||
}
|
||||
|
||||
switch ($method){
|
||||
case 'POST':
|
||||
curl_setopt( $ci, CURLOPT_POST, TRUE );
|
||||
|
||||
if ( !empty($postfields) ){
|
||||
curl_setopt( $ci, CURLOPT_POSTFIELDS, $postfields );
|
||||
}
|
||||
|
||||
if ( !empty($auth_header) && $this->curl_auth_header ){
|
||||
curl_setopt( $ci, CURLOPT_HTTPHEADER, array( 'Content-Type: application/atom+xml', $auth_header ) );
|
||||
}
|
||||
break;
|
||||
case 'DELETE':
|
||||
curl_setopt( $ci, CURLOPT_CUSTOMREQUEST, 'DELETE' );
|
||||
if ( !empty($postfields) ){
|
||||
$url = "{$url}?{$postfields}";
|
||||
}
|
||||
}
|
||||
|
||||
curl_setopt($ci, CURLOPT_URL, $url);
|
||||
$response = curl_exec($ci);
|
||||
|
||||
Hybrid_Logger::debug( "OAuth1Client::request(). dump request info: ", serialize( curl_getinfo($ci) ) );
|
||||
Hybrid_Logger::debug( "OAuth1Client::request(). dump request result: ", serialize( $response ) );
|
||||
|
||||
$this->http_code = curl_getinfo($ci, CURLINFO_HTTP_CODE);
|
||||
$this->http_info = array_merge($this->http_info, curl_getinfo($ci));
|
||||
|
||||
curl_close ($ci);
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the header info to store.
|
||||
*/
|
||||
function getHeader($ch, $header) {
|
||||
$i = strpos($header, ':');
|
||||
|
||||
if ( !empty($i) ){
|
||||
$key = str_replace('-', '_', strtolower(substr($header, 0, $i)));
|
||||
$value = trim(substr($header, $i + 2));
|
||||
$this->http_header[$key] = $value;
|
||||
}
|
||||
|
||||
return strlen($header);
|
||||
}
|
||||
}
|
245
web/third_party/hybridauth/Hybrid/thirdparty/OAuth/OAuth2Client.php
vendored
Normal file
245
web/third_party/hybridauth/Hybrid/thirdparty/OAuth/OAuth2Client.php
vendored
Normal file
@ -0,0 +1,245 @@
|
||||
<?php
|
||||
/*!
|
||||
* HybridAuth
|
||||
* http://hybridauth.sourceforge.net | http://github.com/hybridauth/hybridauth
|
||||
* (c) 2009-2012, HybridAuth authors | http://hybridauth.sourceforge.net/licenses.html
|
||||
*/
|
||||
|
||||
// A service client for the OAuth 2 flow.
|
||||
// v0.1
|
||||
class OAuth2Client
|
||||
{
|
||||
public $api_base_url = "";
|
||||
public $authorize_url = "";
|
||||
public $token_url = "";
|
||||
public $token_info_url = "";
|
||||
|
||||
public $client_id = "" ;
|
||||
public $client_secret = "" ;
|
||||
public $redirect_uri = "" ;
|
||||
public $access_token = "" ;
|
||||
public $refresh_token = "" ;
|
||||
|
||||
public $access_token_expires_in = "" ;
|
||||
public $access_token_expires_at = "" ;
|
||||
|
||||
//--
|
||||
|
||||
public $sign_token_name = "access_token";
|
||||
public $decode_json = true;
|
||||
public $curl_time_out = 30;
|
||||
public $curl_connect_time_out = 30;
|
||||
public $curl_ssl_verifypeer = false;
|
||||
public $curl_header = array();
|
||||
public $curl_useragent = "OAuth/2 Simple PHP Client v0.1; HybridAuth http://hybridauth.sourceforge.net/";
|
||||
public $curl_authenticate_method = "POST";
|
||||
public $curl_proxy = null;
|
||||
|
||||
//--
|
||||
|
||||
public $http_code = "";
|
||||
public $http_info = "";
|
||||
|
||||
//--
|
||||
|
||||
public function __construct( $client_id = false, $client_secret = false, $redirect_uri='' )
|
||||
{
|
||||
$this->client_id = $client_id;
|
||||
$this->client_secret = $client_secret;
|
||||
$this->redirect_uri = $redirect_uri;
|
||||
}
|
||||
|
||||
public function authorizeUrl( $extras = array() )
|
||||
{
|
||||
$params = array(
|
||||
"client_id" => $this->client_id,
|
||||
"redirect_uri" => $this->redirect_uri,
|
||||
"response_type" => "code"
|
||||
);
|
||||
|
||||
if( count($extras) )
|
||||
foreach( $extras as $k=>$v )
|
||||
$params[$k] = $v;
|
||||
|
||||
return $this->authorize_url . "?" . http_build_query( $params );
|
||||
}
|
||||
|
||||
public function authenticate( $code )
|
||||
{
|
||||
$params = array(
|
||||
"client_id" => $this->client_id,
|
||||
"client_secret" => $this->client_secret,
|
||||
"grant_type" => "authorization_code",
|
||||
"redirect_uri" => $this->redirect_uri,
|
||||
"code" => $code
|
||||
);
|
||||
|
||||
$response = $this->request( $this->token_url, $params, $this->curl_authenticate_method );
|
||||
|
||||
$response = $this->parseRequestResult( $response );
|
||||
|
||||
if( ! $response || ! isset( $response->access_token ) ){
|
||||
throw new Exception( "The Authorization Service has return: " . $response->error );
|
||||
}
|
||||
|
||||
if( isset( $response->access_token ) ) $this->access_token = $response->access_token;
|
||||
if( isset( $response->refresh_token ) ) $this->refresh_token = $response->refresh_token;
|
||||
if( isset( $response->expires_in ) ) $this->access_token_expires_in = $response->expires_in;
|
||||
|
||||
// calculate when the access token expire
|
||||
if( isset($response->expires_in)) {
|
||||
$this->access_token_expires_at = time() + $response->expires_in;
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
public function authenticated()
|
||||
{
|
||||
if ( $this->access_token ){
|
||||
if ( $this->token_info_url && $this->refresh_token ){
|
||||
// check if this access token has expired,
|
||||
$tokeninfo = $this->tokenInfo( $this->access_token );
|
||||
|
||||
// if yes, access_token has expired, then ask for a new one
|
||||
if( $tokeninfo && isset( $tokeninfo->error ) ){
|
||||
$response = $this->refreshToken( $this->refresh_token );
|
||||
|
||||
// if wrong response
|
||||
if( ! isset( $response->access_token ) || ! $response->access_token ){
|
||||
throw new Exception( "The Authorization Service has return an invalid response while requesting a new access token. given up!" );
|
||||
}
|
||||
|
||||
// set new access_token
|
||||
$this->access_token = $response->access_token;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Format and sign an oauth for provider api
|
||||
*/
|
||||
public function api( $url, $method = "GET", $parameters = array() )
|
||||
{
|
||||
if ( strrpos($url, 'http://') !== 0 && strrpos($url, 'https://') !== 0 ) {
|
||||
$url = $this->api_base_url . $url;
|
||||
}
|
||||
|
||||
$parameters[$this->sign_token_name] = $this->access_token;
|
||||
$response = null;
|
||||
|
||||
switch( $method ){
|
||||
case 'GET' : $response = $this->request( $url, $parameters, "GET" ); break;
|
||||
case 'POST' : $response = $this->request( $url, $parameters, "POST" ); break;
|
||||
}
|
||||
|
||||
if( $response && $this->decode_json ){
|
||||
$response = json_decode( $response );
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* GET wrappwer for provider apis request
|
||||
*/
|
||||
function get( $url, $parameters = array() )
|
||||
{
|
||||
return $this->api( $url, 'GET', $parameters );
|
||||
}
|
||||
|
||||
/**
|
||||
* POST wreapper for provider apis request
|
||||
*/
|
||||
function post( $url, $parameters = array() )
|
||||
{
|
||||
return $this->api( $url, 'POST', $parameters );
|
||||
}
|
||||
|
||||
// -- tokens
|
||||
|
||||
public function tokenInfo($accesstoken)
|
||||
{
|
||||
$params['access_token'] = $this->access_token;
|
||||
$response = $this->request( $this->token_info_url, $params );
|
||||
return $this->parseRequestResult( $response );
|
||||
}
|
||||
|
||||
public function refreshToken( $parameters = array() )
|
||||
{
|
||||
$params = array(
|
||||
"client_id" => $this->client_id,
|
||||
"client_secret" => $this->client_secret,
|
||||
"grant_type" => "refresh_token"
|
||||
);
|
||||
|
||||
foreach($parameters as $k=>$v ){
|
||||
$params[$k] = $v;
|
||||
}
|
||||
|
||||
$response = $this->request( $this->token_url, $params, "POST" );
|
||||
return $this->parseRequestResult( $response );
|
||||
}
|
||||
|
||||
// -- utilities
|
||||
|
||||
private function request( $url, $params=false, $type="GET" )
|
||||
{
|
||||
Hybrid_Logger::info( "Enter OAuth2Client::request( $url )" );
|
||||
Hybrid_Logger::debug( "OAuth2Client::request(). dump request params: ", serialize( $params ) );
|
||||
|
||||
if( $type == "GET" ){
|
||||
$url = $url . ( strpos( $url, '?' ) ? '&' : '?' ) . http_build_query( $params );
|
||||
}
|
||||
|
||||
$this->http_info = array();
|
||||
$ch = curl_init();
|
||||
|
||||
curl_setopt($ch, CURLOPT_URL , $url );
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER , 1 );
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT , $this->curl_time_out );
|
||||
curl_setopt($ch, CURLOPT_USERAGENT , $this->curl_useragent );
|
||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT , $this->curl_connect_time_out );
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER , $this->curl_ssl_verifypeer );
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER , $this->curl_header );
|
||||
|
||||
if($this->curl_proxy){
|
||||
curl_setopt( $ch, CURLOPT_PROXY , $this->curl_proxy);
|
||||
}
|
||||
|
||||
if( $type == "POST" ){
|
||||
curl_setopt($ch, CURLOPT_POST, 1);
|
||||
if($params) curl_setopt( $ch, CURLOPT_POSTFIELDS, $params );
|
||||
}
|
||||
|
||||
$response = curl_exec($ch);
|
||||
Hybrid_Logger::debug( "OAuth2Client::request(). dump request info: ", serialize( curl_getinfo($ch) ) );
|
||||
Hybrid_Logger::debug( "OAuth2Client::request(). dump request result: ", serialize( $response ) );
|
||||
|
||||
$this->http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
$this->http_info = array_merge($this->http_info, curl_getinfo($ch));
|
||||
|
||||
curl_close ($ch);
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
private function parseRequestResult( $result )
|
||||
{
|
||||
if( json_decode( $result ) ) return json_decode( $result );
|
||||
|
||||
parse_str( $result, $ouput );
|
||||
|
||||
$result = new StdClass();
|
||||
|
||||
foreach( $ouput as $k => $v )
|
||||
$result->$k = $v;
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
981
web/third_party/hybridauth/Hybrid/thirdparty/OpenID/LightOpenID.php
vendored
Normal file
981
web/third_party/hybridauth/Hybrid/thirdparty/OpenID/LightOpenID.php
vendored
Normal file
@ -0,0 +1,981 @@
|
||||
<?php
|
||||
// https://github.com/iignatov/LightOpenID
|
||||
|
||||
/**
|
||||
* This class provides a simple interface for OpenID 1.1/2.0 authentication.
|
||||
*
|
||||
* It requires PHP >= 5.1.2 with cURL or HTTP/HTTPS stream wrappers enabled.
|
||||
*
|
||||
* @version v1.1.2 2013-01-15
|
||||
* @link http://gitorious.org/lightopenid Official Repo
|
||||
* @link http://github.com/iignatov/LightOpenID GitHub Clone
|
||||
* @author Mewp
|
||||
* @copyright Copyright (c) 2010, Mewp
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT License
|
||||
*/
|
||||
class LightOpenID
|
||||
{
|
||||
public $returnUrl
|
||||
, $required = array()
|
||||
, $optional = array()
|
||||
, $verify_peer = null
|
||||
, $capath = null
|
||||
, $cainfo = null
|
||||
, $data
|
||||
, $oauth = array();
|
||||
private $identity, $claimed_id;
|
||||
protected $server, $version, $trustRoot, $aliases, $identifier_select = false
|
||||
, $ax = false, $sreg = false, $setup_url = null, $headers = array(), $proxy = null
|
||||
, $xrds_override_pattern = null, $xrds_override_replacement = null;
|
||||
static protected $ax_to_sreg = array(
|
||||
'namePerson/friendly' => 'nickname',
|
||||
'contact/email' => 'email',
|
||||
'namePerson' => 'fullname',
|
||||
'birthDate' => 'dob',
|
||||
'person/gender' => 'gender',
|
||||
'contact/postalCode/home' => 'postcode',
|
||||
'contact/country/home' => 'country',
|
||||
'pref/language' => 'language',
|
||||
'pref/timezone' => 'timezone',
|
||||
);
|
||||
|
||||
function __construct($host, $proxy = null)
|
||||
{
|
||||
$this->trustRoot = (strpos($host, '://') ? $host : 'http://' . $host);
|
||||
if ((!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off')
|
||||
|| (isset($_SERVER['HTTP_X_FORWARDED_PROTO'])
|
||||
&& $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')
|
||||
) {
|
||||
$this->trustRoot = (strpos($host, '://') ? $host : 'https://' . $host);
|
||||
}
|
||||
|
||||
if(($host_end = strpos($this->trustRoot, '/', 8)) !== false) {
|
||||
$this->trustRoot = substr($this->trustRoot, 0, $host_end);
|
||||
}
|
||||
|
||||
$this->set_proxy($proxy);
|
||||
|
||||
$uri = rtrim(preg_replace('#((?<=\?)|&)openid\.[^&]+#', '', $_SERVER['REQUEST_URI']), '?');
|
||||
$this->returnUrl = $this->trustRoot . $uri;
|
||||
|
||||
$this->data = ($_SERVER['REQUEST_METHOD'] === 'POST') ? $_POST : $_GET;
|
||||
|
||||
if(!function_exists('curl_init') && !in_array('https', stream_get_wrappers())) {
|
||||
throw new ErrorException('You must have either https wrappers or curl enabled.');
|
||||
}
|
||||
}
|
||||
|
||||
function __set($name, $value)
|
||||
{
|
||||
switch ($name) {
|
||||
case 'identity':
|
||||
if (strlen($value = trim((String) $value))) {
|
||||
if (preg_match('#^xri:/*#i', $value, $m)) {
|
||||
$value = substr($value, strlen($m[0]));
|
||||
} elseif (!preg_match('/^(?:[=@+\$!\(]|https?:)/i', $value)) {
|
||||
$value = "http://$value";
|
||||
}
|
||||
if (preg_match('#^https?://[^/]+$#i', $value, $m)) {
|
||||
$value .= '/';
|
||||
}
|
||||
}
|
||||
$this->$name = $this->claimed_id = $value;
|
||||
break;
|
||||
case 'trustRoot':
|
||||
case 'realm':
|
||||
$this->trustRoot = trim($value);
|
||||
break;
|
||||
case 'xrdsOverride':
|
||||
if (is_array($value)) {
|
||||
list($pattern, $replacement) = $value;
|
||||
$this->xrds_override_pattern = $pattern;
|
||||
$this->xrds_override_replacement = $replacement;
|
||||
} else {
|
||||
trigger_error('Invalid value specified for "xrdsOverride".', E_USER_ERROR);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function __get($name)
|
||||
{
|
||||
switch ($name) {
|
||||
case 'identity':
|
||||
# We return claimed_id instead of identity,
|
||||
# because the developer should see the claimed identifier,
|
||||
# i.e. what he set as identity, not the op-local identifier (which is what we verify)
|
||||
return $this->claimed_id;
|
||||
case 'trustRoot':
|
||||
case 'realm':
|
||||
return $this->trustRoot;
|
||||
case 'mode':
|
||||
return empty($this->data['openid_mode']) ? null : $this->data['openid_mode'];
|
||||
}
|
||||
}
|
||||
|
||||
function set_proxy($proxy)
|
||||
{
|
||||
if (!empty($proxy)) {
|
||||
// When the proxy is a string - try to parse it.
|
||||
if (!is_array($proxy)) {
|
||||
$proxy = parse_url($proxy);
|
||||
}
|
||||
|
||||
// Check if $proxy is valid after the parsing.
|
||||
if ($proxy && !empty($proxy['host'])) {
|
||||
// Make sure that a valid port number is specified.
|
||||
if (array_key_exists('port', $proxy)) {
|
||||
if (!is_int($proxy['port'])) {
|
||||
$proxy['port'] = is_numeric($proxy['port']) ? intval($proxy['port']) : 0;
|
||||
}
|
||||
|
||||
if ($proxy['port'] <= 0) {
|
||||
throw new ErrorException('The specified proxy port number is invalid.');
|
||||
}
|
||||
}
|
||||
|
||||
$this->proxy = $proxy;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the server specified in the url exists.
|
||||
*
|
||||
* @param $url url to check
|
||||
* @return true, if the server exists; false otherwise
|
||||
*/
|
||||
function hostExists($url)
|
||||
{
|
||||
if (strpos($url, '/') === false) {
|
||||
$server = $url;
|
||||
} else {
|
||||
$server = @parse_url($url, PHP_URL_HOST);
|
||||
}
|
||||
|
||||
if (!$server) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return !!gethostbynamel($server);
|
||||
}
|
||||
|
||||
protected function request_curl($url, $method='GET', $params=array(), $update_claimed_id)
|
||||
{
|
||||
$params = http_build_query($params, '', '&');
|
||||
$curl = curl_init($url . ($method == 'GET' && $params ? '?' . $params : ''));
|
||||
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
|
||||
curl_setopt($curl, CURLOPT_HEADER, false);
|
||||
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
|
||||
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Accept: application/xrds+xml, */*'));
|
||||
|
||||
if (!empty($this->proxy)) {
|
||||
curl_setopt($curl, CURLOPT_PROXY, $this->proxy['host']);
|
||||
|
||||
if (!empty($this->proxy['port'])) {
|
||||
curl_setopt($curl, CURLOPT_PROXYPORT, $this->proxy['port']);
|
||||
}
|
||||
|
||||
if (!empty($this->proxy['user'])) {
|
||||
curl_setopt($curl, CURLOPT_PROXYUSERPWD, $this->proxy['user'] . ':' . $this->proxy['pass']);
|
||||
}
|
||||
}
|
||||
|
||||
if($this->verify_peer !== null) {
|
||||
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, $this->verify_peer);
|
||||
if($this->capath) {
|
||||
curl_setopt($curl, CURLOPT_CAPATH, $this->capath);
|
||||
}
|
||||
|
||||
if($this->cainfo) {
|
||||
curl_setopt($curl, CURLOPT_CAINFO, $this->cainfo);
|
||||
}
|
||||
}
|
||||
|
||||
if ($method == 'POST') {
|
||||
curl_setopt($curl, CURLOPT_POST, true);
|
||||
curl_setopt($curl, CURLOPT_POSTFIELDS, $params);
|
||||
} elseif ($method == 'HEAD') {
|
||||
curl_setopt($curl, CURLOPT_HEADER, true);
|
||||
curl_setopt($curl, CURLOPT_NOBODY, true);
|
||||
} else {
|
||||
curl_setopt($curl, CURLOPT_HEADER, true);
|
||||
curl_setopt($curl, CURLOPT_HTTPGET, true);
|
||||
}
|
||||
$response = curl_exec($curl);
|
||||
|
||||
if($method == 'HEAD' && curl_getinfo($curl, CURLINFO_HTTP_CODE) == 405) {
|
||||
curl_setopt($curl, CURLOPT_HTTPGET, true);
|
||||
$response = curl_exec($curl);
|
||||
$response = substr($response, 0, strpos($response, "\r\n\r\n"));
|
||||
}
|
||||
|
||||
if($method == 'HEAD' || $method == 'GET') {
|
||||
$header_response = $response;
|
||||
|
||||
# If it's a GET request, we want to only parse the header part.
|
||||
if($method == 'GET') {
|
||||
$header_response = substr($response, 0, strpos($response, "\r\n\r\n"));
|
||||
}
|
||||
|
||||
$headers = array();
|
||||
foreach(explode("\n", $header_response) as $header) {
|
||||
$pos = strpos($header,':');
|
||||
if ($pos !== false) {
|
||||
$name = strtolower(trim(substr($header, 0, $pos)));
|
||||
$headers[$name] = trim(substr($header, $pos+1));
|
||||
}
|
||||
}
|
||||
|
||||
if($update_claimed_id) {
|
||||
# Updating claimed_id in case of redirections.
|
||||
$effective_url = curl_getinfo($curl, CURLINFO_EFFECTIVE_URL);
|
||||
if($effective_url != $url) {
|
||||
$this->identity = $this->claimed_id = $effective_url;
|
||||
}
|
||||
}
|
||||
|
||||
if($method == 'HEAD') {
|
||||
return $headers;
|
||||
} else {
|
||||
$this->headers = $headers;
|
||||
}
|
||||
}
|
||||
|
||||
if (curl_errno($curl)) {
|
||||
throw new ErrorException(curl_error($curl), curl_errno($curl));
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
protected function parse_header_array($array, $update_claimed_id)
|
||||
{
|
||||
$headers = array();
|
||||
foreach($array as $header) {
|
||||
$pos = strpos($header,':');
|
||||
if ($pos !== false) {
|
||||
$name = strtolower(trim(substr($header, 0, $pos)));
|
||||
$headers[$name] = trim(substr($header, $pos+1));
|
||||
|
||||
# Following possible redirections. The point is just to have
|
||||
# claimed_id change with them, because the redirections
|
||||
# are followed automatically.
|
||||
# We ignore redirections with relative paths.
|
||||
# If any known provider uses them, file a bug report.
|
||||
if($name == 'location' && $update_claimed_id) {
|
||||
if(strpos($headers[$name], 'http') === 0) {
|
||||
$this->identity = $this->claimed_id = $headers[$name];
|
||||
} elseif($headers[$name][0] == '/') {
|
||||
$parsed_url = parse_url($this->claimed_id);
|
||||
$this->identity =
|
||||
$this->claimed_id = $parsed_url['scheme'] . '://'
|
||||
. $parsed_url['host']
|
||||
. $headers[$name];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $headers;
|
||||
}
|
||||
|
||||
protected function request_streams($url, $method='GET', $params=array(), $update_claimed_id)
|
||||
{
|
||||
if(!$this->hostExists($url)) {
|
||||
throw new ErrorException("Could not connect to $url.", 404);
|
||||
}
|
||||
|
||||
$params = http_build_query($params, '', '&');
|
||||
switch($method) {
|
||||
case 'GET':
|
||||
$opts = array(
|
||||
'http' => array(
|
||||
'method' => 'GET',
|
||||
'header' => 'Accept: application/xrds+xml, */*',
|
||||
'ignore_errors' => true,
|
||||
), 'ssl' => array(
|
||||
'CN_match' => parse_url($url, PHP_URL_HOST),
|
||||
),
|
||||
);
|
||||
$url = $url . ($params ? '?' . $params : '');
|
||||
if (!empty($this->proxy)) {
|
||||
$opts['http']['proxy'] = $this->proxy_url();
|
||||
}
|
||||
break;
|
||||
case 'POST':
|
||||
$opts = array(
|
||||
'http' => array(
|
||||
'method' => 'POST',
|
||||
'header' => 'Content-type: application/x-www-form-urlencoded',
|
||||
'content' => $params,
|
||||
'ignore_errors' => true,
|
||||
), 'ssl' => array(
|
||||
'CN_match' => parse_url($url, PHP_URL_HOST),
|
||||
),
|
||||
);
|
||||
if (!empty($this->proxy)) {
|
||||
$opts['http']['proxy'] = $this->proxy_url();
|
||||
}
|
||||
break;
|
||||
case 'HEAD':
|
||||
// We want to send a HEAD request, but since get_headers() doesn't
|
||||
// accept $context parameter, we have to change the defaults.
|
||||
$default = stream_context_get_options(stream_context_get_default());
|
||||
|
||||
// PHP does not reset all options. Instead, it just sets the options
|
||||
// available in the passed array, therefore set the defaults manually.
|
||||
$default += array(
|
||||
'http' => array(),
|
||||
'ssl' => array()
|
||||
);
|
||||
$default['http'] += array(
|
||||
'method' => 'GET',
|
||||
'header' => '',
|
||||
'ignore_errors' => false
|
||||
);
|
||||
$default['ssl'] += array(
|
||||
'CN_match' => ''
|
||||
);
|
||||
|
||||
$opts = array(
|
||||
'http' => array(
|
||||
'method' => 'HEAD',
|
||||
'header' => 'Accept: application/xrds+xml, */*',
|
||||
'ignore_errors' => true,
|
||||
),
|
||||
'ssl' => array(
|
||||
'CN_match' => parse_url($url, PHP_URL_HOST)
|
||||
)
|
||||
);
|
||||
|
||||
// Enable validation of the SSL certificates.
|
||||
if ($this->verify_peer) {
|
||||
$default['ssl'] += array(
|
||||
'verify_peer' => false,
|
||||
'capath' => '',
|
||||
'cafile' => ''
|
||||
);
|
||||
$opts['ssl'] += array(
|
||||
'verify_peer' => true,
|
||||
'capath' => $this->capath,
|
||||
'cafile' => $this->cainfo
|
||||
);
|
||||
}
|
||||
|
||||
// Change the stream context options.
|
||||
stream_context_get_default($opts);
|
||||
|
||||
$headers = get_headers($url . ($params ? '?' . $params : ''));
|
||||
|
||||
// Restore the stream context options.
|
||||
stream_context_get_default($default);
|
||||
|
||||
if (!empty($headers)) {
|
||||
if (intval(substr($headers[0], strlen('HTTP/1.1 '))) == 405) {
|
||||
// The server doesn't support HEAD - emulate it with a GET.
|
||||
$args = func_get_args();
|
||||
$args[1] = 'GET';
|
||||
call_user_func_array(array($this, 'request_streams'), $args);
|
||||
$headers = $this->headers;
|
||||
} else {
|
||||
$headers = $this->parse_header_array($headers, $update_claimed_id);
|
||||
}
|
||||
} else {
|
||||
$headers = array();
|
||||
}
|
||||
|
||||
return $headers;
|
||||
}
|
||||
|
||||
if ($this->verify_peer) {
|
||||
$opts['ssl'] += array(
|
||||
'verify_peer' => true,
|
||||
'capath' => $this->capath,
|
||||
'cafile' => $this->cainfo
|
||||
);
|
||||
}
|
||||
|
||||
$context = stream_context_create ($opts);
|
||||
$data = file_get_contents($url, false, $context);
|
||||
# This is a hack for providers who don't support HEAD requests.
|
||||
# It just creates the headers array for the last request in $this->headers.
|
||||
if(isset($http_response_header)) {
|
||||
$this->headers = $this->parse_header_array($http_response_header, $update_claimed_id);
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
protected function request($url, $method='GET', $params=array(), $update_claimed_id=false)
|
||||
{
|
||||
if (function_exists('curl_init')
|
||||
&& (!in_array('https', stream_get_wrappers()) || !ini_get('safe_mode') && !ini_get('open_basedir'))
|
||||
) {
|
||||
return $this->request_curl($url, $method, $params, $update_claimed_id);
|
||||
}
|
||||
return $this->request_streams($url, $method, $params, $update_claimed_id);
|
||||
}
|
||||
|
||||
protected function proxy_url()
|
||||
{
|
||||
$result = '';
|
||||
|
||||
if (!empty($this->proxy)) {
|
||||
$result = $this->proxy['host'];
|
||||
|
||||
if (!empty($this->proxy['port'])) {
|
||||
$result = $result . ':' . $this->proxy['port'];
|
||||
}
|
||||
|
||||
if (!empty($this->proxy['user'])) {
|
||||
$result = $this->proxy['user'] . ':' . $this->proxy['pass'] . '@' . $result;
|
||||
}
|
||||
|
||||
$result = 'http://' . $result;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
protected function build_url($url, $parts)
|
||||
{
|
||||
if (isset($url['query'], $parts['query'])) {
|
||||
$parts['query'] = $url['query'] . '&' . $parts['query'];
|
||||
}
|
||||
|
||||
$url = $parts + $url;
|
||||
$url = $url['scheme'] . '://'
|
||||
. (empty($url['username'])?''
|
||||
:(empty($url['password'])? "{$url['username']}@"
|
||||
:"{$url['username']}:{$url['password']}@"))
|
||||
. $url['host']
|
||||
. (empty($url['port'])?'':":{$url['port']}")
|
||||
. (empty($url['path'])?'':$url['path'])
|
||||
. (empty($url['query'])?'':"?{$url['query']}")
|
||||
. (empty($url['fragment'])?'':"#{$url['fragment']}");
|
||||
return $url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function used to scan for <meta>/<link> tags and extract information
|
||||
* from them
|
||||
*/
|
||||
protected function htmlTag($content, $tag, $attrName, $attrValue, $valueName)
|
||||
{
|
||||
preg_match_all("#<{$tag}[^>]*$attrName=['\"].*?$attrValue.*?['\"][^>]*$valueName=['\"](.+?)['\"][^>]*/?>#i", $content, $matches1);
|
||||
preg_match_all("#<{$tag}[^>]*$valueName=['\"](.+?)['\"][^>]*$attrName=['\"].*?$attrValue.*?['\"][^>]*/?>#i", $content, $matches2);
|
||||
|
||||
$result = array_merge($matches1[1], $matches2[1]);
|
||||
return empty($result)?false:$result[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs Yadis and HTML discovery. Normally not used.
|
||||
* @param $url Identity URL.
|
||||
* @return String OP Endpoint (i.e. OpenID provider address).
|
||||
* @throws ErrorException
|
||||
*/
|
||||
function discover($url)
|
||||
{
|
||||
if (!$url) throw new ErrorException('No identity supplied.');
|
||||
# Use xri.net proxy to resolve i-name identities
|
||||
if (!preg_match('#^https?:#', $url)) {
|
||||
$url = "https://xri.net/$url";
|
||||
}
|
||||
|
||||
# We save the original url in case of Yadis discovery failure.
|
||||
# It can happen when we'll be lead to an XRDS document
|
||||
# which does not have any OpenID2 services.
|
||||
$originalUrl = $url;
|
||||
|
||||
# A flag to disable yadis discovery in case of failure in headers.
|
||||
$yadis = true;
|
||||
|
||||
# Allows optional regex replacement of the URL, e.g. to use Google Apps
|
||||
# as an OpenID provider without setting up XRDS on the domain hosting.
|
||||
if (!is_null($this->xrds_override_pattern) && !is_null($this->xrds_override_replacement)) {
|
||||
$url = preg_replace($this->xrds_override_pattern, $this->xrds_override_replacement, $url);
|
||||
}
|
||||
|
||||
# We'll jump a maximum of 5 times, to avoid endless redirections.
|
||||
for ($i = 0; $i < 5; $i ++) {
|
||||
if ($yadis) {
|
||||
$headers = $this->request($url, 'HEAD', array(), true);
|
||||
|
||||
$next = false;
|
||||
if (isset($headers['x-xrds-location'])) {
|
||||
$url = $this->build_url(parse_url($url), parse_url(trim($headers['x-xrds-location'])));
|
||||
$next = true;
|
||||
}
|
||||
|
||||
if (isset($headers['content-type'])
|
||||
&& (strpos($headers['content-type'], 'application/xrds+xml') !== false
|
||||
|| strpos($headers['content-type'], 'text/xml') !== false)
|
||||
) {
|
||||
# Apparently, some providers return XRDS documents as text/html.
|
||||
# While it is against the spec, allowing this here shouldn't break
|
||||
# compatibility with anything.
|
||||
# ---
|
||||
# Found an XRDS document, now let's find the server, and optionally delegate.
|
||||
$content = $this->request($url, 'GET');
|
||||
|
||||
preg_match_all('#<Service.*?>(.*?)</Service>#s', $content, $m);
|
||||
foreach($m[1] as $content) {
|
||||
$content = ' ' . $content; # The space is added, so that strpos doesn't return 0.
|
||||
|
||||
# OpenID 2
|
||||
$ns = preg_quote('http://specs.openid.net/auth/2.0/', '#');
|
||||
if(preg_match('#<Type>\s*'.$ns.'(server|signon)\s*</Type>#s', $content, $type)) {
|
||||
if ($type[1] == 'server') $this->identifier_select = true;
|
||||
|
||||
preg_match('#<URI.*?>(.*)</URI>#', $content, $server);
|
||||
preg_match('#<(Local|Canonical)ID>(.*)</\1ID>#', $content, $delegate);
|
||||
if (empty($server)) {
|
||||
return false;
|
||||
}
|
||||
# Does the server advertise support for either AX or SREG?
|
||||
$this->ax = (bool) strpos($content, '<Type>http://openid.net/srv/ax/1.0</Type>');
|
||||
$this->sreg = strpos($content, '<Type>http://openid.net/sreg/1.0</Type>')
|
||||
|| strpos($content, '<Type>http://openid.net/extensions/sreg/1.1</Type>');
|
||||
|
||||
$server = $server[1];
|
||||
if (isset($delegate[2])) $this->identity = trim($delegate[2]);
|
||||
$this->version = 2;
|
||||
|
||||
$this->server = $server;
|
||||
return $server;
|
||||
}
|
||||
|
||||
# OpenID 1.1
|
||||
$ns = preg_quote('http://openid.net/signon/1.1', '#');
|
||||
if (preg_match('#<Type>\s*'.$ns.'\s*</Type>#s', $content)) {
|
||||
|
||||
preg_match('#<URI.*?>(.*)</URI>#', $content, $server);
|
||||
preg_match('#<.*?Delegate>(.*)</.*?Delegate>#', $content, $delegate);
|
||||
if (empty($server)) {
|
||||
return false;
|
||||
}
|
||||
# AX can be used only with OpenID 2.0, so checking only SREG
|
||||
$this->sreg = strpos($content, '<Type>http://openid.net/sreg/1.0</Type>')
|
||||
|| strpos($content, '<Type>http://openid.net/extensions/sreg/1.1</Type>');
|
||||
|
||||
$server = $server[1];
|
||||
if (isset($delegate[1])) $this->identity = $delegate[1];
|
||||
$this->version = 1;
|
||||
|
||||
$this->server = $server;
|
||||
return $server;
|
||||
}
|
||||
}
|
||||
|
||||
$next = true;
|
||||
$yadis = false;
|
||||
$url = $originalUrl;
|
||||
$content = null;
|
||||
break;
|
||||
}
|
||||
if ($next) continue;
|
||||
|
||||
# There are no relevant information in headers, so we search the body.
|
||||
$content = $this->request($url, 'GET', array(), true);
|
||||
|
||||
if (isset($this->headers['x-xrds-location'])) {
|
||||
$url = $this->build_url(parse_url($url), parse_url(trim($this->headers['x-xrds-location'])));
|
||||
continue;
|
||||
}
|
||||
|
||||
$location = $this->htmlTag($content, 'meta', 'http-equiv', 'X-XRDS-Location', 'content');
|
||||
if ($location) {
|
||||
$url = $this->build_url(parse_url($url), parse_url($location));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$content) $content = $this->request($url, 'GET');
|
||||
|
||||
# At this point, the YADIS Discovery has failed, so we'll switch
|
||||
# to openid2 HTML discovery, then fallback to openid 1.1 discovery.
|
||||
$server = $this->htmlTag($content, 'link', 'rel', 'openid2.provider', 'href');
|
||||
$delegate = $this->htmlTag($content, 'link', 'rel', 'openid2.local_id', 'href');
|
||||
$this->version = 2;
|
||||
|
||||
if (!$server) {
|
||||
# The same with openid 1.1
|
||||
$server = $this->htmlTag($content, 'link', 'rel', 'openid.server', 'href');
|
||||
$delegate = $this->htmlTag($content, 'link', 'rel', 'openid.delegate', 'href');
|
||||
$this->version = 1;
|
||||
}
|
||||
|
||||
if ($server) {
|
||||
# We found an OpenID2 OP Endpoint
|
||||
if ($delegate) {
|
||||
# We have also found an OP-Local ID.
|
||||
$this->identity = $delegate;
|
||||
}
|
||||
$this->server = $server;
|
||||
return $server;
|
||||
}
|
||||
|
||||
throw new ErrorException("No OpenID Server found at $url", 404);
|
||||
}
|
||||
throw new ErrorException('Endless redirection!', 500);
|
||||
}
|
||||
|
||||
protected function sregParams()
|
||||
{
|
||||
$params = array();
|
||||
# We always use SREG 1.1, even if the server is advertising only support for 1.0.
|
||||
# That's because it's fully backwards compatibile with 1.0, and some providers
|
||||
# advertise 1.0 even if they accept only 1.1. One such provider is myopenid.com
|
||||
$params['openid.ns.sreg'] = 'http://openid.net/extensions/sreg/1.1';
|
||||
if ($this->required) {
|
||||
$params['openid.sreg.required'] = array();
|
||||
foreach ($this->required as $required) {
|
||||
if (!isset(self::$ax_to_sreg[$required])) continue;
|
||||
$params['openid.sreg.required'][] = self::$ax_to_sreg[$required];
|
||||
}
|
||||
$params['openid.sreg.required'] = implode(',', $params['openid.sreg.required']);
|
||||
}
|
||||
|
||||
if ($this->optional) {
|
||||
$params['openid.sreg.optional'] = array();
|
||||
foreach ($this->optional as $optional) {
|
||||
if (!isset(self::$ax_to_sreg[$optional])) continue;
|
||||
$params['openid.sreg.optional'][] = self::$ax_to_sreg[$optional];
|
||||
}
|
||||
$params['openid.sreg.optional'] = implode(',', $params['openid.sreg.optional']);
|
||||
}
|
||||
return $params;
|
||||
}
|
||||
|
||||
protected function axParams()
|
||||
{
|
||||
$params = array();
|
||||
if ($this->required || $this->optional) {
|
||||
$params['openid.ns.ax'] = 'http://openid.net/srv/ax/1.0';
|
||||
$params['openid.ax.mode'] = 'fetch_request';
|
||||
$this->aliases = array();
|
||||
$counts = array();
|
||||
$required = array();
|
||||
$optional = array();
|
||||
foreach (array('required','optional') as $type) {
|
||||
foreach ($this->$type as $alias => $field) {
|
||||
if (is_int($alias)) $alias = strtr($field, '/', '_');
|
||||
$this->aliases[$alias] = 'http://axschema.org/' . $field;
|
||||
if (empty($counts[$alias])) $counts[$alias] = 0;
|
||||
$counts[$alias] += 1;
|
||||
${$type}[] = $alias;
|
||||
}
|
||||
}
|
||||
foreach ($this->aliases as $alias => $ns) {
|
||||
$params['openid.ax.type.' . $alias] = $ns;
|
||||
}
|
||||
foreach ($counts as $alias => $count) {
|
||||
if ($count == 1) continue;
|
||||
$params['openid.ax.count.' . $alias] = $count;
|
||||
}
|
||||
|
||||
# Don't send empty ax.requied and ax.if_available.
|
||||
# Google and possibly other providers refuse to support ax when one of these is empty.
|
||||
if($required) {
|
||||
$params['openid.ax.required'] = implode(',', $required);
|
||||
}
|
||||
if($optional) {
|
||||
$params['openid.ax.if_available'] = implode(',', $optional);
|
||||
}
|
||||
}
|
||||
return $params;
|
||||
}
|
||||
|
||||
protected function authUrl_v1($immediate)
|
||||
{
|
||||
$returnUrl = $this->returnUrl;
|
||||
# If we have an openid.delegate that is different from our claimed id,
|
||||
# we need to somehow preserve the claimed id between requests.
|
||||
# The simplest way is to just send it along with the return_to url.
|
||||
if($this->identity != $this->claimed_id) {
|
||||
$returnUrl .= (strpos($returnUrl, '?') ? '&' : '?') . 'openid.claimed_id=' . $this->claimed_id;
|
||||
}
|
||||
|
||||
$params = array(
|
||||
'openid.return_to' => $returnUrl,
|
||||
'openid.mode' => $immediate ? 'checkid_immediate' : 'checkid_setup',
|
||||
'openid.identity' => $this->identity,
|
||||
'openid.trust_root' => $this->trustRoot,
|
||||
) + $this->sregParams();
|
||||
|
||||
return $this->build_url(parse_url($this->server)
|
||||
, array('query' => http_build_query($params, '', '&')));
|
||||
}
|
||||
|
||||
protected function authUrl_v2($immediate)
|
||||
{
|
||||
$params = array(
|
||||
'openid.ns' => 'http://specs.openid.net/auth/2.0',
|
||||
'openid.mode' => $immediate ? 'checkid_immediate' : 'checkid_setup',
|
||||
'openid.return_to' => $this->returnUrl,
|
||||
'openid.realm' => $this->trustRoot,
|
||||
);
|
||||
|
||||
if ($this->ax) {
|
||||
$params += $this->axParams();
|
||||
}
|
||||
|
||||
if ($this->sreg) {
|
||||
$params += $this->sregParams();
|
||||
}
|
||||
|
||||
if (!$this->ax && !$this->sreg) {
|
||||
# If OP doesn't advertise either SREG, nor AX, let's send them both
|
||||
# in worst case we don't get anything in return.
|
||||
$params += $this->axParams() + $this->sregParams();
|
||||
}
|
||||
|
||||
if (!empty($this->oauth) && is_array($this->oauth)) {
|
||||
$params['openid.ns.oauth'] = 'http://specs.openid.net/extensions/oauth/1.0';
|
||||
$params['openid.oauth.consumer'] = str_replace(array('http://', 'https://'), '', $this->trustRoot);
|
||||
$params['openid.oauth.scope'] = implode(' ', $this->oauth);
|
||||
}
|
||||
|
||||
if ($this->identifier_select) {
|
||||
$params['openid.identity'] = $params['openid.claimed_id']
|
||||
= 'http://specs.openid.net/auth/2.0/identifier_select';
|
||||
} else {
|
||||
$params['openid.identity'] = $this->identity;
|
||||
$params['openid.claimed_id'] = $this->claimed_id;
|
||||
}
|
||||
|
||||
return $this->build_url(parse_url($this->server)
|
||||
, array('query' => http_build_query($params, '', '&')));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns authentication url. Usually, you want to redirect your user to it.
|
||||
* @return String The authentication url.
|
||||
* @param String $select_identifier Whether to request OP to select identity for an user in OpenID 2. Does not affect OpenID 1.
|
||||
* @throws ErrorException
|
||||
*/
|
||||
function authUrl($immediate = false)
|
||||
{
|
||||
if ($this->setup_url && !$immediate) return $this->setup_url;
|
||||
if (!$this->server) $this->discover($this->identity);
|
||||
|
||||
if ($this->version == 2) {
|
||||
return $this->authUrl_v2($immediate);
|
||||
}
|
||||
return $this->authUrl_v1($immediate);
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs OpenID verification with the OP.
|
||||
* @return Bool Whether the verification was successful.
|
||||
* @throws ErrorException
|
||||
*/
|
||||
function validate()
|
||||
{
|
||||
# If the request was using immediate mode, a failure may be reported
|
||||
# by presenting user_setup_url (for 1.1) or reporting
|
||||
# mode 'setup_needed' (for 2.0). Also catching all modes other than
|
||||
# id_res, in order to avoid throwing errors.
|
||||
if(isset($this->data['openid_user_setup_url'])) {
|
||||
$this->setup_url = $this->data['openid_user_setup_url'];
|
||||
return false;
|
||||
}
|
||||
if($this->mode != 'id_res') {
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->claimed_id = isset($this->data['openid_claimed_id'])?$this->data['openid_claimed_id']:$this->data['openid_identity'];
|
||||
$params = array(
|
||||
'openid.assoc_handle' => $this->data['openid_assoc_handle'],
|
||||
'openid.signed' => $this->data['openid_signed'],
|
||||
'openid.sig' => $this->data['openid_sig'],
|
||||
);
|
||||
|
||||
if (isset($this->data['openid_ns'])) {
|
||||
# We're dealing with an OpenID 2.0 server, so let's set an ns
|
||||
# Even though we should know location of the endpoint,
|
||||
# we still need to verify it by discovery, so $server is not set here
|
||||
$params['openid.ns'] = 'http://specs.openid.net/auth/2.0';
|
||||
} elseif (isset($this->data['openid_claimed_id'])
|
||||
&& $this->data['openid_claimed_id'] != $this->data['openid_identity']
|
||||
) {
|
||||
# If it's an OpenID 1 provider, and we've got claimed_id,
|
||||
# we have to append it to the returnUrl, like authUrl_v1 does.
|
||||
$this->returnUrl .= (strpos($this->returnUrl, '?') ? '&' : '?')
|
||||
. 'openid.claimed_id=' . $this->claimed_id;
|
||||
}
|
||||
|
||||
if ($this->data['openid_return_to'] != $this->returnUrl) {
|
||||
# The return_to url must match the url of current request.
|
||||
# I'm assuing that noone will set the returnUrl to something that doesn't make sense.
|
||||
return false;
|
||||
}
|
||||
|
||||
$server = $this->discover($this->claimed_id);
|
||||
|
||||
foreach (explode(',', $this->data['openid_signed']) as $item) {
|
||||
# Checking whether magic_quotes_gpc is turned on, because
|
||||
# the function may fail if it is. For example, when fetching
|
||||
# AX namePerson, it might containg an apostrophe, which will be escaped.
|
||||
# In such case, validation would fail, since we'd send different data than OP
|
||||
# wants to verify. stripslashes() should solve that problem, but we can't
|
||||
# use it when magic_quotes is off.
|
||||
$value = $this->data['openid_' . str_replace('.','_',$item)];
|
||||
$params['openid.' . $item] = function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc() ? stripslashes($value) : $value;
|
||||
|
||||
}
|
||||
|
||||
$params['openid.mode'] = 'check_authentication';
|
||||
|
||||
$response = $this->request($server, 'POST', $params);
|
||||
|
||||
return preg_match('/is_valid\s*:\s*true/i', $response);
|
||||
}
|
||||
|
||||
protected function getAxAttributes()
|
||||
{
|
||||
$result = array();
|
||||
|
||||
if ($alias = $this->getNamespaceAlias('http://openid.net/srv/ax/1.0', 'ax')) {
|
||||
$prefix = 'openid_' . $alias;
|
||||
$length = strlen('http://axschema.org/');
|
||||
|
||||
foreach (explode(',', $this->data['openid_signed']) as $key) {
|
||||
$keyMatch = $alias . '.type.';
|
||||
|
||||
if (strncmp($key, $keyMatch, strlen($keyMatch)) !== 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$key = substr($key, strlen($keyMatch));
|
||||
$idv = $prefix . '_value_' . $key;
|
||||
$idc = $prefix . '_count_' . $key;
|
||||
$key = substr($this->getItem($prefix . '_type_' . $key), $length);
|
||||
|
||||
if (!empty($key)) {
|
||||
if (($count = intval($this->getItem($idc))) > 0) {
|
||||
$value = array();
|
||||
|
||||
for ($i = 1; $i <= $count; $i++) {
|
||||
$value[] = $this->getItem($idv . '_' . $i);
|
||||
}
|
||||
|
||||
$value = ($count == 1) ? reset($value) : $value;
|
||||
} else {
|
||||
$value = $this->getItem($idv);
|
||||
}
|
||||
|
||||
if (!is_null($value)) {
|
||||
$result[$key] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// No alias for the AX schema has been found,
|
||||
// so there is no AX data in the OP's response.
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
protected function getSregAttributes()
|
||||
{
|
||||
$attributes = array();
|
||||
$sreg_to_ax = array_flip(self::$ax_to_sreg);
|
||||
foreach (explode(',', $this->data['openid_signed']) as $key) {
|
||||
$keyMatch = 'sreg.';
|
||||
if (strncmp($key, $keyMatch, strlen($keyMatch)) !== 0) {
|
||||
continue;
|
||||
}
|
||||
$key = substr($key, strlen($keyMatch));
|
||||
if (!isset($sreg_to_ax[$key])) {
|
||||
# The field name isn't part of the SREG spec, so we ignore it.
|
||||
continue;
|
||||
}
|
||||
$attributes[$sreg_to_ax[$key]] = $this->data['openid_sreg_' . $key];
|
||||
}
|
||||
return $attributes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets AX/SREG attributes provided by OP. should be used only after successful validaton.
|
||||
* Note that it does not guarantee that any of the required/optional parameters will be present,
|
||||
* or that there will be no other attributes besides those specified.
|
||||
* In other words. OP may provide whatever information it wants to.
|
||||
* * SREG names will be mapped to AX names.
|
||||
* * @return Array Array of attributes with keys being the AX schema names, e.g. 'contact/email'
|
||||
* @see http://www.axschema.org/types/
|
||||
*/
|
||||
function getAttributes()
|
||||
{
|
||||
if (isset($this->data['openid_ns'])
|
||||
&& $this->data['openid_ns'] == 'http://specs.openid.net/auth/2.0'
|
||||
) { # OpenID 2.0
|
||||
# We search for both AX and SREG attributes, with AX taking precedence.
|
||||
return $this->getAxAttributes() + $this->getSregAttributes();
|
||||
}
|
||||
return $this->getSregAttributes();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an OAuth request token if the OpenID+OAuth hybrid protocol has been used.
|
||||
*
|
||||
* In order to use the OpenID+OAuth hybrid protocol, you need to add at least one
|
||||
* scope to the $openid->oauth array before you get the call to getAuthUrl(), e.g.:
|
||||
* $openid->oauth[] = 'https://www.googleapis.com/auth/plus.me';
|
||||
*
|
||||
* Furthermore the registered consumer name must fit the OpenID realm.
|
||||
* To register an OpenID consumer at Google use: https://www.google.com/accounts/ManageDomains
|
||||
*
|
||||
* @return string|bool OAuth request token on success, FALSE if no token was provided.
|
||||
*/
|
||||
function getOAuthRequestToken()
|
||||
{
|
||||
$alias = $this->getNamespaceAlias('http://specs.openid.net/extensions/oauth/1.0');
|
||||
|
||||
return !empty($alias) ? $this->data['openid_' . $alias . '_request_token'] : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the alias for the specified namespace, if it's present.
|
||||
*
|
||||
* @param string $namespace The namespace for which an alias is needed.
|
||||
* @param string $hint Common alias of this namespace, used for optimization.
|
||||
* @return string|null The namespace alias if found, otherwise - NULL.
|
||||
*/
|
||||
private function getNamespaceAlias($namespace, $hint = null)
|
||||
{
|
||||
$result = null;
|
||||
|
||||
if (empty($hint) || $this->getItem('openid_ns_' . $hint) != $namespace) {
|
||||
// The common alias is either undefined or points to
|
||||
// some other extension - search for another alias..
|
||||
$prefix = 'openid_ns_';
|
||||
$length = strlen($prefix);
|
||||
|
||||
foreach ($this->data as $key => $val) {
|
||||
if (strncmp($key, $prefix, $length) === 0 && $val === $namespace) {
|
||||
$result = trim(substr($key, $length));
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$result = $hint;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an item from the $data array by the specified id.
|
||||
*
|
||||
* @param string $id The id of the desired item.
|
||||
* @return string|null The item if found, otherwise - NULL.
|
||||
*/
|
||||
private function getItem($id)
|
||||
{
|
||||
return isset($this->data[$id]) ? $this->data[$id] : null;
|
||||
}
|
||||
}
|
10
web/third_party/hybridauth/Hybrid/thirdparty/index.html
vendored
Normal file
10
web/third_party/hybridauth/Hybrid/thirdparty/index.html
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>403 Forbidden</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p>Directory access is forbidden.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
0
web/third_party/hybridauth/log/hybridauth.log
vendored
Normal file
0
web/third_party/hybridauth/log/hybridauth.log
vendored
Normal file
Loading…
x
Reference in New Issue
Block a user