Subversion Repositories oidplus

Rev

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

Rev 1143 Rev 1149
Line 107... Line 107...
107
                        $data = array(
107
                        $data = array(
108
                                "payload" => $payload,
108
                                "payload" => $payload,
109
                                "signature" => base64_encode($signature)
109
                                "signature" => base64_encode($signature)
110
                        );
110
                        );
111
 
111
 
112
                        if (!function_exists('curl_init')) {
-
 
113
                                throw new OIDplusException(_L('The "%1" PHP extension is not installed at your system. Please enable the PHP extension <code>%2</code>.','CURL','php_curl'));
-
 
114
                        }
-
 
115
 
-
 
116
                        if (OIDplus::getEditionInfo()['vendor'] != 'ViaThinkSoft') {
112
                        if (OIDplus::getEditionInfo()['vendor'] != 'ViaThinkSoft') {
117
                                // The oid-info.com import functionality is a confidential API between ViaThinkSoft and oid-info.com and cannot be used in forks of OIDplus
113
                                // The oid-info.com import functionality is a confidential API between ViaThinkSoft and oid-info.com and cannot be used in forks of OIDplus
118
                                throw new OIDplusException(_L('This feature is only available in the ViaThinkSoft edition of OIDplus'));
114
                                throw new OIDplusException(_L('This feature is only available in the ViaThinkSoft edition of OIDplus'));
119
                        }
115
                        }
120
 
116
 
121
                        $ch = curl_init();
-
 
122
                        if (ini_get('curl.cainfo') == '') curl_setopt($ch, CURLOPT_CAINFO, OIDplus::localpath() . 'vendor/cacert.pem');
-
 
123
                        curl_setopt($ch, CURLOPT_URL, 'https://oidplus.viathinksoft.com/reg2/query.php');
-
 
124
                        curl_setopt($ch, CURLOPT_USERAGENT, 'ViaThinkSoft-OIDplus/2.0');
-
 
125
                        curl_setopt($ch, CURLOPT_POST, 1);
-
 
126
                        if (function_exists('gzdeflate')) {
117
                        if (function_exists('gzdeflate')) {
127
                                $compressed = "1";
118
                                $compressed = "1";
128
                                $data2 = gzdeflate(json_encode($data));
119
                                $data2 = gzdeflate(json_encode($data));
129
                        } else {
120
                        } else {
130
                                $compressed = "0";
121
                                $compressed = "0";
131
                                $data2 = json_encode($data);
122
                                $data2 = json_encode($data);
132
                        }
123
                        }
-
 
124
 
133
                        curl_setopt($ch, CURLOPT_POSTFIELDS, "query=".urlencode($query)."&compressed=$compressed&data=".urlencode(base64_encode($data2)));
125
                        $res_curl = url_post_contents(
134
                        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
126
                                'https://oidplus.viathinksoft.com/reg2/query.php',
-
 
127
                                array(
-
 
128
                                        "query"      => $query,
135
                        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
129
                                        "compressed" => $compressed,
136
                        curl_setopt($ch, CURLOPT_AUTOREFERER, true);
130
                                        "data"       => base64_encode($data2)
-
 
131
                                )
-
 
132
                        );
-
 
133
 
137
                        if (!($res_curl = @curl_exec($ch))) {
134
                        if ($res_curl === false) {
138
                                throw new OIDplusException(_L('Communication with ViaThinkSoft server failed: %1',curl_error($ch)));
135
                                throw new OIDplusException(_L('Communication with %1 server failed', 'ViaThinkSoft'));
139
                        }
136
                        }
140
                        curl_close($ch);
-
 
141
 
137
 
142
                        $json = @json_decode($res_curl, true);
138
                        $json = @json_decode($res_curl, true);
143
 
139
 
144
                        if (!$json) {
140
                        if (!$json) {
145
                                return array(
141
                                return array(
Line 223... Line 219...
223
                        $data = array(
219
                        $data = array(
224
                                "payload" => $payload,
220
                                "payload" => $payload,
225
                                "signature" => base64_encode($signature)
221
                                "signature" => base64_encode($signature)
226
                        );
222
                        );
227
 
223
 
228
                        if (!function_exists('curl_init')) {
-
 
229
                                throw new OIDplusException(_L('The "%1" PHP extension is not installed at your system. Please enable the PHP extension <code>%2</code>.','CURL','php_curl'));
-
 
230
                        }
-
 
231
 
-
 
232
                        if (OIDplus::getEditionInfo()['vendor'] != 'ViaThinkSoft') {
224
                        if (OIDplus::getEditionInfo()['vendor'] != 'ViaThinkSoft') {
233
                                // The oid-info.com import functionality is a confidential API between ViaThinkSoft and oid-info.com and cannot be used in forks of OIDplus
225
                                // The oid-info.com import functionality is a confidential API between ViaThinkSoft and oid-info.com and cannot be used in forks of OIDplus
234
                                throw new OIDplusException(_L('This feature is only available in the ViaThinkSoft edition of OIDplus'));
226
                                throw new OIDplusException(_L('This feature is only available in the ViaThinkSoft edition of OIDplus'));
235
                        }
227
                        }
236
 
228
 
237
                        $ch = curl_init();
-
 
238
                        if (ini_get('curl.cainfo') == '') curl_setopt($ch, CURLOPT_CAINFO, OIDplus::localpath() . 'vendor/cacert.pem');
-
 
239
                        curl_setopt($ch, CURLOPT_URL, 'https://oidplus.viathinksoft.com/reg2/query.php');
-
 
240
                        curl_setopt($ch, CURLOPT_USERAGENT, 'ViaThinkSoft-OIDplus/2.0');
-
 
241
                        curl_setopt($ch, CURLOPT_POST, 1);
-
 
242
                        if (function_exists('gzdeflate')) {
229
                        if (function_exists('gzdeflate')) {
243
                                $compressed = "1";
230
                                $compressed = "1";
244
                                $data2 = gzdeflate(json_encode($data));
231
                                $data2 = gzdeflate(json_encode($data));
245
                        } else {
232
                        } else {
246
                                $compressed = "0";
233
                                $compressed = "0";
247
                                $data2 = json_encode($data);
234
                                $data2 = json_encode($data);
248
                        }
235
                        }
-
 
236
 
249
                        curl_setopt($ch, CURLOPT_POSTFIELDS, "query=".urlencode($query)."&compressed=$compressed&data=".urlencode(base64_encode($data2)));
237
                        $res_curl = url_post_contents(
250
                        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
238
                                'https://oidplus.viathinksoft.com/reg2/query.php',
-
 
239
                                array(
-
 
240
                                        "query"      => $query,
251
                        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
241
                                        "compressed" => $compressed,
252
                        curl_setopt($ch, CURLOPT_AUTOREFERER, true);
242
                                        "data"       => base64_encode($data2)
-
 
243
                                )
-
 
244
                        );
-
 
245
 
253
                        if (!($res_curl = @curl_exec($ch))) {
246
                        if ($res_curl === false) {
254
                                throw new OIDplusException(_L('Communication with ViaThinkSoft server failed: %1',curl_error($ch)));
247
                                throw new OIDplusException(_L('Communication with %1 server failed', 'ViaThinkSoft'));
255
                        }
248
                        }
256
                        curl_close($ch);
-
 
257
 
249
 
258
                        $out['text'] = '<p><a '.OIDplus::gui()->link('oidplus:datatransfer$export').'><img src="img/arrow_back.png" width="16" alt="'._L('Go back').'"> '._L('Go back to data transfer main page').'</a></p>';
250
                        $out['text'] = '<p><a '.OIDplus::gui()->link('oidplus:datatransfer$export').'><img src="img/arrow_back.png" width="16" alt="'._L('Go back').'"> '._L('Go back to data transfer main page').'</a></p>';
259
 
251
 
260
                        $json = @json_decode($res_curl, true);
252
                        $json = @json_decode($res_curl, true);
261
 
253
 
Line 504... Line 496...
504
                        $data = array(
496
                        $data = array(
505
                                "payload" => $payload,
497
                                "payload" => $payload,
506
                                "signature" => base64_encode($signature)
498
                                "signature" => base64_encode($signature)
507
                        );
499
                        );
508
 
500
 
509
                        if (!function_exists('curl_init')) {
-
 
510
                                throw new OIDplusException(_L('The "%1" PHP extension is not installed at your system. Please enable the PHP extension <code>%2</code>.','CURL','php_curl'));
-
 
511
                        }
-
 
512
 
-
 
513
                        if (OIDplus::getEditionInfo()['vendor'] != 'ViaThinkSoft') {
501
                        if (OIDplus::getEditionInfo()['vendor'] != 'ViaThinkSoft') {
514
                                // The oid-info.com import functionality is a confidential API between ViaThinkSoft and oid-info.com and cannot be used in forks of OIDplus
502
                                // The oid-info.com import functionality is a confidential API between ViaThinkSoft and oid-info.com and cannot be used in forks of OIDplus
515
                                throw new OIDplusException(_L('This feature is only available in the ViaThinkSoft edition of OIDplus'));
503
                                throw new OIDplusException(_L('This feature is only available in the ViaThinkSoft edition of OIDplus'));
516
                        }
504
                        }
517
 
505
 
518
                        $ch = curl_init();
-
 
519
                        if (ini_get('curl.cainfo') == '') curl_setopt($ch, CURLOPT_CAINFO, OIDplus::localpath() . 'vendor/cacert.pem');
-
 
520
                        curl_setopt($ch, CURLOPT_URL, 'https://oidplus.viathinksoft.com/reg2/query.php');
-
 
521
                        curl_setopt($ch, CURLOPT_USERAGENT, 'ViaThinkSoft-OIDplus/2.0');
-
 
522
                        curl_setopt($ch, CURLOPT_POST, 1);
-
 
523
                        if (function_exists('gzdeflate')) {
506
                        if (function_exists('gzdeflate')) {
524
                                $compressed = "1";
507
                                $compressed = "1";
525
                                $data2 = gzdeflate(json_encode($data));
508
                                $data2 = gzdeflate(json_encode($data));
526
                        } else {
509
                        } else {
527
                                $compressed = "0";
510
                                $compressed = "0";
528
                                $data2 = json_encode($data);
511
                                $data2 = json_encode($data);
529
                        }
512
                        }
-
 
513
 
530
                        curl_setopt($ch, CURLOPT_POSTFIELDS, "query=".urlencode($query)."&compressed=$compressed&data=".urlencode(base64_encode($data2)));
514
                        $res = url_post_contents(
531
                        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
515
                                'https://oidplus.viathinksoft.com/reg2/query.php',
-
 
516
                                array(
-
 
517
                                        "query"      => $query,
532
                        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
518
                                        "compressed" => $compressed,
533
                        curl_setopt($ch, CURLOPT_AUTOREFERER, true);
519
                                        "data"       => base64_encode($data2)
-
 
520
                                )
-
 
521
                        );
-
 
522
 
534
                        if (!($res = @curl_exec($ch))) {
523
                        if ($res === false) {
535
                                throw new OIDplusException(_L('Communication with ViaThinkSoft server failed: %1',curl_error($ch)));
524
                                throw new OIDplusException(_L('Communication with %1 server failed', 'ViaThinkSoft'));
536
                        }
525
                        }
537
                        curl_close($ch);
-
 
538
 
526
 
539
                        $out['text'] = '<p><a '.OIDplus::gui()->link('oidplus:datatransfer$import').'><img src="img/arrow_back.png" width="16" alt="'._L('Go back').'"> '._L('Go back to data transfer main page').'</a></p>';
527
                        $out['text'] = '<p><a '.OIDplus::gui()->link('oidplus:datatransfer$import').'><img src="img/arrow_back.png" width="16" alt="'._L('Go back').'"> '._L('Go back to data transfer main page').'</a></p>';
540
 
528
 
541
                        $json = @json_decode($res, true);
529
                        $json = @json_decode($res, true);
542
 
530
 
Line 1170... Line 1158...
1170
         * @throws OIDplusException
1158
         * @throws OIDplusException
1171
         */
1159
         */
1172
        public function getNotifications(string $user=null): array {
1160
        public function getNotifications(string $user=null): array {
1173
                $notifications = array();
1161
                $notifications = array();
1174
                if ((!$user || ($user == 'admin')) && OIDplus::authUtils()->isAdminLoggedIn()) {
1162
                if ((!$user || ($user == 'admin')) && OIDplus::authUtils()->isAdminLoggedIn()) {
1175
                        if (!function_exists('curl_init')) {
1163
                        if (!url_post_contents_available()) {
1176
                                $title = _L('OID-Info.com import/export');
1164
                                $title = _L('OID-Info.com import/export');
1177
                                $notifications[] = array('ERR', _L('OIDplus plugin "%1" is enabled, but the required PHP extension "%2" is not installed.', '<a '.OIDplus::gui()->link('oidplus:datatransfer').'>'.htmlentities($title).'</a>', 'php_curl'));
1165
                                $notifications[] = array('ERR', _L('OIDplus plugin "%1" is enabled, but the required PHP extension "%2" is not installed.', '<a '.OIDplus::gui()->link('oidplus:datatransfer').'>'.htmlentities($title).'</a>', 'php_curl'));
1178
                        }
1166
                        }
1179
                }
1167
                }
1180
                return $notifications;
1168
                return $notifications;