strcspn bug: http://bugs.php.net/bug.php?id=39032
[mediawiki.git] / api.php
blobfd56db4ff3ba0af78bec422c9369eec0019ef093
1 <?php
4 /**
5 * API for MediaWiki 1.8+
7 * Copyright (C) 2006 Yuri Astrakhan <FirstnameLastname@gmail.com>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write to the Free Software Foundation, Inc.,
21 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 * http://www.gnu.org/copyleft/gpl.html
25 $wgApiStartTime = microtime(true);
27 /**
28 * When no format parameter is given, this format will be used
30 define('API_DEFAULT_FORMAT', 'xmlfm');
32 /**
33 * Location of all api-related files (must end with a slash '/')
35 define('API_DIR', 'includes/api/');
37 /**
38 * List of classes and containing files.
40 $wgApiAutoloadClasses = array (
42 'ApiMain' => API_DIR . 'ApiMain.php',
44 // Utility classes
45 'ApiBase' => API_DIR . 'ApiBase.php',
46 'ApiQueryBase' => API_DIR . 'ApiQueryBase.php',
47 'ApiResult' => API_DIR . 'ApiResult.php',
48 'ApiPageSet' => API_DIR . 'ApiPageSet.php',
50 // Formats
51 'ApiFormatBase' => API_DIR . 'ApiFormatBase.php',
52 'ApiFormatYaml' => API_DIR . 'ApiFormatYaml.php',
53 'ApiFormatXml' => API_DIR . 'ApiFormatXml.php',
54 'ApiFormatJson' => API_DIR . 'ApiFormatJson.php',
56 // Modules (action=...) - should match the $apiModules list
57 'ApiHelp' => API_DIR . 'ApiHelp.php',
58 'ApiLogin' => API_DIR . 'ApiLogin.php',
59 'ApiQuery' => API_DIR . 'ApiQuery.php',
61 // Query items (meta/prop/list=...)
62 'ApiQuerySiteinfo' => API_DIR . 'ApiQuerySiteinfo.php',
63 'ApiQueryInfo' => API_DIR . 'ApiQueryInfo.php',
64 'ApiQueryRevisions' => API_DIR . 'ApiQueryRevisions.php',
65 'ApiQueryAllpages' => API_DIR . 'ApiQueryAllpages.php'
68 /**
69 * List of available modules: action name => module class
70 * The class must also be listed in the $wgApiAutoloadClasses array.
72 $wgApiModules = array (
73 'help' => 'ApiHelp',
74 'login' => 'ApiLogin',
75 'query' => 'ApiQuery'
78 /**
79 * List of available formats: format name => format class
80 * The class must also be listed in the $wgApiAutoloadClasses array.
82 $wgApiFormats = array (
83 'json' => 'ApiFormatJson',
84 'jsonfm' => 'ApiFormatJson',
85 'xml' => 'ApiFormatXml',
86 'xmlfm' => 'ApiFormatXml',
87 'yaml' => 'ApiFormatYaml',
88 'yamlfm' => 'ApiFormatYaml'
91 // Initialise common code
92 require (dirname(__FILE__) . '/includes/WebStart.php');
93 wfProfileIn('api.php');
95 // Verify that the API has not been disabled
96 // The next line should be
97 // if (isset ($wgEnableAPI) && !$wgEnableAPI) {
98 // but will be in a safe mode until api is stabler
99 if (!isset ($wgEnableAPI) || !$wgEnableAPI) {
100 echo 'MediaWiki API is not enabled for this site. Add the following line to your LocalSettings.php';
101 echo '<pre><b>$wgEnableAPI=true;</b></pre>';
102 die(-1);
105 $wgAutoloadClasses = array_merge($wgAutoloadClasses, $wgApiAutoloadClasses);
107 if (!isset($wgEnableWriteAPI))
108 $wgEnableWriteAPI = false; // This should be 'true' later, once the api is stable.
110 $processor = new ApiMain($wgApiStartTime, $wgApiModules, $wgApiFormats, $wgEnableWriteAPI);
111 $processor->execute();
113 wfProfileOut('api.php');
114 wfLogProfilingData();
115 exit; // Done!