- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 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
<?php
if($_GET['id'] == 10 ){
$location = "/articles/lyustry/lustra-na-kuhne/";
}elseif($_GET['id'] == 13 and $_GET['id_type'] == 17){
$location = "/market/interernye_svetilniki/lyustry/";
}elseif(
$_GET['id'] == 13 and $_GET['id_type'] == 22 and $_GET['act'] == 'sub_type'){
$location = "/market/interernye_svetilniki/bolshie_lyustry/";
}elseif(
$_GET['id'] == 13 and $_GET['id_type'] == 34 and $_GET['act'] == 'sub_type'){
$location = "/market/interernye_svetilniki/lyustry/bolee_6_rozhkov/";
}elseif(
$_GET['id'] == 13 and $_GET['id_type'] == 2 ){
$location = "/market/interernye_svetilniki/podvesnye/";
}elseif(
$_GET['id'] == 13 and $_GET['id_type'] == 40 and $_GET['act'] == 'sub_type'){
$location = "/market/interernye_svetilniki/podvesnye/odinochnyj_podves/";
}elseif(
$_GET['id'] == 13 and $_GET['id_type'] == 41 and $_GET['act'] == 'sub_type'){
$location = "/market/interernye_svetilniki/podvesnye/trojnoj_i_bolee/";
}elseif(
$_GET['id'] == 13 and $_GET['id_type'] == 5 ){
$location = "/market/interernye_svetilniki/nastenno-potolochnye/";
}elseif(
$_GET['id'] == 13 and $_GET['id_type'] == 35 and $_GET['act'] == 'sub_type'){
$location = "/market/interernye_svetilniki/potolochnye/";
}elseif(
$_GET['id'] == 13 and $_GET['id_type'] == 52 ){
$location = "/market/interernye_svetilniki/vlagozawitnye/";
}elseif(
$_GET['id'] == 13 and $_GET['id_type'] == 51 ){
$location = "/market/interernye_svetilniki/podsvetka_kartin/";
}elseif(
$_GET['id'] == 13 and $_GET['id_type'] == 7 ){
$location = "/market/interernye_svetilniki/bra/";
}elseif(
$_GET['id'] == 13 and $_GET['id_type'] == 37 and $_GET['act'] == 'sub_type'){
$location = "/market/interernye_svetilniki/bra/odnorozhkovye/";
}elseif(
$_GET['id'] == 13 and $_GET['id_type'] == 38 and $_GET['act'] == 'sub_type'){
$location = "/market/interernye_svetilniki/bra/dvuhrozhkovye/";
}elseif(
$_GET['id'] == 13 and $_GET['id_type'] == 39 and $_GET['act'] == 'sub_type'){
$location = "/market/interernye_svetilniki/bra/treh_i_bolee_rozhkovye/";
}elseif(
$_GET['id'] == 13 and $_GET['id_type'] == 1 ){
$location = "/market/interernye_svetilniki/tochechnye/";
}elseif(
$_GET['id'] == 13 and $_GET['id_type'] == 42 and $_GET['act'] == 'sub_type'){
$location = "/market/interernye_svetilniki/tochechnye/odinochnye/";
}elseif(
$_GET['id'] == 13 and $_GET['id_type'] == 43 and $_GET['act'] == 'sub_type'){
$location = "/market/interernye_svetilniki/tochechnye/dvojnye/";
}elseif(
$_GET['id'] == 13 and $_GET['id_type'] == 44 and $_GET['act'] == 'sub_type'){
$location = "/market/interernye_svetilniki/tochechnye/tri_i_bolee/";
}
elseif(
$_GET['id'] == 13 and $_GET['id_type'] == 8){
$location = "/market/interernye_svetilniki/nastolnye_lampy/";
}elseif(
$_GET['id'] == 13 and $_GET['id_type'] == 46 and $_GET['act'] == 'sub_type'){
$location = "/market/interernye_svetilniki/nastolnye_lampy/ofisnye/";
}elseif(
$_GET['id'] == 13 and $_GET['id_type'] == 47 and $_GET['act'] == 'sub_
type'){
$location = "/market/interernye_svetilniki/nastolnye_lampy/prikrovatnye_domashnie_ili_interernye/";
}elseif(
$_GET['id'] == 13 and $_GET['id_type'] == 6 ){
$location = "/market/interernye_svetilniki/torshery/";
}elseif(
$_GET['id'] == 13 and $_GET['id_type'] == 9 ){
$location = "/market/ulichnye_svetilniki/";
}...
И так далее..
Клиент поставил нашу CMS, на старой были ссылки типа /?id=10 и т.д. Сделал ему для примера скрипт редиректа с использованием switch case и вот что я увидел через две недели 0_0 Неприкрытый говнокод.
nur 01.04.2010 14:23 # +6.6
VeroLom 01.04.2010 14:29 # −4.2
nur 01.04.2010 15:02 # +0.4
VeroLom 22.04.2010 10:59 # 0
VeroLom 01.04.2010 14:40 # −5
case 10: $location = "/articles/lyustry/lustra-na-kuhne/";
проще.
Abductio 01.04.2010 15:11 # +3.8
VeroLom 22.04.2010 11:06 # 0
striker 01.04.2010 16:12 # +1
guest 01.04.2010 16:45 # +3.2
Dreyk 01.04.2010 23:13 # 0
VeroLom 22.04.2010 10:58 # 0
mrbig66 01.04.2010 16:46 # +1.8
guest 02.04.2010 10:46 # +2.2
guest 03.04.2010 20:23 # 0
VeroLom 22.04.2010 11:22 # 0
guest 02.04.2010 13:48 # +2.4
VeroLom 22.04.2010 11:32 # −1
Vasiliy 28.04.2010 09:05 # +1
guest 29.04.2010 18:11 # 0
Death 02.04.2010 18:21 # +1
неужели нельзя один раз вначале проверок написать
$id = (int)$_GET['id'];
$type = (int)$_GET['id_type']
$act = (string)$_GET['act'];
и все проверки будут в виде if ($id==13 && $type==47 && $act=='sub_type')
по крайней мере более локанично и яснее...
если же по теме как хранить ЧП-ссылки, то тут ответ один:
в базе с полями [id,type,act,url] и выдавать при полном соответсвии всех нужных и отсутсвии лишних параметров...
mrbig66 02.04.2010 22:28 # +3
VeroLom 22.04.2010 11:31 # 0