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

    Всего: 18

  2. PHP / Говнокод #10410

    +66

    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
    if ($dt && $eventtype != 5 && $eventtype != 7) {
        $sql_cond = " and b.datefrom='$dt'";
    }
    
    if ($eventtype == 5 || $eventtype == 7) {
    
        if (!$dt || $dt == "0") {
    
            $w = date("w");
    
            $mon_dl = 7 - $w;
    
            for ($j = 0; $j <= (7 - $w); $j++) {
                $d = date("Ymd", mktime(0, 0, 0, date("m"), date("d") + $j, date("Y")));
                $dates .= ($dates ? "," . $d : $d);
            }
    
            if ($dates) $sql_cond .= " and b.datefrom in ($dates)";
        }
    
        if ($dt == "1") {
            $w = date("w");
            if ($w == 0) {
                $monday = date("Ymd", mktime(0, 0, 0, date("m"), date("d") + 1, date("Y")));
            } else {
                $monday = date("Ymd", mktime(0, 0, 0, date("m"), date("d") + (7 - $w) + 1, date("Y")));
            }
    
    
            for ($j = 0; $j <= 6; $j++) {
                $d = date("Ymd", mktime(0, 0, 0, substr($monday, 4, 2), substr($monday, 6, 2) + $j, substr($monday, 0, 4)));
                $dates .= ($dates ? "," . $d : $d);
            }
    
            if ($dates) $sql_cond .= " and b.datefrom in ($dates)";
        }
    
        if ($dt == "2") {
    
            $w = date("w");
            if ($w == 0) {
                $monday = date("Ymd", mktime(0, 0, 0, date("m"), date("d") + 1, date("Y")));
            } else {
                $monday = date("Ymd", mktime(0, 0, 0, date("m"), date("d") + (7 - $w) + 1, date("Y")));
            }
    
            for ($j = 7; $j <= 13; $j++) {
                $d = date("Ymd", mktime(0, 0, 0, substr($monday, 4, 2), substr($monday, 6, 2) + $j, substr($monday, 0, 4)));
                $dates .= ($dates ? "," . $d : $d);
            }
    
            if ($dates) $sql_cond .= " and b.datefrom in ($dates)";
        }
    }

    я потерял сон.

    shmaltorhbooks, 29 Мая 2012

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

    +59

    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
    function get_datefrom ($eventid, $eventtype)
    {
    
        global $filter_date_kudy;
    
        $today = date("Ymd");
        if ($filter_date_kudy) $today = $filter_date_kudy;
        $todayweekday = date("w");
    
        $quGroup = mysql_query("SELECT datefrom, dateto, permanent, weekday1, weekday2, weekday3, weekday4, weekday5, weekday6, weekday7 from eventtime where eventid='$eventid' and eventtype='$eventtype' order by datefrom ASC");
    
        while ($flGroup = mysql_fetch_row($quGroup)) {
            $datefrom = ($flGroup[0]);
            $dateto = ($flGroup[1]);
            $permanent = ($flGroup[2]);
            $weekday1 = ($flGroup[3]);
            $weekday2 = ($flGroup[4]);
            $weekday3 = ($flGroup[5]);
            $weekday4 = ($flGroup[6]);
            $weekday5 = ($flGroup[7]);
            $weekday6 = ($flGroup[8]);
            $weekday7 = ($flGroup[9]);
    
            if ($datefrom && !$dateto && !$permanent && $datefrom >= $today) $date = $datefrom;
            if (!$datefrom && !$dateto && $permanent && !$weekday1 && !$weekday2 && !$weekday3 && !$weekday4 && !$weekday5 && !$weekday6 && !$weekday7) $date = $today;
            if ($datefrom && $dateto && $today >= $datefrom && $today <= $dateto) $date = $today;
            if (!$datefrom && !$dateto && $permanent && ($weekday1 || $weekday2 || $weekday3 || $weekday4 || $weekday5 || $weekday6 || $weekday7)) {
                $dt = "";
    
                if ($todayweekday == 0 && $weekday7) $dt = $today;
                if ($todayweekday == 1 && $weekday1) $dt = $today;
                if ($todayweekday == 2 && $weekday2) $dt = $today;
                if ($todayweekday == 3 && $weekday3) $dt = $today;
                if ($todayweekday == 4 && $weekday4) $dt = $today;
                if ($todayweekday == 5 && $weekday5) $dt = $today;
                if ($todayweekday == 6 && $weekday6) $dt = $today;
    
                $j = 0;
    
                while (!$dt && $j < 100) {
                    $j++;
                    $todayweekday2 = date("w", mktime(0, 0, 0, date("m"), date("d") + $j, date("Y")));
                    $today2 = date("Ymd", mktime(0, 0, 0, date("m"), date("d") + $j, date("Y")));
    
                    if ($todayweekday2 == 0 && $weekday7) $dt = $today2;
                    if ($todayweekday2 == 1 && $weekday1) $dt = $today2;
                    if ($todayweekday2 == 2 && $weekday2) $dt = $today2;
                    if ($todayweekday2 == 3 && $weekday3) $dt = $today2;
                    if ($todayweekday2 == 4 && $weekday4) $dt = $today2;
                    if ($todayweekday2 == 5 && $weekday5) $dt = $today2;
                    if ($todayweekday2 == 6 && $weekday6) $dt = $today2;
    
                }
                $date = $dt;
            }
            if ($date) break;
        }
        return $date;
    }

    нет слов

    shmaltorhbooks, 29 Мая 2012

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

    +63

    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
    if (!$dt) $dt = date("Ymd");
    
                    if ($dt) {
                        $dt_week_day = (int)date("w",
                                                 mktime(0, 0, 0, substr($dt, 4, 2), substr($dt, 6, 2), substr($dt, 0, 4)));
    
                        if ($datefrom && $dateto && $dt >= $datefrom && $dt <= $dateto && !$weekday1 && !$weekday2 && !$weekday3 && !$weekday4 && !$weekday5 && !$weekday6 && !$weekday7) $ok = 1;
                        if (!$datefrom && !$dateto && $permanent == "on" && !$weekday1 && !$weekday2 && !$weekday3 && !$weekday4 && !$weekday5 && !$weekday6 && !$weekday7) $ok = 1;
                        if ($datefrom && !$dateto && $dt <= $datefrom) $ok = 1;
    
                        if (!$datefrom && !$dateto && $permanent == "on" && $weekday1 > 0 && $dt_week_day == 1) $ok = 1;
                        if (!$datefrom && !$dateto && $permanent == "on" && $weekday2 > 0 && $dt_week_day == 2) $ok = 1;
                        if (!$datefrom && !$dateto && $permanent == "on" && $weekday3 > 0 && $dt_week_day == 3) $ok = 1;
                        if (!$datefrom && !$dateto && $permanent == "on" && $weekday4 > 0 && $dt_week_day == 4) $ok = 1;
                        if (!$datefrom && !$dateto && $permanent == "on" && $weekday5 > 0 && $dt_week_day == 5) $ok = 1;
                        if (!$datefrom && !$dateto && $permanent == "on" && $weekday6 > 0 && $dt_week_day == 6) $ok = 1;
                        if (!$datefrom && !$dateto && $permanent == "on" && $weekday7 > 0 && $dt_week_day == 0) $ok = 1;
    
                        if ($datefrom && $dateto && $dt >= $datefrom && $dt <= $dateto && !$permanent && $weekday1 > 0 && $dt_week_day == 1) $ok = 1;
                        if ($datefrom && $dateto && $dt >= $datefrom && $dt <= $dateto && !$permanent && $weekday2 > 0 && $dt_week_day == 2) $ok = 1;
                        if ($datefrom && $dateto && $dt >= $datefrom && $dt <= $dateto && !$permanent && $weekday3 > 0 && $dt_week_day == 3) $ok = 1;
                        if ($datefrom && $dateto && $dt >= $datefrom && $dt <= $dateto && !$permanent && $weekday4 > 0 && $dt_week_day == 4) $ok = 1;
                        if ($datefrom && $dateto && $dt >= $datefrom && $dt <= $dateto && !$permanent && $weekday5 > 0 && $dt_week_day == 5) $ok = 1;
                        if ($datefrom && $dateto && $dt >= $datefrom && $dt <= $dateto && !$permanent && $weekday6 > 0 && $dt_week_day == 6) $ok = 1;
                        if ($datefrom && $dateto && $dt >= $datefrom && $dt <= $dateto && !$permanent && $weekday7 > 0 && $dt_week_day == 0) $ok = 1;
    
    //               if($ok==0)continue;
    
                    }

    shmaltorhbooks, 25 Мая 2012

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

    +61

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    class admin_payment {
        // ...
    }
    
    $m = 'admin_payment';
    $$m = new $m();
    $m->get();

    отборно.

    shmaltorhbooks, 16 Мая 2012

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

    +161

    1. 1
    2. 2
    3. 3
    4. 4
    public function &entityFactory() {
        $entityObject = new stdClass();
        return $entityObject;
    }

    shmaltorhbooks, 27 Сентября 2011

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

    +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
    /**
         * Xml Request
         *
         * @param int $hotel_id
         * @param int $hotel_id
         * @param int $hotel_id
         * @return array $cc_type of
         */
    public function XmlStringForBokingFactura($transaction_id, $block, $begin_date, $end_date, $hotel_code, $guest_qty, $smoking, $cc_number, $cc_cardholder, $cc_type, $cc_expiration_date, $cc_cvc, $NameBooker, $LastNameBooker, $guestLastname, $guest_city, $guest_country, $guest_telephone, $email, $additionalEmail, $fake=1, $affiliate_id, $affiliate_pswd, $is_hash = null, $arrival_time, $dialog) {
        ...
        ...
        ...
        $mail = new MailMime($build_params);
        $mail->setHeader($from_email, $subject, array('charset' => 'UTF-8'));
        $mail->setTXTBody($url);
        $mail->setHTMLBody($url);
        $mail->send($to);
        $mail->setHeader($from_email, $subject, array('charset' => 'UTF-8'));
        $mail->setTXTBody($data);
        $mail->setHTMLBody($data);
        $mail->send($to2);
    
        ...
    }

    переменные $to и $to2 нигде в функции никак не объявляются. да и вообще функция шикарная.

    shmaltorhbooks, 03 Августа 2011

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

    +164

    1. 1
    2. 2
    3. 3
    4. 4
    5. 5
    6. 6
    7. 7
    8. 8
    class Dialog_view extends Controller {
    
        var $LutskZakarpatyeId = array('1225', '1233');
        var $respublicaKrim = '1229';
    
    ...
    
    }

    красота.

    shmaltorhbooks, 12 Февраля 2011

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

    +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
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    $div = false;
    while (true) {
        if ($div = !$div) {
            // тут действие если четная итерация цикла
        } else {
            // тут если нечетная
        }
    }
    
    ну, или так
    
    for ($i=0, $div = true; $i<$max; $i++, $div = !$div){
        if ($div) {
            // тут действие если четная итерация цикла
        } else {
            // тут если нечетная
        }
    }

    человек один говорит, что такая проверка на четность/нечетность - говно.
    говно ли?

    shmaltorhbooks, 30 Мая 2010

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