1. Лучший говнокод

    В номинации:
    За время:
  2. 1C / Говнокод #6113

    −103

    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
    к = 0;
    ТЗ2=СоздатьОбъект("ТаблицаЗначений");
    ВыгрузитьТабличнуюЧасть(ТЗ2,"ТМЦ,Кво");
    ТЗ2.НоваяКолонка("Арт");
    ТЗ2.ВыбратьСтроки();
    Пока ТЗ2.ПолучитьСтроку()=1 Цикл
    	ТМЦ_=ТЗ2.ПолучитьЗначение(к+1,"ТМЦ");
    	Если Лев(ТМЦ_,5)="Набор" Тогда
    		ТЗ2.Арт=ТМЦ_.Родитель;
    	Иначе
    		ТЗ2.Арт=ТМЦ_.Родитель.Родитель;
    	КонецЕсли;
    	к=к+1;
    КонецЦикла;

    Из 7.7. Особенно радует момент ТМЦ_=ТЗ2.ПолучитьЗначение(к+1,"ТМЦ");

    bytemdfab, 29 Марта 2011

    Комментарии (2)
  3. bash / Говнокод #6078

    −130

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    #!/bin/bash
    if [[ -d "$1" ]]; then
            /usr/bin/ls -lad -- "${1}" | awk '$1~/dr.x/{print $3}'                                                                                                  #if user
            gid="`/usr/bin/ls -lnad -- \"${1}\" | awk '{print $4}'`"
            USERS="`/usr/bin/ls -lad -- \"${1}\" | awk '{print $3}'`|`cat /etc/group | nawk -F: -v var2=$gid '$3 == var2 {print $4}' | tail -1`|`cat /etc/passwd | nawk -F: -v var2=$gid '$4 == var2 {print var=var\"|\"$1}' | tail -1`|`niscat group.org_dir | nawk -F: -v var2=$gid '$3 == var2 {print var=var\"|\"$4}' | tail -1`|`niscat passwd.org_dir | nawk -F: -v var2=$gid '$4 == var2 {print var=var\"|\"$1}' | tail -1`|`/usr/bin/ls -lad -- \"${1}\" | awk '{print $3}'`" #owner | group | passwd | niscat group | niscat passwd | owner
            if test "`/usr/bin/ls -lnad -- \"${1}\" | awk '$1~/..r.x[r-]/{print $4}'`";then                                                 #if group
                    echo ${USERS} | sed -e 's/,/|/g' | sed 's/||*/|/g' | nawk -F"|" '{for (i=1;i<=NF;i++) print $i}' | sort | uniq | sed -e '/^$/d' | grep -v "`/usr/bin/ls -lad -- "$1" | awk '{print $3}'`"
            fi
            if test "`/usr/bin/ls -lnad -- \"${1}\" | awk '$1~/r.x$/{print $4}'`";then                                                              #if other
                    niscat passwd.org_dir | cat /etc/passwd - | awk -F: '{print $1}' | sort | uniq | sed -e '/^$/d' | egrep -v "(`echo ${USERS} | sed -e 's/,/|/g' | sed 's/||*/|/g'`)"
            fi
    fi

    Одногрупник написал на баше лабораторную работу

    Ccik, 24 Марта 2011

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

    +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
    <?php
    $str=$argv[1];
    $sz=sizeof($str);
    $c=1;
    while($c){
    for($i=0;$i<=10;$i++){
    $str = strtolower($str);
    $per = str_shuffle($str);
    #echo "$per\n";
    $res=system("egrep ' ".$per." ' ./dict.txt | gawk '{ print $1 }'");
    if($res!="" && $sz=sizeof($res)){echo "Success $res\n";};
    };
    };
    ?>

    Поиск слов в словаре

    AliceGoth, 23 Марта 2011

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

    +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
    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
    <?
    class ActiveRecord {
    static function find_by_id($id) {
    	$class = get_called_class(); // LSI magic comes from here
    	$sql = 'SELECT FROM `' . $class . '` WHERE `id`=\'' . $id .  "';";
    	echo "Generate sql for select by id\n";
    	echo $sql . "\n";
    	return(new $class);
    }
    
    function save() {
    
    $class = get_class();
    
    if(!isset($this->id)) {
    echo "Generate sql for new Record:\n";
    $sql = 'INSERT INTO `' . $class . '` ';
    $sql_fields = '(';
    $sql_values = '(';
    foreach($this->fields as $field => $type) {
    	if($field != 'id') {
    	$sql_fields .= '`' . $field . '`,';
    	$sql_values .= "'" . $this->{$field} . "',";
    	}
    }
    $sql = $sql . substr($sql_fields, 0, -1) . ') VALUES ' . substr($sql_values, 0, -1) . ');';
    echo 'sql: ' . $sql . "\n";
    $this->id = 1;
    } 
    else {
    	echo "Generate sql for Update:\n";
    	 
    	$sql = 'UPDATE `' . $class . '` SET ';
    	foreach($this->fields as $field => $type) {
    	if($field != 'id') {
    	$sql .= '`' . $field . '`=\'' . $this->{$field} . '\',';
    	}
    	}
    	$sql = substr($sql, 0, -1) . ';';
    	echo 'sql: ' . $sql . "\n";
    }
    }
    }

    qbasic, 21 Марта 2011

    Комментарии (2)
  6. Perl / Говнокод #6045

    −126

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    #!/usr/bin/perl
    
    @zips = ();
    while(<>){
    @zips = m{([a-z]5[a-z])}igx;
    for(my $j=0;$j<=$#zips;$j++){
    $i = index($_,$zips[$j]);
    print "$zips[$j] pos $i\n";
    };
    print "$zips\n";
    
    }

    Находит комбинацию буква 5 буква

    AliceGoth, 20 Марта 2011

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

    +160

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    if ( (CheckDEADcall > 0) && (VD_live_customer_call==1) )
    					{
    					if (CheckDEADcallON < 1)
    					{
    					if( document.images ) { document.images['livecall'].src = image_livecall_DEAD.src;}
    						CheckDEADcallON=1;
    					}
    					}

    Оттуда же.

    7ion, 20 Марта 2011

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

    +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
    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
    65. 65
    66. 66
    else
    		{
    		fronter = user;
    		LasTCID			= MDnextResponse_array[0];
    		document.vicidial_form.lead_id.value			= MDnextResponse_array[1];
    		LeaDPreVDispO	= MDnextResponse_array[2];
    		document.vicidial_form.vendor_lead_code.value	= MDnextResponse_array[4];
    		document.vicidial_form.list_id.value			= MDnextResponse_array[5];
    		document.vicidial_form.gmt_offset_now.value		= MDnextResponse_array[6];
    		document.vicidial_form.phone_code.value			= MDnextResponse_array[7];
    		if ( (disable_alter_custphone=='Y') || (disable_alter_custphone=='HIDE') )
    			{
    			var tmp_pn = document.getElementById("phone_numberDISP");
    			if (disable_alter_custphone=='Y')
    {
    tmp_pn.innerHTML		= MDnextResponse_array[8];
    }
    			}
    		document.vicidial_form.phone_number.value		= MDnextResponse_array[8];
    		document.vicidial_form.title.value= MDnextResponse_array[9];
    		document.vicidial_form.first_name.value			= MDnextResponse_array[10];
    		document.vicidial_form.middle_initial.value		= MDnextResponse_array[11];
    		document.vicidial_form.last_name.value			= MDnextResponse_array[12];
    		document.vicidial_form.address1.value			= MDnextResponse_array[13];
    		document.vicidial_form.address2.value			= MDnextResponse_array[14];
    		document.vicidial_form.address3.value			= MDnextResponse_array[15];
    		document.vicidial_form.city.value= MDnextResponse_array[16];
    		document.vicidial_form.state.value= MDnextResponse_array[17];
    		document.vicidial_form.province.value			= MDnextResponse_array[18];
    		document.vicidial_form.postal_code.value		= MDnextResponse_array[19];
    		document.vicidial_form.country_code.value		= MDnextResponse_array[20];
    		document.vicidial_form.gender.value= MDnextResponse_array[21];
    		document.vicidial_form.date_of_birth.value		= MDnextResponse_array[22];
    		document.vicidial_form.alt_phone.value			= MDnextResponse_array[23];
    		document.vicidial_form.email.value= MDnextResponse_array[24];
    		document.vicidial_form.security_phrase.value	= MDnextResponse_array[25];
    		var REGcommentsNL = new RegExp("!N","g");
    		MDnextResponse_array[26] = MDnextResponse_array[26].replace(REGcommentsNL, "\n");
    		document.vicidial_form.comments.value			= MDnextResponse_array[26];
    		document.vicidial_form.called_count.value		= MDnextResponse_array[27];
    		previous_called_count			= MDnextResponse_array[27];
    		previous_dispo	= MDnextResponse_array[2];
    		CBentry_time	= MDnextResponse_array[28];
    		CBcallback_time	= MDnextResponse_array[29];
    		CBuser			= MDnextResponse_array[30];
    		CBcomments		= MDnextResponse_array[31];
    		dialed_number	= MDnextResponse_array[32];
    		dialed_label	= MDnextResponse_array[33];
    		source_id		= MDnextResponse_array[34];
    		document.vicidial_form.rank.value= MDnextResponse_array[35];
    		document.vicidial_form.owner.value= MDnextResponse_array[36];
    	//	CalL_ScripT_id	= MDnextResponse_array[37];
    		script_recording_delay			= MDnextResponse_array[38];
    		CalL_XC_a_NuMber= MDnextResponse_array[39];
    		CalL_XC_b_NuMber= MDnextResponse_array[40];
    		CalL_XC_c_NuMber= MDnextResponse_array[41];
    		CalL_XC_d_NuMber= MDnextResponse_array[42];
    		CalL_XC_e_NuMber= MDnextResponse_array[43];
    
    		timer_action = campaign_timer_action;
    		timer_action_message = campaign_timer_action_message;
    		timer_action_seconds = campaign_timer_action_seconds;
    			
    		lead_dial_number = document.vicidial_form.phone_number.value;
    		var dispnum = document.vicidial_form.phone_number.value;
    		var status_display_number = phone_number_format(dispnum);

    7ion, 20 Марта 2011

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

    +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
    if (prepopulate_transfer_preset_enabled > 0)
    									{
    if (prepopulate_transfer_preset == 'PRESET_1')
    										{document.vicidial_form.xfernumber.value = CalL_XC_a_NuMber;}
    if (prepopulate_transfer_preset == 'PRESET_2')
    										{document.vicidial_form.xfernumber.value = CalL_XC_b_NuMber;}
    if (prepopulate_transfer_preset == 'PRESET_3')
    										{document.vicidial_form.xfernumber.value = CalL_XC_c_NuMber;}
    if (prepopulate_transfer_preset == 'PRESET_4')
    										{document.vicidial_form.xfernumber.value = CalL_XC_d_NuMber;}
    if (prepopulate_transfer_preset == 'PRESET_5')
    										{document.vicidial_form.xfernumber.value = CalL_XC_e_NuMber;}
    									}
    if ( (quick_transfer_button == 'PRESET_1') || (quick_transfer_button == 'PRESET_2') || (quick_transfer_button == 'PRESET_3') || (quick_transfer_button == 'PRESET_4') || (quick_transfer_button == 'PRESET_5') )
    									{
    									document.getElementById("QuickXfer").innerHTML = "<a href=\"#\" onclick=\"mainxfer_send_redirect('XfeRBLIND','" + lastcustchannel + "','" + lastcustserverip + "');return false;\"><IMG SRC=\"./images/vdc_LB_quickxfer.gif\" border=0 alt=\"QUICK TRANSFER\"></a>";
    
    									if (quick_transfer_button == 'PRESET_1')
    										{document.vicidial_form.xfernumber.value = CalL_XC_a_NuMber;}
    									if (quick_transfer_button == 'PRESET_2')
    										{document.vicidial_form.xfernumber.value = CalL_XC_b_NuMber;}
    									if (quick_transfer_button == 'PRESET_3')
    										{document.vicidial_form.xfernumber.value = CalL_XC_c_NuMber;}
    									if (quick_transfer_button == 'PRESET_4')
    										{document.vicidial_form.xfernumber.value = CalL_XC_d_NuMber;}
    									if (quick_transfer_button == 'PRESET_5')
    										{document.vicidial_form.xfernumber.value = CalL_XC_e_NuMber;}
    									}

    7ion, 20 Марта 2011

    Комментарии (2)
  10. Си / Говнокод #6025

    +126

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    format MS COFF
    
    public fuckHighLevel as '_fuckHighLevel@4'
    
    fuckHighLevel:
            pop ebx
    
                pop eax
                add eax, 1
    
            jmp ebx

    Вызываем ассемблерную процедуру из Си.
    Вместо retn используем безусловыный переход на адрес возврата.
    Но работает же!

    danilissimus, 19 Марта 2011

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

    +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
    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
    65. 65
    66. 66
    67. 67
    68. 68
    69. 69
    70. 70
    71. 71
    72. 72
    73. 73
    74. 74
    75. 75
    76. 76
    77. 77
    78. 78
    79. 79
    80. 80
    81. 81
    82. 82
    83. 83
    84. 84
    elseif( $action == "pingationmod" ) { 
    echoheader( "options", "pingationMod" ); 
    echo <<<HTML 
    <form action="{$PHP_SELF}" method="post"> 
    <div style="padding-top:5px;padding-bottom:2px;"> 
    <table width="100%"> 
    <tr> 
    <td width="4"><img src="engine/skins/images/tl_lo.gif" width="4" height="4" border="0"></td> 
    <td background="engine/skins/images/tl_oo.gif"><img src="engine/skins/images/tl_oo.gif" width="1" height="4" border="0"></td> 
    <td width="6"><img src="engine/skins/images/tl_ro.gif" width="6" height="4" border="0"></td> 
    </tr> 
    <tr> 
    <td background="engine/skins/images/tl_lb.gif"><img src="engine/skins/images/tl_lb.gif" width="4" height="1" border="0"></td> 
    <td style="padding:5px;" bgcolor="#FFFFFF"> 
    <table width="100%"> 
    <tr> 
    <td bgcolor="#EFEFEF" height="29" style="padding-left:10px;"><div class="navigation">Отправка уведомлений в пинг сервисы</div></td> 
    </tr> 
    </table> 
    <div class="unterline"></div> 
    <table width="100%"> 
    <tr> 
    <td style="padding:2px;" height="100" align="center"> 
    HTML; 
         
    echo "Вы действительно хотите отправить уведомления в пинг сервисы, на (<b>" . count( $selected_news ). "</b>) $lang[mass_confirm_1]<br><br> 
    <input class=bbcodes type=submit value=\"   $lang[mass_yes]   \"> &nbsp; <input type=button class=bbcodes value=\"  $lang[mass_no]  \" onclick=\"javascript:document.location='$PHP_SELF?mod=editnews&action=list'\"> 
    <input type=hidden name=action value=\"do_mass_ping\"> 
    <input type=hidden name=user_hash value=\"{$dle_login_hash}\"> 
    <input type=hidden name=mod value=\"massactions\">"; 
    foreach ( $selected_news as $newsid ) { 
    $newsid = intval($newsid); 
    echo "<input type=hidden name=selected_news[] value=\"$newsid\">"; 
    } 
    echo <<<HTML 
    </tr> 
    </table> 
    </td> 
    <td background="engine/skins/images/tl_rb.gif"><img src="engine/skins/images/tl_rb.gif" width="6" height="1" border="0"></td> 
    </tr> 
    <tr> 
    <td><img src="engine/skins/images/tl_lu.gif" width="4" height="6" border="0"></td> 
    <td background="engine/skins/images/tl_ub.gif"><img src="engine/skins/images/tl_ub.gif" width="1" height="6" border="0"></td> 
    <td><img src="engine/skins/images/tl_ru.gif" width="6" height="6" border="0"></td> 
    </tr> 
    </table> 
    </div></form> 
    HTML; 
    echofooter(); 
    exit(); 
    }elseif( $action == "do_mass_ping" ) { 
    include ENGINE_DIR .'/inc/include/pingfunction.php'; 
    include ENGINE_DIR .'/data/pingdata.php'; 
    foreach ( $selected_news as $newsid ) { 
    $newsid = intval($newsid); 
    $sql_select = "SELECT id, title, date, category, alt_name, flag FROM ".PREFIX ."_post WHERE id=".$newsid; 
    $sql_result = $db->query( $sql_select ); 
    while ( $row = $db->get_row( $sql_result ) ) { 
    $row['date'] = strtotime( $row['date'] ); 
    $title = $row['title']; 
    if( $config['allow_alt_url'] == "yes") { 
    if( $row['flag'] and $config['seo_type'] ) { 
    if( $row['category'] and $config['seo_type'] == 2 ) { 
    $full_link = $config['http_home_url'] .get_url( $row['category'] ) ."/".$row['id'] ."-".$row['alt_name'] .".html"; 
    }else { 
    $full_link = $config['http_home_url'] .$row['id'] ."-".$row['alt_name'] .".html"; 
    } 
    }else { 
    $full_link = $config['http_home_url'] .date( 'Y/m/d/',$row['date'] ) .$row['alt_name'] .".html"; 
    } 
    }else { 
    $full_link = $config['http_home_url'] ."index.php?newsid=".$row['id']; 
    } 
    } 
    pingationMod($title, $full_link, 0, $pingdata['service'], $pingdata['zaderjka']); 
    } 
    if($pingdata['allow_log']){ 
     
    saveLog("Массовая отправка уведомлений в пинг сервисы"); 
    } 
     
    clear_cache(); 
    msg( "info", "Уведомления успешно отправлены", "Уведомления успешно отправлены в пинг сервисы", $_SESSION['admin_referrer'] ); 
    }

    qbasic, 16 Марта 2011

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