[ Index ]

PHP Cross Reference of phpwcms V1.4.3 _r380 (23.11.09)

title

Body

[close]

/include/inc_act/ -> ajax_connector.php (source)

   1  <?php
   2  /*************************************************************************************
   3     Copyright notice
   4     
   5     (c) 2002-2009 Oliver Georgi (oliver@phpwcms.de) // All rights reserved.
   6   
   7     This script is part of PHPWCMS. The PHPWCMS web content management system is
   8     free software; you can redistribute it and/or modify it under the terms of
   9     the GNU General Public License as published by the Free Software Foundation;
  10     either version 2 of the License, or (at your option) any later version.
  11    
  12     The GNU General Public License can be found at http://www.gnu.org/copyleft/gpl.html
  13     A copy is found in the textfile GPL.txt and important notices to the license 
  14     from the author is found in LICENSE.txt distributed with these scripts.
  15    
  16     This script is distributed in the hope that it will be useful, but WITHOUT ANY 
  17     WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
  18     PARTICULAR PURPOSE.  See the GNU General Public License for more details.
  19   
  20     This copyright notice MUST APPEAR in all copies of the script!
  21  *************************************************************************************/
  22  
  23  // general wrapper for ajax based queries
  24  
  25  session_start();
  26  $phpwcms = array();
  27  require('../../config/phpwcms/conf.inc.php');
  28  require ('../inc_lib/default.inc.php');
  29  require (PHPWCMS_ROOT.'/include/inc_lib/dbcon.inc.php');
  30  require (PHPWCMS_ROOT.'/include/inc_lib/general.inc.php');
  31  require (PHPWCMS_ROOT.'/include/inc_lib/backend.functions.inc.php');
  32  
  33  if(empty($_SESSION["wcs_user"])) {
  34      die('Sorry, access forbidden');
  35  }
  36  
  37  $action        = isset($_POST['action']) ? $_POST['action'] : false;
  38  $method        = isset($_POST['method']) ? $_POST['method'] : 'json';
  39  $value        = isset($_POST['value']) ? $_POST['value'] : 'json';
  40  
  41  // do charset conversions for value
  42  if(PHPWCMS_CHARSET != 'utf-8') {
  43  
  44      if(function_exists('mb_convert_encoding')) {
  45      
  46          $value = @mb_convert_encoding( $value, PHPWCMS_CHARSET, 'utf-8' );
  47      
  48      } else {
  49  
  50          $value = utf8_decode($value);
  51  
  52      }
  53  
  54  }
  55  
  56  $data        = array();
  57  
  58  switch($action) {
  59  
  60      case 'category':        $where  = "cat_status=1 AND cat_type NOT IN('module_shop') AND ";
  61                              $where .= "cat_name LIKE '" . aporeplace( preg_replace('/[^\w\- ]/', '', $value) ) . "%'";
  62                              $result = _dbGet('phpwcms_categories', 'cat_name', $where, 'cat_name', 'cat_name', 20);
  63      
  64                              if(isset($result[0])) {
  65      
  66                                  foreach($result as $value) {
  67                                      $data[] = utf8_encode($value['cat_name']);
  68                                  }
  69                              }
  70                              break;
  71                              
  72      case 'newstags':        $where  = "cat_status=1 AND cat_type='news' AND ";
  73                              $where .= "cat_name LIKE '" . aporeplace( preg_replace('/[^\w\- ]/', '', $value) ) . "%'";
  74                              $result = _dbGet('phpwcms_categories', 'cat_name', $where, 'cat_name', 'cat_name', 20);
  75      
  76                              if(isset($result[0])) {
  77      
  78                                  foreach($result as $value) {
  79                                      $data[] = utf8_encode($value['cat_name']);
  80                                  }
  81                              }
  82                              break;
  83                          
  84      case 'lang':            $data = is_array($phpwcms['allowed_lang']) && count($phpwcms['allowed_lang']) ? $phpwcms['allowed_lang'] : array($phpwcms['default_lang']);
  85                              sort($data);
  86                              break;
  87  
  88  }
  89  
  90  switch($method) {
  91      
  92      
  93      default:    header('Content-type: application/json');
  94                  if(!function_exists('json_encode')) {
  95                      
  96                      require (PHPWCMS_ROOT.'/include/inc_ext/JSON/JSON.php');
  97                      $json = new Services_JSON();
  98  
  99                      echo $json->encode( $data );
 100                  
 101                  } else {
 102  
 103                      echo json_encode( $data );
 104                  
 105                  }
 106                  
 107  
 108  }
 109  
 110  
 111  ?>


Generated: Wed Dec 30 05:55:15 2009 Cross-referenced by PHPXref 0.7