File indexing completed on 2024-12-29 05:24:45

0001 <?php
0002 /** @var Zend_Controller_Request_Http $request */
0003 $request =  Zend_Controller_Front::getInstance()->getRequest();
0004 $token = $request->getCookie(Default_Model_SingleSignOnToken::ACTION_LOGOUT, null);
0005 $modelSso = new Default_Model_SingleSignOnToken();
0006 if (isset($token) AND $modelSso->isValid($token)) :
0007     $store_config_list = Zend_Registry::get('application_store_config_list');
0008 
0009     $urls = '';
0010     foreach ($store_config_list as $key => $item) {
0011         if (empty($item['cross_domain_login'])) {
0012             continue;
0013         }
0014         $urls .= "'//{$key}/logout/propagate/',";
0015     }
0016     $urls = substr($urls, 0, -1); ?>
0017     <script type="application/javascript">
0018         $(document).ready(function(){
0019             urls = [<?=$urls?>];
0020             origin = 'http://<?=$_SERVER["HTTP_HOST"]?>';
0021 
0022             var propagateLogout = (function () {
0023                 return {
0024                     process: function (origin, urls) {
0025                         for (var i = 0; i < urls.length; i++) {
0026                             var data = {'origin': origin};
0027                             var request_config = {
0028                                 'type': 'POST',
0029                                 'dataType': 'text',
0030                                 'cache': false,
0031                                 'data': data,
0032                                 'url': urls[i],
0033                                 'xhrFields': {
0034                                     'withCredentials': true
0035                                 }
0036                             };
0037                             $.ajax(request_config);
0038                         }
0039                     }
0040                 }
0041             })();
0042 
0043             propagateLogout.process(origin, urls);
0044         });
0045     </script>
0046 <?php
0047     setcookie(Default_Model_SingleSignOnToken::ACTION_LOGOUT, false, time() - 38500, '/',Local_Tools_ParseDomain::get_domain($request->getHttpHost()), null, true);
0048 endif;