1. Список говнокодов пользователя guest

    Всего: 1419

  2. JavaScript / Говнокод #672

    +133.8

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    iplist += "<ul id='iplist'>";
    jsonData="[";
    for(var i=0;i<selections.length;i++) {
        jsonData += Ext.util.JSON.encode(selections[i])+",";
        iplist += "<li>" + selections[i] + "; </li>";
    }
    jsonData = jsonData.substring(0,jsonData.length-1) + "]";
    iplist += "</ul>";
    win.show();
    Ext.get("list").update(iplist);
    win.hide();
    win.show();

    В ExtJS не хотел обновляться компонент окна.

    guest, 05 Марта 2009

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

    +139

    1. 1
    print( '?> <span class="TextContentRedBig"> <? В одноместный двоих не селят ?> </span><? ');

    Блин почему не работает???

    guest, 05 Марта 2009

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

    +145

    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
    <?php
    require_once('global.php');
    
    $id = $_GET['id'];
    if( !$lore_system->db->id_exists( $id, 'lore_articles') )
    {
    	$lore_system->te->assign('error_message', 'invalid_article');
    	$lore_system->te->display('error_message.tpl');
    	exit;
    }
    if( !$lore_db_interface->article_is_published( $id ) )
    {
    	$lore_system->te->assign('error_message', 'article_not_published');
    	$lore_system->te->display('error_message.tpl');
    	exit;
    }
    
    $action = ( isset( $_REQUEST['action'] ) ) ? $_REQUEST['action'] : 'article';
    switch( $action )
    {
    	case 'print':
    		$article = $lore_db_interface->get_article_info( $id );
    		$article['comments'] = $lore_db_interface->get_article_comments( $id );
    		
    		$lore_system->te->assign('category_path', $lore_db_interface->get_category_path( $article['category_id'] ));
    		$lore_system->te->assign('article', $article);
    		$lore_system->te->display('article_print.tpl');
    	break;
    		
    	case 'article':
    		if( !@in_array( $id, $lore_user_session->session_vars['viewed_articles'] ) )
    		{
    			$lore_db_interface->increment_article_views( $id );
    			$lore_user_session->session_vars['viewed_articles'][] = $id;
    		}
    		
    		$article			= $lore_db_interface->get_article_info( $id );
    		$article['comments']		= $lore_db_interface->get_article_comments( $id );
    		$article['num_comments']	= count($article['comments']);
    		$article['attachments']		= $lore_db_interface->get_article_attachments( $id );
    		$article['allow_comments']	= $lore_db_interface->can_comment_on_article( $id );
    		$article['related_articles']	= $lore_db_interface->get_related_articles( $id );
    
    		if( $lore_user_session->has_article_write_permission( $id ) )
    		{
    			$article['display_edit_link'] = true;
    		}
    
    		if( $lore_system->settings['enable_glossary_popups'] )
    		{
    			$glossary_terms = $lore_db_interface->get_glossary_terms();
    			if( count($glossary_terms) )
    			{
    				$term_html = array();
    				$html_tags = array();
    				$term_c = 0;
    
    				// strip out HTML tags first
    				@preg_match_all("/<[^>]+>/", $article['content'], $matches);
    				for( $i = 1; $i < count($matches[0]); $i++ )
    				{
    					// save html tag for later
    					$html_tags[$i] = $matches[0][$i];
    					
    					// parse in placeholder
    					$article['content'] = str_replace( $matches[0][$i], "{{h$i}}", $article['content']);
    				}
    					
    				foreach( $glossary_terms AS $term )
    				{
    					// Add "i" (NOT case sensitive) modifier to regular expression if necessary
    					$case = ( $term['case_sensitive'] ) ? '' : 'i';
    					
    					$term['definition'] = ereg_replace("[\n\r]", '', $term['definition']);
    					
    					$lore_system->te->assign('term', htmlspecialchars(str_replace("'", "\\'", $term['term'])) );

    guest, 05 Марта 2009

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

    +149

    1. 1
    $article['content'] = preg_replace("/\b" . $matches[0][$i] . "\b/", "{{g$term_c}}", $article['content']);

    guest, 05 Марта 2009

    Комментарии (0)
  6. PHP / Говнокод #668

    +143.5

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    function getQueryString($fileName, $v1 = "", $v2 = "", $v3 = "", $v4 = "", $v5 = "", $v6 = "", $v7 = "", $v8 = "", $v9 = "", $v10 = "", $v11 = "", $v12 = "", $v13 = "", $v14 = "", $v15 = "")
    {
    	global $queryStringCache;
    	
    	if(!isset($queryStringCache[$fileName]))
    	{
    		$queryStringCache[$fileName] = file_get_contents(dirname(__FILE__).'/sql/'.$fileName);
    	}
    	
    	$query = sprintf($queryStringCache[$fileName], $v1, $v2, $v3, $v4, $v5, $v6, $v7, $v8, $v9, $v10, $v11, $v12, $v13, $v14);
    	return $query;
    }

    guest, 05 Марта 2009

    Комментарии (0)
  7. Java / Говнокод #667

    +133.7

    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
    public class ImageRotator {
    
        public static BufferedImage rotate(BufferedImage originalImage, int angle) {
            BufferedImage image = null;
            switch (angle) {
                case 90:
                case -270:
                    image = ImageRotator.rotate90Right(originalImage);
                    break;
                case 270:
                case -90:
                    image = ImageRotator.rotate90Left(originalImage);
                    break;
                case 180:
                case -180:
                    image = ImageRotator.rotate180(originalImage);
                    break;
                default:
                    image = originalImage;
                    break;
            }
            return image;
        }
    
        private static BufferedImage rotate90Left(BufferedImage bi) {
            int width = bi.getWidth();
            int height = bi.getHeight();
            BufferedImage biFlip = new BufferedImage(height, width, bi.getType());
            for (int i = 0; i < width; i++) {
                for (int j = 0; j < height; j++) {
                    biFlip.setRGB(height - 1 - j, width - 1 - i, bi.getRGB(i, j));
                }
            }
            return biFlip;
        }
    
        private static BufferedImage rotate90Right(BufferedImage bi) {
            int width = bi.getWidth();
            int height = bi.getHeight();
            BufferedImage biFlip = new BufferedImage(height, width, bi.getType());
            for (int i = 0; i < width; i++) {
                for (int j = 0; j < height; j++) {
                    biFlip.setRGB(j, i, bi.getRGB(i, j));
                }
            }
            return biFlip;
        }
    
        private static BufferedImage rotate180(BufferedImage bi) {
            int width = bi.getWidth();
            int height = bi.getHeight();
            BufferedImage biFlip = new BufferedImage(width, height, bi.getType());
            for (int i = 0; i < width; i++) {
                for (int j = 0; j < height; j++) {
                    biFlip.setRGB(i, j, bi.getRGB(width - 1 - i, height - 1 - j));
                }
            }
            return biFlip;
        }
    }

    Есть в Java для работы с изображениями такой класс как AphineTransform, но в после 3 часов активного взаимодействия с ним добился только того что изображение после болшого кол-ва поворотов привращалось в точку. Поэтому из себя была выдавлена эта заглушка...

    guest, 05 Марта 2009

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

    +193

    1. 1
    2. 2
    header('Content-Type: text/html; charset=utf-8\n\n');
    session_commit();session_start();session_commit();session_start();  // магия, блять

    В PHP иногда возникает проблема с обновлением сессии (ну не успевает записать и всё тут), а сразу после обновления идёт вызов аяксом нового файла с header(...) и запросом этой же переменной сессии. Вот так вот решил кто-то (и кстати работает на ура):

    guest, 05 Марта 2009

    Комментарии (17)
  9. Си / Говнокод #665

    +140.7

    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
    #include <stdio.h>
    #include <string.h>
    #define icon_no -
    
    const char ICON_DEF[]     = ".png";
    const char ICON_NO[]      = "-";
    int main(int argc, char * argv[] ) {
    	char result[128];
    	char string[128];
    	strcpy(string,ICON_DEF);
    	char * ext_pnt = strrchr(string,'.');
    	if(!ext_pnt)
    		return 1;
    
    	char * ext = &ext_pnt[1];
    	int i;
    	printf("ext=%s\n",ext);
    	for ( i = 1; i< argc ; i++ ) {
    		char * arg = argv[i];
    		int extlen = strlen(ext);
    		if( strncmp(ext,arg,extlen) == 0 ) {
    			strcpy(result,&arg[extlen+1]);
    		} else {
    			strcpy(result,ICON_NO);
    			strcat(result,ext_pnt);
    		}
    		printf("arg[%d]=%s, result: %s\n", i, arg, result);
    	}
    
    
      return 0;
    }

    guest, 04 Марта 2009

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

    −854

    1. 1
    select * from Etbagent where id=555

    слово хуй

    guest, 04 Марта 2009

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

    +167.3

    1. 1
    2. 2
    3. 3
    GLOBAL $_SERVER; 
    GLOBAL $_COOKIE;
    .......

    Вот переделывал код одного товариша, и так и не смог понять зачем вот эти строчки он добавлял в КАЖДЫЙ файл

    guest, 04 Марта 2009

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