Is there a simple way to extract basic data from a MediaWiki install from *outside* the main scripts?
For example, suppose you need to have an ordinary static HTML page, but have it access the current NUMBEROFARTICLES from the wiki. (This is for a situation where the wiki is part of a larger site, not the entire site in itself. Something along the lines of "while you are here, check out our wiki, which has NUMBEROFARTICLES articles".)
Obviously, the page would need a little bit of PHP code to do this - which doesn't sound difficult in itself - but I am unsure of what I'd need to do to persuade the MediaWiki scripts that it OK to provide this information.
Thanks for any help,
Tony
You don't really have to "convince" mediawiki to give you that info - just build a script that queries the database for the info you want.
Here's one that works on MediaWiki 1.4.4. I just took index.php, stripped it down, added a few lines of code from SiteStatsUpdate.php, and viola. Call it articlecount.php and put it alongside index.php, access it with http://yoursite.com/articlecount.php. You could grab it from another app using either CURL or file_get_contents() if Apache is setup to allow it - usually is by default.
<?php
$wgRequestTime = microtime();
unset( $IP );
@ini_set( 'allow_url_fopen', 0 ); # For security...
define( 'MEDIAWIKI', true );
include( './includes/Defines.php' ); include( './LocalSettings.php' ); include( 'includes/Setup.php' );
$dbr =& wfGetDB( DB_SLAVE ); extract( $dbr->tableNames( 'cur' ) ); $sql = "SELECT COUNT(cur_namespace) AS total FROM $cur"; $res = $dbr->query( $sql, $fname ); $curRow = $dbr->fetchObject( $res ); $pages = $curRow->total + $this->mPages; echo $pages;
?>
- MHart
----- Original Message ----- From: "Tony Wilson" mediawiki@redhill.net.au To: mediawiki-l@Wikimedia.org Sent: Tuesday, June 28, 2005 7:03 AM Subject: [Mediawiki-l] Extracting simple wiki data from an HTML page
Is there a simple way to extract basic data from a MediaWiki install from *outside* the main scripts?
For example, suppose you need to have an ordinary static HTML page, but have it access the current NUMBEROFARTICLES from the wiki. (This is for a situation where the wiki is part of a larger site, not the entire site in itself. Something along the lines of "while you are here, check out our wiki, which has NUMBEROFARTICLES articles".)
Obviously, the page would need a little bit of PHP code to do this - which doesn't sound difficult in itself - but I am unsure of what I'd need to do to persuade the MediaWiki scripts that it OK to provide this information.
Thanks for any help,
Tony _______________________________________________ MediaWiki-l mailing list MediaWiki-l@Wikimedia.org http://mail.wikipedia.org/mailman/listinfo/mediawiki-l
Frequently in situations like that, I prefer to do a few things: * Make it an include and output the text it gives me * Make it output Javascript and include a <script> tag in the HTML.
On 6/28/05, MHart wiki@matthart.com wrote:
You don't really have to "convince" mediawiki to give you that info - just build a script that queries the database for the info you want.
Here's one that works on MediaWiki 1.4.4. I just took index.php, stripped it down, added a few lines of code from SiteStatsUpdate.php, and viola. Call it articlecount.php and put it alongside index.php, access it with http://yoursite.com/articlecount.php. You could grab it from another app using either CURL or file_get_contents() if Apache is setup to allow it - usually is by default.
<?php $wgRequestTime = microtime(); unset( $IP ); @ini_set( 'allow_url_fopen', 0 ); # For security... define( 'MEDIAWIKI', true ); include( './includes/Defines.php' ); include( './LocalSettings.php' ); include( 'includes/Setup.php' ); $dbr =& wfGetDB( DB_SLAVE ); extract( $dbr->tableNames( 'cur' ) ); $sql = "SELECT COUNT(cur_namespace) AS total FROM $cur"; $res = $dbr->query( $sql, $fname ); $curRow = $dbr->fetchObject( $res ); $pages = $curRow->total + $this->mPages; echo $pages; ?>
- MHart
----- Original Message ----- From: "Tony Wilson" mediawiki@redhill.net.au To: mediawiki-l@Wikimedia.org Sent: Tuesday, June 28, 2005 7:03 AM Subject: [Mediawiki-l] Extracting simple wiki data from an HTML page
Is there a simple way to extract basic data from a MediaWiki install from *outside* the main scripts?
For example, suppose you need to have an ordinary static HTML page, but have it access the current NUMBEROFARTICLES from the wiki. (This is for a situation where the wiki is part of a larger site, not the entire site in itself. Something along the lines of "while you are here, check out our wiki, which has NUMBEROFARTICLES articles".)
Obviously, the page would need a little bit of PHP code to do this - which doesn't sound difficult in itself - but I am unsure of what I'd need to do to persuade the MediaWiki scripts that it OK to provide this information.
Thanks for any help,
Tony _______________________________________________ MediaWiki-l mailing list MediaWiki-l@Wikimedia.org http://mail.wikipedia.org/mailman/listinfo/mediawiki-l
MediaWiki-l mailing list MediaWiki-l@Wikimedia.org http://mail.wikipedia.org/mailman/listinfo/mediawiki-l
mediawiki-l@lists.wikimedia.org