diff options
| author | ctrlcctrlv <wizardchan@hush.com> | 2013-08-20 16:53:05 +0000 |
|---|---|---|
| committer | ctrlcctrlv <wizardchan@hush.com> | 2013-08-20 16:53:05 +0000 |
| commit | a29a9324eaec81938869ceb66cb99b2deebb84b1 (patch) | |
| tree | 4ea9e90e2810810df7edd5c7785ca2d0d0a4f998 /inc | |
| parent | db5ce2cb8ff90c3a0a47dd8a0da91fb3bdb0851b (diff) | |
Make it possible to disable API, disable it by default
Diffstat (limited to 'inc')
| -rw-r--r-- | inc/config.php | 9 | ||||
| -rw-r--r-- | inc/functions.php | 36 |
2 files changed, 31 insertions, 14 deletions
diff --git a/inc/config.php b/inc/config.php index ae3ce0c0..f7226614 100644 --- a/inc/config.php +++ b/inc/config.php @@ -1343,6 +1343,15 @@ // }); /* + * ============= + * API settings + * ============= + */ + + // Whether or not to use the API, disabled by default. + $config['api']['enabled'] = false; + +/* * ==================== * Other/uncategorized * ==================== diff --git a/inc/functions.php b/inc/functions.php index a75ebb8a..a8dd1dda 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -1299,8 +1299,10 @@ function buildIndex() { if (!$config['try_smarter']) $antibot = create_antibot($board['uri']); - $api = new Api(); - $catalog = array(); + if ($config['api']['enabled']) { + $api = new Api(); + $catalog = array(); + } for ($page = 1; $page <= $config['max_pages']; $page++) { $filename = $board['dir'] . ($page == 1 ? $config['file_index'] : sprintf($config['file_page'], $page)); @@ -1324,12 +1326,14 @@ function buildIndex() { file_write($filename, Element('index.html', $content)); // json api - $threads = $content['threads']; - $json = json_encode($api->translatePage($threads)); - $jsonFilename = $board['dir'] . ($page-1) . ".json"; // pages should start from 0 - file_write($jsonFilename, $json); + if ($config['api']['enabled']) { + $threads = $content['threads']; + $json = json_encode($api->translatePage($threads)); + $jsonFilename = $board['dir'] . ($page-1) . ".json"; // pages should start from 0 + file_write($jsonFilename, $json); - $catalog[$page-1] = $threads; + $catalog[$page-1] = $threads; + } } if ($page < $config['max_pages']) { for (;$page<=$config['max_pages'];$page++) { @@ -1342,9 +1346,11 @@ function buildIndex() { } // json api catalog - $json = json_encode($api->translateCatalog($catalog)); - $jsonFilename = $board['dir'] . "catalog.json"; - file_write($jsonFilename, $json); + if ($config['api']['enabled']) { + $json = json_encode($api->translateCatalog($catalog)); + $jsonFilename = $board['dir'] . "catalog.json"; + file_write($jsonFilename, $json); + } } function buildJavascript() { @@ -1765,10 +1771,12 @@ function buildThread($id, $return = false, $mod = false) { $build_pages[] = thread_find_page($id); // json api - $api = new Api(); - $json = json_encode($api->translateThread($thread)); - $jsonFilename = $board['dir'] . $config['dir']['res'] . $id . ".json"; - file_write($jsonFilename, $json); + if ($config['api']['enabled']) { + $api = new Api(); + $json = json_encode($api->translateThread($thread)); + $jsonFilename = $board['dir'] . $config['dir']['res'] . $id . ".json"; + file_write($jsonFilename, $json); + } if ($return) { return $body; |
