[ Index ]
 

Code source de Dotclear 1.2.5

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/layout/ -> lib.mod.php (source)

   1  <?php
   2  # ***** BEGIN LICENSE BLOCK *****
   3  # This file is part of DotClear.
   4  # Copyright (c) 2004 Olivier Meunier and contributors. All rights
   5  # reserved.
   6  #
   7  # DotClear is free software; you can redistribute it and/or modify
   8  # it under the terms of the GNU General Public License as published by
   9  # the Free Software Foundation; either version 2 of the License, or
  10  # (at your option) any later version.
  11  # 
  12  # DotClear is distributed in the hope that it will be useful,
  13  # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15  # GNU General Public License for more details.
  16  # 
  17  # You should have received a copy of the GNU General Public License
  18  # along with DotClear; if not, write to the Free Software
  19  # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  20  #
  21  # ***** END LICENSE BLOCK *****
  22  
  23  # Recherche d'un mode, des id, tout ça
  24  
  25  # Fix a bug in PHP 4.1 with queries like ?arg (and no value)
  26  function rebuildQuery()
  27  {
  28      if (!empty($_SERVER['QUERY_STRING']))
  29      {
  30          $q = explode('&',$_SERVER['QUERY_STRING']);
  31          $T = array();
  32          foreach ($q as $v)
  33          {
  34              $t = explode('=',$v);
  35              if (empty($t[1])) {
  36                  $t[1] = '0';
  37              }
  38              $T[] = $t[0].'='.$t[1];
  39          }
  40          return implode('&',$T);
  41      }
  42      return '';
  43  }
  44  
  45  function dcGetMod()
  46  {
  47      $args = '';
  48      
  49      if (!empty($_GET['q'])) {
  50          return 'search';
  51      }
  52      
  53      # Méthode de scan des URL
  54      if (dc_url_scan == 'path_info') {
  55          if (preg_match('/^'.preg_quote(dc_blog_url,'/').'(.*)$/',$_SERVER['REQUEST_URI'],$match)) {
  56              $args = preg_replace('/^[\/]?(.*?)[\/]?$/','$1',$match[1]);
  57          }
  58      } elseif (dc_url_scan == 'query_string' && !empty($_SERVER['QUERY_STRING'])) {
  59          parse_str(rebuildQuery(),$qs);
  60          $qs = array_keys($qs);
  61          if ($_GET[$qs[0]] == '') {
  62              $args = $qs[0];
  63              unset($_GET[$qs[0]]);
  64              unset($_REQUEST[$qs[0]]);
  65          }
  66      } else {
  67          $args = '';
  68      }
  69      
  70      if ($args != '' && preg_match('!^([a-z]{2}(-[a-z]{2})?)(/(.*)|\z)$!',$args,$match)) {
  71          $_GET['l'] = $match[1];
  72          $args = (!empty($match[4])) ? $match[4] : '';
  73      }
  74      
  75      if($args != '')
  76      {
  77          if(preg_match('!^([0-9]{4}/[0-9]{2})(/|\z)!',$args,$match))
  78          {
  79              $_GET['d'] = $match[1];
  80              if(preg_match('!^([0-9]{4}/[0-9]{2}/[0-9]{2})(/|\z)!',$args,$match))
  81              {
  82                  $_GET['d'] = $match[1];
  83                  if(preg_match('!^[0-9]{4}/[0-9]{2}/[0-9]{2}/([0-9]+)!',$args,$match))
  84                  {
  85                      $_GET['p'] = $match[1];
  86                  }
  87              }
  88          }
  89          elseif(preg_match('!^([A-Z][A-Za-z0-9_-]*)([^/]*)?(/|\z)!',$args,$match))
  90          {
  91              $_GET['cat'] = $match[1];
  92              if(preg_match('!^[A-Z][A-Za-z0-9_-]*([^/]*?)/([0-9]{4}/[0-9]{2})!',$args,$match))
  93              {
  94                  $_GET['d'] = $match[2];
  95                  if(preg_match('!^[A-Z][A-Za-z0-9_-]*([^/]*)?/([0-9]{4}/[0-9]{2}/[0-9]{2})!',$args,$match))
  96                  {
  97                      $_GET['d'] = $match[2];
  98                  }
  99              }
 100          }
 101          
 102      }
 103      
 104      $GLOBALS['dc_args'] = $args;
 105      
 106      if (!empty($_GET['p'])) {
 107          return 'post';
 108      } elseif (!empty($_GET['d']) && strlen($_GET['d']) == 10) {
 109          return 'day';
 110      } elseif (!empty($_GET['d']) && strlen($_GET['d']) == 7) {
 111          return 'month';
 112      } elseif (!empty($_GET['cat'])) {
 113          return 'cat';
 114      } else {
 115          return 'home';
 116      }
 117  }
 118  ?>


Généré le : Fri Feb 23 21:40:15 2007 par Balluche grâce à PHPXref 0.7