1. C++ / Говнокод #6435

    +165

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    std::vector <CElement> elemGun
     std::vector <CElement> eOther
    ...
    elemGun[0].wVx/=2.f;
    elemGun[0].wVy/=2.f;
    eOther.push_back(elemGun[0]);
    elemGun[0].wVx*=2.f;
    elemGun[0].wVy*=2.f;
    ...

    ssAVEL, 21 Апреля 2011

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

    +160

    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
    public function isValidModule($module)
        {
            if (!is_string($module)) {
                return false;
            }
    
            $module        = strtolower($module);
            $controllerDir = $this->getControllerDirectory();
            foreach (array_keys($controllerDir) as $moduleName) {
                if ($module == strtolower($moduleName)) {
                    return true;
                }
            }
    
            return false;
        }

    Великий и могучий Zend Framework в очередной раз очаровывает своих адептов изяществом и простотой(((

    hacpaka, 21 Апреля 2011

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

    +156

    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
    // #1
    this.vml_capable = (document.all && !(navigator.userAgent.indexOf("Opera")>=0)) ? true : false;
    
    // #2
    styleSheet.addRule("v\\: *", "behavior:url(#default#VML); position:absolute" );
    styleSheet.addRule("v\\:roundrect", "behavior:url(#default#VML); position:absolute" );
    styleSheet.addRule("v\\:oval", "behavior:url(#default#VML); position:absolute" );
    styleSheet.addRule("v\\:roundrect", "behavior:url(#default#VML); position:absolute" );
    styleSheet.addRule("v\\:fill", "behavior:url(#default#VML); position:absolute" );
    styleSheet.addRule("v\\:line", "behavior:url(#default#VML); position:absolute" );
    styleSheet.addRule("v\\:shape", "behavior:url(#default#VML); position:absolute" );
    styleSheet.addRule("v\\:polyline", "behavior:url(#default#VML); position:absolute" );
    styleSheet.addRule("v\\:stroke", "behavior:url(#default#VML); position:absolute" );

    Библиотека svg2vml

    albburtsev, 21 Апреля 2011

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

    +143

    1. 1
    2. 2
    3. 3
    4. 4
    for (int i = 0; i < ptr->len; i++)
    {
    	*(((unsigned char *) ptr->payload) + i) = (unsigned char) toupper(*(((unsigned char *) ptr->payload) + i));
    }

    Перевод символов, находящихся в строке по адресу ptr->payload (типа void *) в верхний регистр.

    Fellrond, 21 Апреля 2011

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

    +169

    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
    bool NSFileExists(const char * FileName)
    {
      struct _stat fStats;
      return (_stat(FileName, &fStats) == 0);
    }
    
    #if 0
    bool NSFileExists(const char * FileName)
    {
      WIN32_FIND_DATA fd;
      HANDLE hFF;
      bool bExist(true);
      hFF = FindFirstFile(FileName, &fd);
      if (hFF == INVALID_HANDLE_VALUE) bExist = false;
      else FindClose(hFF);
      return bExist;
    }
    #endif
    
    #if 0
    bool NSFileExists(const char * FileName)
    {
      HANDLE hFile = ::CreateFile(FileName, 0, 0, 0, OPEN_EXISTING, 0, 0);
      if (hFile != INVALID_HANDLE_VALUE)
      {
        CloseHandle(hFile);
        return true;
      }
      return false;
    }
    #endif

    Эволюция!
    Без комментариев...

    JeremyW, 21 Апреля 2011

    Комментарии (16)
  6. C++ / Говнокод #6430

    +157

    1. 1
    2. 2
    3. 3
    // ...
    ReplaceHtmlEntities( std::string(abstract), true );
    // ...

    В одном из проектов было найдено (очередная операция подергивания):

    void ReplaceHtmlEntities(std::string &, bool /* = true */);
    abstract - const char *

    JeremyW, 21 Апреля 2011

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

    +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
    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
    protected function getMebelNavigationHtml()
    {
    $nav = <<<EODD
    <td>
    	<div class="g-c right">
    		<div class="tab">
    			<nobr><a href="/mebel">Мебель</a></nobr>
    		</div>
    		<div class="body">
    			<table>
    				<tr>
    					<td class="col">
    						<ul>
    							<li class="head"><a href="/mebel/stulchiki">Стульчики</a></li>
    							<li class="head"><a href="/mebel/krovatki">Кроватки</a></li>
    							<li class="head"><a href="/mebel/manezhi">Манежи</a></li>
    							<li class="head"><a href="/mebel/komody">Комоды</a></li>
    							<li class="head"><a href="/mebel/pelenalnye-stoliki">Пеленальные столики</a></li>
    							<li class="head"><a href="/mebel/electrokacheli">Электрокачели</a></li>
    							<li class="head"><a href="/mebel/napolnie-ka4eli">Напольные качели</a></li>
    							<li class="head"><a href="/mebel/kresla-kachalki">Кресла-качалки</a></li>
    							<li class="head"><a href="/mebel/hodunki">Ходунки</a></li>
    							<li class="head"><a href="/mebel/kolybeli">Колыбели</a></li>
    							<li class="head"><a href="/mebel/shkafy">Шкафы</a></li>
    							<li class="head"><a href="/mebel/detskie-komnaty">Детские комнаты</a></li>
    							<li class="head"><a href="/mebel/matrasy">Матрасы</a></li>
    							<li class="head"><a href="/mebel/aksessuary">Аксессуары</a></li>
    						</ul>
    					</td>
    					<td class="col">
    						<ul>
    							<li class="head"><a href="/mebel/postel">Постельные принадлежности</a></li>
    							<li><a href="/mebel/postel/odeyala">Одеяла</a></li>
    							<li><a href="/mebel/postel/podushki">Подушки</a></li>
    							<li><a href="/mebel/postel/komplekty-postelnogo-belya">Комплекты постельного белья</a></li>
    							<li><a href="/mebel/postel/spalnye-meshki">Спальные мешки</a></li>
    							<li><a href="/mebel/postel/komplekty-na-vypisku">Комплекты на выписку</a></li>
    							<li><a href="/mebel/postel/baldahiny">Балдахины</a></li>
    							<li><a href="/mebel/postel/aksessuary">Аксессуары</a></li>
    							<li><a href="/mebel/postel/prosini-i-kleenki">Простыни и клеенки</a></li>
    							<li><a href="/mebel/postel/bortiki">Бортики</a></li>
    						</ul>
    					</td>
    				</tr>
    			</table>
    		</div>
    	</div>
    	<a href="/mebel">Мебель</a>
    </td>
    EODD;
    		return $nav;
    }

    Хардкоженая навигация. Даже не в шаблоне...

    vsushkov, 21 Апреля 2011

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

    +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
    public function drawItem($category, $level=0, $last=false)
        {
            // ...
    		
            if($this->isIgrushkiCategory($category) && ($level == 0))
                // ...
            } elseif ($level == 1) {
                // ...
            } elseif ($level == 2) {
                // ...
            } else {
                Mage::log('пришол пиздец!');
            }
            return $html;
        }

    ни программировать, ни по русски писать...

    vsushkov, 21 Апреля 2011

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

    +161

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    9. 9
    public function setAmbiguityIdentity($flag)
        {
            if (is_integer($flag)) {
                $this->_ambiguityIdentity = (1 === $flag ? true : false);
            } elseif (is_bool($flag)) {
                $this->_ambiguityIdentity = $flag;
            }
            return $this;
        }

    Zend Framework компонент Zend_Auth_Adapter_DbTable. (Слегка смутила строка 4)

    sonic, 21 Апреля 2011

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

    +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
    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
    <?php
    if(isset($_GET['pid'])){
    $pid = $_GET['pid'];
    echo $pid;
    $szi=iconv_strlen($pid);
    if(file_exists("./$pid.txt")){
    $fc=fopen("$pid.txt","r");
    if($fc<0)exit(0);
    fseek($fc,0,0);
    $url = fread($fc,filesize("./$pid.txt"));
    fclose($fc);
      header('Location: '.$url);
    } else {
      echo "File not exist<br>";
    };
    
    };
    $idx=0;
    $fc=fopen("index.txt","r");
    if($fc<0)exit(0);
    $idx = fread($fc,filesize("index.txt"));
    fclose($fc);
    $fc=fopen("./$idx.txt","r");
    if($fc<0)exit(0);
    $url = fread($fc,filesize("./$idx.txt"));
    fclose($fc);
    echo "<a href=\"http://netelis.hmsite.net/index.php?pid=$idx\">$url</a>";
    
    if(isset($_POST['url'])){
    $url=$_POST['url'];
    if (parse_url($url)) {
        echo "Your url is ok.";
      for($i=0;$i<=$idx;$i+=2){
        $fc=fopen("$i.txt","r");
      if($fc<0)exit(0);
        $urla = fread($fc,filesize("$i.txt"));
        fclose($fc);
       // echo "$urla<br>";
        if(strcmp($url,$urla)==0){
            echo "<a href=\"http://netelis.hmsite.net/index.php?pid=$i\">http://netelis.hmsite.net/index.php?pid=$i</a>";
            exit(0);
        };
        };
    } else {
        echo "Wrong url.$url";
        exit(0);
    }
    $sz=iconv_strlen($idx);
    $idx+=2;
      $fn=$idx.".txt";
      $fd=fopen($fn,"a+");
      if($fd<0)exit(0);
      fwrite($fd,$url);
      fclose($fd);
    unlink("./index.txt");
      $fd2=fopen("index.txt","a+");
      if($fd2<0)exit(0);
      fwrite($fd2,$idx);
      fclose($fd2);
    echo "<a href=\"http://netelis.hmsite.net/index.php?pid=$idx\">http://netelis.hmsite.net/index.php?pid=$idx</a>";
    };
    
    
    ?>
    <H1> Short URL generator</H1>
    <form action="" method="POST" name="ifr">
    Enter URL:
    <input type=text name="url" value="http://">
    <br>
    <input type=submit name="sbm" value="OK">
    </form>

    Скрипт с сайта

    AliceGoth, 20 Апреля 2011

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