This repository has been archived by the owner on Jun 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 201
/
redirect.php
55 lines (43 loc) · 2.38 KB
/
redirect.php
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
<?php
/*
$Id$
osCommerce, Open Source E-Commerce Solutions
http://www.oscommerce.com
Copyright (c) 2003 osCommerce
Released under the GNU General Public License
*/
require('includes/application_top.php');
switch ($_GET['action']) {
case 'url':
if (isset($_GET['goto']) && tep_not_null($_GET['goto'])) {
$check_query = tep_db_query("select products_url from products_description where products_url = '" . tep_db_input($_GET['goto']) . "' limit 1");
if (tep_db_num_rows($check_query)) {
tep_redirect($_GET['goto']);
}
}
break;
case 'manufacturer':
if (isset($_GET['manufacturers_id']) && tep_not_null($_GET['manufacturers_id'])) {
$manufacturer_query = tep_db_query("select manufacturers_url from manufacturers_info where manufacturers_id = '" . (int)$_GET['manufacturers_id'] . "' and languages_id = '" . (int)$languages_id . "'");
if (tep_db_num_rows($manufacturer_query)) {
// url exists in selected language
$manufacturer = tep_db_fetch_array($manufacturer_query);
if (tep_not_null($manufacturer['manufacturers_url'])) {
tep_db_query("update manufacturers_info set url_clicked = url_clicked+1, date_last_click = now() where manufacturers_id = '" . (int)$_GET['manufacturers_id'] . "' and languages_id = '" . (int)$languages_id . "'");
tep_redirect($manufacturer['manufacturers_url']);
}
} else {
// no url exists for the selected language, lets use the default language then
$manufacturer_query = tep_db_query("select mi.languages_id, mi.manufacturers_url from manufacturers_info mi, languages l where mi.manufacturers_id = '" . (int)$_GET['manufacturers_id'] . "' and mi.languages_id = l.languages_id and l.code = '" . DEFAULT_LANGUAGE . "'");
if (tep_db_num_rows($manufacturer_query)) {
$manufacturer = tep_db_fetch_array($manufacturer_query);
if (tep_not_null($manufacturer['manufacturers_url'])) {
tep_db_query("update manufacturers_info set url_clicked = url_clicked+1, date_last_click = now() where manufacturers_id = '" . (int)$_GET['manufacturers_id'] . "' and languages_id = '" . (int)$manufacturer['languages_id'] . "'");
tep_redirect($manufacturer['manufacturers_url']);
}
}
}
}
break;
}
tep_redirect(tep_href_link('index.php'));