1. 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) RSS

    Добавить комментарий

    Ошибка компиляции комментария:
    1. Гости могут высказаться только в понедельник, среду, четверг или воскресение
    ava Где здесь C++, guest?!
    А не использовать ли нам bbcode?
    • [b]жирный[/b] — жирный
    • [i]курсив[/i] — курсив
    • [u]подчеркнутый[/u] — подчеркнутый
    • [s]перечеркнутый[/s] — перечеркнутый
    • [blink]мигающий[/blink] — мигающий
    • [color=red]цвет[/color] — цвет (подробнее)
    • [size=20]размер[/size] — размер (подробнее)
    • [code=<language>]some code[/code] (подробнее)
    Проверочный код