haraldpdl / oscommerce forked from osCommerce/oscommerce

osCommerce Online Merchant v3.x

This URL has Read+Write access

commit  57308c5e88eae1e278cdef471397e20129e5ae66
tree    65f58710726c222ae3657ddf18257fb4bfd0afe3
parent  7c37dfd984dead1abc9b0673341ce7fe5ea4b7b6
oscommerce / redirect.php
100644 82 lines (67 sloc) 3.919 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<?php
/*
$Id$
 
osCommerce, Open Source E-Commerce Solutions
http://www.oscommerce.com
 
Copyright (c) 2007 osCommerce
 
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License v2 (1991)
as published by the Free Software Foundation.
*/
 
  $_SERVER['SCRIPT_FILENAME'] = __FILE__;
 
  require('includes/application_top.php');
 
  switch ($_GET['action']) {
    case 'banner':
      if (isset($_GET['goto']) && is_numeric($_GET['goto'])) {
        if ($osC_Services->isStarted('banner') && $osC_Banner->isActive($_GET['goto'])) {
          osc_redirect($osC_Banner->getURL($_GET['goto'], true));
        }
      }
      break;
 
    case 'url':
      if (isset($_GET['goto']) && !empty($_GET['goto'])) {
        $Qcheck = $osC_Database->query('select products_url from :table_products_description where products_url = :products_url limit 1');
        $Qcheck->bindTable(':table_products_description', TABLE_PRODUCTS_DESCRIPTION);
        $Qcheck->bindValue(':products_url', $_GET['goto']);
        $Qcheck->execute();
 
        if ($Qcheck->numberOfRows() === 1) {
          osc_redirect('http://' . $_GET['goto']);
        }
      }
      break;
 
    case 'manufacturer':
      if (isset($_GET['manufacturers_id']) && !empty($_GET['manufacturers_id'])) {
        $Qmanufacturer = $osC_Database->query('select manufacturers_url from :table_manufacturers_info where manufacturers_id = :manufacturers_id and languages_id = :languages_id');
        $Qmanufacturer->bindTable(':table_manufacturers_info', TABLE_MANUFACTURERS_INFO);
        $Qmanufacturer->bindInt(':manufacturers_id', $_GET['manufacturers_id']);
        $Qmanufacturer->bindInt(':languages_id', $osC_Language->getID());
        $Qmanufacturer->execute();
 
        if ($Qmanufacturer->numberOfRows() && !osc_empty($Qmanufacturer->value('manufacturers_url'))) {
          $Qupdate = $osC_Database->query('update :table_manufacturers_info set url_clicked = url_clicked+1, date_last_click = now() where manufacturers_id = :manufacturers_id and languages_id = :languages_id');
          $Qupdate->bindTable(':table_manufacturers_info', TABLE_MANUFACTURERS_INFO);
          $Qupdate->bindInt(':manufacturers_id', $_GET['manufacturers_id']);
          $Qupdate->bindInt(':languages_id', $osC_Language->getID());
          $Qupdate->execute();
 
          osc_redirect($Qmanufacturer->value('manufacturers_url'));
        } else {
// no url exists for the selected language, lets use the default language then
          $Qmanufacturer = $osC_Database->query('select mi.languages_id, mi.manufacturers_url from :table_manufacturers_info mi, :table_languages l where mi.manufacturers_id = :manufacturers_id and mi.languages_id = l.languages_id and l.code = :code');
          $Qmanufacturer->bindTable(':table_manufacturers_info', TABLE_MANUFACTURERS_INFO);
          $Qmanufacturer->bindTable(':table_languages', TABLE_LANGUAGES);
          $Qmanufacturer->bindInt(':manufacturers_id', $_GET['manufacturers_id']);
          $Qmanufacturer->bindValue(':code', DEFAULT_LANGUAGE);
          $Qmanufacturer->execute();
 
          if ($Qmanufacturer->numberOfRows() && !osc_empty($Qmanufacturer->value('manufacturers_url'))) {
            $Qupdate = $osC_Database->query('update :table_manufacturers_info set url_clicked = url_clicked+1, date_last_click = now() where manufacturers_id = :manufacturers_id and languages_id = :languages_id');
            $Qupdate->bindTable(':table_manufacturers_info', TABLE_MANUFACTURERS_INFO);
            $Qupdate->bindInt(':manufacturers_id', $_GET['manufacturers_id']);
            $Qupdate->bindInt(':languages_id', $Qmanufacturer->valueInt('languages_id'));
            $Qupdate->execute();
 
            osc_redirect($Qmanufacturer->value('manufacturers_url'));
          }
        }
      }
      break;
  }
 
  osc_redirect(osc_href_link(FILENAME_DEFAULT));
?>