| | 111 | function validateAPIKey($blogid, $loginid, $key) { |
| | 112 | requireComponent('Textcube.Function.Setting'); |
| | 113 | global $service; |
| | 114 | $loginid = POD::escapeString($loginid); |
| | 115 | $key = POD::escapeString($key); |
| | 116 | $userid = getUserIdByEmail($loginid); |
| | 117 | if( $userid === false ) { return false; } |
| | 118 | $currentAPIKey = setting::getUserSettingGlobal('APIKey',null,$userid); |
| | 119 | if($currentAPIKey == null) { |
| | 120 | if(!User::confirmPassword($userid, $key)) { |
| | 121 | header('HTTP/1.1 403 Forbidden'); |
| | 122 | exit; |
| | 123 | } |
| | 124 | } else if($currentAPIKey != $key) { |
| | 125 | header('HTTP/1.1 403 Forbidden'); |
| | 126 | exit; |
| | 127 | } |
| | 128 | return true; |
| | 129 | } |
| | 130 | |