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

    +164

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    if($password===$_POST['password'] && $login===$_POST['login'])
    	{	
    // устанавливаем login & pass	
    	$_SESSION['login']=$_POST['login'];	
    	
    	$_SESSION['password']=$_POST['password'];
    // Перенаправляем в админ панель	
    	Header("Location: config.php");	
    	}
    else { ... }

    NemoReturns, 29 Апреля 2011

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

    +192

    1. 1
    class AutocompleteAddressZaplatka2 extends AutocompleteAddressZaplatka

    Фундаментальные объектно-ориентированные костыли ...

    _tL, 29 Апреля 2011

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

    +164

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    $cur = date('Y-m-d',time());
    $date_arr = explode('-',$cur);
    $year =$date_arr[0];
    $month =$date_arr[1];
    $day =$date_arr[2];

    _tL, 29 Апреля 2011

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

    +162

    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
    function show_price_list() {
    $period_1 = $period_2 = $period_3 = $period_4 = $period_5 = $period_6 = "";
    $query = "
    		SELECT id, price, type
    		FROM price 
    		ORDER BY type, start
    	";
    $this->registry['sql']->query($query);
    if ($this->registry['sql']->getNumberRows()>0) {
    	foreach ($this->registry['sql']->getFetchObject() as $oRow) {
    		switch($oRow->type) {
    			case 0: $period_1 .= '<td><input type="text" name="period['.$oRow->id.']" value="'.$oRow->price.'"></td>';
    			break;
    			case 1: $period_2 .= '<td><input type="text" name="period['.$oRow->id.']" value="'.$oRow->price.'"></td>';
    			break;
    			case 2: $period_3 .= '<td><input type="text" name="period['.$oRow->id.']" value="'.$oRow->price.'"></td>';
    			break;
    			case 3: $period_4 .= '<td><input type="text" name="period['.$oRow->id.']" value="'.$oRow->price.'"></td>';
    			break;
    			case 4: $period_5 .= '<td><input type="text" name="period['.$oRow->id.']" value="'.$oRow->price.'"></td>';
    			break;
    			case 5: $period_6 .= '<td><input type="text" name="period['.$oRow->id.']" value="'.$oRow->price.'"></td>';
    			break;
    		}
    	}
    }
    @$this->registry['template']->set('period_1', $period_1);
    @$this->registry['template']->set('period_2', $period_2);
    @$this->registry['template']->set('period_3', $period_3);
    @$this->registry['template']->set('period_4', $period_4);
    @$this->registry['template']->set('period_5', $period_5);
    @$this->registry['template']->set('period_6', $period_6);
    
    	}

    Классика жанра

    1_and_0, 29 Апреля 2011

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

    +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
    class CIBlockFindTools
    
    ...
    
    function GetSectionID($section_id, $section_code, $arFilter)
    {
    	$section_id = intval($section_id);
    	if($section_id > 0)
    	{
    		return $section_id;
    	} else if(){
                  }
                 return 0;
    ...
    }

    битрикс суров, использует свою реализацию intval(). как мы могли без этого жить?

    hunterman, 29 Апреля 2011

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

    +163

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    $lu=0;
    $ray_array = file("allray.txt");
    while (empty($rayon)) //пока район не заполнен значением
    {
    preg_match("#".trim($ray_array[$lu++])."#", $text, $rayon);
    }

    Многострочный поиск

    Uchkuma, 29 Апреля 2011

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

    +158

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    if ($result === false) {
                $result = $translated;
            }
    
            if ($result === false){
                $result = $translated;
            }

    Magento. Так работают переводы.

    vsushkov, 28 Апреля 2011

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

    +168

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    if ($sum == 30) {
        return 24;
    } else {
        return $sum * 0.8;
    }

    stark, 28 Апреля 2011

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

    +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
    function bigplus(){
    	$args = func_get_args();
    	$maxlength = 0;
    	$mlkey = 0;
    	$inmind = 0;
    	foreach($args as $key=>$arg){
    		$args[$key] = array_reverse(str_split($arg));
    		$length = count($args[$key]);
    		if($maxlength<$length){
    			$maxlength = $length;
    			$mlkey = $key;
    		}
    	}
    	for($pos=0; $pos<$maxlength; $pos++){
    		$c = 0;
    		for($i=0; $i<count($args); $i++){
    			if(!isset($args[$i][$pos])){
    				$args[$i][$pos]=0;
    			}
    			$c+=$args[$i][$pos];
    		}
    		$args[0][$pos] = $c+$inmind;
    		$inmind = floor(($args[0][$pos])/10);
    		$args[0][$pos] %= 10;
    	}
    	if($inmind>0){
    		$args[0][] = $inmind;
    	}
    	return implode(array_reverse($args[0]));
    }

    Народ, знаю что говнокод, помогите советом как исправить?
    Функция выводит результат сложения любого числа положительных чисел произвольной длины.
    Не придумал ничего умнее, чем реализовать сложение "в столбик".

    knes, 28 Апреля 2011

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

    +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
    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
    // Подходы различной национальности
    
    /* Первый */
    function filesize_format($bytes, $format = '', $force = ''){
       $force = strtoupper($force);
       $defaultFormat = '%01d %s';
       if (strlen($format) == 0)
       $format = $defaultFormat;
       $bytes = max(0, (int) $bytes);
       $units = array('B', 'KB', 'MB', 'GB', 'TB', 'PB');
       $power = array_search($force, $units);
       if ($power === false)
       $power = $bytes > 0 ? floor(log($bytes, 1024)) : 0;
       return sprintf($format, $bytes / pow(1024, $power), $units[$power]);
    }
    /* Второй */
    function files_size( $size )
    {
        $name = array('Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB');
        $mysize = $size ? round( $size / pow(1024, ( $i = floor( log( $size, 1024 ) ) ) ), 2) .' ' .$name[$i] : $size.' Bytes';
        return $mysize;
    }
    /* Третий */
       function humanSize($size) {
          $a = array("bytes", "kb", "Mb", "Gb", "Tb", "Pb");
          $pos = 0;
          while ($size >= 1024) {
           $size /= 1024;
           $pos++;
          }
          return round($size,2)." ".$a[$pos];
         }

    Вопрос: Определите географические координаты места написания каждого...

    DoctorHouse, 27 Апреля 2011

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