123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118 |
- <?php
- function rebuildQuery()
- {
- if (!empty($_SERVER['QUERY_STRING']))
- {
- $q = explode('&',$_SERVER['QUERY_STRING']);
- $T = array();
- foreach ($q as $v)
- {
- $t = explode('=',$v);
- if (empty($t[1])) {
- $t[1] = '0';
- }
- $T[] = $t[0].'='.$t[1];
- }
- return implode('&',$T);
- }
- return '';
- }
- function dcGetMod()
- {
- $args = '';
-
- if (!empty($_GET['q'])) {
- return 'search';
- }
-
-
- if (dc_url_scan == 'path_info') {
- if (preg_match('/^'.preg_quote(dc_blog_url,'/').'(.*)$/',$_SERVER['REQUEST_URI'],$match)) {
- $args = preg_replace('/^[\/]?(.*?)[\/]?$/','$1',$match[1]);
- }
- } elseif (dc_url_scan == 'query_string' && !empty($_SERVER['QUERY_STRING'])) {
- parse_str(rebuildQuery(),$qs);
- $qs = array_keys($qs);
- if ($_GET[$qs[0]] == '') {
- $args = $qs[0];
- unset($_GET[$qs[0]]);
- unset($_REQUEST[$qs[0]]);
- }
- } else {
- $args = '';
- }
-
- if ($args != '' && preg_match('!^([a-z]{2}(-[a-z]{2})?)(/(.*)|\z)$!',$args,$match)) {
- $_GET['l'] = $match[1];
- $args = (!empty($match[4])) ? $match[4] : '';
- }
-
- if($args != '')
- {
- if(preg_match('!^([0-9]{4}/[0-9]{2})(/|\z)!',$args,$match))
- {
- $_GET['d'] = $match[1];
- if(preg_match('!^([0-9]{4}/[0-9]{2}/[0-9]{2})(/|\z)!',$args,$match))
- {
- $_GET['d'] = $match[1];
- if(preg_match('!^[0-9]{4}/[0-9]{2}/[0-9]{2}/([0-9]+)!',$args,$match))
- {
- $_GET['p'] = $match[1];
- }
- }
- }
- elseif(preg_match('!^([A-Z][A-Za-z0-9_-]*)([^/]*)?(/|\z)!',$args,$match))
- {
- $_GET['cat'] = $match[1];
- if(preg_match('!^[A-Z][A-Za-z0-9_-]*([^/]*?)/([0-9]{4}/[0-9]{2})!',$args,$match))
- {
- $_GET['d'] = $match[2];
- if(preg_match('!^[A-Z][A-Za-z0-9_-]*([^/]*)?/([0-9]{4}/[0-9]{2}/[0-9]{2})!',$args,$match))
- {
- $_GET['d'] = $match[2];
- }
- }
- }
-
- }
-
- $GLOBALS['dc_args'] = $args;
-
- if (!empty($_GET['p'])) {
- return 'post';
- } elseif (!empty($_GET['d']) && strlen($_GET['d']) == 10) {
- return 'day';
- } elseif (!empty($_GET['d']) && strlen($_GET['d']) == 7) {
- return 'month';
- } elseif (!empty($_GET['cat'])) {
- return 'cat';
- } else {
- return 'home';
- }
- }
- ?>
|