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

    +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
    $a=array(
    		'save'=>array(
    			'state'=>array('new'=>array(1, 1), 0=>array(0, 0), 1=>array(1, 1), 3=>array(1, 1), 4=>array(0, 0), 5=>array(0, 0), 6=>array(1, 1)),
    			'dest'=>1,
    		),
    		'save_and_back'=>array(
    			'state'=>array('new'=>array(1, 1), 0=>array(0, 0), 1=>array(1, 1), 3=>array(1, 1), 4=>array(0, 0), 5=>array(0, 0), 6=>array(1, 1)),
    			'dest'=>1,
    		),
    		'save_as_a_copy'=>array(
    			'state'=>array('new'=>array(0, 0), 0=>array(1, 1), 1=>array(1, 1), 3=>array(1, 1), 4=>array(1, 1), 5=>array(1, 1), 6=>array(1, 1)),
    			'dest'=>1,
    		),
    		'resend'=>array(
    			'state'=>array('new'=>array(0, 0), 0=>array(1, 1), 1=>array(1, 1), 3=>array(1, 1), 4=>array(1, 1), 5=>array(1, 1), 6=>array(1, 1)),
    			'dest'=>1,
    		),
    		'send'=>array(
    			'state'=>array('new'=>array(0, 1), 0=>array(0, 0), 1=>array(0, 1), 3=>array(0, 1), 4=>array(0, 0), 5=>array(0, 1), 6=>array(0, 1)),
    			'dest'=>array(1,3),
    		),
    		'testsend'=>array(
    			'state'=>array('new'=>array(0, 1), 0=>array(0, 0), 1=>array(0, 1), 3=>array(0, 1), 4=>array(0, 0), 5=>array(0, 1), 6=>array(0, 1)),
    			'dest'=>array(1,3),
    		),
    		'offer'=>array(
    			'state'=>array('new'=>array(1, 0), 0=>array(0, 0), 1=>array(1, 0), 3=>array(0, 0), 4=>array(0, 0), 5=>array(0, 0), 6=>array(1, 0)),
    			'dest'=>5,
    		),
    		'reject'=>array(
    			'state'=>array('new'=>array(0, 0), 0=>array(0, 0), 1=>array(0, 0), 3=>array(0, 0), 4=>array(0, 0), 5=>array(0, 1), 6=>array(0, 0)),
    			'dest'=>6,
    		),
    		'cancel'=>array(
    			'state'=>array('new'=>array(0, 0), 0=>array(0, 0), 1=>array(1, 1), 3=>array(0, 0), 4=>array(0, 0), 5=>array(0, 0), 6=>array(0, 0)),
    			'dest'=>1,
    		),
    	);

    Без комментариев.

    pro_co_ru, 20 Июня 2011

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

    +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
    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
    public function getList($sort) {
            if ($sort == 'id')
                $select = $this->select()->order('id ASC');            
            if ($sort == 'id2')
                $select = $this->select()->order('id DESC');
            if ($sort == 'username')
                $select = $this->select()->order('username ASC');
            if ($sort == 'username2')
                $select = $this->select()->order('username DESC');
            if ($sort == 'firstname')
                $select = $this->select()->order('firstname ASC');
            if ($sort == 'firstname2')
                $select = $this->select()->order('firstname DESC');
            if ($sort == 'lastname')
                $select = $this->select()->order('lastname ASC');
            if ($sort == 'lastname2')
                $select = $this->select()->order('lastname DESC');
            if ($sort == 'lastdate')
                $select = $this->select()->order('lastdate ASC');
            if ($sort == 'lastdate2')
                $select = $this->select()->order('lastdate DESC');
            if ($sort == 'regdate')
                $select = $this->select()->order('regdate ASC');
            if ($sort == 'regdate2')
                $select = $this->select()->order('regdate DESC');
            if ($sort == 'city')
                $select = $this->select()->order('city ASC');
            if ($sort == 'city2')
                $select = $this->select()->order('city DESC');
            if ($sort == 'vote')
                $select = $this->select()->order('vote ASC');
            if ($sort == 'vote2')
                $select = $this->select()->order('vote DESC');
            $result = $this->fetchAll($select);
            return $result;
        }

    Кусочек кода, написанный в классической манере "if-else" для Zend Framework

    coderov, 20 Июня 2011

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

    +155

    1. 1
    2. 2
    3. 3
    $pageController = new PageController();
    $photo = $pageController->getPhoto($pageRecord->id);
    $photo =  $photo ;

    А вдруг ПХП с первого раза не понял что в переменной должно быть фото? Повторение мать учения.

    Kos, 19 Июня 2011

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

    +176

    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
    /**
        * получить перечень экзаменов на указанную дату
        * @global GathererDB $db
        * @param string $examdate must be $db->qstr()'ed
        * @return array 
        */
       function examsOnDate($examdate)
       {
         global $db;
         ob_start();
     ?>
    select distinct e.EXAMID from EXAMS e
    inner join STATIONEXAMS se on se.EXAMFK=e.SYS_GUID
    inner join PARTICIPANTSEXAMS pe on pe.EXAMFK=e.SYS_GUID
    where e.EXAMDATE=<?php print $examdate; ?>
    <?php
         $sql = ob_get_clean();
    
         $exams = $db->getcol($sql);
         return $exams;
       }

    Из скрипта для обслуживания сайта ЕГЭ.
    Изумительное применение буфера.

    7ion, 18 Июня 2011

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

    +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
    $this->addException(Mage::helper('dataflow')->__('Found %d rows.', $this->_countRows));
    $this->addException(Mage::helper('dataflow')->__('Starting %s :: %s', $adapterName, $adapterMethod));
    
    $batchModel->setParams($this->getVars())
        ->setAdapter($adapterName)
        ->save();
    
    // $adapter->$adapterMethod();
    
    return $this;
    
    $dom = new DOMDocument();
    // $dom->loadXML($this->getData());
    if (Mage::app()->getRequest()->getParam('files')) {
        $path = Mage::app()->getConfig()->getTempVarDir().'/import/';
        $file = $path.urldecode(Mage::app()->getRequest()->getParam('files'));
        if (file_exists($file)) {
            $dom->load($file);
        }
    } else {
    
        $this->validateDataString();
        $dom->loadXML($this->getData());
    }

    Magento 1.5 stable. после return'a идёт около 70 строк... Насладиться можно тут http://svn.magentocommerce.com/source/branches/1.5/app/code/core/Mage/Dataflow/Model/Convert/Parser/Xml/Excel.php

    message, 17 Июня 2011

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

    +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
    <?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
    <?php echo $this->getChildHtml('form_before') ?>
    <form action="<?php echo $this->getUrl('checkout/cart/updatePost') ?>" method="post">
    <fieldset>
    <table id="shopping-cart-table" class="data-table cart-table">
        <col width="1" />
        <col />
        <col width="1" />
    <?php if ($this->helper('wishlist')->isAllowInCart()) : ?>
        <col width="1" />
    <?php endif ?>
    <?php if ($this->helper('tax')->displayCartPriceExclTax() || $this->helper('tax')->displayCartBothPrices()): ?>
        <col width="1" />
    <?php endif; ?>
    <?php if ($this->helper('tax')->displayCartPriceInclTax() || $this->helper('tax')->displayCartBothPrices()): ?>
        <col width="1" />
    <?php endif; ?>
        <col width="1" />
    <?php if ($this->helper('tax')->displayCartPriceExclTax() || $this->helper('tax')->displayCartBothPrices()): ?>
        <col width="1" />
    <?php endif; ?>
    <?php if ($this->helper('tax')->displayCartPriceInclTax() || $this->helper('tax')->displayCartBothPrices()): ?>
        <col width="1" />
    <?php endif; ?>
        <col width="1" />
    
    <?php $mergedCells = ($this->helper('tax')->displayCartBothPrices() ? 2 : 1); ?>

    Ну так, для уверенности, можно и 4 раза. Искал в этом смысл - смысла не найдено. Copyright (c) 2011 Magento Inc.

    message, 17 Июня 2011

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

    +158

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    private function exportPTCsvFile(array $transactions, array $refunds, $fileName)
    	{
    		$csv[] = array('Date', 'Time Zone', 'Name',  'Type',  ' Status',  'Currency',  'Gross', 'Fee', 'Net', 'From Email Address', 'Transaction ID', ' Item Title', 'Deal ID', 'Deal City', 'Merchant ID', 'User ID', 'Purchase Date', 'CMS Transaction ID', 'CMS Quantity', 'CMS Amount', 'Kash Used', 'CC Digits', 'Coupon Link', 'Paymentech Response');
    
    		// headers...
    		
    		foreach ($csv as $titles) {
    		    print utf8_encode(implode(',', $titles))."\n";
    		}
                   // Rest of code...
    }

    kovel, 17 Июня 2011

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

    +159

    1. 1
    2. 2
    3. 3
    function doXmlEscape($val) {
      return str_replace(array('&', '<', '>', '"', "'"), array('&', '<', '>', '"', '''), $val);
    }

    http://vkontakte.ru/developers.php?o=-1&p=%D0%9F%D1%80%D0%B8%D0%BC%D0%B5%D1%80 +%D0%BE%D0%B1%D1%80%D0%B0%D0%B1%D0%BE%D1 %82%D1%87%D0%B8%D0%BA%D0%B0+%D1%83%D0%B2 %D0%B5%D0%B4%D0%BE%D0%BC%D0%BB%D0%B5%D0% BD%D0%B8%D0%B9+%D0%BD%D0%B0+%D1%8F%D0%B7 %D1%8B%D0%BA%D0%B5+PHP

    Ох и разработчики... T_T

    inf, 17 Июня 2011

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

    +154

    1. 1
    2. 2
    3. 3
    4. 4
    $value = $this->model->getById(DataUtil::fromGET("id"));
    foreach($this->model->get(PaginationUtil::getStart(),PaginationUtil::$countOnPage) as $value){
       return NewsUtils::createNewsLayout_ND($value);
    }

    В проект был взят стажер, и начал появляться такой вот индусский код.

    Kos, 17 Июня 2011

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

    +154

    1. 1
    Insert into reading_count_pages (page_id, reading_count) values (973, 1)

    Любителям простых SQL-инъекций:
    Сайт одного университета: http://impuls.vntu.edu.ua/, писали, видимо, студенты должники.

    На разных страницах сайта можно наблюдать MySQL ерроры, подставляя данные в GET-запрос. Так же, по запросам можно судить о качестве проектирования сайта.
    Пример (http://impuls.vntu.edu.ua/?news_id=973%60):
    Insert into reading_count_pages (page_id, reading_count) values (973, 1), потом выполняется group by по айдишке и считается каунт. Еще пример: http://impuls.vntu.edu.ua/?all&t=50000&f=0

    rO_ot, 16 Июня 2011

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