Subversion Repositories oidplus

Rev

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

Rev 800 Rev 801
Line 52... Line 52...
52
 
52
 
53
                        $root_oid = self::getFreeRootOid(false);
53
                        $root_oid = self::getFreeRootOid(false);
54
                        OIDplus::logger()->log("[INFO]OID(oid:$root_oid)+RA($email)!", "Requested a free OID for email '$email' to be placed into root '$root_oid'");
54
                        OIDplus::logger()->log("[INFO]OID(oid:$root_oid)+RA($email)!", "Requested a free OID for email '$email' to be placed into root '$root_oid'");
55
 
55
 
56
                        $timestamp = time();
56
                        $timestamp = time();
57
                        $activate_url = OIDplus::webpath(null,false) . '?goto='.urlencode('oidplus:com.viathinksoft.freeoid.activate_freeoid$'.$email.'$'.$timestamp.'$'.OIDplus::authUtils()->makeAuthKey('com.viathinksoft.freeoid.activate_freeoid;'.$email.';'.$timestamp));
57
                        $activate_url = OIDplus::webpath(null,OIDplus::PATH_ABSOLUTE_CANONICAL) . '?goto='.urlencode('oidplus:com.viathinksoft.freeoid.activate_freeoid$'.$email.'$'.$timestamp.'$'.OIDplus::authUtils()->makeAuthKey('com.viathinksoft.freeoid.activate_freeoid;'.$email.';'.$timestamp));
58
 
58
 
59
                        $message = file_get_contents(__DIR__ . '/request_msg.tpl');
59
                        $message = file_get_contents(__DIR__ . '/request_msg.tpl');
60
                        $message = str_replace('{{SYSTEM_URL}}', OIDplus::webpath(null,false), $message);
60
                        $message = str_replace('{{SYSTEM_URL}}', OIDplus::webpath(null,OIDplus::PATH_ABSOLUTE_CANONICAL), $message);
61
                        $message = str_replace('{{SYSTEM_TITLE}}', OIDplus::config()->getValue('system_title'), $message);
61
                        $message = str_replace('{{SYSTEM_TITLE}}', OIDplus::config()->getValue('system_title'), $message);
62
                        $message = str_replace('{{ADMIN_EMAIL}}', OIDplus::config()->getValue('admin_email'), $message);
62
                        $message = str_replace('{{ADMIN_EMAIL}}', OIDplus::config()->getValue('admin_email'), $message);
63
                        $message = str_replace('{{ACTIVATE_URL}}', $activate_url, $message);
63
                        $message = str_replace('{{ACTIVATE_URL}}', $activate_url, $message);
64
 
64
 
65
                        OIDplus::mailUtils()->sendMail($email, OIDplus::config()->getValue('system_title').' - Free OID request', $message, OIDplus::config()->getValue('global_cc'));
65
                        OIDplus::mailUtils()->sendMail($email, OIDplus::config()->getValue('system_title').' - Free OID request', $message, OIDplus::config()->getValue('global_cc'));
Line 156... Line 156...
156
                        $message .= "RA Name: $ra_name\n";
156
                        $message .= "RA Name: $ra_name\n";
157
                        $message .= "RA eMail: $email\n";
157
                        $message .= "RA eMail: $email\n";
158
                        $message .= "URL for more information: $url\n";
158
                        $message .= "URL for more information: $url\n";
159
                        $message .= "OID Name: $title\n";
159
                        $message .= "OID Name: $title\n";
160
                        $message .= "\n";
160
                        $message .= "\n";
161
                        $message .= "More details: ".OIDplus::webpath(null,false)."?goto=oid:$new_oid\n";
161
                        $message .= "More details: ".OIDplus::webpath(null,OIDplus::PATH_ABSOLUTE_CANONICAL)."?goto=oid:$new_oid\n";
162
 
162
 
163
                        OIDplus::mailUtils()->sendMail($email, OIDplus::config()->getValue('system_title')." - OID $new_oid registered", $message, OIDplus::config()->getValue('global_cc'));
163
                        OIDplus::mailUtils()->sendMail($email, OIDplus::config()->getValue('system_title')." - OID $new_oid registered", $message, OIDplus::config()->getValue('global_cc'));
164
 
164
 
165
                        // Send delegation information to user
165
                        // Send delegation information to user
166
 
166
 
167
                        $message = file_get_contents(__DIR__ . '/allocated_msg.tpl');
167
                        $message = file_get_contents(__DIR__ . '/allocated_msg.tpl');
168
                        $message = str_replace('{{SYSTEM_URL}}', OIDplus::webpath(null,false), $message);
168
                        $message = str_replace('{{SYSTEM_URL}}', OIDplus::webpath(null,OIDplus::PATH_ABSOLUTE_CANONICAL), $message);
169
                        $message = str_replace('{{SYSTEM_TITLE}}', OIDplus::config()->getValue('system_title'), $message);
169
                        $message = str_replace('{{SYSTEM_TITLE}}', OIDplus::config()->getValue('system_title'), $message);
170
                        $message = str_replace('{{ADMIN_EMAIL}}', OIDplus::config()->getValue('admin_email'), $message);
170
                        $message = str_replace('{{ADMIN_EMAIL}}', OIDplus::config()->getValue('admin_email'), $message);
171
                        $message = str_replace('{{NEW_OID}}', $new_oid, $message);
171
                        $message = str_replace('{{NEW_OID}}', $new_oid, $message);
172
                        OIDplus::mailUtils()->sendMail($email, OIDplus::config()->getValue('system_title').' - Free OID allocated', $message, OIDplus::config()->getValue('global_cc'));
172
                        OIDplus::mailUtils()->sendMail($email, OIDplus::config()->getValue('system_title').' - Free OID allocated', $message, OIDplus::config()->getValue('global_cc'));
173
 
173
 
Line 193... Line 193...
193
 
193
 
194
                if (explode('$',$id)[0] == 'oidplus:com.viathinksoft.freeoid') {
194
                if (explode('$',$id)[0] == 'oidplus:com.viathinksoft.freeoid') {
195
                        $handled = true;
195
                        $handled = true;
196
 
196
 
197
                        $out['title'] = _L('Register a free OID');
197
                        $out['title'] = _L('Register a free OID');
198
                        $out['icon'] = file_exists(__DIR__.'/img/main_icon.png') ? OIDplus::webpath(__DIR__,true).'img/main_icon.png' : '';
198
                        $out['icon'] = file_exists(__DIR__.'/img/main_icon.png') ? OIDplus::webpath(__DIR__,OIDplus::PATH_RELATIVE).'img/main_icon.png' : '';
199
 
199
 
200
                        // Note: We are using the highest OID instead of the rowcount, because there might be OIDs which could have been deleted in between
200
                        // Note: We are using the highest OID instead of the rowcount, because there might be OIDs which could have been deleted in between
201
                        $highest_id = $this->freeoid_max_id();
201
                        $highest_id = $this->freeoid_max_id();
202
 
202
 
203
                        $out['text'] .= '<p>'._L('Currently <a %1>%2 free OIDs have been</a> registered. Please enter your email below to receive a free OID.',OIDplus::gui()->link(self::getFreeRootOid(true)),$highest_id).'</p>';
203
                        $out['text'] .= '<p>'._L('Currently <a %1>%2 free OIDs have been</a> registered. Please enter your email below to receive a free OID.',OIDplus::gui()->link(self::getFreeRootOid(true)),$highest_id).'</p>';
Line 241... Line 241...
241
                        $email = explode('$',$id)[1];
241
                        $email = explode('$',$id)[1];
242
                        $timestamp = explode('$',$id)[2];
242
                        $timestamp = explode('$',$id)[2];
243
                        $auth = explode('$',$id)[3];
243
                        $auth = explode('$',$id)[3];
244
 
244
 
245
                        $out['title'] = _L('Activate Free OID');
245
                        $out['title'] = _L('Activate Free OID');
246
                        $out['icon'] = file_exists(__DIR__.'/img/main_icon.png') ? OIDplus::webpath(__DIR__,true).'img/main_icon.png' : '';
246
                        $out['icon'] = file_exists(__DIR__.'/img/main_icon.png') ? OIDplus::webpath(__DIR__,OIDplus::PATH_RELATIVE).'img/main_icon.png' : '';
247
 
247
 
248
                        if ($already_registered_oid = $this->alreadyHasFreeOid($email, true)) {
248
                        if ($already_registered_oid = $this->alreadyHasFreeOid($email, true)) {
249
                                throw new OIDplusException(_L('This email address already has a FreeOID registered (%1)', $already_registered_oid));
249
                                throw new OIDplusException(_L('This email address already has a FreeOID registered (%1)', $already_registered_oid));
250
                        } else {
250
                        } else {
251
                                if (!OIDplus::authUtils()->validateAuthKey('com.viathinksoft.freeoid.activate_freeoid;'.$email.';'.$timestamp, $auth)) {
251
                                if (!OIDplus::authUtils()->validateAuthKey('com.viathinksoft.freeoid.activate_freeoid;'.$email.';'.$timestamp, $auth)) {
Line 288... Line 288...
288
 
288
 
289
        public function tree(&$json, $ra_email=null, $nonjs=false, $req_goto='') {
289
        public function tree(&$json, $ra_email=null, $nonjs=false, $req_goto='') {
290
                if (empty(self::getFreeRootOid(false))) return false;
290
                if (empty(self::getFreeRootOid(false))) return false;
291
 
291
 
292
                if (file_exists(__DIR__.'/img/main_icon16.png')) {
292
                if (file_exists(__DIR__.'/img/main_icon16.png')) {
293
                        $tree_icon = OIDplus::webpath(__DIR__,true).'img/main_icon16.png';
293
                        $tree_icon = OIDplus::webpath(__DIR__,OIDplus::PATH_RELATIVE).'img/main_icon16.png';
294
                } else {
294
                } else {
295
                        $tree_icon = null; // default icon (folder)
295
                        $tree_icon = null; // default icon (folder)
296
                }
296
                }
297
 
297
 
298
                $json[] = array(
298
                $json[] = array(