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

    +170

    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
    $замены = array(
    	'{' => 'начало',
    	'}' => 'конец',
    	'for' => 'циклдля',
    	'echo' => 'вывод',
    	'print' => 'печать',
    	'while' => 'пока',
    	'foreach' => 'циклмассив',
    	'$' => 'пер ',
    	'=' => ':=',
    	//'==' => '=',
    	'!=' => '<>',
    	'function' => 'функ',
    	'true' => 'правда',
    	'false' => 'ложь',
    	'if' => 'если',
    	'else' => 'иначе',
    	'as' => 'как',
    	'array' => 'массив',
    	'_GET' => 'ГЕТ',
    	'_POST' => 'ПОСТ',
    	'return' => 'вернуть',
    );
    
    isset($_GET['debug']) ? print(ВПоХаПэ(file_get_contents($_GET['f']))) : Компилить(file_get_contents($_GET['f']));
    
    function Компилить($сорсец) {
    	eval(ВПоХаПэ($сорсец));
    }
    
    function ВПоХаПэ($сорсец) {
    	global $замены;
    	return str_replace(array_values($замены), array_keys($замены), $сорсец);
    }
    
    function ИзПоХаПэ($сорсец) {
    	global $замены;
    	return str_replace(array_keys($замены), array_values($замены), $сорсец);
    }

    Транслятор псевдоязыка в PHP

    Мартин, 30 Марта 2011

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

    +111

    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
    public const string Message = "messagebox";
                public const string Message_Error = "messagebox.error";
                public const string Message_Question = "messagebox.question";
    
            public void ProcessUrl(string url, object urlContext, EventHandler<ProcessUrlArgs> callback)
            {
                switch (url)
                {
                    case Url.Message:
                        urlArgs.Result = XtraMessageBox.Show((string) urlContext, captionText, MessageBoxButtons.OK,
                                                             MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
                        callback(this, urlArgs);
                        return;
                    case Url.Message_Error:
                        urlArgs.Result = XtraMessageBox.Show((string) urlContext, captionText, MessageBoxButtons.OK,
                                                             MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
                        callback(this, urlArgs);
                        return;
                    case Url.Message_Question:
                        urlArgs.Result = XtraMessageBox.Show((string) urlContext, captionText, MessageBoxButtons.OKCancel,
                                                             MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);
                        callback(this, urlArgs);
                        return;
                }
     
         // дальше идет уже ручная разборка Url

    Человек изобрел своего диспетчера контролов внутри формы. Вместо специфических методов вызывающий формирует строку вида
    "command.subcommand.parameter1.parameter 2", передается диспетчеру а он уже парсит это обратно.
    К примеру "prefix.persons.view.23.all" означает что нужно создать юзер контрол PersonDetail для персоны с id 23 и показать все опции. Но можно передать и "message" тогда покажется messagebox. Все это происходит внутри одного UI модуля, и все классы internal. более того, этих usercontrols всего 4 разных и все это говно можно заменить на 4 метода с парой параметров в каждом. Но там было бы слишком просто и легко отслеживать что откуда вызывается. А в случае единственного метода ProcessUrl (который не url :) ) все гораздо веселее.

    eval_2009, 30 Марта 2011

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

    +168

    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
    $('#status:first').html('Выберите нужный подарок и НАЖМИТЕ по нему!');
    $("#status:eq(1)").html("Ваш баланс:<span class='balans'>"+balans);
    $("#status:eq(1)").html($("#status:eq(1)").html()+"</span>");
    function otkritPodarokOdin(){
    	document.getElementById('podarokOdin').style.display='block';
    	if($('.balans').html() == '10' || parseFloat($('.balans').html()) > 10){}else{
    		$('div[id="podarokOdin"]').hide();
    		$('#status:first').html('Ошибка!НЕДОСТАТОЧНО СРЕДСТВ НА СЧЕТУ!');
    	}
    };
    function otkritPodarokDva(){
    	document.getElementById('podarokDva').style.display='block';
    	if($('.balans').html() == '10' || parseFloat($('.balans').html()) > 10){}else{
    		$('div[id="podarokDva"]').hide();
    		$('#status:first').html('Ошибка!НЕДОСТАТОЧНО СРЕДСТВ НА СЧЕТУ!');
    	}
    };
    function otkritPodarokTri(){
    	document.getElementById('podarokTri').style.display='block';
    	if($('.balans').html() == '10' || parseFloat($('.balans').html()) > 10){}else{
    		$('div[id="podarokTri"]').hide();
    		$('#status:first').html('Ошибка!НЕДОСТАТОЧНО СРЕДСТВ НА СЧЕТУ!');
    	}
    };
    function otkritPodarokChetyre(){
    	document.getElementById('podarokChetyre').style.display='block';
    	if($('.balans').html() == '10' || parseFloat($('.balans').html()) > 10){}else{
    		$('div[id="podarokChetyre"]').hide();
    		$('#status:first').html('Ошибка!НЕДОСТАТОЧНО СРЕДСТВ НА СЧЕТУ!');
    	}
    };
    function otkritPodarokPyat(){
    	document.getElementById('podarokPyat').style.display='block';
    	if($('.balans').html() == '10' || parseFloat($('.balans').html()) > 10){}else{
    		$('div[id="podarokPyat"]').hide();
    		$('#status:first').html('Ошибка!НЕДОСТАТОЧНО СРЕДСТВ НА СЧЕТУ!');
    	}
    };
    function otkritPodarokShest(){
    	document.getElementById('podarokShest').style.display='block';
    	if($('.balans').html() == '10' || parseFloat($('.balans').html()) > 10){}else{
    		$('div[id="podarokShest"]').hide();
    		$('#status:first').html('Ошибка!НЕДОСТАТОЧНО СРЕДСТВ НА СЧЕТУ!');
    	}
    };

    Воздержусь указывать где говнокод. Собственно повсюду.

    stuffort, 30 Марта 2011

    Комментарии (11)
  4. JavaScript / Говнокод #6143

    +170

    1. 1
    var obj=getObjById($(this).attr("id"));

    Вот такое хорошое применение jquery =)
    http://javascript.ru/forum/misc/16224-pokritikujjte-podkhod-pozhalujjsta.html

    vulkan, 30 Марта 2011

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

    +159

    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
    if (is_dir($read_dir)) {
    	if ($open_dir = @opendir($read_dir)) {
    		while (false !== ($dir_temp = readdir($open_dir))){
    			if ($dir_temp != "." && $dir_temp != ".." && is_dir($read_dir.'/'.$dir_temp) && $filtre == '') {
    				if(!(file_exists("../templates/".$dir_temp."/parameter/info.php"))) {
    					echo messStop(LG_DIR.' ' . $dir_temp . ' '.LG_MOD_ERROR_IS_FILE_);
    				} else {
    					require("../templates/".$dir_temp."/parameter/info.php");
    					echo "<tr><td>";
    					if(!(file_exists("../templates/".$dir_temp."/parameter/previews.jpg"))) {
    						echo "<a href=\"?am=mod[template]&template=[edit]&name=$dir_temp\" OnMouseOver=\"Tip('<img width=&quot;175&quot; src=&quot;../images/all/no_prewies.png&quot; >')\" />$temp_name</a>";
    					} else {
    						echo "<a href=\"?am=mod[template]&template=[edit]&name=$dir_temp\" OnMouseOver=\"Tip('<img width=&quot;175&quot; src=&quot;../templates/$dir_temp/parameter/previews.jpg&quot; >')\" />$temp_name</a>";
    					}
    					echo "</td><td>$temp_version</td><td>$temp_date</td><td>$temp_autor</td></tr>";
    				}
    			} elseif ($dir_temp != "." && $dir_temp != ".." && is_dir($read_dir.'/'.$dir_temp) && $dir_temp == $filtre) {
    				if(!(file_exists("../templates/".$dir_temp."/parameter/info.php"))) {
    					echo messStop(LG_DIR.' ' . $dir_temp . ' '.LG_MOD_ERROR_IS_FILE_);
    				} else {
    					require("../templates/".$dir_temp."/parameter/info.php");
    					echo "<tr><td>";
    					if(!(file_exists("../templates/".$dir_temp."/parameter/previews.jpg"))) {
    						echo "<a href=\"?am=mod[template]&template=[edit]&name=$dir_temp\" OnMouseOver=\"Tip('<img width=&quot;175&quot; src=&quot;../images/all/no_prewies.png&quot; >')\" />$temp_name</a>";
    					} else {
    						echo "<a href=\"?am=mod[template]&template=[edit]&name=$dir_temp\" OnMouseOver=\"Tip('<img width=&quot;175&quot; src=&quot;../templates/$dir_temp/parameter/previews.jpg&quot; >')\" />$temp_name</a>";
    					}
    					echo "</td><td>$temp_version</td><td>$temp_date</td><td>$temp_autor</td></tr>";
    				}
    			} elseif(!is_dir($read_dir.'/'.$filtre) && $filtre != '' && $filtre != $dir_temp) {
    				$returnMessWarn = messSearch(LG_ERR_FILTRE_NULL);
    			}
    		}
    	closedir($open_dir);
    	}
    }

    Данный код выводит списком шаблоны от системы.... Самое страшное, когда спустя некоторое время, со свежими мозгами потребовалось усовершенствовать всё это, в итоге проблема решилась просто, всё переписатьс нуля по человечески.

    nethak, 30 Марта 2011

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

    +158

    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
    function showOrders (tab, type, page) {
        $('#grid').load('../../citizen/'+type);
        switch (page) {
            case 'cmain':
                var activeTab_class = 'mainActiveTab';
                var unactiveTab_class = 'mainUnactiveTab';
            break;
            case 'corders':
                var activeTab_class = 'activeTab';
                var unactiveTab_class = 'unactiveTab';
            break;
        }
        var some_tab = document.getElementsByClassName(activeTab_class);
        var count = some_tab.length;
            for (var i = 0; i<= (count-1); i++) {
                some_tab[i].className = unactiveTab_class;
            }
        tab.className = activeTab_class;
    }

    у нас так WebUI программируется =)

    nur, 30 Марта 2011

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

    +155

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    if($upload) { $ftpsucc=1; } else { $ftpsucc=0; } 
    // check upload status: 
    print (!$upload) ? 'Cannot upload' : 'Upload complete'; 
    print "\n"; 
    // close the FTP stream 
    ftp_close($conn_id); 
    ?>

    Из комментариев php.net. Переменная $ftpsucc далее не используется.

    Sinless, 30 Марта 2011

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

    +167

    1. 1
    Перейти на страницу <span onmouseover="this.className='menu_over'" onmouseout="this.className='menu'" class="menu" onClick="window.location='<?echo $arItem["DETAIL_PAGE_URL"]?>'">--></span>

    тег "a" видимо был незнаком.

    Fisher, 30 Марта 2011

    Комментарии (20)
  9. Perl / Говнокод #6138

    −124

    1. 1
    grep {$a_b_props = ($a_b_props && $a_b_props.".").(($block < 1)? &dupl($tempProps{$_}) : $tempProps{$_}) if /^[ab]_/} sort keys %tempProps;

    туда же...

    abadonna, 30 Марта 2011

    Комментарии (0)
  10. ActionScript / Говнокод #6137

    −125

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    <a href="javascript:void(0);"
    onclick="$('menu_main_dropdown2').style.display = ( 
    $('menu_main_dropdown2').style.display=='none' ? 'inline' : 'none' );
    $('menu_main_dropdown').style.display = 'none';this.blur(); return false;"
    class="top_menu_item">
    Account</a>

    Скрытие /показ блока меню

    Vasiliy, 30 Марта 2011

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