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

    +154

    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
    switch($step) {
            case 0:
                    setup_config_display_header();
    ?>
    <p><?php _e( 'Welcome to WordPress. Before getting started, we need some information on the database. You will need to know the following items before proceeding.' ) ?></p>
    <ol>
            <li><?php _e( 'Database name' ); ?></li>
            <li><?php _e( 'Database username' ); ?></li>
            <li><?php _e( 'Database password' ); ?></li>
            <li><?php _e( 'Database host' ); ?></li>
            <li><?php _e( 'Table prefix (if you want to run more than one WordPress in a single database)' ); ?></li>
    </ol>
    <p><strong><?php _e( "If for any reason this automatic file creation doesn’t work, don’t worry. All this does is fill in the database information to a configuration file. You may also simply open <code>wp-config-sample.php</code> in a text editor, fill in your information, and save it as <code>wp-config.php</code>." ); ?></strong></p>
    <p><?php _e( "In all likelihood, these items were supplied to you by your Web Host. If you do not have this information, then you will need to contact them before you can continue. If you’re all ready…" ); ?></p>
    <p class="step"><a href="setup-config.php?step=1<?php if ( isset( $_GET['noapi'] ) ) echo '&noapi'; ?>" class="button button-large"><?php _e( 'Let’s go!' ); ?></a></p>
    <?php
            break;
            case 1:
                    setup_config_display_header();
    //...
            case 2:
            foreach ( array( 'dbname', 'uname', 'pwd', 'dbhost', 'prefix' ) as $key )
                    $$key = trim( wp_unslash( $_POST[ $key ] ) );
            $tryagain_link = '</p><p class="step"><a href="setup-config.php?step=1" onclick="javascript:history.go(-1);return false;" class="button button-large">' . __( 'Try again' ) . '</a>';
            if ( empty( $prefix ) )
                    wp_die( __( '<strong>ERROR</strong>: "Table Prefix" must not be empty.' . $tryagain_link ) );
            // Validate $prefix: it can only contain letters, numbers and underscores.
            if ( preg_match( '|[^a-z0-9_]|i', $prefix ) )
                    wp_die( __( '<strong>ERROR</strong>: "Table Prefix" can only contain numbers, letters, and underscores.' . $tryagain_link ) );
            // Test the db connection.
            /**#@+
             * @ignore
             */
            define('DB_NAME', $dbname);
            define('DB_USER', $uname);
            define('DB_PASSWORD', $pwd);
            define('DB_HOST', $dbhost);
            /**#@-*/
            // We'll fail here if the values are no good.
            require_wp_db();
    
    // еще двести строк свитча с html, обработкой данных прямо на лету и даже небольшим количеством инлайн-js

    Захотел я подцепиться к внутреннему api установки вордпресса, чтобы эту самую установку делать через конфиг-файлы и композер. В результате проще оказалось имитировать окружение веб-сервера, заполнять всякие $_GET-$_POST и просто подключать нужный файл. А как они сами с этим адом работают - для меня остается загадкой

    Целиком https://core.trac.wordpress.org/browser/tags/3.9.2/src/wp-admin/setup-config.php и https://core.trac.wordpress.org/browser/tags/3.9.2/src/wp-admin/install.php

    Fike, 30 Августа 2014

    Комментарии (1)
  2. C++ / Говнокод #16619

    +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
    void nearest(double v) {
        double d = 0.1;
        double v2 = v + d;
        double v3;
        double v4;
        while (v2 != v) {
            v3 = v + d;
            v4 = v - d;
            d = d * 0.9;
            v2 = v + d;
        }
        qDebug() << QString::number(v2,'f',30) << QString::number(v3,'f',30) << QString::number(v4,'f',30);
    }
    
    void roundTest() {
        double v1 = 1.90;
        double v2 = 1.91;
        QString vr1 = QString::number((v1+v2)*0.5,'f',2);
        QString vr2 = QString::number((v1+v2)*0.500000000000000111022302462516,'f',2);
        qDebug() << vr1 << vr2;
    }
    
    #define DOUBLE_HALF 0.500000000000000111022302462516

    Когда-нибудь меня за это побьют

    overloop, 29 Августа 2014

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

    +124

    1. 1
    ru.m.wikipedia.org/wiki/Мобильный_вирус

    "Наиболее перспективной платформой для написания вирусов является Java 2ME , так как подавляющее большинство современных телефонов поддерживает данную платформу"
    Не, ну это пиздец. Сегодня полдня доказывал чуваку что на его говнозвонилке вирусов быть не может технически. Потом посмотрел в вики и охуел - такое ощущение что статью писал кто то из лаборатории Касперского, с целью напугать хомячков и попиарить себя.
    Соседняя статья:
    "Некомпетентные пользователи ошибочно относят к компьютерным вирусам и другие виды вредоносных программ — программы-шпионы и прочее."
    http://ru.wikipedia.org/wiki/Компьютерный_вирус

    Pythoner, 29 Августа 2014

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

    +159

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    if (!isset($_SESSION[$_SESSION['tab_name']]['FILE_ATTRIBUTES'][$request['itemId']][$request['itemFieldId']])) {
          $_SESSION[$_SESSION['tab_name']]['FILE_ATTRIBUTES'][$request['itemId']][$request['itemFieldId']] = $request['itemFieldId'];
    } else {
          unset($_SESSION[$_SESSION['tab_name']]['FILE_ATTRIBUTES'][$request['itemId']][$request['itemFieldId']]);
    }

    И это часный проект где программисту платять большие деньги.
    А еще у автора более 5 лет опыта
    А сам сок, такого дерьма в проекте более 1000 обращений.

    vv3d0x, 29 Августа 2014

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

    +154

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    foreach ($params as $param) {
    	$param_type = (isset($param['type']) ? $param['type'] : 's');
    	$param_value = (isset($param['value']) ? $param['value'] : $param);
    	// <...>
    }

    Угадайте, что произошло, когда значение параметра оказалось равным 'type'?

    Tesstarossa, 29 Августа 2014

    Комментарии (10)
  6. Python / Говнокод #16614

    −102

    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
    def booleanize(value):
        """Return value as a boolean."""
    
        true_values = ("yes", "true", "1")
        false_values = ("no", "false", "0")
    
        if isinstance(value, bool):
            return value
    
        if value.lower() in true_values:
            return True
    
        elif value.lower() in false_values:
            return False

    В комментариях не нуждается.

    Niyakiy, 29 Августа 2014

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

    +153

    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
    if(!empty($this->aActions))
    			$sMenuItems = htmlspecialcharsbx(CAdminPopup::PhpToJavaScript($this->aActions));
    ?>
    <tr class="adm-list-table-row<?=(isset($this->aFeatures["footer"]) && $this->aFeatures["footer"] == true? ' footer':'')?><?=$this->bEditMode?' adm-table-row-active' : ''?>"<?=($sMenuItems <> ""? ' oncontextmenu="return '.$sMenuItems.';"':'');?><?=($sDefAction <> ""? ' ondblclick="'.$sDefAction.'"'.(!empty($sDefTitle)? ' title="'.GetMessage("admin_lib_list_double_click").' '.$sDefTitle.'"':''):'')?>>
    <?
    
    		if(count($this->pList->arActions)>0 || $this->pList->bCanBeEdited):
    			$check_id = RandString(5);
    ?>
    	<td class="adm-list-table-cell adm-list-table-checkbox adm-list-table-checkbox-hover<?=$this->bReadOnly? ' adm-list-table-checkbox-disabled':''?>"><input type="checkbox" class="adm-checkbox adm-designed-checkbox" name="ID[]" id="<?=$this->table_id."_".$this->id."_".$check_id;?>" value="<?=$this->id?>" autocomplete="off" title="<?=GetMessage("admin_lib_list_check")?>"<?=$this->bReadOnly? ' disabled="disabled"':''?><?=$this->bEditMode ? ' checked="checked" disabled="disabled"' : ''?> /><label class="adm-designed-checkbox-label adm-checkbox" for="<?=$this->table_id."_".$this->id."_".$check_id;?>"></label></td>
    <?
    		endif;
    
    		if($this->pList->bShowActions):
    			if(!empty($this->aActions)):
    ?>
    	<td class="adm-list-table-cell adm-list-table-popup-block" onclick="BX.adminList.ShowMenu(this.firstChild, this.parentNode.oncontextmenu(), this.parentNode);"><div class="adm-list-table-popup" title="<?=GetMessage("admin_lib_list_actions_title")?>"></div></td>
    <?
    			else:
    ?>
    	<td class="adm-list-table-cell"></td>
    <?
    			endif;
    		endif;

    bitrix

    Лапша PHP кода, с подливкой из HTML. Присутствуют специи из альтернативного синтаксиса оператора if для шаблонов

    memclutter, 29 Августа 2014

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

    +157

    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
    for ($j=1; $j<8; $j++) {
        $up = "";
        $down = "";
        for ($i=1; $i<7; $i++) {
            if (($i==4)&&($j==4)) {
                $up = $up.'<td class="simp" colspan="2" rowspan="4">Военная<br>Подготовка</td>';
                continue;
            }
            if (($i==4)&&($j>3)&&($j<6)) {
                continue;
            }
            $x = $i*2-1;
            $y = $j*2-1;
            if (($table[$x][$y]==$table[$x][$y+1])&&($table[$x+1][$y+1]==$table[$x+1][$y])&&($table[$x+1][$y+1]==$table[$x][$y])) {
                $up = $up.str_replace("<br><br>","","<td title='".$table[$x][$y]['description']."'  class='simp' colspan='2' rowspan='2'>".$table[$x][$y]['subject']."<br>".$table[$x][$y]['auditory']."<br>".$table[$x][$y]['lecturer']."</td>");
            }
            else {
                $cnt = 0;
                if ($table[$x][$y]==$s) $cnt++;
                if ($table[$x][$y+1]==$s) $cnt++;
                if ($table[$x+1][$y]==$s) $cnt++;
                if ($table[$x+1][$y+1]==$s) $cnt++;
                if ($cnt==3) {
                    $up = $up."<td title='".$table[$x][$y]['description']."'  class='insm'>".$table[$x][$y]['subject']."<br>".$table[$x][$y]['auditory']."<br>".$table[$x][$y]['lecturer']."</td>";
                    $up = $up."<td title='".$table[$x+1][$y]['description']."'  class='insm'>".$table[$x+1][$y]['subject']."<br>".$table[$x+1][$y]['auditory']."<br>".$table[$x+1][$y]['lecturer']."</td>";
                    $down = $down."<td title='".$table[$x][$y+1]['description']."'  class='insm'>".$table[$x][$y+1]['subject']."<br>".$table[$x][$y+1]['auditory']."<br>".$table[$x][$y+1]['lecturer']."</td>";
                    $down = $down."<td title='".$table[$x+1][$y+1]['description']."'  class='insm'>".$table[$x+1][$y+1]['subject']."<br>".$table[$x+1][$y+1]['auditory']."<br>".$table[$x+1][$y+1]['lecturer']."</td>";
                }
                else {
                    if ($table[$x][$y]==$table[$x][$y+1]) { // Левые совпадают
                        $up = $up."<td title='".$table[$x][$y]['description']."'  class='insm' rowspan='2'>".$table[$x][$y]['subject']."<br>".$table[$x][$y]['auditory']."<br>".$table[$x][$y]['lecturer']."</td>";
                        if ($table[$x+1][$y]==$table[$x+1][$y+1]) {
                            $up = $up."<td title='".$table[$x+1][$y]['description']."'  class='insm' rowspan='2'>".$table[$x+1][$y]['subject']."<br>".$table[$x+1][$y]['auditory']."<br>".$table[$x+1][$y]['lecturer']."</td>";
                        }
                        else {
                            $up = $up."<td title='".$table[$x+1][$y]['description']."'  class='insm'>".$table[$x+1][$y]['subject']."<br>".$table[$x+1][$y]['auditory']."<br>".$table[$x+1][$y]['lecturer']."</td>";
                            $down = $down."<td title='".$table[$x+1][$y+1]['description']."'  class='insm'>".$table[$x+1][$y+1]['subject']."<br>".$table[$x+1][$y+1]['auditory']."<br>".$table[$x+1][$y+1]['lecturer']."</td>";
                        }
                    } else {
                        if ($table[$x+1][$y]==$table[$x+1][$y+1]) { // Правые совпадают
                            $up = $up."<td title='".$table[$x][$y]['description']."'  class='insm'>".$table[$x][$y]['subject']."<br>".$table[$x][$y]['auditory']."<br>".$table[$x][$y]['lecturer']."</td>";
                            $down = $down."<td title='".$table[$x][$y+1]['description']."'  class='insm'>".$table[$x][$y+1]['subject']."<br>".$table[$x][$y+1]['auditory']."<br>".$table[$x][$y+1]['lecturer']."</td>";
                            $up = $up."<td title='".$table[$x+1][$y]['description']."'  class='insm' rowspan='2'>".$table[$x+1][$y]['subject']."<br>".$table[$x+1][$y]['auditory']."<br>".$table[$x+1][$y]['lecturer']."</td>";
                        }
                        else {
                            if ($table[$x][$y]==$table[$x+1][$y]) { // Верхние совпадают
                                $up = $up."<td title='".$table[$x][$y]['description']."'  class='insm' colspan='2'>".$table[$x][$y]['subject']."<br>".$table[$x][$y]['auditory']."<br>".$table[$x][$y]['lecturer']."</td>";
                                if ($table[$x][$y+1]==$table[$x+1][$y+1]) {
                                    $down = $down."<td title='".$table[$x][$y+1]['description']."'  class='insm' colspan='2'>".$table[$x][$y+1]['subject']."<br>".$table[$x][$y+1]['auditory']."<br>".$table[$x][$y+1]['lecturer']."</td>";
                                }
                                else {
                                    $down = $down."<td title='".$table[$x][$y+1]['description']."'  class='insm'>".$table[$x][$y+1]['subject']."<br>".$table[$x][$y+1]['auditory']."<br>".$table[$x][$y+1]['lecturer']."</td>";
                                    $down = $down."<td title='".$table[$x+1][$y+1]['description']."'  class='insm'>".$table[$x+1][$y+1]['subject']."<br>".$table[$x+1][$y+1]['auditory']."<br>".$table[$x+1][$y+1]['lecturer']."</td>";
                                }
                            }
                            else {
                                if ($table[$x][$y+1]==$table[$x+1][$y+1]) { // Нижние совпадают
                                    $up = $up."<td title='".$table[$x][$y]['description']."'  class='insm'>".$table[$x][$y]['subject']."<br>".$table[$x][$y]['auditory']."<br>".$table[$x][$y]['lecturer']."</td>";
                                    $up = $up."<td title='".$table[$x+1][$y]['description']."'  class='insm'>".$table[$x+1][$y]['subject']."<br>".$table[$x+1][$y]['auditory']."<br>".$table[$x+1][$y]['lecturer']."</td>";
                                    $down = $down."<td title='".$table[$x][$y+1]['description']."'  class='insm' colspan='2'>".$table[$x][$y+1]['subject']."<br>".$table[$x][$y+1]['auditory']."<br>".$table[$x][$y+1]['lecturer']."</td>";
                                }
                                else {
                                    $up = $up."<td title='".$table[$x][$y]['description']."'  class='insm'>".$table[$x][$y]['subject']."<br>".$table[$x][$y]['auditory']."<br>".$table[$x][$y]['lecturer']."</td>";
     ...

    Рендер расписания занятий из базы данных в табличку на HTML

    Evgesko, 28 Августа 2014

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

    +133

    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
    private void button1_Click(object sender, EventArgs e)
             {
                 OpenFileDialog ofd = new OpenFileDialog();
                 if(ofd.ShowDialog() == DialogResult.OK)
                 {
                     gs_path = ofd.FileName;
                     BinaryReader br = new BinaryReader(new FileStream(gs_path, FileMode.Open, FileAccess.Read));
                     int sys = 0;
                     do {
                         ofset++;
                         br.BaseStream.Seek(ofset, SeekOrigin.Begin);
                         if (br.ReadInt64() == 6875716118506401907)
                         {
                             if (br.ReadInt64() == 521392779117)
                             {
                                 sys = 1;
                             }
                         }
                     } while (sys == 0);
                     br.BaseStream.Seek(ofset + 20, SeekOrigin.Begin);
                     textBox1.Text = br.ReadSingle().ToString();
                     br.BaseStream.Seek(ofset + 24, SeekOrigin.Begin);
                     textBox2.Text = br.ReadSingle().ToString();
                     br.BaseStream.Seek(ofset + 28, SeekOrigin.Begin);
                     textBox3.Text = br.ReadSingle().ToString();
                     br.BaseStream.Seek(ofset + 32, SeekOrigin.Begin);
                     textBox4.Text = br.ReadSingle().ToString();
                     br.BaseStream.Seek(ofset + 36, SeekOrigin.Begin);
                     textBox5.Text = br.ReadSingle().ToString();
                     br.BaseStream.Seek(ofset + 40, SeekOrigin.Begin);
                     textBox6.Text = br.ReadSingle().ToString();
                     br.BaseStream.Seek(ofset + 44, SeekOrigin.Begin);
                     textBox7.Text = br.ReadSingle().ToString();
                     br.Close();
                 }
             }
    ...
            string gs_path;
             int ofset = 0;
             public Form1()
             {
                 InitializeComponent();
             }
    ...
            private void button2_Click(object sender, EventArgs e)
             {
                 BinaryWriter bw = new BinaryWriter(new FileStream(gs_path, FileMode.Open, FileAccess.Write));
                 bw.BaseStream.Seek(ofset + 20, SeekOrigin.Begin);
                 bw.Write(Convert.ToSingle(textBox1.Text));
                 bw.BaseStream.Seek(ofset + 24, SeekOrigin.Begin);
                 bw.Write(Convert.ToSingle(textBox2.Text));
                 bw.BaseStream.Seek(ofset + 28, SeekOrigin.Begin);
                 bw.Write(Convert.ToSingle(textBox3.Text));
                 bw.BaseStream.Seek(ofset + 32, SeekOrigin.Begin);
                 bw.Write(Convert.ToSingle(textBox4.Text));
                 bw.BaseStream.Seek(ofset + 36, SeekOrigin.Begin);
                 bw.Write(Convert.ToSingle(textBox5.Text));
                 bw.BaseStream.Seek(ofset + 40, SeekOrigin.Begin);
                 bw.Write(Convert.ToSingle(textBox6.Text));
                 bw.BaseStream.Seek(ofset + 44, SeekOrigin.Begin);
                 bw.Write(Convert.ToSingle(textBox7.Text));
                 bw.Close();
             }

    http://kn1fe-zone.ru/index.php?threads/%D0%9F%D1%80%D0%B8%D0%BC%D0%B5%D1%80-%D0%BF%D1%80%D0%BE%D0%B3%D1%80%D0%B0%D0% BC%D0%BC%D1%8B-%D1%81-%D0%B0%D0%B2%D1%82%D0%BE%D0%BF%D0%BE%D0% B8%D1%81%D0%BA%D0%BE%D0%BC-%D0%B7%D0%BD%D0%B0%D1%87%D0%B5%D0%BD%D0% B8%D0%B9.381/

    ХОСПАДИ ДЕСЯТЬ ИЗ ДЕСЯТИ!!!!1111 Принесите мачете и спирт!

    DesmondHume, 28 Августа 2014

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

    +155

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    global $strError, $MESS, $HTTP_GET_VARS, $arrFORM_FILTER;
    	global $find_date_create_1, $find_date_create_2, $lAdmin;
    	$str = "";
    	CheckFilterDates($find_date_create_1, $find_date_create_2, $date1_wrong, $date2_wrong, $date2_less);
    	if ($date1_wrong=="Y") $str.= GetMessage("FORM_WRONG_DATE_CREATE_FROM")."<br>";
    	if ($date2_wrong=="Y") $str.= GetMessage("FORM_WRONG_DATE_CREATE_TO")."<br>";
    	if ($date2_less=="Y") $str.= GetMessage("FORM_FROM_TILL_DATE_CREATE")."<br>";

    bitrix

    - использование HTTP_GET_VARS уже давно deprecated
    - магические переменные find_date_create_1, find_date_create_2, да и lAdmin тоже не понятно что
    - зачем-то используются символы Y и N вместо true и false или 1 и 0

    memclutter, 28 Августа 2014

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