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

    +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
    40. 40
    41. 41
    42. 42
    43. 43
    44. 44
    45. 45
    <?php
    $banners = array(
    /*
    	array(
    		'file' => '/files/images/domofony/domofon.swf',
    		'w' => 295,
    		'h' => 40,
    		//'url' => ''
    	),
    */
        array(
            'file' => '/files/banners/mega-sale.swf',
            'w' => 600,
            'h' => 90,
            'url' => 'http://podryad.tv/mega-sale.html'
        )
    
    );
    
    $banners = array();
    
    if(sizeof($banners)) {
    
    $b = $banners[array_rand($banners)];
    
    $b_html = "<div style='position:relative; text-align:center; width: {$b['w']}px; height: {$b['h']}px; margin: 0 auto 10px auto; padding-top: 10px;'>";
    if($b['url']) $b_html .= "
        <a href='{$b['url']}' target=_blank style='display:block; width: 100%; height: 100%; position: absolute; top:0; left:0; z-index:5; background: url(\"/images/px.png\") top left repeat transparent;'></a>";
    $b_html .= "
        <object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' width='{$b['w']}' height='{$b['h']}' align='middle'>
            <param name='allowScriptAccess' value='sameDomain' />
            <param name='allowFullScreen' value='false' />
            <param name='movie' value='{$b['file']}' />
            <param name='quality' value='high' />
            <param name='bgcolor' value='#ffffff' />
            <param name='wmode' value='opaque' />
            <embed src='{$b['file']}' quality='high' bgcolor='#ffffff' allowscriptaccess='sameDomain' allowfullscreen='false' wmode='opaque' width='{$b['w']}' height='{$b['h']}' align='middle' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />
        </object>
    </div>";
    
    echo $b_html; unset($b_html);
    
    }
    unset($banners);
    ?>

    baner view. Уничтож меня, уничтож меня полностью...

    Razban_Guestov, 22 Октября 2012

    Комментарии (22)
  2. Куча / Говнокод #11968

    +128

    1. 1
    f = expr `catches` [Handler (\ (ex :: ArithException) -> handleArith ex), Handler (\ (ex :: IOException)    -> handleIO    ex)]

    Собственно это пример как в хаскеле перехватывать исключения из одного выражения expr.
    Выглядит конечно отстойно. Очень многословно и судя по всему метода проще нет. И понятное дело, в чистых ленивых функциях это не работает. Ловить исключения можно только в грязных IO-функциях, тк сигнатура такова: catches :: IO a -> [Handler a] -> IO a

    HaskellGovno, 21 Октября 2012

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

    +9

    1. 1
    http://ideone.com/vvkWO4

    Fai, 21 Октября 2012

    Комментарии (8)
  4. C++ / Говнокод #11966

    +28

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    const std::string cyrillic = "аАбБвВгГдДеЕёЁжЖзЗиИйЙкКлЛмМнНоОпПрРсСтТуУфФхХцЦчЧшШщЩъЪыЫьЬэЭюЮяЯ";
    
    std::string cyrillic_toupper(std::string s)
    {
       if(cyrillic.find(s) == std::string::npos)
          throw std::runtime_error(std::string("cyrillic_toupper(): ") + "'" + s + "' is not cyrillic char");
    
       return cyrillic.substr(cyrillic.find(s) + 2, 2);
    }

    an0nym, 21 Октября 2012

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

    +42

    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
    <?php 
    if (isset($_GET['file'])) {
    	$dirname = 'download';
    	$file = (string) $_GET['file'];
    	$file = $dirname . DIRECTORY_SEPARATOR . trim($file);
    	if (is_file($file)) {
    		header('Content-Description: File Transfer');
    		header('Content-Type: application/octet-stream');
    		header('Content-Disposition: attachment; filename=' . basename($file));
    		header('Content-Transfer-Encoding: binary');
    		header('Expires: 0');
    		header('Cache-Control: must-revalidate');
    		header('Pragma: public');
    		header('Content-Length: ' . filesize($file));
    		ob_clean();
    		flush();
    		readfile($file);
    		exit();
    	}
    }

    вопрос:
    Нужно чтобы при клике по ссылке запускалось скачивание файла, но ссылка должна быть не прямая как site.ru/download/file1.rar
    - а вот такая: site.ru/download/1/

    ответ:
    создайте файл download.php и папку download для файлов.
    использовать так: localhost/download.php?file=01.jpg

    ahref, 20 Октября 2012

    Комментарии (8)
  6. JavaScript / Говнокод #11963

    +151

    1. 1
    var ext = /.+[.](jpg|JPG|gif|GIF|bmp|BMP|png|PNG|jpeg|JPEG)$/;

    Stallman, 20 Октября 2012

    Комментарии (12)
  7. C++ / Говнокод #11962

    +21

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    #include <stdio.h>
    #include <stdlib.h>
    #include <math.h>
    
    int main()
    {
        unsigned int input[65536];
        int counter=0;
        while(scanf("%u", &(input[counter++])) != EOF);
        while (counter-- > 0) printf("%.4f\n", sqrt((double)(input[counter])));
        return 0;
    }

    Реализация задачи http://acm.timus.ru/problem.aspx?space=1&num=1001

    kganker, 19 Октября 2012

    Комментарии (51)
  8. C# / Говнокод #11960

    +134

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    public static byte[] ConvertToMessage(Stream stream)
            {
                int length = (int) stream.Length;
                byte[] buffer = new byte[length + 4];
                buffer[0] = (byte) (length & 0xff);
                buffer[1] = (byte) ((length & 0xff00) >> 8);
                buffer[2] = (byte) ((length & 0xff0000) >> 16);
                buffer[3] = (byte) ((length & 0xff000000L) >> 24);
                stream.Read(buffer, 4, length);
                return buffer;
            }

    А товарищи знают толк в извращенствах

    Yukiakze, 19 Октября 2012

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

    +61

    1. 1
    'timestamp' => strval(date('U')),

    Русский аутсорс.

    grelkin, 19 Октября 2012

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

    +67

    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
    if( $proverka === true )
        $_SESSION['id'] = $user['id'];
    if( $proverka === true )
        $_SESSION['milo'] = $user['milo'];
    if( $proverka === true )
        $_SESSION['parol'] = $user['parol'];
    if( $proverka === true )
        $_SESSION['prava'] = $user['prava'];
    if( $proverka === false )
        echo 'Ввиденные вами данные неверны!';
    if( $proverka === false )
        $_SESSION['id'] = '';
    if( $proverka === false )
        $_SESSION['milo'] = '';
    if( $proverka === false )
        $_SESSION['parol'] = '';
    if( $proverka === false )
        $_SESSION['prava'] = '';

    0-0 //-0 //-\\

    Snickers, 19 Октября 2012

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