1. PHP / Говнокод #8594

    +162

    1. 1
    if ($_REQUEST['call']==''){ echo 'Расторжение'; } else echo 'Расторжение';

    ferry-very-good, 21 Ноября 2011

    Комментарии (21)
  2. PHP / Говнокод #8591

    +163

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    $sql = "INSERT INTO loginhistory(id_user)
    	     VALUES('$id_user')"; // create query to db - add new login history 
    $result = mysql_query($sql) or die("MySQL error: ".mysql_error()); // execute it and save result to variable $result
    $sql = "SELECT id
    	     FROM loginhistory
    	     WHERE id_user = '$id_user'
    	     ORDER BY id DESC
                 LIMIT 1"; // get ID of the last record in loginhostory
    $result = mysql_query($sql) or die("MySQL error: ".mysql_error()); // execute this query

    Классика (:

    denis90, 21 Ноября 2011

    Комментарии (31)
  3. PHP / Говнокод #8577

    +161

    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
    <?php
    /**
     * Cleaning Input Script
     * Copyright 2009 - www.pgmr.co.uk - [email protected]
     */
    function clean($str) {
    	if(!get_magic_quotes_gpc()) {
     	$str = addslashes($str);
     }
    	$str = strip_tags(htmlspecialchars($str));
    	return $str;
    }
    ?>

    "Универсальная функция для защиты сайта от XSS, SQL и JS-инъекций."
    http://2lx.ru/2011/04/funkciya-dlya-zashhity-sajta-ot-vzloma/

    jokz, 19 Ноября 2011

    Комментарии (9)
  4. PHP / Говнокод #8569

    +161

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    function to_int_convert($num)
    {
        $arr_num = str_split($num);
        $new_num = "";
        foreach($arr_num as $key => $value)
                if($value == intval($value))
                $new_num = $new_num.$value;
        return $new_num;
    }

    korchasa, 18 Ноября 2011

    Комментарии (5)
  5. PHP / Говнокод #8568

    +158

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    foreach ($aa as $key => $value) {
                $aa[$key][2] = str_replace(',', '.', $aa[$key][2]);
                $aa[$key][3] = str_replace(',', '.', $aa[$key][3]);
                $aa[$key][4] = str_replace(',', '.', $aa[$key][4]);
            }

    jf4ever, 18 Ноября 2011

    Комментарии (7)
  6. PHP / Говнокод #8567

    +155

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    function some_function ($aa, $bb) {
            $col_names = _cfg::get('ccc');
            foreach ($bb as $key => $value) {
                $bb[$key][0] = array_search($bb[$key][0], $aa);
                $bb[$key][1] = array_search($bb[$key][1], $aa);
                
                foreach ($this->currency_names as $currency_key => $currency_value) {
                    if ($oil_array[$key][5] == $this->currency_names[$currency_key]['name']) $oil_array[$key][5] = $this->currency_names[$currency_key]['id'];
                }
                $bb[$key] = array_combine($col_names, $bb[$key]);
            }
            return $bb;

    продолжение с Говнокод #8566

    jf4ever, 18 Ноября 2011

    Комментарии (3)
  7. PHP / Говнокод #8566

    +162

    1. 1
    2. 2
    $id = $this->db->fetchCol('SELECT id FROM data;');
    $names = $this->db->fetchCol('SELECT name FROM points INNER JOIN data ON points.id = data.point_id_from;');

    Zend Db usage

    jf4ever, 18 Ноября 2011

    Комментарии (5)
  8. PHP / Говнокод #8565

    +160

    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
    47. 47
    48. 48
    49. 49
    50. 50
    51. 51
    52. 52
    53. 53
    54. 54
    55. 55
    56. 56
    57. 57
    58. 58
    59. 59
    60. 60
    61. 61
    62. 62
    63. 63
    64. 64
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    function &GetObject($cls, $p=null, $flags=0)
    {	//HIDE($objects,$i,$ext,$n,$v)
    	static $objects;
    	if (is_array($cls)) {
    		$i = null;
    		foreach($cls as $n=>$v) $i->$n = $v;
    		$result = &$i;
    		return $result;
    	}
    	if (!($flags&O_NEW) && isset($objects[$cls])) return $objects[$cls];
    
    	$ext = new WExtern($cls, 'c');
    	if (!($flags&O_NEW) && isset($objects[$i=$ext->Id()])) return $objects[$i];
        if ($flags&O_INSTANCE) {$x = null; $result = &$x; return $result;}
    
    	if (!$ext->Exists()) $ext->Prepare();
    	if (($flags&O_NOERROR) && !class_exists($ext->c)) {
    		$co = $ext->c;
    		$cc = $co{0}.'B'.substr($co,1);
    		if (($flags&O_NOERROR) && !class_exists($cc)) {
    			$i = false;
    			return $i;
    		} else {
    			$ext->c = $cc;
    		}
    	}
    	
    	if (!class_exists($ext->c)) {
    		$co = $ext->c;
    		$cc = $co{0}.'B'.substr($co,1);
    		if (!class_exists($cc)) {
    			$i = false;
    			return $i;
    		} else {
    			$ext->c = $cc;
    		}
    	}
    	$c = $ext->c;
    	$i = new $c;
    
    	if (isset($ext->I) && $ext->I) $i->_I = reset($ext->I);	// Instance ID
    	if (isset($ext->A) && $ext->A) $i->_A = $ext->A;		// Alias ID
    
    	if (!($flags&O_NEW)) {
    		$objects[$ext->Id()] = &$i;
    		if ($ext->Id()!=$cls) $objects[$cls] = &$i;
    	}
    	$options = &WConfig::Get('OPTIONS');
    	if (/*is_a($i, 'wobject')*/ $i instanceof wobject && $options) {
    		$o = $options;
    		$c = get_class($i);
    		do{
    			$c = strtolower($c);
    			if (isset($o[$c])) {
        			$i->o = array_merge($o[$c], isset($i->o) ?$i->o :array());
    			}
    		}while($c=get_parent_class($c));
    		if (isset($ext->A) && isset($o[$ext->A])) 	$i->o = array_merge(isset($i->o) ?$i->o :array(), $o[$ext->A]);
    		if ($ext->I && isset($o[$ext->Id()])) 		$i->o = array_merge(isset($i->o) ?$i->o :array(), $o[$o[$ext->Id()]]);
    	}
    
    	if (is_object($p)) {
    		if (isset($p->o)) $i->o = array_merge(isset($i->o) ?$i->o :array(), $p->o);
    		$p = isset($p->c) ? $p->c : null;
    	}
    	if (method_exists($i,'Create')  && $p!==false) {
    		call_user_func_array(array(&$i,'Create'), is_array($p) ?$p : (isset($p) ? array($p) : array()));
    	}
    
    	return $i;
    }

    Одна из базовых функций фремворка.

    Orion189, 18 Ноября 2011

    Комментарии (14)
  9. PHP / Говнокод #8562

    +166

    1. 1
    foreach ($_GET as $xxx => $rvar) { $$xxx = $rvar; }

    может боян конешн

    pusinsky, 18 Ноября 2011

    Комментарии (12)
  10. PHP / Говнокод #8551

    +163

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    if (isset($_GET['last_user']) && (int)$_GET['last_user']){
        $last_user = 0;
    }else{
        $last_user = (int)$_GET['last_user'];
    }

    no comments.. )

    Igogo, 17 Ноября 2011

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