function execute($par) { global $wgOut, $wgScriptPath, $wgRequest; $wgOut->addScriptFile("{$wgScriptPath}/extensions/metasearch/proxy.js"); $cat_stack = new MsCategoryStack($wgRequest->getArray('ms-cat')); /// TODO: Copied from QueryPage if ($cat_stack->get_top()->is_root()) { throw new MsException("Cat stack is {$cat_stack}. Please select a category", MsException::BAD_INPUT); } else { if (!$cat_stack->get_top()->has_databases()) { throw new MsException('Please select a category that has databases!', MsException::BAD_INPUT); } } // get "the" database if ($wgRequest->getVal('ms-db')) { $database = new MsDatabase($wgRequest->getVal('ms-db')); } else { $database = $cat_stack->get_top()->get_one_database(MsCategory::AS_OBJECTS); } if (!$database) { throw new MsException("No db in top cat of {$cat_stack} / ms-db param"); } // verify that we've got some 'proxydriver' type driver. // We cannot handle other drivers! if (!$database->is_driver_type('proxydriver')) { throw new MsException("MsProxyPage can only handle 'proxydriver' databases. " . "Unfortunately [{$database}] is not such a database.", MsException::BAD_INSTALLATION); } // Load common proxy engine configuration // (for proxify, etc.) $proxy_conf = MsProxyConfiguration::get_instance(); // Get values for the template: $start_url = $database->get('start_url'); if (!$start_url) { throw new MsException("start_url field missing in config for {$database}!", MsException::BAD_CONFIGURATION); } $template = new MsProxyTemplate(); # eigentlich unnoetig: #$template->set_from_array($this->database->conf); $template->set('assistant_text', wfMsg('ms-assistant-starting-bla')); $template->set('assistant_msg', 'ms-assistant-happy'); $template->set('iframe_start', $proxy_conf->proxify($start_url)); # das ist jetzt eher quick & dirty, aber den cat_stack brauch dann keiner mehr: $cat_stack->pop(); # poppen fuer catchooser_link (damit der catchooser nicht direkt zur cat leitet) $template->set('leave_biokemika_link', '#'); $template->set('catchooser_link', $this->special_page->get_sub_title('choose')->escapeFullURL(str_replace('[]', '%5B%5D', $cat_stack->build_query('ms-cat')))); //print $template->get('iframe_start');exit(); $wgOut->addTemplate($template); }
public function get_hook() { // (sub) iframe injection $conf = MsProxyConfiguration::get_instance(); $html = '<!-- BioKemika Assistant Updater Hook: -->'; $html .= '<iframe style="display: none;" src="' . $conf->proxy_assistant_url . '?' . http_build_query($this->conf) . '"></iframe>'; $html .= '<!-- BioKemika Auto Iframe height updater hook -->'; $target_url = $conf->proxy_assistant_url . '?height='; $html .= <<<SCRIPT <script type="text/javascript"> // This is the MetaSearch iframe height updater injection //try{ \tvar old_onload = window.onload; \tvar target_url = "{$target_url}"; \twindow.onload = function(){ \t\tif (typeof(old_onload)=="function"){ \t\t\told_onload(); \t\t} \t\theight = document.body.scrollHeight + 10; \t\tdocument.getElementById('ms-proxy-iframe-height-updater-injection').src = \t\t\ttarget_url + height; \t}; //} catch(e) {} </script><iframe style="display:none;" id="ms-proxy-iframe-height-updater-injection" src=""></iframe> SCRIPT; $html .= '<!-- End of Hook -->'; return $html; }
function init() { // check and set default parameters $this->database->set_default('start_url', 'http://www.example.net'); $this->database->set_default('domain', 'www.example.net'); // Trigger initialisieren: Array mit Trigger-Objekten! // Nicht hier, erst wenn man sie (wirklich) braucht, // ist perfomanter. $this->conf = MsProxyConfiguration::get_instance(); }
* * www.your-site.com.proxy.biokemika.de/your/page.html * * Needs no rewriting, will just take a look at the * HTTP_HOST_NAME. * * This is a valid entry point to MediaWiki! **/ // lightweight MediaWiki Environment error_reporting(E_ALL); putenv('MW_INSTALL_PATH=' . dirname(__FILE__) . "/../.."); require_once '../../includes/WebStart.php'; // Set up Metasearch system require_once 'MetaSearch_body.php'; // important defs $conf = MsProxyConfiguration::get_instance(); $url = $conf->get_request_url(); $db = $conf->create_database($url); if (!$db) { throw new MsException("Got no DB for {$url}"); } // Set up HTTP Request $request = new HttpRequest($url); $options = array(); $headers = array(); if (isset($_SERVER['HTTP_USER_AGENT'])) { $headers['User-Agent'] = $_SERVER['HTTP_USER_AGENT']; } $options['timeout'] = 30; # Compression? Don't use since we've got at least 100mbit bandwith, # so that isn't important