- <?php
-
- function buildURL($URI, $https = false)
- {
- $url = 'http';
- if ($https && USE_HTTPS)
- $url .= 's';
-
- $url .= '://'.FORUM_DOMAIN;
- if ($https && USE_HTTPS && HTTPS_PORT != 443)
- $url .= ':'.HTTPS_PORT;
-
- if ((!$https || !USE_HTTPS) && HTTP_PORT != 80)
- $url .= ':'.HTTP_PORT;
-
- if (strpos($URI, FORUM_PATH) === 0)
- $url .= $URI;
- else
- $url .= FORUM_PATH.'/'.$URI;
-
- return $url;
- }
-
- function post_default($key, $default='')
- {
- $_POST[$key] = (isset($_POST[$key])) ? stripslashes($_POST[$key]) : $default;
- }
-
- function input_clean(&$input, &$dbobj, $opts = null)
- {
- $input = trim($input);
-
- if ($opts != null)
- {
- if (in_array('spchars', $opts)) //special chars
- $input = htmlspecialchars($input);
-
- if (in_array('strip', $opts)) //strip tags
- $input = strip_tags($input);
-
- if (in_array('nnegint', $opts)) //non-negative integer
- {
- $int_options = array('options' => array('min_range' => 0));
- $input = filter_var($input, FILTER_VALIDATE_INT, $int_options);
- }
- }
- else
- $input = strip_tags($input);
-
- $input = $dbobj->real_escape_string($input);
- }
-
- function post_clean($key, &$dbobj, $opts = null)
- {
- input_clean($_POST[$key], $dbobj, $opts);
- }
-
- function get_clean($key, &$dbobj, $intval = true)
- {
- if (array_key_exists($key, $_GET))
- {
- $opts = ($intval) ? array('strip', 'nnegint') : null;
- input_clean($_GET[$key], $dbobj, $opts);
- }
- else
- {
- $_GET[$key] = ($intval) ? 0 : '';
- }
- }
- ?>
|