<?php
+if ( isset( $_SERVER ) && array_key_exists( 'REQUEST_METHOD', $_SERVER ) ) {
+ print "This script must be run from the command line\n";
+ exit();
+}
+
+
require_once('nusoap.php');
$t = 'Hello, World!';
-$s = new soapclient( 'http://localhost:80/soap/' );
+$s = new soapclient( 'http://mediawiki.mormo.org:80/soap/' );
print "==echoString==\n";
$r = $s->call( 'echoString', array( $t ) );
print( "Error: ".$s->getError() . "\n" );
print "\n\n==searchTitles==\n";
-$r = $s->call( 'searchTitles', array( 'furt', 1 ) );
+$r = $s->call( 'searchTitles', array( 'Frankfurt', 0 ) );
print_r( $r );
print( "Error: ".$s->getError() . "\n" );
@ini_set( "allow_url_fopen", 0 ); # For security...
if(!file_exists("../LocalSettings.php")) {
- die( "You'll have to <a href='config/index.php'>set the wiki up</a> first!" );
+ die( "You'll have to <a href='../config/index.php'>set the wiki up</a> first!" );
}
define( "MEDIAWIKI", true );
if ( $main_only != 0 && $main_only != 1 ) {
return new soap_fault('Client', 'The second parameter to this service must be 0 or 1');
}
+
- # Query the DB
+ # Connect to the DB
$dbr =& wfGetDB( DB_SLAVE );
- $sql = 'SELECT cur_title, cur_namespace FROM cur WHERE '
+ # Normalize the search pattern
+ $pattern = $dbr->strencode( $wgLang->stripForSearch( $pattern ) );
+
+ # Prepare the query
+
+ $sql = 'SELECT cur_id, cur_namespace, cur_title FROM cur, searchindex WHERE '
. ( $main_only ? 'cur_namespace=0 AND ' :'' )
- . "cur_title like '%".$dbr->strencode($pattern)."%'";
+ . "cur_id=si_page AND MATCH(si_title) AGAINST('{$pattern}' IN BOOLEAN MODE)";
$res = $dbr->query( $sql, $fname, true );
}
$answer = array(
- 'count' => 1,
+ 'count' => 0,
'base' => $wgServer.$wgArticlePath,
- 'hits' => array()
+ 'hits' => array(),
);
- while ( $line = $dbr->fetchObject( $res ) && $answer['count'] < 200 ) {
+ while ( ($line = $dbr->fetchObject( $res )) && $answer['count'] < 200 ) {
$nt = Title::newFromDBkey( $wgLang->getNsText( $line->cur_namespace ) . ':' . $line->cur_title );
$answer['hits'][] = array(
'title' => $nt->getText(),