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

    +41

    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
    function sqldate2time($date) {
        list($y, $m, $d) = explode('-', $date);
        $res = mktime(3,0,0,$m,$d,$y);
        return($res);
    }//function
     
    //Добавляем к дате указанное кол-во дней
    function add_days($date, $days = 1) {
        $t = sqldate2time($date);
        $t += (86400*$days);
     
        return(date('Y-m-d', $t));
    }//function

    Попытка на каком-то форуме, прибавить интервал времени (к примеру 7 дней)

    nepster, 14 Сентября 2012

    Комментарии (7)
  2. ActionScript / Говнокод #11771

    −86

    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
    switch(page) {
    		case 0:
    			showCurrentCar(page);
    			hidePreviousCar(currentModel);
    			currentModel = page;
    			break;
    		case 1:
    			showCurrentCar(page);
    			hidePreviousCar(currentModel);
    			currentModel = page;
    			break;
    		case 2:
    			showCurrentCar(page);
    			hidePreviousCar(currentModel);
    			currentModel = page;
    			break;
    		case 3:
    			showCurrentCar(page);
    			hidePreviousCar(currentModel);
    			currentModel = page;
    			break;
    	}

    Долго искал отличия кейсов, не нашол

    Edd, 14 Сентября 2012

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

    +58

    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
    // что-то страшно мне стало
    class Mysql{
      private $db = null; 
      private $result = null; 
    //private $row = null;
     
     function __construct($dbname,$dbuser,$dbpass,$dbhost){
        $this->db = mysql_connect($dbhost, $dbuser, $dbpass) or die("MySQL Error: " . mysql_error());
        mysql_select_db($dbname) or die ("<br>Invalid query: " . mysql_error());
        mysql_query("SET NAMES utf8") or die ("<br>Invalid query: " . mysql_error());
     }
     function connect(){
        if(!$this->db){
        exit("Error connect BD!");
        }
     }
    
     function query($query){
        if(!$query){exit("No [query]");}
    	$this->result = $query = mysql_query($query) or die ("<br>Invalid query: " . mysql_error());
    	return $query;
     } 
    }

    kuler, 13 Сентября 2012

    Комментарии (21)
  4. Perl / Говнокод #11769

    −108

    1. 1
    push @sqls, defined($result->{sql}) ? $result->{sql} : return;

    Не знаю, что тут написать. Сегодня это встретил в коде.

    Elvenfighter, 13 Сентября 2012

    Комментарии (3)
  5. C++ / Говнокод #11768

    +28

    1. 1
    2. 2
    std::size_t _;
    std:size_t __;

    http://ideone.com/Ie1AY

    HaskellGovno, 13 Сентября 2012

    Комментарии (44)
  6. Java / Говнокод #11767

    +75

    1. 1
    2. 2
    3. 3
    4. 4
    Process process = Runtime.getRuntime().exec("su");
    OutputStream outputStream = process.getOutputStream();
    String cmd = "keycode " + KeyEvent.KEYCODE_BACK;
    outputStream.write((cmd + "\n").getBytes("ASCII"));

    Андроид. Вот такой вот прекрасный способ программно нажать кнопочку "Back".

    http://stackoverflow.com/questions/5832861/android-back-key-by-software

    bormand, 13 Сентября 2012

    Комментарии (8)
  7. SQL / Говнокод #11766

    −160

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    QString query4="INSERT INTO `"+mb+"`.`cubes` (`user_id`, `name`) VALUES (0, '"+name+"')";
    mysql.sqlQuery(query4, true);
    mysql.sqlQuery("SELECT * FROM `"+mb+"`.`cubes` WHERE name='"+name+"' AND user_id="+QString::number(userID), true);
    mysql.data_connection_bind(true);
    mysql.getRow();
    int id=mysql.getUint32(o);
    mysql.sqlQuery("UPDATE `"+mb+"`.`cubes` SET user_id=1 WHERE user_id="+QString::number(userID), true);
    mysql.sqlQuery("DELETE FROM `"+mb+"`.`users` WHERE `name`="+QString::number(getpid()), true);
    qDebug()<<"CubeID"<<id;

    Судя по словам автора: он не осилил lastInsertId, поэтому пытался вставить запись с заранее не существующим user_id, чтобы затем однозначно извлеч эту строку и получить уже долгожданое поле id.

    Try, 13 Сентября 2012

    Комментарии (3)
  8. SQL / Говнокод #11765

    −158

    1. 1
    2. 2
    3. 3
    4. 4
    SELECT ft_login,fi_system,ft_password,fk_id
    FROM users u
    INNER JOIN taccountscontent t ON u.id = t.fk_id
    WHERE u.id IN (select id from users where id=123)

    Оригинал http://www.askdev.ru/question/16663/%D0%97%D0%B0%D0%BF%D1%80%D0%BE%D1%81-%D0%BA-%D0%91%D0%94-%D0%B8-%D1%86%D0%B8%D0%BA%D0%BB-While/

    et, 13 Сентября 2012

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

    +53

    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
    <?if($arElement["PROPERTIES"]["POSTAV"]["VALUE_ENUM_ID"]==73){?>
    <?if($arElement["PREVIEW_PICTURE"]["HEIGHT"]<105){?><div width="115px" height="105px"><?}?>
    
      <a href="<?=$arElement["DETAIL_PICTURE"]["SRC"]?>" class="preview" onclick="return false;" onmousedown="window.location.href='<?=$arElement["DETAIL_PAGE_URL"]?>';"><img src="<?=$arElement["PREVIEW_PICTURE"]["SRC"]?>"  width="115" border="0px" alt="<?=$arElement["PREVIEW_PICTURE"]["ALT"]?>" title="<?=$arElement["NAME"]?>"/></a></div>
    <?if($arElement["PREVIEW_PICTURE"]["HEIGHT"]<105){?></div><?}?>
    <?}else{?>
        <a href="<?=$arElement["DETAIL_PICTURE"]["SRC"]?>" class="preview" onclick="return false;" onmousedown="window.location.href='<?=$arElement["DETAIL_PAGE_URL"]?>';"><img src="<?=$arElement["PREVIEW_PICTURE"]["SRC"]?>" width="115" height="105" border="0px" alt="<?=$arElement["PREVIEW_PICTURE"]["ALT"]?>" title="<?=$arElement["NAME"]?>"/></a>
    <?}?>
    	<br>&nbsp;
    					<?endif?></td>
                                              </tr>
                                            </table></td>
    									</tr>
    								</table>
    
                                    </div>
    		  </td>
    		<?$cell++;
    		if($cell%$arParams["LINE_ELEMENT_COUNT"] == 0):?>
    	</tr>
    		<?endif?>
    
    		<?endforeach; // foreach($arResult["ITEMS"] as $arElement):?>
    
    		<?if($cell%$arParams["LINE_ELEMENT_COUNT"] != 0):?>
    			<?while(($cell++)%$arParams["LINE_ELEMENT_COUNT"] != 0):?>
    
    			<?endwhile;?>
    			</tr>
    		<?endif?>
    
    </table></div>
     <?if($arParams["DISPLAY_BOTTOM_PAGER"]):?>
    	<br />
    	<?
    	$arResult["NAV_STRING"] = str_replace('|&nbsp;<a href="/e-store/rings/diamond.php?bitrix_include_areas=Y&amp;bitrix_show_mode=configure&amp;login=yes&amp;SHOWALL_1=1">Все</a>','',$arResult["NAV_STRING"]);
    	?>
    	<?=$arResult["NAV_STRING"]?>
    <?endif;?>

    randombot, 13 Сентября 2012

    Комментарии (9)
  10. Ruby / Говнокод #11763

    −166

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    class User < ActiveRecord::Base
        
      def full_name
      	user_info=User.find(self.id)
      	[user_info.name,user_info.surname].join(" ")
      end
    end

    Получаем полное имя себя

    1101_debian, 13 Сентября 2012

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