Subversion Repositories oidplus

Rev

Rev 1199 | Rev 1206 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1199 Rev 1201
Line 40... Line 40...
40
        }
40
        }
41
 
41
 
42
        /**
42
        /**
43
         * @param string $email
43
         * @param string $email
44
         * @param bool $getId
44
         * @param bool $getId
45
         * @return bool|null
45
         * @return string|null|bool If $getId=true, then returns ID or NULL.  If $getId=False, then returns TRUE or FALSE.
46
         * @throws OIDplusException
46
         * @throws OIDplusException
47
         */
47
         */
48
        public static function alreadyHasFreeOid(string $email, bool $getId = false)/*: ?bool*/ {
48
        public static function alreadyHasFreeOid(string $email, bool $getId = false) {
49
                $res = OIDplus::db()->query("select id from ###objects where ra_email = ? and id like ?", array($email, self::getFreeRootOid(true).'.%'));
49
                $res = OIDplus::db()->query("select id from ###objects where ra_email = ? and id like ?", array($email, self::getFreeRootOid(true).'.%'));
50
                $res->naturalSortByField('id');
50
                $res->naturalSortByField('id');
51
                if ($row = $res->fetch_array()) {
51
                if ($row = $res->fetch_array()) {
52
                        return $getId ? $row['id'] : true;
52
                        return $getId ? $row['id'] : true;
53
                }
53
                }
Line 67... Line 67...
67
                if ($actionID == 'request_freeoid') {
67
                if ($actionID == 'request_freeoid') {
68
                        _CheckParamExists($params, 'email');
68
                        _CheckParamExists($params, 'email');
69
                        $email = $params['email'];
69
                        $email = $params['email'];
70
 
70
 
71
                        if ($already_registered_oid = $this->alreadyHasFreeOid($email, true)) {
71
                        if ($already_registered_oid = $this->alreadyHasFreeOid($email, true)) {
72
                                throw new OIDplusException(_L('This email address already has a FreeOID registered (%1)', $already_registered_oid));
72
                                throw new OIDplusHtmlException(_L('This email address already has a FreeOID registered (%1)', '<a '.OIDplus::gui()->link($already_registered_oid).'>'.htmlentities($already_registered_oid).'</a>'));
73
                        }
73
                        }
74
 
74
 
75
                        if (!OIDplus::mailUtils()->validMailAddress($email)) {
75
                        if (!OIDplus::mailUtils()->validMailAddress($email)) {
76
                                throw new OIDplusException(_L('Invalid email address'));
76
                                throw new OIDplusException(_L('Invalid email address'));
77
                        }
77
                        }
Line 277... Line 277...
277
                                if (OIDplus::config()->getValue('freeoid_root_oid') == '1.3.6.1.4.1.37476.9000') {
277
                                if (OIDplus::config()->getValue('freeoid_root_oid') == '1.3.6.1.4.1.37476.9000') {
278
                                        $out['text'] .= '<p>'._L('<b>Note:</b> Since September 2022, owners of FreeOID automatically receive a free ISO-7816 compliant <b>Application Identifier</b> (AID) with the format <code>D2:76:00:01:86:F0:(FreeOID):FF:(PIX)</code> (up to 64 bits application specific PIX, depending on the length of the FreeOID number).');
278
                                        $out['text'] .= '<p>'._L('<b>Note:</b> Since September 2022, owners of FreeOID automatically receive a free ISO-7816 compliant <b>Application Identifier</b> (AID) with the format <code>D2:76:00:01:86:F0:(FreeOID):FF:(PIX)</code> (up to 64 bits application specific PIX, depending on the length of the FreeOID number).');
279
$out['text'] .= ' - <a '.OIDplus::gui()->link('aid:D276000186F1').'>'._L('More information').'</a></p>';
279
                                        $out['text'] .= ' - <a '.OIDplus::gui()->link('aid:D276000186F1').'>'._L('More information').'</a></p>';
280
                                }
280
                                }
281
                        } catch (\Exception $e) {
281
                        } catch (\Exception $e) {
-
 
282
                                $htmlmsg = $e instanceof OIDplusException ? $e->getHtmlMessage() : htmlentities($e->getMessage());
282
                                $out['text'] = _L('Error: %1',$e->getMessage());
283
                                $out['text'] = _L('Error: %1',$htmlmsg);
283
                        }
284
                        }
284
                } else if (explode('$',$id)[0] == 'oidplus:com.viathinksoft.freeoid.activate_freeoid') {
285
                } else if (explode('$',$id)[0] == 'oidplus:com.viathinksoft.freeoid.activate_freeoid') {
285
                        $handled = true;
286
                        $handled = true;
286
 
287
 
287
                        $email = explode('$',$id)[1];
288
                        $email = explode('$',$id)[1];
Line 290... Line 291...
290
 
291
 
291
                        $out['title'] = _L('Activate Free OID');
292
                        $out['title'] = _L('Activate Free OID');
292
                        $out['icon'] = file_exists(__DIR__.'/img/main_icon.png') ? OIDplus::webpath(__DIR__,OIDplus::PATH_RELATIVE).'img/main_icon.png' : '';
293
                        $out['icon'] = file_exists(__DIR__.'/img/main_icon.png') ? OIDplus::webpath(__DIR__,OIDplus::PATH_RELATIVE).'img/main_icon.png' : '';
293
 
294
 
294
                        if ($already_registered_oid = $this->alreadyHasFreeOid($email, true)) {
295
                        if ($already_registered_oid = $this->alreadyHasFreeOid($email, true)) {
295
                                throw new OIDplusException(_L('This email address already has a FreeOID registered (%1)', $already_registered_oid));
296
                                throw new OIDplusHtmlException(_L('This email address already has a FreeOID registered (%1)', '<a '.OIDplus::gui()->link($already_registered_oid).'>'.htmlentities($already_registered_oid).'</a>'));
296
                        } else {
297
                        } else {
297
                                if (!OIDplus::authUtils()->validateAuthKey('com.viathinksoft.freeoid.activate_freeoid;'.$email.';'.$timestamp, $auth)) {
298
                                if (!OIDplus::authUtils()->validateAuthKey('com.viathinksoft.freeoid.activate_freeoid;'.$email.';'.$timestamp, $auth)) {
298
                                        $out['icon'] = 'img/error.png';
299
                                        $out['icon'] = 'img/error.png';
299
                                        $out['text'] = _L('Invalid authorization. Is the URL OK?');
300
                                        $out['text'] = _L('Invalid authorization. Is the URL OK?');
300
                                } else {
301
                                } else {