summaryrefslogtreecommitdiff
path: root/inc/functions.php
diff options
context:
space:
mode:
authorMichael Save <savetheinternet@tinyboard.org>2012-03-14 15:38:28 +1100
committerMichael Save <savetheinternet@tinyboard.org>2012-03-14 15:38:28 +1100
commite09dd8782efae9226c31ab67d61456a5ef0bfe8d (patch)
tree3dc9f502049c4961faa95f8ea8811ca8d9d160d2 /inc/functions.php
parentc8d1f1cdd4439933f9bd4a451ec73b26d21b97d8 (diff)
less warnings in CLI mode
Diffstat (limited to 'inc/functions.php')
-rw-r--r--inc/functions.php40
1 files changed, 22 insertions, 18 deletions
diff --git a/inc/functions.php b/inc/functions.php
index d7136fa7..12b51d25 100644
--- a/inc/functions.php
+++ b/inc/functions.php
@@ -45,24 +45,28 @@
$config['post_url'] = $config['root'] . $config['file_post'];
if(!isset($config['referer_match']))
- $config['referer_match'] = '/^' .
- (preg_match($config['url_regex'], $config['root']) ? '' :
- 'https?:\/\/' . $_SERVER['HTTP_HOST']) .
- preg_quote($config['root'], '/') .
- '(' .
- str_replace('%s', '\w+', preg_quote($config['board_path'], '/')) .
- '(' .
- preg_quote($config['file_index'], '/') . '|' .
- str_replace('%d', '\d+', preg_quote($config['file_page'])) .
- ')?' .
- '|' .
- str_replace('%s', '\w+', preg_quote($config['board_path'], '/')) .
- preg_quote($config['dir']['res'], '/') .
- str_replace('%d', '\d+', preg_quote($config['file_page'], '/')) .
- '|' .
- preg_quote($config['file_mod'], '/') . '\?\/.+' .
- ')([#?](.+)?)?$/i';
-
+ if(isset($_SERVER['HTTP_HOST'])) {
+ $config['referer_match'] = '/^' .
+ (preg_match($config['url_regex'], $config['root']) ? '' :
+ 'https?:\/\/' . $_SERVER['HTTP_HOST']) .
+ preg_quote($config['root'], '/') .
+ '(' .
+ str_replace('%s', '\w+', preg_quote($config['board_path'], '/')) .
+ '(' .
+ preg_quote($config['file_index'], '/') . '|' .
+ str_replace('%d', '\d+', preg_quote($config['file_page'])) .
+ ')?' .
+ '|' .
+ str_replace('%s', '\w+', preg_quote($config['board_path'], '/')) .
+ preg_quote($config['dir']['res'], '/') .
+ str_replace('%d', '\d+', preg_quote($config['file_page'], '/')) .
+ '|' .
+ preg_quote($config['file_mod'], '/') . '\?\/.+' .
+ ')([#?](.+)?)?$/i';
+ } else {
+ // CLI mode
+ $config['referer_match'] = '//';
+ }
if(!isset($config['cookies']['path']))
$config['cookies']['path'] = &$config['root'];