Advertisement
Guest User

seourl.php

a guest
Jul 29th, 2013
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.65 KB | None | 0 0
  1. <?php
  2. class ControllerCommonSeoUrl extends Controller {
  3.     public function index() {
  4.         if (isset($this->request->get['_route_'])) {
  5.             $parts = explode('/', $this->request->get['_route_']);
  6.            
  7.             foreach ($parts as $part) {
  8.                 $query = $this->db->query("SELECT * FROM " . DB_PREFIX . "url_alias WHERE keyword = '" . $this->db->escape($part) . "'");
  9.                
  10.                 if ($query->num_rows) {
  11.                     $url = explode('=', $query->row['query']);
  12.                    
  13.                     if ($url[0] == 'product_id') {
  14.                         $this->request->get['product_id'] = $url[1];
  15.                     }
  16.                    
  17.                     if ($url[0] == 'category_id') {
  18.                         if (!isset($this->request->get['path'])) {
  19.                             $this->request->get['path'] = $url[1];
  20.                         } else {
  21.                             $this->request->get['path'] = '_' . $url[1];
  22.                         }
  23.                     }  
  24.                    
  25.                     if ($url[0] == 'manufacturer_id') {
  26.                         $this->request->get['manufacturer_id'] = $url[1];
  27.                     }
  28.                    
  29.                     if ($url[0] == 'information_id') {
  30.                         $this->request->get['information_id'] = $url[1];
  31.                     }  
  32.                 } else {
  33.                     $this->request->get['route'] = 'error/not_found';  
  34.                 }
  35.             }
  36.            
  37.             if (isset($this->request->get['product_id'])) {
  38.                 $this->request->get['route'] = 'product/product';
  39.             } elseif (isset($this->request->get['path'])) {
  40.                 $this->request->get['route'] = 'product/category';
  41.             } elseif (isset($this->request->get['manufacturer_id'])) {
  42.                 $this->request->get['route'] = 'product/manufacturer';
  43.             } elseif (isset($this->request->get['information_id'])) {
  44.                 $this->request->get['route'] = 'information/information';
  45.             }
  46.            
  47.             if (isset($this->request->get['route'])) {
  48.                 return $this->forward($this->request->get['route']);
  49.             }
  50.         }
  51.     }
  52. }
  53. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement