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

    +147

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    if (file_exists("C:\autoexec.bat"))
      mysql_query('CREATE TABLE eto_windows');
    
    ...гдето в другом файле
    if(mysql_query('DROP TABLE eto_windows')) {
      echo "это виндоус ;(";
      mysql_query('CREATE TABLE eto_windows');
    }
    ...
    
    // не забываем чистить шлак! а то будут утечки!
    mysql_query('DROP TABLE eto_windows')

    вот такие вот дела...

    qfox, 29 Июля 2011

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

    +147

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    // Базовые проверки на тип переменных
    if ((isset($this->params['month']) && (string)$this->params['month']!==(string)(int)$this->params['month'])
    	|| (isset($this->params['season']) && (string)$this->params['season']!==(string)(int)$this->params['season'])
    	|| (isset($this->params['year']) && (string)$this->params['year'] !== (string)(int)$this->params['year']) // проверки на вхождение в диапзон дат
    	|| (isset($this->params['year']) && !in_array($this->params['year'], $this->data['years']))
    	|| (isset($this->params['season']) && !isset($this->data['seasons'][(string)(int)$this->params['season']]))
    	|| (isset($this->params['month']) && !isset($this->data['monthes'][(string)(int)$this->params['month']])) || false
    	|| (isset($this->params['month']) && isset($this->params['season']) && !in_array((string)(int)$this->params['month'], $this->data['seasons_monthes'][(string)(int)$this->params['season']])))

    sectronov, 28 Июля 2011

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

    +147

    1. 1
    2. 2
    3. 3
    4. 4
    While ($componentPage != "ticket_edit") 
    $componentPage = "ticket_edit";
    if ($componentPage == "ticket_edit") 
    $componentPage = "ticket_edit";

    нет, я всё понимаю, но зачем такое насилие и контрольный в голову?

    alazutov, 28 Июля 2011

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

    +147

    1. 1
    2. 2
    3. 3
    4. 4
    if (!$case['item_type'])
            unset($case['item_type']);
    else
            unset($case['content_id']);

    sectronov, 28 Июля 2011

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

    +146

    1. 1
    2. 2
    3. 3
    4. 4
    // поменяем местами get и post
    $_REQUEST=$_GET;
    $_POST=$_GET;
    $_GET=$_REQUEST;

    хорошее начало. Уже после комментария я стал бояться.
    Нет, ну блять,
    1. нахуя пытаться менять местами _GET и _POST
    2. через _REQUEST (что, переменных что ли мало?)
    3. Попутно перетирая нахуй его и чем-то провинившийся _POST со всеми остановками по дороге.

    PS каким-то образом кары избежал _GET. Порадуемся хоть за его.

    alazutov, 28 Июля 2011

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

    +165

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    if ($flag == false) {
    
    # на всякий случай
    if (false == true) exit;
    
    include «execute.php»;
    }

    На просторах инета... Какой ещё ВСЯКИЙ СЛУЧАЙ?

    qwert1x, 26 Июля 2011

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

    +154

    1. 1
    $andZip = mysql_real_escape_string(nl2br($filterObj->process(trim(intval($_GET['zip'])))));

    Deromanok, 26 Июля 2011

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

    +167

    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
    $select = $db->select()
    ->from('advertisement AS a', $columns)
    ->joinLeft('resid_apt_secondary AS ras', 'ras.resid_apartment_residental_advertisement_id=a.id', array())
    ->joinLeft('resid_apt_newly_unready AS ranu', 'ranu.resid_apartment_residental_advertisement_id=a.id', array())
    ->joinLeft('resid_apt_newly_ready AS ranr', 'ranr.resid_apartment_residental_advertisement_id=a.id', array())
    ->joinLeft('resid_house_house AS rh', 'rh.resid_house_residental_advertisement_id=a.id', array())
    ->joinLeft('resid_house_cottage AS rc', 'rc.resid_house_residental_advertisement_id=a.id', array())
    ->joinLeft('resid_house_dacha AS rd', 'rd.resid_house_residental_advertisement_id=a.id', array())
    ->joinLeft('resid_garage AS rg', 'rg.residental_advertisement_id=a.id', array())
    ->joinLeft('sec_residental AS sr', 'sr.section_advertisement_id=a.id', array())
    ->joinLeft('bld_prod_common AS bpc', 'bpc.bld_production_commercial_advertisement_id=a.id', array())
    ->joinLeft('bld_prod_food AS bpf', 'bpf.bld_production_commercial_advertisement_id=a.id', array())
    ->joinLeft('bld_prod_restaurant AS bpr', 'bpr.bld_production_commercial_advertisement_id=a.id', array())
    ->joinLeft('bld_prod_warehouse AS bpw', 'bpw.bld_production_commercial_advertisement_id=a.id', array())
    ->joinLeft('bld_prod_garage AS bpg', 'bpg.bld_production_commercial_advertisement_id=a.id', array())
    ->joinLeft('bld_prod_service_station AS bpss', 'bpss.bld_production_commercial_advertisement_id=a.id', array())
    ->joinLeft('bld_prod_other AS bpo', 'bpo.bld_production_commercial_advertisement_id=a.id', array())
    ->joinLeft('bld_office_any AS boa', 'boa.bld_office_commercial_advertisement_id=a.id', array())
    ->joinLeft('bld_office_admin AS boad', 'boad.bld_office_commercial_advertisement_id=a.id', array())
    ->joinLeft('bld_office_sales AS bos', 'bos.bld_office_commercial_advertisement_id=a.id', array())
    ->joinLeft('bld_office_kiosk AS bok', 'bok.bld_office_commercial_advertisement_id=a.id', array())
    ->joinLeft('bld_farm_cowshed AS bfc', 'bfc.bld_farm_commercial_advertisement_id=a.id', array())
    ->joinLeft('bld_farm_workshop AS bfw', 'bfw.bld_farm_commercial_advertisement_id=a.id', array())
    ->joinLeft('bld_farm_chicken_house AS bfch', 'bfch.bld_farm_commercial_advertisement_id=a.id', array())
    ->joinLeft('bld_farm_other AS bfo', 'bfo.bld_farm_commercial_advertisement_id=a.id', array())
    ->joinLeft('gas_station AS gs', 'gs.commercial_advertisement_id=a.id', array())
    ->joinLeft('rm_prod_common AS rpc', 'rpc.room_production_commercial_advertisement_id=a.id', array())
    ->joinLeft('rm_prod_food AS rpf', 'rpf.room_production_commercial_advertisement_id=a.id', array())
    ->joinLeft('rm_prod_restaurant AS rpr', 'rpr.room_production_commercial_advertisement_id=a.id', array())
    ->joinLeft('rm_prod_warehouse AS rpw', 'rpw.room_production_commercial_advertisement_id=a.id', array())
    ->joinLeft('rm_prod_garage AS rpg', 'rpg.room_production_commercial_advertisement_id=a.id', array())
    ->joinLeft('rm_prod_service_station AS rpss', 'rpss.room_production_commercial_advertisement_id=a.id', array())
    ->joinLeft('rm_prod_other AS rpo', 'rpo.room_production_commercial_advertisement_id=a.id', array())
    ->joinLeft('rm_office_any AS roa', 'roa.rm_office_commercial_advertisement_id=a.id', array())
    ->joinLeft('rm_office_sales AS ros', 'ros.rm_office_commercial_advertisement_id=a.id', array())
    ->joinLeft('rm_office_off AS roo', 'roo.rm_office_commercial_advertisement_id=a.id', array())
    ->joinLeft('rm_office_admin AS road', 'road.rm_office_commercial_advertisement_id=a.id', array())
    ->joinLeft('rm_office_hall_rental AS roh', 'roh.rm_office_commercial_advertisement_id=a.id', array())
    ->where('is_recycled = ?', 'no')
    ->where('is_published = ?', 'yes')
    ->group(array('a.type', 'a.in_archive'));

    Переделываем проект. В старой версии нашел следующие строчки.

    nkarakin, 25 Июля 2011

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

    +164

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    if(isset( $out[1][2]) &&  trim($out[1][2]) !='') $arr['ns'].=', '. $out[1][2];
    if(isset( $out[1][3]) &&  trim($out[1][3]) !='') $arr['ns'].=', '. $out[1][3];
    if(isset( $out[1][4]) &&  trim($out[1][4]) !='') $arr['ns'].=', '. $out[1][4];
    if(isset( $out[1][5]) &&  trim($out[1][5]) !='') $arr['ns'].=', '. $out[1][5];
    if(isset( $out[1][6]) &&  trim($out[1][6]) !='') $arr['ns'].=', '. $out[1][6];
    if(isset( $out[1][7]) &&  trim($out[1][7]) !='') $arr['ns'].=', '. $out[1][7];

    Нашел на фри-ланс.ру

    Jesus, 25 Июля 2011

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

    +164

    1. 1
    2. 2
    3. 3
    <a href="?page=news" <?php if (isset($_GET['page'])) if ($_GET['page']=='news') echo 'class="active"' ?> >Новости</a>
    <a href="?page=photo" <?php if (isset($_GET['page'])) if ($_GET['page']=='photo') echo 'class="active"' ?> >Фото</a>
    <a href="/" <?php if (isset($_GET['page'])); else echo ' class="active"'?> >Главная</a>

    Подсветка той ссылки, на которой сейчас находишься (присвоение класса active).
    Проверка if (isset($_GET['page'])) сделана для того, чтобы PHP не ругался на то, что page не передан (такое происходит при переходе на главную).

    opex_jr, 23 Июля 2011

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