00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 class BMLT_Satellite
00026 {
00027
00028
00029
00030
00031
00032 static private $bmlt_instance = null;
00033
00034
00035
00036
00037
00038
00039
00040 static function MakeBMLT ( $is_csv = false,
00041 $in_http_vars = null
00042 )
00043 {
00044 if ( !$in_http_vars )
00045 {
00046 $in_http_vars = array_merge_recursive ( $_GET, $_POST );
00047 }
00048
00049
00050 if ( !(self::$bmlt_instance instanceof BMLT_Satellite) )
00051 {
00052
00053 include_once ( dirname ( __FILE__ )."/config.inc" );
00054
00055 if ( is_array ( $preset_service_bodies ) && count ( $preset_service_bodies ) )
00056 {
00057
00058 if ( is_array ( $in_http_vars ) && count ( $in_http_vars ) )
00059 {
00060
00061 if ( !isset ( $in_http_vars['preset_service_bodies'] ) )
00062 {
00063 $in_http_vars['preset_service_bodies'] = $preset_service_bodies;
00064 }
00065 }
00066 else
00067 {
00068 if ( !isset ( $_GET['preset_service_bodies'] ) && !isset ( $_POST['preset_service_bodies'] ) )
00069 {
00070 $in_http_vars = array_merge_recursive ( $_GET, $_POST );
00071 $in_http_vars['preset_service_bodies'] = $preset_service_bodies;
00072 }
00073 }
00074 }
00075
00076 if ( !isset ( $in_http_vars['search_spec_map_center'] ) )
00077 {
00078 $in_http_vars['search_spec_map_center'] = "$map_center_latitude,$map_center_longitude,$map_zoom";
00079 }
00080
00081
00082 self::$bmlt_instance = new BMLT_Satellite ( $root_server_root, $gkey_my, $support_old_browsers, $bmlt_initial_view, $is_csv, $in_http_vars, $lang_enum );
00083 }
00084
00085 return self::$bmlt_instance;
00086 }
00087
00088
00089
00090
00091
00092
00093
00094 static function is_mobile ( $in_http_vars = null
00095 )
00096 {
00097 $ret = isset ( $in_http_vars['simulate_iphone'] ) || preg_match ( '/ipod/i', $_SERVER['HTTP_USER_AGENT'] ) || preg_match ( '/iphone/i', $_SERVER['HTTP_USER_AGENT'] );
00098
00099 if ( !$ret )
00100 {
00101 $ret = isset ( $in_http_vars['simulate_android'] ) || preg_match ( '/android/i', $_SERVER['HTTP_USER_AGENT'] );
00102 }
00103
00104 if ( !$ret )
00105 {
00106 $ret = isset ( $in_http_vars['simulate_blackberry'] ) || preg_match ( '/blackberry/i', $_SERVER['HTTP_USER_AGENT'] );
00107 }
00108
00109 if ( !$ret )
00110 {
00111 $ret = isset ( $in_http_vars['simulate_opera_mini'] ) || preg_match ( "/opera\s+mini/i", $_SERVER['HTTP_USER_AGENT'] );
00112 }
00113
00114 return $ret;
00115 }
00116
00117
00118
00119
00120
00121
00122
00123 static function call_curl ( $in_uri,
00124 $in_post = false,
00125 &$http_status = null
00126 )
00127 {
00128 $ret = null;
00129
00130
00131 if ( !extension_loaded ( 'curl' ) )
00132 {
00133 if ( ini_get ( 'allow_url_fopen' ) )
00134 {
00135 $ret = file_get_contents ( $in_uri );
00136 }
00137 }
00138 else
00139 {
00140
00141 $resource = curl_init();
00142
00143
00144 if ( $in_post )
00145 {
00146 $spli = explode ( "?", $in_uri, 2 );
00147
00148 if ( is_array ( $spli ) && count ( $spli ) )
00149 {
00150 $in_uri = $spli[0];
00151 $in_params = $spli[1];
00152
00153 parse_str($in_params, $temp);
00154
00155
00156
00157
00158 $in_params = http_build_query($temp);
00159
00160 curl_setopt ( $resource, CURLOPT_POST, true );
00161 curl_setopt ( $resource, CURLOPT_POSTFIELDS, $in_params );
00162 }
00163 }
00164
00165
00166 curl_setopt ( $resource, CURLOPT_URL, $in_uri );
00167
00168
00169 curl_setopt ( $resource, CURLOPT_RETURNTRANSFER, true );
00170
00171
00172
00173
00174
00175 curl_setopt ( $resource, CURLOPT_HEADER, false );
00176
00177
00178
00179
00180
00181
00182 curl_setopt ( $resource, CURLOPT_MAXREDIRS, 3 );
00183
00184
00185 curl_setopt ( $resource, CURLOPT_CONNECTTIMEOUT, 10 );
00186
00187
00188 curl_setopt ( $resource, CURLOPT_ENCODING, 'gzip,deflate' );
00189
00190
00191 $content = curl_exec ( $resource );
00192
00193
00194 if ( $content === false )
00195 {
00196
00197 die ( '<pre>curl failure calling $in_uri, '.curl_error ( $resource )."\n".curl_errno ( $resource ).'</pre>' );
00198 }
00199 else
00200 {
00201
00202
00203
00204
00205 $http_status = curl_getinfo ($resource, CURLINFO_HTTP_CODE );
00206 }
00207
00208
00209 curl_close ( $resource );
00210
00211
00212 if ( $content !== false )
00213 {
00214 $ret = $content;
00215 }
00216 }
00217
00218 return $ret;
00219 }
00220
00221
00222
00223
00224
00225
00226 var $root_server_root = '';
00227 var $root_server_uri = '';
00228 var $gkey = '';
00229 var $support_old_browsers = true;
00230 var $bmlt_initial_view = '';
00231 var $http_vars = '';
00232 var $params = '';
00233 var $ajax_call = false;
00234 var $lang_enum = null;
00235 var $csv_call = false;
00236
00237
00238
00239
00240
00241
00242 private function __construct ( $in_root_server_root,
00243 $in_gkey,
00244 $in_support_old_browsers,
00245 $in_bmlt_initial_view,
00246 $in_csv_call = false,
00247 $in_http_vars = null,
00248 $in_lang_enum = null
00249 )
00250 {
00251 $this->http_vars = array ( $_GET, $_POST );
00252 if ( !isset ( $this->http_vars['advanced_search_mode'] ) || !$this->http_vars['advanced_search_mode'] )
00253 {
00254 unset ( $this->http_vars['result_type_advanced'] );
00255 }
00256
00257 if ( is_array ( $in_http_vars ) && count ( $in_http_vars ) )
00258 {
00259 if ( !isset ( $in_http_vars['advanced_search_mode'] ) || !$in_http_vars['advanced_search_mode'] )
00260 {
00261 unset ( $in_http_vars['result_type_advanced'] );
00262 }
00263
00264 foreach ( $in_http_vars as $key => $value )
00265 {
00266 if ( isset ( $key ) && !isset ( $this->http_vars[$key] ) )
00267 {
00268 if ( !isset ( $value ) )
00269 {
00270 $value = null;
00271 }
00272
00273 $this->http_vars[$key] = $value;
00274 }
00275 }
00276 }
00277
00278
00279 $this->csv_call = $in_csv_call;
00280 $this->root_server_root = $in_root_server_root;
00281 $this->root_server_uri = $this->root_server_root.'client_interface/'.(($this->csv_call == true) ? 'csv' : 'xhtml').'/index.php';
00282 $this->gkey = $in_gkey;
00283 $this->support_old_browsers = $in_support_old_browsers;
00284 $this->bmlt_initial_view = $in_bmlt_initial_view;
00285 $this->ajax_call = false;
00286 $this->lang_enum = $in_lang_enum;
00287
00288 if ( self::is_mobile ( $this->http_vars ) )
00289 {
00290 header ( 'Location: '.$this->root_server_root );
00291 }
00292
00293
00294 if ( !(isset ( $this->http_vars['redirect_ajax'] ) && $this->http_vars['redirect_ajax'])
00295 && !$this->csv_call
00296 && !isset ( $this->http_vars['search_form'] )
00297 && !isset ( $this->http_vars['result_type_advanced'] )
00298 && !isset ( $this->http_vars['single_meeting_id'] )
00299 && !isset ( $this->http_vars['do_search'] )
00300 && !isset ( $this->http_vars['search_form'] )
00301 )
00302 {
00303
00304 $this->http_vars['search_form'] = true;
00305 }
00306
00307
00308 $this->http_vars['script_name'] = $_SERVER['SCRIPT_NAME'];
00309 $this->http_vars['satellite'] = $_SERVER['SCRIPT_NAME'];
00310 $this->http_vars['satellite_standalone'] = 1;
00311
00312
00313 if ( !$this->support_old_browsers )
00314 {
00315 $this->http_vars['supports_ajax'] = 'yes';
00316 $this->http_vars['no_ajax_check'] = 'yes';
00317 }
00318 else
00319 {
00320
00321 unset ( $this->http_vars['no_ajax_check'] );
00322 }
00323
00324 $this->http_vars['start_view'] = $this->bmlt_initial_view;
00325
00326 $this->http_vars['gmap_key'] = $this->gkey;
00327
00328 if ( isset ( $this->lang_enum ) && $this->lang_enum )
00329 {
00330 $this->http_vars['lang_enum'] = $this->lang_enum;
00331 }
00332
00333
00334 $this->params = '';
00335
00336 foreach ( $this->http_vars as $key => $value )
00337 {
00338 if ( $key != 'switcher' )
00339 {
00340
00341 if ( is_array ( $value ) )
00342 {
00343 foreach ( $value as $val )
00344 {
00345 $this->params .= '&'.urlencode ( $key );
00346
00347 if ( is_array ( $val ) )
00348 {
00349 $val = join ( ",", $val );
00350 }
00351
00352 $this->params .= "%5B%5D=". urlencode ( $val );
00353 }
00354
00355
00356 $key = null;
00357 }
00358
00359
00360 if ( isset ( $key ) )
00361 {
00362 $this->params .= '&'.urlencode ( $key );
00363
00364
00365 if ( $value )
00366 {
00367 $this->params .= "=". urlencode ( $value );
00368 }
00369 }
00370 }
00371 }
00372
00373
00374
00375
00376
00377 if ( isset ( $this->http_vars['redirect_ajax'] ) && $this->http_vars['redirect_ajax'] )
00378 {
00379 $this->ajax_call = true;
00380 die ( $this->Execute() );
00381 }
00382 elseif ( !$this->csv_call && isset ( $this->http_vars['result_type_advanced'] ) && $this->http_vars['result_type_advanced'] && (($this->http_vars['result_type_advanced'] == 'booklet') || ($this->http_vars['result_type_advanced'] == 'listprint')))
00383 {
00384 die ( $this->Execute() );
00385 }
00386 }
00387
00388
00389
00390
00391
00392
00393
00394
00395
00396
00397 function Execute ( $in_phase = null,
00398
00399
00400
00401
00402
00403
00404
00405
00406
00407 $in_http_vars = null
00408 )
00409 {
00410 $content = '';
00411
00412 if ( $this->csv_call && ('csv' != $in_phase) && ('csv_formats' != $in_phase) )
00413 {
00414 $in_phase = 'csv';
00415 }
00416
00417
00418 if ( is_array ( $in_http_vars ) && count ( $in_http_vars ) )
00419 {
00420 if ( !isset ( $in_http_vars['advanced_search_mode'] ) || !$in_http_vars['advanced_search_mode'] )
00421 {
00422 unset ( $in_http_vars['result_type_advanced'] );
00423 }
00424
00425 if ( isset ( $this->lang_enum ) && $this->lang_enum )
00426 {
00427 $this->http_vars['lang_enum'] = $this->lang_enum;
00428 }
00429
00430 $this->http_vars = $in_http_vars;
00431
00432 $this->params = '';
00433
00434 foreach ( $this->http_vars as $key => $value )
00435 {
00436 if ( $key != 'switcher' )
00437 {
00438
00439 if ( is_array ( $value ) )
00440 {
00441 foreach ( $value as $val )
00442 {
00443 $this->params .= '&'.urlencode ( $key );
00444
00445 if ( is_array ( $val ) )
00446 {
00447 $val = join ( ",", $val );
00448 }
00449
00450 $this->params .= "%5B%5D=". urlencode ( $val );
00451 }
00452
00453
00454 $key = null;
00455 }
00456
00457
00458 if ( isset ( $key ) )
00459 {
00460 $this->params .= '&'.urlencode ( $key );
00461
00462
00463 if ( $value )
00464 {
00465 $this->params .= "=". urlencode ( $value );
00466 }
00467 }
00468 }
00469 }
00470 }
00471
00472
00473 if ( $this->ajax_call )
00474 {
00475 $uri = "$this->root_server_uri?switcher=RedirectAJAX$this->params";
00476 $content = self::call_curl ( $uri );
00477 }
00478 else
00479 {
00480 switch ( $in_phase )
00481 {
00482 case 'csv':
00483
00484 $uri = "$this->root_server_uri?switcher=GetSearchResults$this->params";
00485 $content .= self::call_curl ( $uri );
00486 break;
00487
00488 case 'csv_formats':
00489
00490 $uri = "$this->root_server_uri?switcher=GetFormats$this->params";
00491 $content .= self::call_curl ( $uri );
00492 break;
00493
00494 case 'simple_formats':
00495
00496 $uri = str_replace("/xhtml","/simple",$this->root_server_uri)."?switcher=GetFormats$this->params";
00497 $content .= self::call_curl ( $uri );
00498 break;
00499
00500 case 'simple_meetings':
00501
00502 $uri = str_replace("/xhtml","/simple",$this->root_server_uri)."?switcher=GetSearchResults$this->params";
00503 $content .= self::call_curl ( $uri );
00504 break;
00505
00506 case 'doctype':
00507 $content = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">';
00508
00509 break;
00510
00511 case 'head':
00512
00513 if ( !$this->support_old_browsers )
00514 {
00515 $content = '<style type="text/css">.bmlt_no_js {text-align:center;font-weight:bold;font-size: large;color:red;}</style>';
00516 }
00517
00518 $uri = "$this->root_server_uri?switcher=GetHeaderXHTML$this->params";
00519 $content .= self::call_curl ( $uri );
00520 break;
00521
00522 default:
00523 if ( isset ( $this->http_vars['result_type_advanced'] ) && ($this->http_vars['result_type_advanced'] == 'booklet') )
00524 {
00525 if ( $use_local_pdf_generator )
00526 {
00527 $uri = ".";
00528 }
00529 else
00530 {
00531 $uri = $this->root_server_root."local_server";
00532 }
00533
00534 $uri .= "/pdf_generator/?list_type=booklet$this->params";
00535
00536 header ( "Location: $uri" );
00537 die();
00538 }
00539 elseif ( isset ( $this->http_vars['result_type_advanced'] ) && ($this->http_vars['result_type_advanced'] == 'listprint') )
00540 {
00541 if ( $use_local_pdf_generator )
00542 {
00543 $uri = ".";
00544 }
00545 else
00546 {
00547 $uri = $this->root_server_root."local_server";
00548 }
00549
00550 $uri .= "/pdf_generator/?list_type=listprint$this->params";
00551
00552 header ( "Location: $uri" );
00553 die();
00554 }
00555 else
00556 {
00557
00558 if ( !$this->support_old_browsers )
00559 {
00560 $content = '<noscript class="no_js"><div>This Meeting Search will not work because your browser does not support JavaScript. However, you can use the <a href="'.htmlspecialchars ( $this->root_server_root ).'">main server</a>.</div></noscript>';
00561 }
00562 if ( isset ( $this->http_vars['single_meeting_id'] ) && $this->http_vars['single_meeting_id'] )
00563 {
00564
00565 $uri = "$this->root_server_uri?switcher=GetOneMeeting$this->params";
00566 $content .= self::call_curl ( $uri );
00567 }
00568 elseif ( isset ( $this->http_vars['do_search'] ) )
00569 {
00570
00571 $uri = "$this->root_server_uri?switcher=GetSearchResults$this->params";
00572 $content .= self::call_curl ( $uri );
00573 }
00574 if ( isset ( $this->http_vars['search_form'] ) )
00575 {
00576
00577 $uri = "$this->root_server_uri?switcher=GetSimpleSearchForm$this->params";
00578 $content .= self::call_curl ( $uri );
00579 }
00580 }
00581 break;
00582 }
00583 }
00584
00585 return $content;
00586 }
00587 };
00588 ?>