예제 #1
0
function generate_calendar($year, $month, $days = array(), $day_name_length = 3, $month_href = NULL, $first_day = 0, $pn = array())
{
    /**
     * mktime will automatically correct, if invalid dates are entered
     * for instance, mktime(0,0,0,12,32,1997) will be the date for Jan 1, 1998
     */
    $first_of_month = gmmktime(0, 0, 0, $month, 1, $year);
    $day_names = array();
    # generate all the day names according to the current locale
    for ($n = 0, $t = (3 + $first_day) * 86400; $n < 7; $n++, $t += 86400) {
        # %A means full textual day name
        $day_names[$n] = ucfirst(gmstrftime('%A', $t));
    }
    list($month, $year, $month_name, $weekday) = explode(',', gmstrftime('%m,%Y,%B,%w', $first_of_month));
    # adjust for $first_day
    $weekday = ($weekday + 7 - $first_day) % 7;
    #note that some locales don't capitalize month and day names
    $title = htmlentities(ucfirst($month_name)) . '&nbsp;' . $year;
    /**
     * previous and next links, if applicable
     */
    list($p, $pl) = each($pn);
    list($n, $nl) = each($pn);
    if ($p) {
        $p = '<span class="calendar-prev">' . ($pl ? '<a href="' . htmlspecialchars($pl) . '">' . $p . '</a>' : $p) . '</span>&nbsp;';
    }
    if ($n) {
        $n = '&nbsp;<span class="calendar-next">' . ($nl ? '<a href="' . htmlspecialchars($nl) . '">' . $n . '</a>' : $n) . '</span>';
    }
    /**
     * Begin calendar. Uses a real <caption>. See http://diveintomark.org/archives/2002/07/03
     */
    $calendar = '<table class="calendar">' . CR;
    $calendar .= '<caption class="calendar-month">' . CR;
    $calendar .= $p . CR;
    $calendar .= $month_href ? '<a href="' . htmlspecialchars($month_href) . '">' . $title . '</a>' : $title;
    $calendar .= $n . CR;
    $calendar .= '</caption>' . CR . '<tr>' . CR;
    if ($day_name_length) {
        #if the day names should be shown ($day_name_length > 0)
        #if day_name_length is >3, the full name of the day will be printed
        foreach ($day_names as $d) {
            $calendar .= '<th abbr="' . htmlentities($d) . '">' . htmlentities($day_name_length < 4 ? substr($d, 0, $day_name_length) : $d) . '</th>' . CR;
        }
        $calendar .= '</tr>' . CR . '<tr>' . CR;
    }
    # initial 'empty' days
    if ($weekday > 0) {
        $calendar .= '<td colspan="' . $weekday . '">&nbsp;</td>' . CR;
    }
    /**
     *  convert indexded array into a named assoc array
     */
    if (isset($days) and is_array($days)) {
        $days_data = array();
        foreach ($days as $day => $values) {
            $days_data[(int) $day] = array('link' => isset($values['0']) ? htmlspecialchars($values['0']) : null, 'text' => isset($values['2']) ? htmlspecialchars($values['1']) : null);
        }
        unset($days);
    }
    for ($day = 1, $days_in_month = gmdate('t', $first_of_month); $day <= $days_in_month; $day++, $weekday++) {
        # start a new week
        if ($weekday == 7) {
            $weekday = 0;
            $calendar .= '</tr>' . CR . '<tr>';
        }
        /**
         * Handle data array for all days
         */
        if (isset($days_data[$day])) {
            $calendar .= '<td>';
            $calendar .= isset($days_data[$day]['link']) ? '<a href="' . $days_data[$day]['link'] . '">' . $day . '</a>' : 'no-link';
            $calendar .= '</td>' . CR;
        } else {
            $calendar .= "<td>{$day}</td>" . CR;
        }
    }
    # remaining "empty" days
    if ($weekday != 7) {
        $calendar .= '<td colspan="' . (7 - $weekday) . '">&nbsp;</td>' . CR;
    }
    $calendar .= '</tr>' . CR . '</table>';
    if (extension_loaded('tidy') === true) {
        $calendar = cleaning($calendar);
    }
    return $calendar;
}
예제 #2
0
파일: oput.php 프로젝트: andrew133/urok6
function cleaning($variable)
{
    $var = htmlentities(trim($variable));
    return $var;
}
if ($_SERVER['REQUEST_METHOD'] == 'POST' && !empty($_POST)) {
    $_SESSION[uniqid()]['ad'] = $_POST;
} elseif (isset($_GET['delete'])) {
    unset($_SESSION[$_GET['delete']]);
    header("Location: HW6.php");
} elseif (isset($_GET['id'])) {
    $name = cleaning($_SESSION[$_GET['id']]['ad']['name']);
    $email = cleaning($_SESSION[$_GET['id']]['ad']['email']);
    $phone = (int) $_SESSION[$_GET['id']]['ad']['phone'];
    $ad_title = cleaning($_SESSION[$_GET['id']]['ad']['ad_title']);
    $ad_description = cleaning($_SESSION[$_GET['id']]['ad']['ad_description']);
    $price = (int) $_SESSION[$_GET['id']]['ad']['price'];
    ?>
    <form method="POST">
        <?php 
    if ($_SESSION[$_GET['id']]['ad']['type'] == 'private_person') {
        ?>
            <p><input type="radio" name="type" value="private_person" checked> Частное лицо
            <input type="radio" name="type" value="company"> Компания</p>
        <?php 
    } else {
        ?>
            <p><input type="radio" name="type" value="private_person"> Частное лицо
            <input type="radio" name="type" value="company" checked> Компания</p>
        <?php 
    }
예제 #3
0
        if(isset($aa[$_GET['id']])){
            $bb = explode(' / ', $aa[$_GET['id']]);
            $name = cleaning($bb[1]);
            $email = cleaning($bb[2]);
            $phone = $bb[4];
            $ad_title = cleaning($bb[7]);
            $ad_description = cleaning($bb[8]);
            $price = $bb[9];
            $type = cleaning($bb[0]);
            $category = cleaning($bb[6]);
            if(isset($bb[3])){
                $otvet = cleaning($bb[3]);
            } else {
                $otvet = '';
            }
            $city = cleaning($bb[5]);
        }
    } ?>
        <form method="POST">
            <? if($type == 'private_person'){?>
                <p><input type="radio" name="type" value="private_person" checked> Частное лицо
                <input type="radio" name="type" value="company"> Компания</p>
            <?  } else { ?>
                <p><input type="radio" name="type" value="private_person"> Частное лицо
                <input type="radio" name="type" value="company" checked> Компания</p>
            <? } ?>
            <p>Ваше имя <input type="text" name="name" value="<?php 
echo $name;
?>
"/></p>
            <p>Электронная почта <input type="email" name="email" value="<?php