1. Список говнокодов пользователя ggg

    Всего: 1

  2. PHP / Говнокод #10023

    +96

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    35. 35
    36. 36
    37. 37
    38. 38
    39. 39
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    46. 46
    // expressions to parse
    		$input_pars = array(
    			's:2'=>'(sort(\d+)/?)?', 				//1-2
    			'id:2'=>'((\d+)/?)?',  			 		//3-4
    			'utkonos_id-shop_id:2-2'=>'(u(\d+)(s(\d+))?/)?', 	//5-6 7-8
    			'iid:1'=>'([0-9a-zA-Z_]+)/?', 				//9
    			'page:2'=>'(pg(\d+)/)?', 				//10-11
    			'chpsize:2'=>'(chp(\d+)/)?', 				//12-13
    			'chlist:2'=>'(chlist_(grid|list)/)?', 				//14-15
    			'p_other:1'=>'(.*)',					//16
    		);
    		if(!$class)unset($input_pars['iid:1']);
    		$m = array();
    		$i=0;
    
    		if(isset($_REQUEST['p_'])&&preg_match('[^'.implode('',$input_pars).'$]',$_REQUEST['p_'],$m)) {
    			//vd($m);
    			foreach($input_pars as $key=>$line) {
    				list($par_name,$num) = explode(':', $key);
    				$par_name_arr = explode('-',$par_name);
    				$num_arr = explode('-',$num);
    				if(count($par_name_arr)>1) {
    					foreach($par_name_arr as $kluch => $par_name) {
    						$i += $num_arr[$kluch];
    						$_REQUEST[$par_name] = $m[$i];
    					}
    				}else{
    					$i += $num;
    					$_REQUEST[$par_name] = $m[$i];
    				}
    			}
    			$_REQUEST['id'] += 0;
    			if ($_REQUEST['s'] === '0') {
    				$_REQUEST['s'] = 0;
    			}
    			if ($_REQUEST['chpsize'] === '0') {
    				$_REQUEST['chpsize'] = 0;
    			}
    			vd($_REQUEST);
    		}else{
    			$_REQUEST['s'] = grv('s',-1);						/// Сортировка
    			$_REQUEST['id'] = grv('id',0);
    			$_REQUEST['shop_id'] = grv('shop_id',0);
    			$_REQUEST['page'] = grv('page',0);
    			$_REQUEST['chpsize'] = (int)grv('chpsize',-1);
    		}

    ggg, 23 Апреля 2012

    Комментарии (2)