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

    +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
    public function selectItems( $id, $withStrictment = 'no' /* $withStrictment = no, retail, discount */ ) {
    		
    		if( $withStrictment == 'discount' ) $onlyWithRetailPriceSql = " and items.articul in ( select articul from items_discount ) ";
    		if( $withStrictment == 'retail' ) $onlyWithRetailPriceSql = " and items.articul in ( select articul from retailPrice ) ";
    	
    		$a = database::select("	SELECT items.* FROM items WHERE items.id = '$id' and items.deleted = 'no' ");
    		$a = $a[0];
    
    		$this->data = database::select("SELECT items.*, 
    										IF(DATEDIFF(now(),created) <= 30, 'Новинка! ', '') as fresh,
    										( items.quantity - coalesce(view_pendeditemsquantity.sum,0) ) as quantity,
    										items_comments.comment as dopDescr, items_comments.comment as comment, items_discount.priceAsUSD as discountPrice,
    										items_packing.packing,
    										concat(items.name, ' - ', items.quantity) as name
    										FROM items 
    										LEFT JOIN view_pendeditemsquantity ON items.articul = view_pendeditemsquantity.articul
    										LEFT JOIN items_comments ON items.articul = items_comments.articul
    										left join items_discount on items.articul = items_discount.articul
    										left join items_packing on items.articul = items_packing.articul
    										WHERE items.group_id in ( select articul from items where is_group = '1' and name = '{$a['name']}' and group_id = '' )
    										  and items.deleted = 'no' 
    										  $onlyWithRetailPriceSql 
    										order by items.quantity desc, items.name asc
    										");
    	}

    guzik, 30 Ноября 2011

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

    +186

    1. 1
    $__language = ($__language == 'en')?'ru':'lv';

    мозговынос

    jokz, 30 Ноября 2011

    Комментарии (11)
  3. Куча / Говнокод #8682

    +147

    1. 1
    2. 2
    [color=red]Обратите внимание:[/color]
    http://govnokod.ru/user/4847

    TarasGovno, 29 Ноября 2011

    Комментарии (12)
  4. Куча / Говнокод #8681

    +147

    1. 1
    2. 2
    Обратите внимание:
    http://govnokod.ru/user/4847

    TarasGovno, 29 Ноября 2011

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

    +967

    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
    try
         {
         var spWave = new SoundPlayer(open.FileName);
         spWave.Play();
         spWave.Stop();
         fileCorrect = true;
         }
    catch (InvalidOperationException)
        {
            MessageBox.Show("Файл не является верным WAV-файлом");
            fileCorrect = false;
        }
    catch
       {
            MessageBox.Show("Ошибка при открытии файла");
            fileCorrect = false;
    }

    Код мой. Писать толковый парсер не было времени.

    MrRasta, 29 Ноября 2011

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

    +162

    1. 1
    $('.tdiv').find('.cancel').parent().append('<span class="error">' + r.msg + '</span>')

    чистая параноя

    Sulik78, 29 Ноября 2011

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

    +177

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    if (preg_replace("/[\D]+/" , '', $word)) {
     $word = str_replace('.','',$word);
     $word = str_replace(',','',$word);
     $word = str_replace(' ','',$word);
     $word = str_replace('$','',$word);
     $word = str_replace('*','',$word);
    }

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

    Daemonium, 29 Ноября 2011

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

    +165

    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
    try {
        $newUserId = $users->insert($data);
    } catch (Exception $e) {
        if ($e->getCode() == '23000') {
            $this->customRedirect(
                array(
                    'notice',
                    'User already exists',
                )
            );
            return;
        } else {
            throw new Exception(null, null, $e);
        }
    }

    Быстрая проверка на уникальность.

    grudzinsky, 29 Ноября 2011

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

    +167

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    if (is_file($GLOBALS['fldr']."modules/sell/images/items/small_".str_replace("<img src=http://www.site.ru/modules/sell/images/items/small_", "", str_replace(" border=0>","",$M['icon'])))) {
       echo "<a  href='".$GLOBALS['fldr']."marki/models/object/current/index.php?id=".$M['id']."'>".replace_icon($M['icon'])."</a>";
      }
    
    function replace_icon($var) {
     return str_replace("<img src=http://www.site.ru/modules/sell/images/items/", "<img src=".$GLOBALS['fldr']."modules/sell/images/items/?img_name=", $var);
    }

    Мы легких путей не ищем...

    Daemonium, 29 Ноября 2011

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

    +146

    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
    if ($url=='/news/index.html')
    {
    	$data = $this->dbf->execute('select * from news where status=1 order by date_add desc,id desc limit 10');
    	$object->smarty->assign('news_body',$data);
    	$object->smarty->assign('title','Новости');
    } elseif(preg_match('@/news/([0-9]+?)/@i',$url,$out)){
    			$data = $this->dbf->execute('select * from news where status=1 and id='.intval($out[1]).' order by date_add desc limit 1');
    			$object->smarty->assign('news_body',$data);
    			$object->smarty->assign('title','Новости');			
    } elseif($url=='/search/') {
    	$data = array();
    			
    	if ($_POST['search']!='' && strlen($_POST['search'])>6)
    	{
    		$data = $this->dbf->execute('select * from pages where content like "%'.mysql_real_escape_string($_POST['search'],$this->dbh->conn).'%" limit 10');
    	}
    	$object->smarty->assign('search',$data);
    	$object->smarty->assign('title','Поиск');
    	$object->smarty->assign('news',$this->dbh->execute('select * from news where status=1 order by date_add desc limit 3'));
    			
    } else {
    	$data = $this->dbf->execute('select * from pages where link="'.mysql_real_escape_string($url,$this->dbh->conn).'"');
    	$this->data = $data[0];
    	$object->smarty->assign('title',$this->data['title']);
    	$object->smarty->assign('news',$this->dbh->execute('select * from news where status=1 order by date_add desc limit 3'));
    }

    laplay, 29 Ноября 2011

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