Ejemplo n.º 1
0
function cal($start)
{
    //转换为字符串
    $startone = chunk_split($start, 1, ",");
    //转换为数组
    $arrone = explode(",", $startone, -1);
    //数组排序并返回最大值和最小值
    $big = 0;
    $lit = 0;
    global $pass;
    global $result;
    //不用全局最后if语句中return $pass;自定义函数外$result=cal($start);不成功
    //return $big-$lit; 自定义函数外$pass=cal($start);可成功赋值
    /*
    <?php
    function cal($start){
    $startone=chunk_split($start,1,",");
    $arrone=explode(",",$startone,-1);
    $big=0;
    $lit=0;
    sort($arrone);
    foreach ($arrone as $key=>$value){
    	$big+=$value*pow(10,$key);
    	$key++;
    }
    rsort($arrone);
    foreach ($arrone as $key => $value){
    	$lit+=$value*pow(10,$key);
    	$key++;
    }
    return $big-$lit;
    }
    $pass=cal(675);			
    echo $pass.'<br />';
    ?>
    */
    sort($arrone);
    foreach ($arrone as $key => $value) {
        $big += $value * pow(10, $key);
        $key++;
    }
    rsort($arrone);
    foreach ($arrone as $key => $value) {
        $lit += $value * pow(10, $key);
        $key++;
    }
    $pass = $big - $lit;
    if ($pass == $start) {
        $result = $pass;
    } else {
        cal($pass);
    }
}
Ejemplo n.º 2
0
function cal($path, $exclude = ".|..", $recursive = true)
{
    global $c, $s;
    $path = rtrim($path, "/") . "/";
    $folder_handle = opendir($path);
    $exclude_array = explode("|", $exclude);
    $result = array();
    while (false !== ($filename = readdir($folder_handle))) {
        if (!in_array(strtolower($filename), $exclude_array)) {
            if (is_dir($path . $filename . "/")) {
                if ($recursive) {
                    cal($path . $filename . "/", $exclude, true);
                }
            } else {
                $c++;
                $s += filesize($path . $filename);
            }
        }
    }
}
Ejemplo n.º 3
0
                $approve = " AND approve=1";
            }
            $sql = "SELECT DISTINCT DAYOFMONTH(date) as day FROM " . PREFIX . "_post WHERE date >= '{$year}-{$month}-01' AND date < '{$year}-{$month}-01' + INTERVAL 1 MONTH" . $approve . $where_date;
            $this_month = $month;
            $this_year = $year;
        } else {
            $sql = "SELECT DISTINCT DAYOFMONTH(date) as day FROM " . PREFIX . "_post WHERE date >= '{$this_year}-{$this_month}-01' AND date < '{$this_year}-{$this_month}-01' + INTERVAL 1 MONTH AND approve=1" . $where_date;
        }
        if ($sql != "") {
            $db->query($sql);
            while ($row = $db->get_row()) {
                $events[$row['day']] = strtotime($this_year . "-" . $this_month . "-" . $row['day']);
            }
            $db->free();
        }
        $tpl->result['calendar'] = cal($this_month, $this_year, $events);
        create_cache("calendar", $tpl->result['calendar'], $cache_id);
    }
}
# Выводим архивы
if ($config['allow_archives'] == "yes") {
    $tpl->result['archive'] = dle_cache("archives", $config['skin']);
    if (!$tpl->result['archive']) {
        $f2 = array('01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12');
        $f3 = array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');
        if ($config['no_date'] and !$config['news_future']) {
            $thisdate = date("Y-m-d H:i:s", $_TIME);
            $where_date = " AND date < '" . $thisdate . "'";
        } else {
            $where_date = "";
        }
Ejemplo n.º 4
0
        }
        if (isset($_POST['jahr'])) {
            $year = $_POST['jahr'];
        } elseif (isset($_GET['y'])) {
            $year = $_GET['y'];
        } else {
            $year = date("Y");
        }
        for ($i = 1; $i <= 12; $i++) {
            if ($month == $i) {
                $sel = "selected=\"selected\"";
            } else {
                $sel = "";
            }
            $mname = array("1" => _jan, "2" => _feb, "3" => _mar, "4" => _apr, "5" => _mai, "6" => _jun, "7" => _jul, "8" => _aug, "9" => _sep, "10" => _okt, "11" => _nov, "12" => _dez);
            $month .= show(_select_field, array("value" => cal($i), "sel" => $sel, "what" => $mname[$i]));
        }
        for ($i = date("Y") - 5; $i < date("Y") + 3; $i++) {
            if ($year == $i) {
                $sel = "selected=\"selected\"";
            } else {
                $sel = "";
            }
            $year .= show(_select_field, array("value" => $i, "sel" => $sel, "what" => $i));
        }
        $min = mktime(0, 0, 0, $month, 1, $year);
        $max = mktime(23, 59, 59, $month + 1, -1, $year);
        $qry = db("SELECT * FROM " . $sql_prefix . "jokes WHERE status LIKE '1' AND date >= " . $min . " AND date <= " . $max . " ORDER BY date ASC");
        while ($get = _fetch($qry)) {
            ?>
<link rel="stylesheet" type="text/css" href="style.css">
Ejemplo n.º 5
0
echo '$y-----';
var_dump($y);
echo "<br>";
var_dump($z);
echo "<br>";
echo "<br>", '$x == $y ----->';
var_dump($x == $y);
echo "<br>", '$x === $y----->';
var_dump($x === $y);
echo "<br>", '$x != $y ----->';
var_dump($x != $y);
echo "<br>", '$x <> $y ----->';
var_dump($x != $y);
echo "<br>", '$x !== $y ----->';
var_dump($x !== $y);
echo "<hr>";
$t = date("H");
if ($t < "20") {
    echo "Have a good day!";
}
echo "<hr>";
function cal($num1, $num2)
{
    $num = $num1 + $num2;
    return $num;
}
echo cal(10, 20), "<hr>";
?>

</body>
</html>
Ejemplo n.º 6
0
    $where_date = " AND date < '" . $thisdate . "'";
} else {
    $where_date = "";
}
$this_month = date('m', $time);
$this_year = date('Y', $time);
$month = $db->safesql(sprintf("%02d", intval($_GET['month'])));
$year = intval($_GET['year']);
$sql = "";
if ($year != '' and $month != '') {
    if ($year == $this_year and $month < $this_month or $year < $this_year) {
        $where_date = "";
        $approve = "";
    } else {
        $approve = " AND approve=1";
    }
    $sql = "SELECT DISTINCT DAYOFMONTH(date) as day FROM " . PREFIX . "_post WHERE date >= '{$year}-{$month}-01' AND date < '{$year}-{$month}-01' + INTERVAL 1 MONTH" . $approve . $where_date;
    $this_month = $month;
    $this_year = $year;
} else {
    $sql = "SELECT DISTINCT DAYOFMONTH(date) as day FROM " . PREFIX . "_post WHERE date >= '{$this_year}-{$this_month}-01' AND date < '{$this_year}-{$this_month}-01' + INTERVAL 1 MONTH AND approve=1" . $where_date;
}
$db->query($sql);
while ($row = $db->get_row()) {
    $events[$row['day']] = strtotime($this_year . "-" . $this_month . "-" . $row['day']);
}
$db->free();
$db->close();
$buffer = cal($this_month, $this_year, $events);
header("Content-type: text/html; charset=" . $config['charset']);
echo $buffer;
Ejemplo n.º 7
0
<?php

error_reporting(0);
include 'lib/functions.php';
writeHello();
echo '<br>';
writeMsg('hello');
echo '<br>';
writeMsg('byebye');
echo '<br>';
writeMsgTo('stijn', 'how are you doing');
echo '<br>';
writeMsgTo('stijn');
echo '<br>';
cal(2, 2);
echo '<br>';
cal2(4, 6);
echo '<br>';
echo '<br>';
echo '<br>';
body();
Ejemplo n.º 8
0
echo '<table class="table table-bordered">', PHP_EOL;
$n = Settings::get("begin_bookings");
$end_bookings = Settings::get("end_bookings");
$debligne = 1;
$month = utf8_encode(strftime("%m", Settings::get("begin_bookings")));
$year = strftime("%Y", Settings::get("begin_bookings"));
$inc = 0;
while ($n <= $end_bookings) {
    if ($debligne == 1) {
        echo '<tr>', PHP_EOL;
        $inc = 0;
        $debligne = 0;
    }
    $inc++;
    echo '<td>', PHP_EOL;
    echo cal($month, $year);
    echo '</td>', PHP_EOL;
    if ($inc == 3) {
        echo '</tr>', PHP_EOL;
        $debligne = 1;
    }
    $month++;
    if ($month == 13) {
        $year++;
        $month = 1;
    }
    $n = mktime(0, 0, 0, $month, 1, $year);
}
if ($inc < 3) {
    $k = $inc;
    while ($k < 3) {
Ejemplo n.º 9
0
function events_content(&$a)
{
    if (!local_user()) {
        notice(t('Permission denied.') . EOL);
        return;
    }
    $o = "";
    // tabs
    $o .= profile_tabs($a, True);
    $o .= '<h2>' . t('Events') . '</h2>';
    $mode = 'view';
    $y = 0;
    $m = 0;
    if ($a->argc > 1) {
        if ($a->argc > 2 && $a->argv[1] == 'event') {
            $mode = 'edit';
            $event_id = intval($a->argv[2]);
        }
        if ($a->argv[1] === 'new') {
            $mode = 'new';
            $event_id = 0;
        }
        if ($a->argc > 2 && intval($a->argv[1]) && intval($a->argv[2])) {
            $mode = 'view';
            $y = intval($a->argv[1]);
            $m = intval($a->argv[2]);
        }
    }
    if ($mode == 'view') {
        $thisyear = datetime_convert('UTC', date_default_timezone_get(), 'now', 'Y');
        $thismonth = datetime_convert('UTC', date_default_timezone_get(), 'now', 'm');
        if (!$y) {
            $y = intval($thisyear);
        }
        if (!$m) {
            $m = intval($thismonth);
        }
        // Put some limits on dates. The PHP date functions don't seem to do so well before 1900.
        // An upper limit was chosen to keep search engines from exploring links millions of years in the future.
        if ($y < 1901) {
            $y = 1900;
        }
        if ($y > 2099) {
            $y = 2100;
        }
        $nextyear = $y;
        $nextmonth = $m + 1;
        if ($nextmonth > 12) {
            $nextmonth = 1;
            $nextyear++;
        }
        $prevyear = $y;
        if ($m > 1) {
            $prevmonth = $m - 1;
        } else {
            $prevmonth = 12;
            $prevyear--;
        }
        $dim = get_dim($y, $m);
        $start = sprintf('%d-%d-%d %d:%d:%d', $y, $m, 1, 0, 0, 0);
        $finish = sprintf('%d-%d-%d %d:%d:%d', $y, $m, $dim, 23, 59, 59);
        $start = datetime_convert('UTC', 'UTC', $start);
        $finish = datetime_convert('UTC', 'UTC', $finish);
        $adjust_start = datetime_convert('UTC', date_default_timezone_get(), $start);
        $adjust_finish = datetime_convert('UTC', date_default_timezone_get(), $finish);
        $r = q("SELECT `event`.*, `item`.`id` AS `itemid`,`item`.`plink`,\n\t\t\t`item`.`author-name`, `item`.`author-avatar`, `item`.`author-link` FROM `event` LEFT JOIN `item` ON `item`.`event-id` = `event`.`id` \n\t\t\tWHERE `event`.`uid` = %d\n\t\t\tAND (( `adjust` = 0 AND `start` >= '%s' AND `start` <= '%s' ) \n\t\t\tOR  (  `adjust` = 1 AND `start` >= '%s' AND `start` <= '%s' )) ", intval(local_user()), dbesc($start), dbesc($finish), dbesc($adjust_start), dbesc($adjust_finish));
        $links = array();
        if (count($r)) {
            $r = sort_by_date($r);
            foreach ($r as $rr) {
                $j = $rr['adjust'] ? datetime_convert('UTC', date_default_timezone_get(), $rr['start'], 'j') : datetime_convert('UTC', 'UTC', $rr['start'], 'j');
                if (!x($links, $j)) {
                    $links[$j] = $a->get_baseurl() . '/' . $a->cmd . '#link-' . $j;
                }
            }
        }
        $o .= '<div id="new-event-link"><a href="' . $a->get_baseurl() . '/events/new' . '" >' . t('Create New Event') . '</a></div>';
        $o .= '<div id="event-calendar-wrapper">';
        $o .= '<a href="' . $a->get_baseurl() . '/events/' . $prevyear . '/' . $prevmonth . '" class="prevcal"><div id="event-calendar-prev" class="icon prev" title="' . t('Previous') . '"></div></a>';
        $o .= cal($y, $m, $links, ' eventcal');
        $o .= '<a href="' . $a->get_baseurl() . '/events/' . $nextyear . '/' . $nextmonth . '" class="nextcal"><div id="event-calendar-next" class="icon next" title="' . t('Next') . '"></div></a>';
        $o .= '</div>';
        $o .= '<div class="event-calendar-end"></div>';
        $last_date = '';
        $fmt = t('l, F j');
        if (count($r)) {
            $r = sort_by_date($r);
            foreach ($r as $rr) {
                $j = $rr['adjust'] ? datetime_convert('UTC', date_default_timezone_get(), $rr['start'], 'j') : datetime_convert('UTC', 'UTC', $rr['start'], 'j');
                $d = $rr['adjust'] ? datetime_convert('UTC', date_default_timezone_get(), $rr['start'], $fmt) : datetime_convert('UTC', 'UTC', $rr['start'], $fmt);
                $d = day_translate($d);
                if ($d !== $last_date) {
                    $o .= '<hr /><a name="link-' . $j . '" ><div class="event-list-date">' . $d . '</div></a>';
                }
                $last_date = $d;
                if ($rr['author-name']) {
                    $o .= '<a href="' . $rr['author-link'] . '" ><img src="' . $rr['author-avatar'] . '" height="32" width="32" />' . $rr['author-name'] . '</a>';
                }
                $o .= format_event_html($rr);
                $o .= !$rr['cid'] ? '<a href="' . $a->get_baseurl() . '/events/event/' . $rr['id'] . '" title="' . t('Edit event') . '" class="edit-event-link icon pencil"></a>' : '';
                if ($rr['plink']) {
                    $o .= '<a href="' . $rr['plink'] . '" title="' . t('link to source') . '" target="external-link" class="plink-event-link icon remote-link"></a></div>';
                }
                $o .= '<div class="clear"></div>';
            }
        }
        return $o;
    }
    if ($mode === 'edit' && $event_id) {
        $r = q("SELECT * FROM `event` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($event_id), intval(local_user()));
        if (count($r)) {
            $orig_event = $r[0];
        }
    }
    if ($mode === 'edit' || $mode === 'new') {
        $n_checked = x($orig_event) && $orig_event['nofinish'] ? ' checked="checked" ' : '';
        $a_checked = x($orig_event) && $orig_event['adjust'] ? ' checked="checked" ' : '';
        $d_orig = x($orig_event) ? $orig_event['desc'] : '';
        $l_orig = x($orig_event) ? $orig_event['location'] : '';
        $eid = x($orig_event) ? $orig_event['id'] : 0;
        $cid = x($orig_event) ? $orig_event['cid'] : 0;
        $uri = x($orig_event) ? $orig_event['uri'] : '';
        if (!x($orig_event)) {
            $sh_checked = '';
        } else {
            $sh_checked = $orig_event['allow_cid'] === '<' . local_user() . '>' && !$orig_event['allow_gid'] && !$orig_event['deny_cid'] && !$orig_event['deny_gid'] ? '' : ' checked="checked" ';
        }
        if ($cid) {
            $sh_checked .= ' disabled="disabled" ';
        }
        $htpl = get_markup_template('event_head.tpl');
        $a->page['htmlhead'] .= replace_macros($htpl, array('$baseurl' => $a->get_baseurl()));
        $tpl = get_markup_template('event_form.tpl');
        $sdt = x($orig_event) ? $orig_event['start'] : 'now';
        $fdt = x($orig_event) ? $orig_event['finish'] : 'now';
        $tz = x($orig_event) && $orig_event['adjust'] ? date_default_timezone_get() : 'UTC';
        $syear = datetime_convert('UTC', $tz, $sdt, 'Y');
        $smonth = datetime_convert('UTC', $tz, $sdt, 'm');
        $sday = datetime_convert('UTC', $tz, $sdt, 'd');
        $shour = x($orig_event) ? datetime_convert('UTC', $tz, $sdt, 'H') : 0;
        $sminute = x($orig_event) ? datetime_convert('UTC', $tz, $sdt, 'i') : 0;
        $fyear = datetime_convert('UTC', $tz, $fdt, 'Y');
        $fmonth = datetime_convert('UTC', $tz, $fdt, 'm');
        $fday = datetime_convert('UTC', $tz, $fdt, 'd');
        $fhour = x($orig_event) ? datetime_convert('UTC', $tz, $fdt, 'H') : 0;
        $fminute = x($orig_event) ? datetime_convert('UTC', $tz, $fdt, 'i') : 0;
        $f = get_config('system', 'event_input_format');
        if (!$f) {
            $f = 'ymd';
        }
        $dateformat = datesel_format($f);
        $timeformat = t('hour:minute');
        require_once 'include/acl_selectors.php';
        $o .= replace_macros($tpl, array('$post' => $a->get_baseurl() . '/events', '$eid' => $eid, '$cid' => $cid, '$uri' => $uri, '$e_text' => t('Event details'), '$e_desc' => sprintf(t('Format is %s %s. Starting date and Description are required.'), $dateformat, $timeformat), '$s_text' => t('Event Starts:') . ' <span class="required">*</span> ', '$s_dsel' => datesel($f, 'start', $syear + 5, $syear, false, $syear, $smonth, $sday), '$s_tsel' => timesel('start', $shour, $sminute), '$n_text' => t('Finish date/time is not known or not relevant'), '$n_checked' => $n_checked, '$f_text' => t('Event Finishes:'), '$f_dsel' => datesel($f, 'finish', $fyear + 5, $fyear, false, $fyear, $fmonth, $fday), '$f_tsel' => timesel('finish', $fhour, $fminute), '$a_text' => t('Adjust for viewer timezone'), '$a_checked' => $a_checked, '$d_text' => t('Description:') . ' <span class="required">*</span>', '$d_orig' => $d_orig, '$l_text' => t('Location:'), '$l_orig' => $l_orig, '$sh_text' => t('Share this event'), '$sh_checked' => $sh_checked, '$acl' => $cid ? '' : populate_acl(x($orig_event) ? $orig_event : $a->user, false), '$submit' => t('Submit')));
        return $o;
    }
}
Ejemplo n.º 10
0
function events_content(&$a)
{
    if (!local_user()) {
        notice(t('Permission denied.') . EOL);
        return;
    }
    if ($a->argc == 1) {
        $_SESSION['return_url'] = $a->get_baseurl() . '/' . $a->cmd;
    }
    if ($a->argc > 2 && $a->argv[1] === 'ignore' && intval($a->argv[2])) {
        $r = q("update event set ignore = 1 where id = %d and uid = %d", intval($a->argv[2]), intval(local_user()));
    }
    if ($a->argc > 2 && $a->argv[1] === 'unignore' && intval($a->argv[2])) {
        $r = q("update event set ignore = 0 where id = %d and uid = %d", intval($a->argv[2]), intval(local_user()));
    }
    if ($a->theme_events_in_profile) {
        nav_set_selected('home');
    } else {
        nav_set_selected('events');
    }
    $editselect = 'none';
    if (feature_enabled(local_user(), 'richtext')) {
        $editselect = 'textareas';
    }
    // First day of the week (0 = Sunday)
    $firstDay = get_pconfig(local_user(), 'system', 'first_day_of_week');
    if ($firstDay === false) {
        $firstDay = 0;
    }
    $i18n = array("firstDay" => $firstDay, "Sun" => t("Sun"), "Mon" => t("Mon"), "Tue" => t("Tue"), "Wed" => t("Wed"), "Thu" => t("Thu"), "Fri" => t("Fri"), "Sat" => t("Sat"), "Sunday" => t("Sunday"), "Monday" => t("Monday"), "Tuesday" => t("Tuesday"), "Wednesday" => t("Wednesday"), "Thursday" => t("Thursday"), "Friday" => t("Friday"), "Saturday" => t("Saturday"), "Jan" => t("Jan"), "Feb" => t("Feb"), "Mar" => t("Mar"), "Apr" => t("Apr"), "May" => t("May"), "Jun" => t("Jun"), "Jul" => t("Jul"), "Aug" => t("Aug"), "Sep" => t("Sept"), "Oct" => t("Oct"), "Nov" => t("Nov"), "Dec" => t("Dec"), "January" => t("January"), "February" => t("February"), "March" => t("March"), "April" => t("April"), "May" => t("May"), "June" => t("June"), "July" => t("July"), "August" => t("August"), "September" => t("September"), "October" => t("October"), "November" => t("November"), "December" => t("December"), "today" => t("today"), "month" => t("month"), "week" => t("week"), "day" => t("day"));
    $htpl = get_markup_template('event_head.tpl');
    $a->page['htmlhead'] .= replace_macros($htpl, array('$baseurl' => $a->get_baseurl(), '$i18n' => $i18n, '$editselect' => $editselect));
    $etpl = get_markup_template('event_end.tpl');
    $a->page['end'] .= replace_macros($etpl, array('$baseurl' => $a->get_baseurl(), '$editselect' => $editselect));
    $o = "";
    // tabs
    if ($a->theme_events_in_profile) {
        $tabs = profile_tabs($a, True);
    }
    $mode = 'view';
    $y = 0;
    $m = 0;
    $ignored = x($_REQUEST, 'ignored') ? intval($_REQUEST['ignored']) : 0;
    if ($a->argc > 1) {
        if ($a->argc > 2 && $a->argv[1] == 'event') {
            $mode = 'edit';
            $event_id = intval($a->argv[2]);
        }
        if ($a->argv[1] === 'new') {
            $mode = 'new';
            $event_id = 0;
        }
        if ($a->argc > 2 && intval($a->argv[1]) && intval($a->argv[2])) {
            $mode = 'view';
            $y = intval($a->argv[1]);
            $m = intval($a->argv[2]);
        }
    }
    if ($mode == 'view') {
        $thisyear = datetime_convert('UTC', date_default_timezone_get(), 'now', 'Y');
        $thismonth = datetime_convert('UTC', date_default_timezone_get(), 'now', 'm');
        if (!$y) {
            $y = intval($thisyear);
        }
        if (!$m) {
            $m = intval($thismonth);
        }
        // Put some limits on dates. The PHP date functions don't seem to do so well before 1900.
        // An upper limit was chosen to keep search engines from exploring links millions of years in the future.
        if ($y < 1901) {
            $y = 1900;
        }
        if ($y > 2099) {
            $y = 2100;
        }
        $nextyear = $y;
        $nextmonth = $m + 1;
        if ($nextmonth > 12) {
            $nextmonth = 1;
            $nextyear++;
        }
        $prevyear = $y;
        if ($m > 1) {
            $prevmonth = $m - 1;
        } else {
            $prevmonth = 12;
            $prevyear--;
        }
        $dim = get_dim($y, $m);
        $start = sprintf('%d-%d-%d %d:%d:%d', $y, $m, 1, 0, 0, 0);
        $finish = sprintf('%d-%d-%d %d:%d:%d', $y, $m, $dim, 23, 59, 59);
        if ($a->argv[1] === 'json') {
            if (x($_GET, 'start')) {
                $start = date("Y-m-d h:i:s", $_GET['start']);
            }
            if (x($_GET, 'end')) {
                $finish = date("Y-m-d h:i:s", $_GET['end']);
            }
        }
        $start = datetime_convert('UTC', 'UTC', $start);
        $finish = datetime_convert('UTC', 'UTC', $finish);
        $adjust_start = datetime_convert('UTC', date_default_timezone_get(), $start);
        $adjust_finish = datetime_convert('UTC', date_default_timezone_get(), $finish);
        if (x($_GET, 'id')) {
            $r = q("SELECT `event`.*, `item`.`id` AS `itemid`,`item`.`plink`,\n\t\t\t\t`item`.`author-name`, `item`.`author-avatar`, `item`.`author-link` FROM `event`\n\t\t\t\tLEFT JOIN `item` ON `item`.`event-id` = `event`.`id` AND `item`.`uid` = `event`.`uid`\n\t\t\t\tWHERE `event`.`uid` = %d AND `event`.`id` = %d", intval(local_user()), intval($_GET['id']));
        } else {
            $r = q("SELECT `event`.*, `item`.`id` AS `itemid`,`item`.`plink`,\n\t\t\t\t`item`.`author-name`, `item`.`author-avatar`, `item`.`author-link` FROM `event`\n\t\t\t\tLEFT JOIN `item` ON `item`.`event-id` = `event`.`id` AND `item`.`uid` = `event`.`uid`\n\t\t\t\tWHERE `event`.`uid` = %d and event.ignore = %d\n\t\t\t\tAND ((`adjust` = 0 AND (`finish` >= '%s' OR (nofinish AND start >= '%s')) AND `start` <= '%s')\n\t\t\t\tOR  (`adjust` = 1 AND (`finish` >= '%s' OR (nofinish AND start >= '%s')) AND `start` <= '%s')) ", intval(local_user()), intval($ignored), dbesc($start), dbesc($start), dbesc($finish), dbesc($adjust_start), dbesc($adjust_start), dbesc($adjust_finish));
        }
        $links = array();
        if (count($r)) {
            $r = sort_by_date($r);
            foreach ($r as $rr) {
                $j = $rr['adjust'] ? datetime_convert('UTC', date_default_timezone_get(), $rr['start'], 'j') : datetime_convert('UTC', 'UTC', $rr['start'], 'j');
                if (!x($links, $j)) {
                    $links[$j] = $a->get_baseurl() . '/' . $a->cmd . '#link-' . $j;
                }
            }
        }
        $events = array();
        $last_date = '';
        $fmt = t('l, F j');
        if (count($r)) {
            $r = sort_by_date($r);
            foreach ($r as $rr) {
                $j = $rr['adjust'] ? datetime_convert('UTC', date_default_timezone_get(), $rr['start'], 'j') : datetime_convert('UTC', 'UTC', $rr['start'], 'j');
                $d = $rr['adjust'] ? datetime_convert('UTC', date_default_timezone_get(), $rr['start'], $fmt) : datetime_convert('UTC', 'UTC', $rr['start'], $fmt);
                $d = day_translate($d);
                $start = $rr['adjust'] ? datetime_convert('UTC', date_default_timezone_get(), $rr['start'], 'c') : datetime_convert('UTC', 'UTC', $rr['start'], 'c');
                if ($rr['nofinish']) {
                    $end = null;
                } else {
                    $end = $rr['adjust'] ? datetime_convert('UTC', date_default_timezone_get(), $rr['finish'], 'c') : datetime_convert('UTC', 'UTC', $rr['finish'], 'c');
                }
                $is_first = $d !== $last_date;
                $last_date = $d;
                $edit = !$rr['cid'] ? array($a->get_baseurl() . '/events/event/' . $rr['id'], t('Edit event'), '', '') : null;
                $title = strip_tags(html_entity_decode(bbcode($rr['summary']), ENT_QUOTES, 'UTF-8'));
                if (!$title) {
                    list($title, $_trash) = explode("<br", bbcode($rr['desc']), 2);
                    $title = strip_tags(html_entity_decode($title, ENT_QUOTES, 'UTF-8'));
                }
                $html = format_event_html($rr);
                $rr['desc'] = bbcode($rr['desc']);
                $rr['location'] = bbcode($rr['location']);
                $events[] = array('id' => $rr['id'], 'start' => $start, 'end' => $end, 'allDay' => false, 'title' => $title, 'j' => $j, 'd' => $d, 'edit' => $edit, 'is_first' => $is_first, 'item' => $rr, 'html' => $html, 'plink' => array($rr['plink'], t('link to source'), '', ''));
            }
        }
        if ($a->argv[1] === 'json') {
            echo json_encode($events);
            killme();
        }
        // links: array('href', 'text', 'extra css classes', 'title')
        if (x($_GET, 'id')) {
            $tpl = get_markup_template("event.tpl");
        } else {
            //			if (get_config('experimentals','new_calendar')==1){
            $tpl = get_markup_template("events-js.tpl");
            //			} else {
            //				$tpl = get_markup_template("events.tpl");
            //			}
        }
        // Get rid of dashes in key names, Smarty3 can't handle them
        foreach ($events as $key => $event) {
            $event_item = array();
            foreach ($event['item'] as $k => $v) {
                $k = str_replace('-', '_', $k);
                $event_item[$k] = $v;
            }
            $events[$key]['item'] = $event_item;
        }
        $o = replace_macros($tpl, array('$baseurl' => $a->get_baseurl(), '$tabs' => $tabs, '$title' => t('Events'), '$new_event' => array($a->get_baseurl() . '/events/new', t('Create New Event'), '', ''), '$previus' => array($a->get_baseurl() . "/events/{$prevyear}/{$prevmonth}", t('Previous'), '', ''), '$next' => array($a->get_baseurl() . "/events/{$nextyear}/{$nextmonth}", t('Next'), '', ''), '$calendar' => cal($y, $m, $links, ' eventcal'), '$events' => $events));
        if (x($_GET, 'id')) {
            echo $o;
            killme();
        }
        return $o;
    }
    if ($mode === 'edit' && $event_id) {
        $r = q("SELECT * FROM `event` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($event_id), intval(local_user()));
        if (count($r)) {
            $orig_event = $r[0];
        }
    }
    // Passed parameters overrides anything found in the DB
    if ($mode === 'edit' || $mode === 'new') {
        if (!x($orig_event)) {
            $orig_event = array();
        }
        // In case of an error the browser is redirected back here, with these parameters filled in with the previous values
        if (x($_REQUEST, 'nofinish')) {
            $orig_event['nofinish'] = $_REQUEST['nofinish'];
        }
        if (x($_REQUEST, 'adjust')) {
            $orig_event['adjust'] = $_REQUEST['adjust'];
        }
        if (x($_REQUEST, 'summary')) {
            $orig_event['summary'] = $_REQUEST['summary'];
        }
        if (x($_REQUEST, 'description')) {
            $orig_event['description'] = $_REQUEST['description'];
        }
        if (x($_REQUEST, 'location')) {
            $orig_event['location'] = $_REQUEST['location'];
        }
        if (x($_REQUEST, 'start')) {
            $orig_event['start'] = $_REQUEST['start'];
        }
        if (x($_REQUEST, 'finish')) {
            $orig_event['finish'] = $_REQUEST['finish'];
        }
    }
    if ($mode === 'edit' || $mode === 'new') {
        $n_checked = x($orig_event) && $orig_event['nofinish'] ? ' checked="checked" ' : '';
        $a_checked = x($orig_event) && $orig_event['adjust'] ? ' checked="checked" ' : '';
        $t_orig = x($orig_event) ? $orig_event['summary'] : '';
        $d_orig = x($orig_event) ? $orig_event['desc'] : '';
        $l_orig = x($orig_event) ? $orig_event['location'] : '';
        $eid = x($orig_event) ? $orig_event['id'] : 0;
        $cid = x($orig_event) ? $orig_event['cid'] : 0;
        $uri = x($orig_event) ? $orig_event['uri'] : '';
        if (!x($orig_event)) {
            $sh_checked = '';
        } else {
            $sh_checked = $orig_event['allow_cid'] === '<' . local_user() . '>' && !$orig_event['allow_gid'] && !$orig_event['deny_cid'] && !$orig_event['deny_gid'] ? '' : ' checked="checked" ';
        }
        if ($cid or $mode !== 'new') {
            $sh_checked .= ' disabled="disabled" ';
        }
        $sdt = x($orig_event) ? $orig_event['start'] : 'now';
        $fdt = x($orig_event) ? $orig_event['finish'] : 'now';
        $tz = date_default_timezone_get();
        if (x($orig_event)) {
            $tz = $orig_event['adjust'] ? date_default_timezone_get() : 'UTC';
        }
        $syear = datetime_convert('UTC', $tz, $sdt, 'Y');
        $smonth = datetime_convert('UTC', $tz, $sdt, 'm');
        $sday = datetime_convert('UTC', $tz, $sdt, 'd');
        $shour = x($orig_event) ? datetime_convert('UTC', $tz, $sdt, 'H') : 0;
        $sminute = x($orig_event) ? datetime_convert('UTC', $tz, $sdt, 'i') : 0;
        $fyear = datetime_convert('UTC', $tz, $fdt, 'Y');
        $fmonth = datetime_convert('UTC', $tz, $fdt, 'm');
        $fday = datetime_convert('UTC', $tz, $fdt, 'd');
        $fhour = x($orig_event) ? datetime_convert('UTC', $tz, $fdt, 'H') : 0;
        $fminute = x($orig_event) ? datetime_convert('UTC', $tz, $fdt, 'i') : 0;
        $f = get_config('system', 'event_input_format');
        if (!$f) {
            $f = 'ymd';
        }
        require_once 'include/acl_selectors.php';
        if ($mode === 'new') {
            $acl = $cid ? '' : populate_acl(x($orig_event) ? $orig_event : $a->user);
        }
        $tpl = get_markup_template('event_form.tpl');
        $o .= replace_macros($tpl, array('$post' => $a->get_baseurl() . '/events', '$eid' => $eid, '$cid' => $cid, '$uri' => $uri, '$title' => t('Event details'), '$desc' => t('Starting date and Title are required.'), '$s_text' => t('Event Starts:') . ' <span class="required" title="' . t('Required') . '">*</span>', '$s_dsel' => datetimesel($f, new DateTime(), DateTime::createFromFormat('Y', $syear + 5), DateTime::createFromFormat('Y-m-d H:i', "{$syear}-{$smonth}-{$sday} {$shour}:{$sminute}"), 'start_text', true, true, '', '', true), '$n_text' => t('Finish date/time is not known or not relevant'), '$n_checked' => $n_checked, '$f_text' => t('Event Finishes:'), '$f_dsel' => datetimesel($f, new DateTime(), DateTime::createFromFormat('Y', $fyear + 5), DateTime::createFromFormat('Y-m-d H:i', "{$fyear}-{$fmonth}-{$fday} {$fhour}:{$fminute}"), 'finish_text', true, true, 'start_text'), '$a_text' => t('Adjust for viewer timezone'), '$a_checked' => $a_checked, '$d_text' => t('Description:'), '$d_orig' => $d_orig, '$l_text' => t('Location:'), '$l_orig' => $l_orig, '$t_text' => t('Title:') . ' <span class="required" title="' . t('Required') . '">*</span>', '$t_orig' => $t_orig, '$sh_text' => t('Share this event'), '$sh_checked' => $sh_checked, '$preview' => t('Preview'), '$acl' => $acl, '$submit' => t('Submit')));
        return $o;
    }
}
Ejemplo n.º 11
0
function events_content(&$a)
{
    if (!local_user()) {
        notice(t('Permission denied.') . EOL);
        return;
    }
    $htpl = get_markup_template('event_head.tpl');
    $a->page['htmlhead'] .= replace_macros($htpl, array('$baseurl' => $a->get_baseurl()));
    $o = "";
    // tabs
    $tabs = profile_tabs($a, True);
    $mode = 'view';
    $y = 0;
    $m = 0;
    if ($a->argc > 1) {
        if ($a->argc > 2 && $a->argv[1] == 'event') {
            $mode = 'edit';
            $event_id = intval($a->argv[2]);
        }
        if ($a->argv[1] === 'new') {
            $mode = 'new';
            $event_id = 0;
        }
        if ($a->argc > 2 && intval($a->argv[1]) && intval($a->argv[2])) {
            $mode = 'view';
            $y = intval($a->argv[1]);
            $m = intval($a->argv[2]);
        }
    }
    if ($mode == 'view') {
        $thisyear = datetime_convert('UTC', date_default_timezone_get(), 'now', 'Y');
        $thismonth = datetime_convert('UTC', date_default_timezone_get(), 'now', 'm');
        if (!$y) {
            $y = intval($thisyear);
        }
        if (!$m) {
            $m = intval($thismonth);
        }
        // Put some limits on dates. The PHP date functions don't seem to do so well before 1900.
        // An upper limit was chosen to keep search engines from exploring links millions of years in the future.
        if ($y < 1901) {
            $y = 1900;
        }
        if ($y > 2099) {
            $y = 2100;
        }
        $nextyear = $y;
        $nextmonth = $m + 1;
        if ($nextmonth > 12) {
            $nextmonth = 1;
            $nextyear++;
        }
        $prevyear = $y;
        if ($m > 1) {
            $prevmonth = $m - 1;
        } else {
            $prevmonth = 12;
            $prevyear--;
        }
        $dim = get_dim($y, $m);
        $start = sprintf('%d-%d-%d %d:%d:%d', $y, $m, 1, 0, 0, 0);
        $finish = sprintf('%d-%d-%d %d:%d:%d', $y, $m, $dim, 23, 59, 59);
        if ($a->argv[1] === 'json') {
            if (x($_GET, 'start')) {
                $start = date("Y-m-d h:i:s", $_GET['start']);
            }
            if (x($_GET, 'end')) {
                $finish = date("Y-m-d h:i:s", $_GET['end']);
            }
        }
        $start = datetime_convert('UTC', 'UTC', $start);
        $finish = datetime_convert('UTC', 'UTC', $finish);
        $adjust_start = datetime_convert('UTC', date_default_timezone_get(), $start);
        $adjust_finish = datetime_convert('UTC', date_default_timezone_get(), $finish);
        if (x($_GET, 'id')) {
            $r = q("SELECT `event`.*, `item`.`id` AS `itemid`,`item`.`plink`,\n\t\t\t\t`item`.`author-name`, `item`.`author-avatar`, `item`.`author-link` FROM `event` LEFT JOIN `item` ON `item`.`event-id` = `event`.`id` \n\t\t\t\tWHERE `event`.`uid` = %d AND `event`.`id` = %d", intval(local_user()), intval($_GET['id']));
        } else {
            $r = q("SELECT `event`.*, `item`.`id` AS `itemid`,`item`.`plink`,\n\t\t\t\t`item`.`author-name`, `item`.`author-avatar`, `item`.`author-link` FROM `event` LEFT JOIN `item` ON `item`.`event-id` = `event`.`id` \n\t\t\t\tWHERE `event`.`uid` = %d\n\t\t\t\tAND (( `adjust` = 0 AND `start` >= '%s' AND `start` <= '%s' ) \n\t\t\t\tOR  (  `adjust` = 1 AND `start` >= '%s' AND `start` <= '%s' )) ", intval(local_user()), dbesc($start), dbesc($finish), dbesc($adjust_start), dbesc($adjust_finish));
        }
        $links = array();
        if (count($r)) {
            $r = sort_by_date($r);
            foreach ($r as $rr) {
                $j = $rr['adjust'] ? datetime_convert('UTC', date_default_timezone_get(), $rr['start'], 'j') : datetime_convert('UTC', 'UTC', $rr['start'], 'j');
                if (!x($links, $j)) {
                    $links[$j] = $a->get_baseurl() . '/' . $a->cmd . '#link-' . $j;
                }
            }
        }
        $events = array();
        $last_date = '';
        $fmt = t('l, F j');
        if (count($r)) {
            $r = sort_by_date($r);
            foreach ($r as $rr) {
                $j = $rr['adjust'] ? datetime_convert('UTC', date_default_timezone_get(), $rr['start'], 'j') : datetime_convert('UTC', 'UTC', $rr['start'], 'j');
                $d = $rr['adjust'] ? datetime_convert('UTC', date_default_timezone_get(), $rr['start'], $fmt) : datetime_convert('UTC', 'UTC', $rr['start'], $fmt);
                $d = day_translate($d);
                $start = $rr['adjust'] ? datetime_convert('UTC', date_default_timezone_get(), $rr['start'], 'c') : datetime_convert('UTC', 'UTC', $rr['start'], 'c');
                if ($rr['nofinish']) {
                    $end = null;
                } else {
                    $end = $rr['adjust'] ? datetime_convert('UTC', date_default_timezone_get(), $rr['finish'], 'c') : datetime_convert('UTC', 'UTC', $rr['finish'], 'c');
                }
                $is_first = $d !== $last_date;
                $last_date = $d;
                $edit = !$rr['cid'] ? array($a->get_baseurl() . '/events/event/' . $rr['id'], t('Edit event'), '', '') : null;
                list($title, $_trash) = explode("<br", bbcode($rr['desc']), 2);
                $title = strip_tags($title);
                $html = format_event_html($rr);
                $rr['desc'] = bbcode($rr['desc']);
                $rr['location'] = bbcode($rr['location']);
                $events[] = array('id' => $rr['id'], 'start' => $start, 'end' => $end, 'allDay' => false, 'title' => $title, 'j' => $j, 'd' => $d, 'edit' => $edit, 'is_first' => $is_first, 'item' => $rr, 'html' => $html, 'plink' => array($rr['plink'], t('link to source'), '', ''));
            }
        }
        if ($a->argv[1] === 'json') {
            echo json_encode($events);
            killme();
        }
        // links: array('href', 'text', 'extra css classes', 'title')
        if (x($_GET, 'id')) {
            $tpl = get_markup_template("event.tpl");
        } else {
            if (get_config('experimentals', 'new_calendar') == 1) {
                $tpl = get_markup_template("events-js.tpl");
            } else {
                $tpl = get_markup_template("events.tpl");
            }
        }
        $o = replace_macros($tpl, array('$baseurl' => $a->get_baseurl(), '$tabs' => $tabs, '$title' => t('Events'), '$new_event' => array($a->get_baseurl() . '/events/new', t('Create New Event'), '', ''), '$previus' => array($a->get_baseurl() . "/events/{$prevyear}/{$prevmonth}", t('Previous'), '', ''), '$next' => array($a->get_baseurl() . "/events/{$nextyear}/{$nextmonth}", t('Next'), '', ''), '$calendar' => cal($y, $m, $links, ' eventcal'), '$events' => $events));
        if (x($_GET, 'id')) {
            echo $o;
            killme();
        }
        return $o;
    }
    if ($mode === 'edit' && $event_id) {
        $r = q("SELECT * FROM `event` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($event_id), intval(local_user()));
        if (count($r)) {
            $orig_event = $r[0];
        }
    }
    if ($mode === 'edit' || $mode === 'new') {
        $n_checked = x($orig_event) && $orig_event['nofinish'] ? ' checked="checked" ' : '';
        $a_checked = x($orig_event) && $orig_event['adjust'] ? ' checked="checked" ' : '';
        $d_orig = x($orig_event) ? $orig_event['desc'] : '';
        $l_orig = x($orig_event) ? $orig_event['location'] : '';
        $eid = x($orig_event) ? $orig_event['id'] : 0;
        $cid = x($orig_event) ? $orig_event['cid'] : 0;
        $uri = x($orig_event) ? $orig_event['uri'] : '';
        if (!x($orig_event)) {
            $sh_checked = '';
        } else {
            $sh_checked = $orig_event['allow_cid'] === '<' . local_user() . '>' && !$orig_event['allow_gid'] && !$orig_event['deny_cid'] && !$orig_event['deny_gid'] ? '' : ' checked="checked" ';
        }
        if ($cid) {
            $sh_checked .= ' disabled="disabled" ';
        }
        $tpl = get_markup_template('event_form.tpl');
        $sdt = x($orig_event) ? $orig_event['start'] : 'now';
        $fdt = x($orig_event) ? $orig_event['finish'] : 'now';
        $tz = date_default_timezone_get();
        if (x($orig_event)) {
            $tz = $orig_event['adjust'] ? date_default_timezone_get() : 'UTC';
        }
        $syear = datetime_convert('UTC', $tz, $sdt, 'Y');
        $smonth = datetime_convert('UTC', $tz, $sdt, 'm');
        $sday = datetime_convert('UTC', $tz, $sdt, 'd');
        $shour = x($orig_event) ? datetime_convert('UTC', $tz, $sdt, 'H') : 0;
        $sminute = x($orig_event) ? datetime_convert('UTC', $tz, $sdt, 'i') : 0;
        $fyear = datetime_convert('UTC', $tz, $fdt, 'Y');
        $fmonth = datetime_convert('UTC', $tz, $fdt, 'm');
        $fday = datetime_convert('UTC', $tz, $fdt, 'd');
        $fhour = x($orig_event) ? datetime_convert('UTC', $tz, $fdt, 'H') : 0;
        $fminute = x($orig_event) ? datetime_convert('UTC', $tz, $fdt, 'i') : 0;
        $f = get_config('system', 'event_input_format');
        if (!$f) {
            $f = 'ymd';
        }
        $dateformat = datesel_format($f);
        $timeformat = t('hour:minute');
        require_once 'include/acl_selectors.php';
        $o .= replace_macros($tpl, array('$post' => $a->get_baseurl() . '/events', '$eid' => $eid, '$cid' => $cid, '$uri' => $uri, '$title' => t('Event details'), '$desc' => sprintf(t('Format is %s %s. Starting date and Description are required.'), $dateformat, $timeformat), '$s_text' => t('Event Starts:') . ' <span class="required">*</span> ', '$s_dsel' => datesel($f, 'start', $syear + 5, $syear, false, $syear, $smonth, $sday), '$s_tsel' => timesel('start', $shour, $sminute), '$n_text' => t('Finish date/time is not known or not relevant'), '$n_checked' => $n_checked, '$f_text' => t('Event Finishes:'), '$f_dsel' => datesel($f, 'finish', $fyear + 5, $fyear, false, $fyear, $fmonth, $fday), '$f_tsel' => timesel('finish', $fhour, $fminute), '$a_text' => t('Adjust for viewer timezone'), '$a_checked' => $a_checked, '$d_text' => t('Description:') . ' <span class="required">*</span>', '$d_orig' => $d_orig, '$l_text' => t('Location:'), '$l_orig' => $l_orig, '$sh_text' => t('Share this event'), '$sh_checked' => $sh_checked, '$acl' => $cid ? '' : populate_acl(x($orig_event) ? $orig_event : $a->user, false), '$submit' => t('Submit')));
        return $o;
    }
}
Ejemplo n.º 12
0
 case 'upd':
     upd($diary->link);
     break;
 case 's':
     srch();
     break;
     // Not needed
 // Not needed
 case 'notes':
     notes();
     break;
 case 'ticker':
     ticker();
     break;
 case 'cal':
     cal($diary->link);
     break;
 case 'time':
     time2($d_date11);
     break;
 case 'events':
     events($diary->link, $d_date5, $d_date6, $d_date10);
     break;
 case 'eventsadd':
     eventsadd($diary->link);
     break;
 case 'eventsedit':
     eventsedit($diary->link);
     break;
 case 'tasks':
     tasks($diary->link);
Ejemplo n.º 13
0
/**
 * DZCP - deV!L`z ClanPortal 1.6 Final
 * http://www.dzcp.de
 * Menu: Kalender
 */
function kalender($month = "", $year = "")
{
    global $db, $sql_prefix;
    if (!empty($month) && !empty($year)) {
        $monat = cal($month);
        $jahr = $year;
    } else {
        $monat = date("m");
        $jahr = date("Y");
    }
    for ($i = 1; $i <= 12; $i++) {
        $mname = array("1" => _jan, "2" => _feb, "3" => _mar, "4" => _apr, "5" => _mai, "6" => _jun, "7" => _jul, "8" => _aug, "9" => _sep, "10" => _okt, "11" => _nov, "12" => _dez);
        if ($monat == $i) {
            $month = $mname[$i];
        }
    }
    $today = mktime(0, 0, 0, date("n"), date("d"), date("Y"));
    $i = 1;
    $show = '';
    while ($i <= 31 && checkdate($monat, $i, $jahr)) {
        $data = '';
        $event = '';
        $bdays = '';
        $cws = '';
        for ($iw = 1; $iw <= 7; $iw++) {
            unset($titlecw);
            unset($titlebd);
            unset($titleev);
            $datum = mktime(0, 0, 0, $monat, $i, $jahr);
            $wday = getdate($datum);
            $wday = $wday['wday'];
            if (!$wday) {
                $wday = 7;
            }
            if ($wday != $iw) {
                $data .= "<td class=\"navKalEmpty\"></td>";
            } else {
                $titlebd = '';
                $bdays = "";
                $qry = db("SELECT id,bday FROM " . $db['users'] . " WHERE bday LIKE '" . cal($i) . "." . $monat . ".____" . "'");
                if (_rows($qry)) {
                    while ($get = _fetch($qry)) {
                        $bdays = "set";
                        $titlebd .= '&lt;img src=../inc/images/bday.gif class=icon alt= /&gt;' . '&nbsp;' . jsconvert(_kal_birthday . rawautor($get['id'])) . '&lt;br />';
                    }
                }
                $cws = "";
                $titlecw = "";
                $qry = db("SELECT datum,gegner FROM " . $db['cw'] . " WHERE DATE_FORMAT(FROM_UNIXTIME(datum), '%d.%m.%Y') = '" . cal($i) . "." . $monat . "." . $jahr . "'");
                if (_rows($qry)) {
                    while ($get = _fetch($qry)) {
                        $cws = "set";
                        $titlecw .= '&lt;img src=../inc/images/cw.gif class=icon alt= /&gt;' . '&nbsp;' . jsconvert(_kal_cw . re($get['gegner'])) . '&lt;br />';
                    }
                }
                $event = "";
                $titleev = "";
                $qry = db("SELECT s1.*, s2.name as katname FROM " . $sql_prefix . "events_info as s1 JOIN " . $sql_prefix . "events_kat as s2\n                   WHERE s1.kat = s2.id AND DATE_FORMAT(FROM_UNIXTIME(start), '%d.%m.%Y') <= '" . cal($i) . "." . $monat . "." . $jahr . "' AND DATE_FORMAT(FROM_UNIXTIME(ende), '%d.%m.%Y') >= '" . cal($i) . "." . $monat . "." . $jahr . "' AND s1.show = 1");
                if (_rows($qry)) {
                    while ($get = _fetch($qry)) {
                        $pfadbild = "inc/images/eventkat/" . $get['kat'];
                        if (file_exists(basePath . "/" . $pfadbild . ".gif")) {
                            $bild = '<img src=../' . $pfadbild . '.gif class=icon  alt= />';
                        } elseif (file_exists(basePath . "/" . $pfadbild . ".jpg")) {
                            $bild = '<img src=../' . $pfadbild . '.jpg class=icon  alt= />';
                        } elseif (file_exists(basePath . "/" . $pfadbild . ".png")) {
                            $bild = '<img src=../' . $pfadbild . '.png class=icon  alt= />';
                        } else {
                            $bild = "<img src=../inc/images/event.gif class=icon alt= />";
                        }
                        $event = "set";
                        $titleev .= '<tr><td>' . $bild . jsconvert(re($get['katname']) . ': ' . re($get['name'])) . '</td></tr>';
                    }
                }
                $info = 'onmouseover="DZCP.showInfo(\'' . cal($i) . '.' . $monat . '.' . $jahr . '\', \'' . $titlebd . $titlecw . $titleev . '\')" onmouseout="DZCP.hideInfo()"';
                if ($event == "set" || $cws == "set" || $bdays == "set") {
                    $day = '<a class="navKal" href="../kalender/?m=' . $monat . '&amp;y=' . $jahr . '&amp;hl=' . $i . '" ' . $info . '>' . cal($i) . '</a>';
                } else {
                    $day = cal($i);
                }
                if (!checkdate($monat, $i, $jahr)) {
                    $data .= '<td class="navKalEmpty"></td>';
                } elseif ($datum == $today) {
                    $data .= show("menu/kal_day", array("day" => $day, "id" => "navKalToday"));
                } else {
                    $data .= show("menu/kal_day", array("day" => $day, "id" => "navKalDays"));
                }
                $i++;
            }
        }
        $show .= "<tr>" . $data . "</tr>";
    }
    if ($monat + 1 == 13) {
        $nm = 1;
        $ny = $jahr + 1;
    } else {
        $nm = $monat + 1;
        $ny = $jahr;
    }
    if ($monat - 1 == 0) {
        $lm = 12;
        $ly = $jahr - 1;
    } else {
        $lm = $monat - 1;
        $ly = $jahr;
    }
    $kalender = show("menu/kalender", array("monat" => $month, "show" => $show, "year" => $jahr, "nm" => $nm, "ny" => $ny, "lm" => $lm, "ly" => $ly, "montag" => _nav_montag, "dienstag" => _nav_dienstag, "mittwoch" => _nav_mittwoch, "donnerstag" => _nav_donnerstag, "freitag" => _nav_freitag, "samstag" => _nav_samstag, "sonntag" => _nav_sonntag));
    return '<div id="navKalender">' . $kalender . '</div>';
}
Ejemplo n.º 14
0
<?
  # Добавить подсветку сегодняшнего числа
  # Реализовать чтобы календарь выводило на любой указанный в $arg[1] год
  # Добавить поддержку многоязычности
  # и чтобы первым днём недели чтобы можно было указать воскресенье или другой день
  return cal($arg[1]);

  function cal($year) {
    return "Календарь на 2015 год:

       Январь               Февраль                 Март          
Вс Пн Вт Ср Чт Пт Сб  Вс Пн Вт Ср Чт Пт Сб  Вс Пн Вт Ср Чт Пт Сб  
             1  2  3   1  2  3  4  5  6  7   1  2  3  4  5  6  7  
 4  5  6  7  8  9 10   8  9 10 11 12 13 14   8  9 10 11 12 13 14  
11 12 13 14 15 16 17  15 16 17 18 19 20 21  15 16 17 18 19 20 21  
18 19 20 21 22 23 24  22 23 24 25 26 27 28  22 23 24 25 26 27 28  
25 26 27 28 29 30 31                        29 30 31              
                                                                  

       Апрель                 Май                   Июнь          
Вс Пн Вт Ср Чт Пт Сб  Вс Пн Вт Ср Чт Пт Сб  Вс Пн Вт Ср Чт Пт Сб  
          1  2  3  4                  1  2      1  2  3  4  5  6  
 5  6  7  8  9 10 11   3  4  5  6  7  8  9   7  8  9 10 11 12 13  
12 13 14 15 16 17 18  10 11 12 13 14 15 16  14 15 16 17 18 19 20  
19 20 21 22 23 24 25  17 18 19 20 21 22 23  21 22 23 24 25 26 27  
26 27 28 29 30        24 25 26 27 28 29 30  28 29 30              
                      31                                          

        Июль                 Август               Сентябрь        
Вс Пн Вт Ср Чт Пт Сб  Вс Пн Вт Ср Чт Пт Сб  Вс Пн Вт Ср Чт Пт Сб  
          1  2  3  4                     1         1  2  3  4  5  
Ejemplo n.º 15
0
<?php

//<!--Calaulator @YingZhou 03/14/2016-->
if (is_ajax()) {
    if (isset($_POST["action"]) && !empty($_POST["action"])) {
        //Checks if action value exists
        $action = $_POST["action"];
        switch ($action) {
            case "mul":
                cal($_POST["value1"], $_POST["value2"], $_POST["operate"]);
                break;
            case "=":
                cal($_POST["value1"], $_POST["value2"], $_POST["operate"]);
                break;
        }
    }
}
//Function to check if the request is an AJAX request
function is_ajax()
{
    return isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest';
}
function cal($value1, $value2, $operate)
{
    $number1 = floatval($value1);
    $number2 = floatval($value2);
    if ($operate == "+") {
        echo $value1 + $value2;
    }
    if ($operate == "-") {
        echo $value1 - $value2;
Ejemplo n.º 16
0
     } elseif (_rows($check_nick)) {
         $index = error(_error_nick_exists, 1);
     } elseif (_rows($check_email)) {
         $index = error(_error_email_exists, 1);
     } else {
         if ($_POST['pwd']) {
             $newpwd = "pwd = '" . md5($_POST['pwd']) . "',";
             $index = info(_info_edit_profile_done, "?action=user&amp;id=" . $userid . "");
             $_SESSION['pwd'] = md5($_POST['pwd']);
         } else {
             $newpwd = "";
             $index = info(_info_edit_profile_done, "?action=user&amp;id=" . $userid . "");
         }
         $icq = preg_replace("=-=Uis", "", $_POST['icq']);
         if ($_POST['t'] && $_POST['m'] && $_POST['j']) {
             $bday = cal($_POST['t']) . "." . cal($_POST['m']) . "." . $_POST['j'];
         }
         if ($_POST['steamid3']) {
             $steamid = $_POST['steamid1'] . ":" . $_POST['steamid2'] . ":" . $_POST['steamid3'];
         }
         $qrycustom = db("SELECT feldname,type FROM " . $db['profile']);
         while ($getcustom = _fetch($qrycustom)) {
             if ($getcustom['type'] == 2) {
                 $customfields .= " " . $getcustom['feldname'] . " = '" . links($_POST[$getcustom['feldname']]) . "', ";
             } else {
                 $customfields .= " " . $getcustom['feldname'] . " = '" . up($_POST[$getcustom['feldname']]) . "', ";
             }
         }
         $qry = db("UPDATE " . $db['users'] . "\n\t\t  \t\t\t SET\t" . $newpwd . "\n\t\t\t            " . $customfields . "\n                  `country`      = '" . $_POST['land'] . "',\n                  `user`         = '" . $_POST['user'] . "',\n\t\t\t  \t\t\t \t\t`nick`         = '" . up($_POST['nick']) . "',\n\t\t\t\t\t\t\t\t\t`rlname`       = '" . up($_POST['rlname']) . "',\n\t\t\t\t\t\t\t\t\t`sex`          = '" . (int) $_POST['sex'] . "',\n\t\t\t\t\t\t\t\t\t`status`       = '" . (int) $_POST['status'] . "',\n\t\t\t\t\t\t\t\t\t`bday`         = '" . $bday . "',\n\t\t\t\t\t\t\t\t\t`email`        = '" . up($_POST['email']) . "',\n\t\t\t\t\t\t\t\t\t`nletter`      = '" . (int) $_POST['nletter'] . "',\n\t\t\t\t\t\t\t\t\t`pnmail`       = '" . (int) $_POST['pnmail'] . "',\n\t\t\t\t\t\t\t\t\t`city`         = '" . up($_POST['city']) . "',\n\t\t\t\t\t\t\t\t\t`gmaps_koord`  = '" . up($_POST['gmaps_koord']) . "',\n\t\t\t\t\t\t\t\t\t`hp`           = '" . links($_POST['hp']) . "',\n\t\t\t\t\t\t\t\t\t`icq`          = '" . (int) $icq . "',\n\t\t\t\t\t\t\t\t\t`hlswid`       = '" . up($_POST['hlswid']) . "',\n\t\t\t\t\t\t\t\t\t`steamid`      = '" . $steamid . "',\n\t\t\t\t\t\t\t\t\t`signatur`     = '" . up($_POST['sig'], 1) . "',\n\t\t\t\t\t\t\t\t\t`beschreibung` = '" . up($_POST['ich'], 1) . "'\n\t\t\t\t\t  WHERE id = " . $userid);
     }
 } elseif ($_GET['do'] == "delete") {
function kalender($month = "", $year = "")
{
    global $db, $sql_prefix;
    if (!empty($month) && !empty($year)) {
        $monat = cal($month);
        $jahr = $year;
    } else {
        $monat = date("m");
        $jahr = date("Y");
    }
    for ($i = 1; $i <= 12; $i++) {
        $mname = array("1" => _jan, "2" => _feb, "3" => _mar, "4" => _apr, "5" => _mai, "6" => _jun, "7" => _jul, "8" => _aug, "9" => _sep, "10" => _okt, "11" => _nov, "12" => _dez);
        if ($monat == $i) {
            $month = $mname[$i];
        }
    }
    $today = mktime(0, 0, 0, date("n"), date("d"), date("Y"));
    $i = 1;
    while ($i <= 31 && checkdate($monat, $i, $jahr)) {
        unset($event);
        unset($data);
        unset($bdays);
        unset($cws);
        for ($iw = 1; $iw <= 7; $iw++) {
            unset($titlecw);
            unset($titlebd);
            unset($titleev);
            $datum = mktime(0, 0, 0, $monat, $i, $jahr);
            $wday = getdate($datum);
            $wday = $wday['wday'];
            if (!$wday) {
                $wday = 7;
            }
            if ($wday != $iw) {
                $data .= "<td class=\"navKalEmpty\"></td>";
            } else {
                $qry = db("SELECT id,bday FROM " . $db['users'] . " WHERE bday LIKE '" . cal($i) . "." . $monat . ".____" . "'");
                if (_rows($qry)) {
                    while ($get = _fetch($qry)) {
                        $bdays = "set";
                        $titlebd .= '<tr><td><img src=../inc/images/bday.gif class=icon alt= /> ' . jsconvert(_kal_birthday . rawautor($get['id'])) . '</td></tr>';
                    }
                } else {
                    $bdays = "";
                    $titlebd = "";
                }
                $qry = db("SELECT datum,cid FROM " . $db['cw'] . " WHERE DATE_FORMAT(FROM_UNIXTIME(datum), '%d.%m.%Y') = '" . cal($i) . "." . $monat . "." . $jahr . "'");
                if (_rows($qry)) {
                    while ($get = _fetch($qry)) {
                        //Clans Mod
                        $clandetailssql = db("SELECT gegner FROM " . $sql_prefix . "clans WHERE id LIKE " . $get['cid']);
                        $clans = _fetch($clandetailssql);
                        $cws = "set";
                        $titlecw .= '<tr><td><img src=../inc/images/cw.gif class=icon alt= /> ' . jsconvert(_kal_cw . re($clans['gegner'])) . '</td></tr>';
                    }
                } else {
                    $cws = "";
                    $titlecw = "";
                }
                $qry = db("SELECT datum,title FROM " . $db['events'] . " WHERE DATE_FORMAT(FROM_UNIXTIME(datum), '%d.%m.%Y') = '" . cal($i) . "." . $monat . "." . $jahr . "'");
                if (_rows($qry)) {
                    while ($get = _fetch($qry)) {
                        $event = "set";
                        $titleev .= '<tr><td><img src=../inc/images/event.gif class=icon alt= /> ' . jsconvert(_kal_event . re($get['title'])) . '</td></tr>';
                    }
                } else {
                    $event = "";
                    $titleev = "";
                }
                $info = 'onmouseover="DZCP.showInfo(\'<tr><td colspan=2 align=center padding=3 class=infoTop>' . cal($i) . '.' . $monat . '.' . $jahr . '</td></tr>' . $titlebd . $titlecw . $titleev . '\')" onmouseout="DZCP.hideInfo()"';
                if ($event == "set" || $cws == "set" || $bdays == "set") {
                    $day = '<a class="navKal" href="../kalender/?m=' . $monat . '&amp;y=' . $jahr . '&amp;hl=' . $i . '" ' . $info . '>' . cal($i) . '</a>';
                } else {
                    $day = cal($i);
                }
                if (!checkdate($monat, $i, $jahr)) {
                    $data .= '<td class="navKalEmpty"></td>';
                } elseif ($datum == $today) {
                    $data .= show("menu/kal_day", array("day" => $day, "id" => "navKalToday"));
                } else {
                    $data .= show("menu/kal_day", array("day" => $day, "id" => "navKalDays"));
                }
                $i++;
            }
        }
        $show .= "<tr>" . $data . "</tr>";
    }
    if ($monat + 1 == 13) {
        $nm = 1;
        $ny = $jahr + 1;
    } else {
        $nm = $monat + 1;
        $ny = $jahr;
    }
    if ($monat - 1 == 0) {
        $lm = 12;
        $ly = $jahr - 1;
    } else {
        $lm = $monat - 1;
        $ly = $jahr;
    }
    $kalender = show("menu/kalender", array("monat" => $month, "show" => $show, "year" => $jahr, "nm" => $nm, "ny" => $ny, "lm" => $lm, "ly" => $ly, "montag" => _nav_montag, "dienstag" => _nav_dienstag, "mittwoch" => _nav_mittwoch, "donnerstag" => _nav_donnerstag, "freitag" => _nav_freitag, "samstag" => _nav_samstag, "sonntag" => _nav_sonntag));
    return '<div id="navKalender">' . $kalender . '</div>';
}
Ejemplo n.º 18
0
function events_content(&$a)
{
    if (!local_channel()) {
        notice(t('Permission denied.') . EOL);
        return;
    }
    nav_set_selected('all_events');
    if (argc() > 2 && argv(1) === 'ignore' && intval(argv(2))) {
        $r = q("update event set ignore = 1 where id = %d and uid = %d", intval(argv(2)), intval(local_channel()));
    }
    if (argc() > 2 && argv(1) === 'unignore' && intval(argv(2))) {
        $r = q("update event set ignore = 0 where id = %d and uid = %d", intval(argv(2)), intval(local_channel()));
    }
    $plaintext = true;
    //	if(feature_enabled(local_channel(),'richtext'))
    //		$plaintext = false;
    $htpl = get_markup_template('event_head.tpl');
    $a->page['htmlhead'] .= replace_macros($htpl, array('$baseurl' => $a->get_baseurl(), '$editselect' => $plaintext ? 'none' : 'textareas'));
    $o = "";
    // tabs
    $channel = $a->get_channel();
    $tabs = profile_tabs($a, True, $channel['channel_address']);
    $mode = 'view';
    $y = 0;
    $m = 0;
    $ignored = x($_REQUEST, 'ignored') ? " and ignored = " . intval($_REQUEST['ignored']) . " " : '';
    if (argc() > 1) {
        if (argc() > 2 && argv(1) == 'event') {
            $mode = 'edit';
            $event_id = argv(2);
        }
        if (argc() > 2 && argv(1) === 'add') {
            $mode = 'add';
            $item_id = intval(argv(2));
        }
        if (argc() > 2 && argv(1) === 'drop') {
            $mode = 'drop';
            $event_id = argv(2);
        }
        if (argv(1) === 'new') {
            $mode = 'new';
            $event_id = '';
        }
        if (argc() > 2 && intval(argv(1)) && intval(argv(2))) {
            $mode = 'view';
            $y = intval(argv(1));
            $m = intval(argv(2));
        }
    }
    if ($mode === 'add') {
        event_addtocal($item_id, local_channel());
        killme();
    }
    if ($mode == 'view') {
        $thisyear = datetime_convert('UTC', date_default_timezone_get(), 'now', 'Y');
        $thismonth = datetime_convert('UTC', date_default_timezone_get(), 'now', 'm');
        if (!$y) {
            $y = intval($thisyear);
        }
        if (!$m) {
            $m = intval($thismonth);
        }
        $export = false;
        if (argc() === 4 && argv(3) === 'export') {
            $export = true;
        }
        // Put some limits on dates. The PHP date functions don't seem to do so well before 1900.
        // An upper limit was chosen to keep search engines from exploring links millions of years in the future.
        if ($y < 1901) {
            $y = 1900;
        }
        if ($y > 2099) {
            $y = 2100;
        }
        $nextyear = $y;
        $nextmonth = $m + 1;
        if ($nextmonth > 12) {
            $nextmonth = 1;
            $nextyear++;
        }
        $prevyear = $y;
        if ($m > 1) {
            $prevmonth = $m - 1;
        } else {
            $prevmonth = 12;
            $prevyear--;
        }
        $dim = get_dim($y, $m);
        $start = sprintf('%d-%d-%d %d:%d:%d', $y, $m, 1, 0, 0, 0);
        $finish = sprintf('%d-%d-%d %d:%d:%d', $y, $m, $dim, 23, 59, 59);
        if (argv(1) === 'json') {
            if (x($_GET, 'start')) {
                $start = date("Y-m-d h:i:s", $_GET['start']);
            }
            if (x($_GET, 'end')) {
                $finish = date("Y-m-d h:i:s", $_GET['end']);
            }
        }
        $start = datetime_convert('UTC', 'UTC', $start);
        $finish = datetime_convert('UTC', 'UTC', $finish);
        $adjust_start = datetime_convert('UTC', date_default_timezone_get(), $start);
        $adjust_finish = datetime_convert('UTC', date_default_timezone_get(), $finish);
        if (x($_GET, 'id')) {
            $r = q("SELECT event.*, item.plink, item.item_flags, item.author_xchan, item.owner_xchan\n                                from event left join item on resource_id = event_hash where resource_type = 'event' and event.uid = %d and event.id = %d limit 1", intval(local_channel()), intval($_GET['id']));
        } else {
            // fixed an issue with "nofinish" events not showing up in the calendar.
            // There's still an issue if the finish date crosses the end of month.
            // Noting this for now - it will need to be fixed here and in Friendica.
            // Ultimately the finish date shouldn't be involved in the query.
            $r = q("SELECT event.*, item.plink, item.item_flags, item.author_xchan, item.owner_xchan\n                              from event left join item on event_hash = resource_id \n\t\t\t\twhere resource_type = 'event' and event.uid = %d {$ignored}\n\t\t\t\tAND (( `adjust` = 0 AND ( `finish` >= '%s' or nofinish = 1 ) AND `start` <= '%s' ) \n\t\t\t\tOR  (  `adjust` = 1 AND ( `finish` >= '%s' or nofinish = 1 ) AND `start` <= '%s' )) ", intval(local_channel()), dbesc($start), dbesc($finish), dbesc($adjust_start), dbesc($adjust_finish));
        }
        $links = array();
        if ($r) {
            xchan_query($r);
            $r = fetch_post_tags($r, true);
            $r = sort_by_date($r);
            foreach ($r as $rr) {
                $j = $rr['adjust'] ? datetime_convert('UTC', date_default_timezone_get(), $rr['start'], 'j') : datetime_convert('UTC', 'UTC', $rr['start'], 'j');
                if (!x($links, $j)) {
                    $links[$j] = $a->get_baseurl() . '/' . $a->cmd . '#link-' . $j;
                }
            }
        }
        $events = array();
        $last_date = '';
        $fmt = t('l, F j');
        if ($r) {
            foreach ($r as $rr) {
                $j = $rr['adjust'] ? datetime_convert('UTC', date_default_timezone_get(), $rr['start'], 'j') : datetime_convert('UTC', 'UTC', $rr['start'], 'j');
                $d = $rr['adjust'] ? datetime_convert('UTC', date_default_timezone_get(), $rr['start'], $fmt) : datetime_convert('UTC', 'UTC', $rr['start'], $fmt);
                $d = day_translate($d);
                $start = $rr['adjust'] ? datetime_convert('UTC', date_default_timezone_get(), $rr['start'], 'c') : datetime_convert('UTC', 'UTC', $rr['start'], 'c');
                if ($rr['nofinish']) {
                    $end = null;
                } else {
                    $end = $rr['adjust'] ? datetime_convert('UTC', date_default_timezone_get(), $rr['finish'], 'c') : datetime_convert('UTC', 'UTC', $rr['finish'], 'c');
                }
                $is_first = $d !== $last_date;
                $last_date = $d;
                // FIXME
                $edit = $rr['item_flags'] & ITEM_WALL ? array($a->get_baseurl() . '/events/event/' . $rr['event_hash'], t('Edit event'), '', '') : null;
                $drop = array($a->get_baseurl() . '/events/drop/' . $rr['event_hash'], t('Delete event'), '', '');
                $title = strip_tags(html_entity_decode(bbcode($rr['summary']), ENT_QUOTES, 'UTF-8'));
                if (!$title) {
                    list($title, $_trash) = explode("<br", bbcode($rr['desc']), 2);
                    $title = strip_tags(html_entity_decode($title, ENT_QUOTES, 'UTF-8'));
                }
                $html = format_event_html($rr);
                $rr['desc'] = bbcode($rr['desc']);
                $rr['location'] = bbcode($rr['location']);
                $events[] = array('id' => $rr['id'], 'hash' => $rr['event_hash'], 'start' => $start, 'end' => $end, 'drop' => $drop, 'allDay' => false, 'title' => $title, 'j' => $j, 'd' => $d, 'edit' => $edit, 'is_first' => $is_first, 'item' => $rr, 'html' => $html, 'plink' => array($rr['plink'], t('Link to Source'), '', ''));
            }
        }
        if ($export) {
            header('Content-type: text/calendar');
            header('content-disposition: attachment; filename="' . t('calendar') . '-' . $channel['channel_address'] . '.ics"');
            echo ical_wrapper($r);
            killme();
        }
        if ($a->argv[1] === 'json') {
            echo json_encode($events);
            killme();
        }
        // links: array('href', 'text', 'extra css classes', 'title')
        if (x($_GET, 'id')) {
            $tpl = get_markup_template("event.tpl");
        } else {
            $tpl = get_markup_template("events-js.tpl");
        }
        $o = replace_macros($tpl, array('$baseurl' => $a->get_baseurl(), '$tabs' => $tabs, '$title' => t('Events'), '$new_event' => array($a->get_baseurl() . '/events/new', t('Create New Event'), '', ''), '$previus' => array($a->get_baseurl() . "/events/{$prevyear}/{$prevmonth}", t('Previous'), '', ''), '$next' => array($a->get_baseurl() . "/events/{$nextyear}/{$nextmonth}", t('Next'), '', ''), '$export' => array($a->get_baseurl() . "/events/{$y}/{$m}/export", t('Export'), '', ''), '$calendar' => cal($y, $m, $links, ' eventcal'), '$events' => $events));
        if (x($_GET, 'id')) {
            echo $o;
            killme();
        }
        return $o;
    }
    if ($mode === 'drop' && $event_id) {
        $r = q("SELECT * FROM `event` WHERE event_hash = '%s' AND `uid` = %d LIMIT 1", dbesc($event_id), intval(local_channel()));
        if ($r) {
            $r = q("delete from event where event_hash = '%s' and uid = %d limit 1", dbesc($event_id), intval(local_channel()));
            if ($r) {
                $r = q("update item set resource_type = '', resource_id = '' where resource_type = 'event' and resource_id = '%s' and uid = %d", dbesc($event_id), intval(local_channel()));
                info(t('Event removed') . EOL);
            } else {
                notice(t('Failed to remove event') . EOL);
            }
            goaway(z_root() . '/events');
        }
    }
    if ($mode === 'edit' && $event_id) {
        $r = q("SELECT * FROM `event` WHERE event_hash = '%s' AND `uid` = %d LIMIT 1", dbesc($event_id), intval(local_channel()));
        if (count($r)) {
            $orig_event = $r[0];
        }
    }
    $channel = $a->get_channel();
    // Passed parameters overrides anything found in the DB
    if ($mode === 'edit' || $mode === 'new') {
        if (!x($orig_event)) {
            $orig_event = array();
        }
        // In case of an error the browser is redirected back here, with these parameters filled in with the previous values
        if (x($_REQUEST, 'nofinish')) {
            $orig_event['nofinish'] = $_REQUEST['nofinish'];
        }
        if (x($_REQUEST, 'adjust')) {
            $orig_event['adjust'] = $_REQUEST['adjust'];
        }
        if (x($_REQUEST, 'summary')) {
            $orig_event['summary'] = $_REQUEST['summary'];
        }
        if (x($_REQUEST, 'description')) {
            $orig_event['description'] = $_REQUEST['description'];
        }
        if (x($_REQUEST, 'location')) {
            $orig_event['location'] = $_REQUEST['location'];
        }
        if (x($_REQUEST, 'start')) {
            $orig_event['start'] = $_REQUEST['start'];
        }
        if (x($_REQUEST, 'finish')) {
            $orig_event['finish'] = $_REQUEST['finish'];
        }
    }
    if ($mode === 'edit' || $mode === 'new') {
        $n_checked = x($orig_event) && $orig_event['nofinish'] ? ' checked="checked" ' : '';
        $a_checked = x($orig_event) && $orig_event['adjust'] ? ' checked="checked" ' : '';
        $t_orig = x($orig_event) ? $orig_event['summary'] : '';
        $d_orig = x($orig_event) ? $orig_event['description'] : '';
        $l_orig = x($orig_event) ? $orig_event['location'] : '';
        $eid = x($orig_event) ? $orig_event['id'] : 0;
        $event_xchan = x($orig_event) ? $orig_event['event_xchan'] : $channel['channel_hash'];
        $mid = x($orig_event) ? $orig_event['mid'] : '';
        if (!x($orig_event)) {
            $sh_checked = '';
        } else {
            $sh_checked = ($orig_event['allow_cid'] === '<' . $channel['channel_hash'] . '>' || !$orig_event['allow_cid']) && !$orig_event['allow_gid'] && !$orig_event['deny_cid'] && !$orig_event['deny_gid'] ? '' : ' checked="checked" ';
        }
        if ($orig_event['event_xchan']) {
            $sh_checked .= ' disabled="disabled" ';
        }
        $sdt = x($orig_event) ? $orig_event['start'] : 'now';
        $fdt = x($orig_event) ? $orig_event['finish'] : 'now';
        $tz = date_default_timezone_get();
        if (x($orig_event)) {
            $tz = $orig_event['adjust'] ? date_default_timezone_get() : 'UTC';
        }
        $syear = datetime_convert('UTC', $tz, $sdt, 'Y');
        $smonth = datetime_convert('UTC', $tz, $sdt, 'm');
        $sday = datetime_convert('UTC', $tz, $sdt, 'd');
        $shour = x($orig_event) ? datetime_convert('UTC', $tz, $sdt, 'H') : 0;
        $sminute = x($orig_event) ? datetime_convert('UTC', $tz, $sdt, 'i') : 0;
        $stext = datetime_convert('UTC', $tz, $sdt);
        $stext = substr($stext, 0, 14) . "00:00";
        $fyear = datetime_convert('UTC', $tz, $fdt, 'Y');
        $fmonth = datetime_convert('UTC', $tz, $fdt, 'm');
        $fday = datetime_convert('UTC', $tz, $fdt, 'd');
        $fhour = x($orig_event) ? datetime_convert('UTC', $tz, $fdt, 'H') : 0;
        $fminute = x($orig_event) ? datetime_convert('UTC', $tz, $fdt, 'i') : 0;
        $ftext = datetime_convert('UTC', $tz, $fdt);
        $ftext = substr($ftext, 0, 14) . "00:00";
        $f = get_config('system', 'event_input_format');
        if (!$f) {
            $f = 'ymd';
        }
        $catsenabled = feature_enabled(local_channel(), 'categories');
        $category = '';
        if ($catsenabled && x($orig_event)) {
            $itm = q("select * from item where resource_type = 'event' and resource_id = '%s' and uid = %d limit 1", dbesc($orig_event['event_hash']), intval(local_channel()));
            $itm = fetch_post_tags($itm);
            if ($itm) {
                $cats = get_terms_oftype($itm[0]['term'], TERM_CATEGORY);
                foreach ($cats as $cat) {
                    if (strlen($category)) {
                        $category .= ', ';
                    }
                    $category .= $cat['term'];
                }
            }
        }
        require_once 'include/acl_selectors.php';
        $perm_defaults = array('allow_cid' => $channel['channel_allow_cid'], 'allow_gid' => $channel['channel_allow_gid'], 'deny_cid' => $channel['channel_deny_cid'], 'deny_gid' => $channel['channel_deny_gid']);
        $tpl = get_markup_template('event_form.tpl');
        $o .= replace_macros($tpl, array('$post' => $a->get_baseurl() . '/events', '$eid' => $eid, '$xchan' => $event_xchan, '$mid' => $mid, '$event_hash' => $event_id, '$title' => t('Event details'), '$desc' => t('Starting date and Title are required.'), '$catsenabled' => $catsenabled, '$placeholdercategory' => t('Categories (comma-separated list)'), '$category' => $category, '$s_text' => t('Event Starts:'), '$stext' => $stext, '$ftext' => $ftext, '$required' => ' <span class="required" title="' . t('Required') . '">*</span>', '$ModalCANCEL' => t('Cancel'), '$ModalOK' => t('OK'), '$s_dsel' => datetimesel($f, new DateTime(), DateTime::createFromFormat('Y', $syear + 5), DateTime::createFromFormat('Y-m-d H:i', "{$syear}-{$smonth}-{$sday} {$shour}:{$sminute}"), 'start_text', true, true, '', '', true), '$n_text' => t('Finish date/time is not known or not relevant'), '$n_checked' => $n_checked, '$f_text' => t('Event Finishes:'), '$f_dsel' => datetimesel($f, new DateTime(), DateTime::createFromFormat('Y', $fyear + 5), DateTime::createFromFormat('Y-m-d H:i', "{$fyear}-{$fmonth}-{$fday} {$fhour}:{$fminute}"), 'finish_text', true, true, 'start_text'), '$adjust' => array('adjust', t('Adjust for viewer timezone'), $a_checked, t('Important for events that happen in a particular place. Not practical for global holidays.')), '$a_text' => t('Adjust for viewer timezone'), '$d_text' => t('Description:'), '$d_orig' => $d_orig, '$l_text' => t('Location:'), '$l_orig' => $l_orig, '$t_text' => t('Title:'), '$t_orig' => $t_orig, '$sh_text' => t('Share this event'), '$sh_checked' => $sh_checked, '$preview' => t('Preview'), '$permissions' => t('Permissions'), '$acl' => $orig_event['event_xchan'] ? '' : populate_acl(x($orig_event) ? $orig_event : $perm_defaults, false), '$submit' => t('Submit')));
        return $o;
    }
}
Ejemplo n.º 19
0
function get_hour($time_in, $time_out)
{
    $data = round((strtotime($time_out) - strtotime($time_in)) / 3600, 1);
    $sum_hour = ceil($data);
    return $sum_hour;
}
$time_in = $car_log['time_in'];
$time_out = $car_log['time_out'];
$hour = get_hour($time_in, $time_out);
//echo 'rate :'.get_rate($time_in, $time_out);//(วันเวลาเข้า, ชั่วโมงทั้งหมด)
//echo '<br/>';
//print_r(cal(1500, get_rate($time_in, $time_out)));
$rate = get_rate($time_in, $time_out);
//(วันเวลาเข้า, ชั่วโมงทั้งหมด)
//echo '<br/>';
$change = cal(1500, get_rate($time_in, $time_out));
?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">

    <title aligne="left">Parkko</title>

    <!-- Bootstrap Core CSS -->
    <link href="css/bootstrap.min.css" rel="stylesheet">
Ejemplo n.º 20
0
                         $bild = '<img src=../' . $pfadbild . '.png class=icon  alt= />';
                     } else {
                         $bild = "<img src=../inc/images/event.gif class=icon alt= />";
                     }
                     $infoEvent .= $bild . jsconvert(re($get['katname']) . ': ' . re($get['name'])) . '<br>';
                 }
                 $info = ' onmouseover="DZCP.showInfo(\'<tr><td>' . $infoEvent . '</td></tr>\')" onmouseout="DZCP.hideInfo()"';
                 $event = '<a href="../event/?action=list&time=' . $datum . '"' . $info . '><img src="../inc/images/event.gif" alt="" /></a>';
             } else {
                 $event = "";
             }
             $events = $bdays . " " . $cws . " " . $event;
             if (isset($_GET['hl']) && $_GET['hl'] == $i) {
                 $day = '<span class="fontMarked">' . cal($i) . '</span>';
             } else {
                 $day = cal($i);
             }
             if (!checkdate($monat, $i, $jahr)) {
                 $data .= '<td class="calDay"></td>';
             } elseif ($datum == $ktoday) {
                 $data .= show($dir . "/day", array("day" => $day, "event" => $events, "class" => "calToday"));
             } else {
                 $data .= show($dir . "/day", array("day" => $day, "event" => $events, "class" => "calDay"));
             }
             $i++;
         }
     }
     $show .= "<tr>" . $data . "</tr>";
 }
 $index = show($dir . "/kalender", array("monate" => $month, "jahr" => $year, "show" => $show, "what" => _button_value_show, "montag" => _montag, "dienstag" => _dienstag, "mittwoch" => _mittwoch, "donnerstag" => _donnerstag, "freitag" => _freitag, "samstag" => _samstag, "sonntag" => _sonntag, "head" => _kalender_head));
 break;
Ejemplo n.º 21
0
<?php

//接收数据
//$_REQUEST[''] 接收请求数据
require 'func1.php';
$num1 = $_REQUEST['num1'];
$num2 = $_REQUEST['num2'];
$oper = $_REQUEST['opType'];
$calresult = 0;
//echo $num1+';'+ $num2 +';' +$oper;
$calresult = cal($num1, $num2, $oper);
echo "函数计算" . $calresult;
?>

     <br>
	 <a href="mycal.php"> 返回上一页 </a>
Ejemplo n.º 22
0
 function get()
 {
     if (observer_prohibited()) {
         return;
     }
     $channel = null;
     if (argc() > 1) {
         $channel = channelx_by_nick(argv(1));
     }
     if (!$channel) {
         notice(t('Channel not found.') . EOL);
         return;
     }
     // since we don't currently have an event permission - use the stream permission
     if (!perm_is_allowed($channel['channel_id'], get_observer_hash(), 'view_stream')) {
         notice(t('Permissions denied.') . EOL);
         return;
     }
     $sql_extra = permissions_sql($channel['channel_id'], get_observer_hash(), 'event');
     $first_day = get_pconfig(local_channel(), 'system', 'cal_first_day');
     $first_day = $first_day ? $first_day : 0;
     $htpl = get_markup_template('event_head.tpl');
     \App::$page['htmlhead'] .= replace_macros($htpl, array('$baseurl' => z_root(), '$module_url' => '/cal/' . $channel['channel_address'], '$modparams' => 2, '$lang' => \App::$language, '$first_day' => $first_day));
     $o = '';
     $tabs = profile_tabs($a, True, $channel['channel_address']);
     $mode = 'view';
     $y = 0;
     $m = 0;
     $ignored = x($_REQUEST, 'ignored') ? " and dismissed = " . intval($_REQUEST['ignored']) . " " : '';
     // logger('args: ' . print_r(\App::$argv,true));
     if (argc() > 3 && intval(argv(2)) && intval(argv(3))) {
         $mode = 'view';
         $y = intval(argv(2));
         $m = intval(argv(3));
     }
     if (argc() <= 3) {
         $mode = 'view';
         $event_id = argv(2);
     }
     if ($mode == 'view') {
         /* edit/create form */
         if ($event_id) {
             $r = q("SELECT * FROM `event` WHERE event_hash = '%s' AND `uid` = %d LIMIT 1", dbesc($event_id), intval($channel['channel_id']));
             if (count($r)) {
                 $orig_event = $r[0];
             }
         }
         // Passed parameters overrides anything found in the DB
         if (!x($orig_event)) {
             $orig_event = array();
         }
         $tz = date_default_timezone_get();
         if (x($orig_event)) {
             $tz = $orig_event['adjust'] ? date_default_timezone_get() : 'UTC';
         }
         $syear = datetime_convert('UTC', $tz, $sdt, 'Y');
         $smonth = datetime_convert('UTC', $tz, $sdt, 'm');
         $sday = datetime_convert('UTC', $tz, $sdt, 'd');
         $shour = datetime_convert('UTC', $tz, $sdt, 'H');
         $sminute = datetime_convert('UTC', $tz, $sdt, 'i');
         $stext = datetime_convert('UTC', $tz, $sdt);
         $stext = substr($stext, 0, 14) . "00:00";
         $fyear = datetime_convert('UTC', $tz, $fdt, 'Y');
         $fmonth = datetime_convert('UTC', $tz, $fdt, 'm');
         $fday = datetime_convert('UTC', $tz, $fdt, 'd');
         $fhour = datetime_convert('UTC', $tz, $fdt, 'H');
         $fminute = datetime_convert('UTC', $tz, $fdt, 'i');
         $ftext = datetime_convert('UTC', $tz, $fdt);
         $ftext = substr($ftext, 0, 14) . "00:00";
         $type = x($orig_event) ? $orig_event['etype'] : 'event';
         $f = get_config('system', 'event_input_format');
         if (!$f) {
             $f = 'ymd';
         }
         $catsenabled = feature_enabled($channel['channel_id'], 'categories');
         $show_bd = perm_is_allowed($channel['channel_id'], get_observer_hash(), 'view_contacts');
         if (!$show_bd) {
             $sql_extra .= " and event.etype != 'birthday' ";
         }
         $category = '';
         $thisyear = datetime_convert('UTC', date_default_timezone_get(), 'now', 'Y');
         $thismonth = datetime_convert('UTC', date_default_timezone_get(), 'now', 'm');
         if (!$y) {
             $y = intval($thisyear);
         }
         if (!$m) {
             $m = intval($thismonth);
         }
         // Put some limits on dates. The PHP date functions don't seem to do so well before 1900.
         // An upper limit was chosen to keep search engines from exploring links millions of years in the future.
         if ($y < 1901) {
             $y = 1900;
         }
         if ($y > 2099) {
             $y = 2100;
         }
         $nextyear = $y;
         $nextmonth = $m + 1;
         if ($nextmonth > 12) {
             $nextmonth = 1;
             $nextyear++;
         }
         $prevyear = $y;
         if ($m > 1) {
             $prevmonth = $m - 1;
         } else {
             $prevmonth = 12;
             $prevyear--;
         }
         $dim = get_dim($y, $m);
         $start = sprintf('%d-%d-%d %d:%d:%d', $y, $m, 1, 0, 0, 0);
         $finish = sprintf('%d-%d-%d %d:%d:%d', $y, $m, $dim, 23, 59, 59);
         if (argv(2) === 'json') {
             if (x($_GET, 'start')) {
                 $start = $_GET['start'];
             }
             if (x($_GET, 'end')) {
                 $finish = $_GET['end'];
             }
         }
         $start = datetime_convert('UTC', 'UTC', $start);
         $finish = datetime_convert('UTC', 'UTC', $finish);
         $adjust_start = datetime_convert('UTC', date_default_timezone_get(), $start);
         $adjust_finish = datetime_convert('UTC', date_default_timezone_get(), $finish);
         if (x($_GET, 'id')) {
             $r = q("SELECT event.*, item.plink, item.item_flags, item.author_xchan, item.owner_xchan\n\t                                from event left join item on resource_id = event_hash where resource_type = 'event' and event.uid = %d and event.id = %d {$sql_extra} limit 1", intval($channel['channel_id']), intval($_GET['id']));
         } else {
             // fixed an issue with "nofinish" events not showing up in the calendar.
             // There's still an issue if the finish date crosses the end of month.
             // Noting this for now - it will need to be fixed here and in Friendica.
             // Ultimately the finish date shouldn't be involved in the query.
             $r = q("SELECT event.*, item.plink, item.item_flags, item.author_xchan, item.owner_xchan\n\t                              from event left join item on event_hash = resource_id \n\t\t\t\t\twhere resource_type = 'event' and event.uid = %d {$ignored} \n\t\t\t\t\tAND (( adjust = 0 AND ( dtend >= '%s' or nofinish = 1 ) AND dtstart <= '%s' ) \n\t\t\t\t\tOR  (  adjust = 1 AND ( dtend >= '%s' or nofinish = 1 ) AND dtstart <= '%s' )) {$sql_extra} ", intval($channel['channel_id']), dbesc($start), dbesc($finish), dbesc($adjust_start), dbesc($adjust_finish));
         }
         $links = array();
         if ($r) {
             xchan_query($r);
             $r = fetch_post_tags($r, true);
             $r = sort_by_date($r);
         }
         if ($r) {
             foreach ($r as $rr) {
                 $j = $rr['adjust'] ? datetime_convert('UTC', date_default_timezone_get(), $rr['dtstart'], 'j') : datetime_convert('UTC', 'UTC', $rr['dtstart'], 'j');
                 if (!x($links, $j)) {
                     $links[$j] = z_root() . '/' . \App::$cmd . '#link-' . $j;
                 }
             }
         }
         $events = array();
         $last_date = '';
         $fmt = t('l, F j');
         if ($r) {
             foreach ($r as $rr) {
                 $j = $rr['adjust'] ? datetime_convert('UTC', date_default_timezone_get(), $rr['dtstart'], 'j') : datetime_convert('UTC', 'UTC', $rr['dtstart'], 'j');
                 $d = $rr['adjust'] ? datetime_convert('UTC', date_default_timezone_get(), $rr['dtstart'], $fmt) : datetime_convert('UTC', 'UTC', $rr['dtstart'], $fmt);
                 $d = day_translate($d);
                 $start = $rr['adjust'] ? datetime_convert('UTC', date_default_timezone_get(), $rr['dtstart'], 'c') : datetime_convert('UTC', 'UTC', $rr['dtstart'], 'c');
                 if ($rr['nofinish']) {
                     $end = null;
                 } else {
                     $end = $rr['adjust'] ? datetime_convert('UTC', date_default_timezone_get(), $rr['dtend'], 'c') : datetime_convert('UTC', 'UTC', $rr['dtend'], 'c');
                 }
                 $is_first = $d !== $last_date;
                 $last_date = $d;
                 $edit = false;
                 $drop = false;
                 $title = strip_tags(html_entity_decode(bbcode($rr['summary']), ENT_QUOTES, 'UTF-8'));
                 if (!$title) {
                     list($title, $_trash) = explode("<br", bbcode($rr['desc']), 2);
                     $title = strip_tags(html_entity_decode($title, ENT_QUOTES, 'UTF-8'));
                 }
                 $html = format_event_html($rr);
                 $rr['desc'] = bbcode($rr['desc']);
                 $rr['location'] = bbcode($rr['location']);
                 $events[] = array('id' => $rr['id'], 'hash' => $rr['event_hash'], 'start' => $start, 'end' => $end, 'drop' => $drop, 'allDay' => false, 'title' => $title, 'j' => $j, 'd' => $d, 'edit' => $edit, 'is_first' => $is_first, 'item' => $rr, 'html' => $html, 'plink' => array($rr['plink'], t('Link to Source'), '', ''));
             }
         }
         if (argv(2) === 'json') {
             echo json_encode($events);
             killme();
         }
         // links: array('href', 'text', 'extra css classes', 'title')
         if (x($_GET, 'id')) {
             $tpl = get_markup_template("event_cal.tpl");
         } else {
             $tpl = get_markup_template("events_cal-js.tpl");
         }
         $nick = $channel['channel_address'];
         $o = replace_macros($tpl, array('$baseurl' => z_root(), '$new_event' => array(z_root() . '/cal', $event_id ? t('Edit Event') : t('Create Event'), '', ''), '$previus' => array(z_root() . "/cal/{$nick}/{$prevyear}/{$prevmonth}", t('Previous'), '', ''), '$next' => array(z_root() . "/cal/{$nick}/{$nextyear}/{$nextmonth}", t('Next'), '', ''), '$export' => array(z_root() . "/cal/{$nick}/{$y}/{$m}/export", t('Export'), '', ''), '$calendar' => cal($y, $m, $links, ' eventcal'), '$events' => $events, '$upload' => t('Import'), '$submit' => t('Submit'), '$prev' => t('Previous'), '$next' => t('Next'), '$today' => t('Today'), '$form' => $form, '$expandform' => x($_GET, 'expandform') ? true : false, '$tabs' => $tabs));
         if (x($_GET, 'id')) {
             echo $o;
             killme();
         }
         return $o;
     }
 }
Ejemplo n.º 23
0
 function get()
 {
     if (argc() > 2 && argv(1) == 'ical') {
         $event_id = argv(2);
         require_once 'include/security.php';
         $sql_extra = permissions_sql(local_channel());
         $r = q("select * from event where event_hash = '%s' {$sql_extra} limit 1", dbesc($event_id));
         if ($r) {
             header('Content-type: text/calendar');
             header('content-disposition: attachment; filename="' . t('event') . '-' . $event_id . '.ics"');
             echo ical_wrapper($r);
             killme();
         } else {
             notice(t('Event not found.') . EOL);
             return;
         }
     }
     if (!local_channel()) {
         notice(t('Permission denied.') . EOL);
         return;
     }
     nav_set_selected('all_events');
     if (argc() > 2 && argv(1) === 'ignore' && intval(argv(2))) {
         $r = q("update event set dismissed = 1 where id = %d and uid = %d", intval(argv(2)), intval(local_channel()));
     }
     if (argc() > 2 && argv(1) === 'unignore' && intval(argv(2))) {
         $r = q("update event set dismissed = 0 where id = %d and uid = %d", intval(argv(2)), intval(local_channel()));
     }
     $first_day = get_pconfig(local_channel(), 'system', 'cal_first_day');
     $first_day = $first_day ? $first_day : 0;
     $htpl = get_markup_template('event_head.tpl');
     \App::$page['htmlhead'] .= replace_macros($htpl, array('$baseurl' => z_root(), '$module_url' => '/events', '$modparams' => 1, '$lang' => \App::$language, '$first_day' => $first_day));
     $o = '';
     $channel = \App::get_channel();
     $mode = 'view';
     $y = 0;
     $m = 0;
     $ignored = x($_REQUEST, 'ignored') ? " and dismissed = " . intval($_REQUEST['ignored']) . " " : '';
     // logger('args: ' . print_r(\App::$argv,true));
     if (argc() > 1) {
         if (argc() > 2 && argv(1) === 'add') {
             $mode = 'add';
             $item_id = intval(argv(2));
         }
         if (argc() > 2 && argv(1) === 'drop') {
             $mode = 'drop';
             $event_id = argv(2);
         }
         if (argc() > 2 && intval(argv(1)) && intval(argv(2))) {
             $mode = 'view';
             $y = intval(argv(1));
             $m = intval(argv(2));
         }
         if (argc() <= 2) {
             $mode = 'view';
             $event_id = argv(1);
         }
     }
     if ($mode === 'add') {
         event_addtocal($item_id, local_channel());
         killme();
     }
     if ($mode == 'view') {
         /* edit/create form */
         if ($event_id) {
             $r = q("SELECT * FROM `event` WHERE event_hash = '%s' AND `uid` = %d LIMIT 1", dbesc($event_id), intval(local_channel()));
             if (count($r)) {
                 $orig_event = $r[0];
             }
         }
         $channel = \App::get_channel();
         // Passed parameters overrides anything found in the DB
         if (!x($orig_event)) {
             $orig_event = array();
         }
         // In case of an error the browser is redirected back here, with these parameters filled in with the previous values
         /*
         if(x($_REQUEST,'nofinish')) $orig_event['nofinish'] = $_REQUEST['nofinish'];
         if(x($_REQUEST,'adjust')) $orig_event['adjust'] = $_REQUEST['adjust'];
         if(x($_REQUEST,'summary')) $orig_event['summary'] = $_REQUEST['summary'];
         if(x($_REQUEST,'description')) $orig_event['description'] = $_REQUEST['description'];
         if(x($_REQUEST,'location')) $orig_event['location'] = $_REQUEST['location'];
         if(x($_REQUEST,'start')) $orig_event['dtstart'] = $_REQUEST['start'];
         if(x($_REQUEST,'finish')) $orig_event['dtend'] = $_REQUEST['finish'];
         if(x($_REQUEST,'type')) $orig_event['etype'] = $_REQUEST['type'];
         */
         $n_checked = x($orig_event) && $orig_event['nofinish'] ? ' checked="checked" ' : '';
         $a_checked = x($orig_event) && $orig_event['adjust'] ? ' checked="checked" ' : '';
         $t_orig = x($orig_event) ? $orig_event['summary'] : '';
         $d_orig = x($orig_event) ? $orig_event['description'] : '';
         $l_orig = x($orig_event) ? $orig_event['location'] : '';
         $eid = x($orig_event) ? $orig_event['id'] : 0;
         $event_xchan = x($orig_event) ? $orig_event['event_xchan'] : $channel['channel_hash'];
         $mid = x($orig_event) ? $orig_event['mid'] : '';
         if (!x($orig_event)) {
             $sh_checked = '';
         } else {
             $sh_checked = ($orig_event['allow_cid'] === '<' . $channel['channel_hash'] . '>' || !$orig_event['allow_cid']) && !$orig_event['allow_gid'] && !$orig_event['deny_cid'] && !$orig_event['deny_gid'] ? '' : ' checked="checked" ';
         }
         if ($orig_event['event_xchan']) {
             $sh_checked .= ' disabled="disabled" ';
         }
         $sdt = x($orig_event) ? $orig_event['dtstart'] : 'now';
         $fdt = x($orig_event) ? $orig_event['dtend'] : '+1 hour';
         $tz = date_default_timezone_get();
         if (x($orig_event)) {
             $tz = $orig_event['adjust'] ? date_default_timezone_get() : 'UTC';
         }
         $syear = datetime_convert('UTC', $tz, $sdt, 'Y');
         $smonth = datetime_convert('UTC', $tz, $sdt, 'm');
         $sday = datetime_convert('UTC', $tz, $sdt, 'd');
         $shour = datetime_convert('UTC', $tz, $sdt, 'H');
         $sminute = datetime_convert('UTC', $tz, $sdt, 'i');
         $stext = datetime_convert('UTC', $tz, $sdt);
         $stext = substr($stext, 0, 14) . "00:00";
         $fyear = datetime_convert('UTC', $tz, $fdt, 'Y');
         $fmonth = datetime_convert('UTC', $tz, $fdt, 'm');
         $fday = datetime_convert('UTC', $tz, $fdt, 'd');
         $fhour = datetime_convert('UTC', $tz, $fdt, 'H');
         $fminute = datetime_convert('UTC', $tz, $fdt, 'i');
         $ftext = datetime_convert('UTC', $tz, $fdt);
         $ftext = substr($ftext, 0, 14) . "00:00";
         $type = x($orig_event) ? $orig_event['etype'] : 'event';
         $f = get_config('system', 'event_input_format');
         if (!$f) {
             $f = 'ymd';
         }
         $catsenabled = feature_enabled(local_channel(), 'categories');
         $category = '';
         if ($catsenabled && x($orig_event)) {
             $itm = q("select * from item where resource_type = 'event' and resource_id = '%s' and uid = %d limit 1", dbesc($orig_event['event_hash']), intval(local_channel()));
             $itm = fetch_post_tags($itm);
             if ($itm) {
                 $cats = get_terms_oftype($itm[0]['term'], TERM_CATEGORY);
                 foreach ($cats as $cat) {
                     if (strlen($category)) {
                         $category .= ', ';
                     }
                     $category .= $cat['term'];
                 }
             }
         }
         require_once 'include/acl_selectors.php';
         $acl = new \Zotlabs\Access\AccessList($channel);
         $perm_defaults = $acl->get();
         $permissions = x($orig_event) ? $orig_event : $perm_defaults;
         //print_r(acl2json($permissions['allow_gid'])); killme();
         $tpl = get_markup_template('event_form.tpl');
         $form = replace_macros($tpl, array('$post' => z_root() . '/events', '$eid' => $eid, '$type' => $type, '$xchan' => $event_xchan, '$mid' => $mid, '$event_hash' => $event_id, '$summary' => array('summary', $event_id ? t('Edit event title') : t('Event title'), $t_orig, t('Required'), '*'), '$catsenabled' => $catsenabled, '$placeholdercategory' => t('Categories (comma-separated list)'), '$c_text' => $event_id ? t('Edit Category') : t('Category'), '$category' => $category, '$required' => '<span class="required" title="' . t('Required') . '">*</span>', '$s_dsel' => datetimesel($f, new \DateTime(), \DateTime::createFromFormat('Y', $syear + 5), \DateTime::createFromFormat('Y-m-d H:i', "{$syear}-{$smonth}-{$sday} {$shour}:{$sminute}"), $event_id ? t('Edit start date and time') : t('Start date and time'), 'start_text', true, true, '', '', true, $first_day), '$n_text' => t('Finish date and time are not known or not relevant'), '$n_checked' => $n_checked, '$f_dsel' => datetimesel($f, new \DateTime(), \DateTime::createFromFormat('Y', $fyear + 5), \DateTime::createFromFormat('Y-m-d H:i', "{$fyear}-{$fmonth}-{$fday} {$fhour}:{$fminute}"), $event_id ? t('Edit finish date and time') : t('Finish date and time'), 'finish_text', true, true, 'start_text', '', false, $first_day), '$nofinish' => array('nofinish', t('Finish date and time are not known or not relevant'), $n_checked, '', array(t('No'), t('Yes')), 'onclick="enableDisableFinishDate();"'), '$adjust' => array('adjust', t('Adjust for viewer timezone'), $a_checked, t('Important for events that happen in a particular place. Not practical for global holidays.'), array(t('No'), t('Yes'))), '$a_text' => t('Adjust for viewer timezone'), '$d_text' => $event_id ? t('Edit Description') : t('Description'), '$d_orig' => $d_orig, '$l_text' => $event_id ? t('Edit Location') : t('Location'), '$l_orig' => $l_orig, '$t_orig' => $t_orig, '$sh_text' => t('Share this event'), '$sh_checked' => $sh_checked, '$share' => array('distr', t('Share this event'), $sh_checked, '', array(t('No'), t('Yes'))), '$preview' => t('Preview'), '$perms_label' => t('Permission settings'), '$acl' => $orig_event['event_xchan'] ? '' : populate_acl(x($orig_event) ? $orig_event : $perm_defaults, false, \Zotlabs\Lib\PermissionDescription::fromGlobalPermission('view_stream')), '$allow_cid' => acl2json($permissions['allow_cid']), '$allow_gid' => acl2json($permissions['allow_gid']), '$deny_cid' => acl2json($permissions['deny_cid']), '$deny_gid' => acl2json($permissions['deny_gid']), '$submit' => t('Submit'), '$advanced' => t('Advanced Options')));
         /* end edit/create form */
         $thisyear = datetime_convert('UTC', date_default_timezone_get(), 'now', 'Y');
         $thismonth = datetime_convert('UTC', date_default_timezone_get(), 'now', 'm');
         if (!$y) {
             $y = intval($thisyear);
         }
         if (!$m) {
             $m = intval($thismonth);
         }
         $export = false;
         if (argc() === 4 && argv(3) === 'export') {
             $export = true;
         }
         // Put some limits on dates. The PHP date functions don't seem to do so well before 1900.
         // An upper limit was chosen to keep search engines from exploring links millions of years in the future.
         if ($y < 1901) {
             $y = 1900;
         }
         if ($y > 2099) {
             $y = 2100;
         }
         $nextyear = $y;
         $nextmonth = $m + 1;
         if ($nextmonth > 12) {
             $nextmonth = 1;
             $nextyear++;
         }
         $prevyear = $y;
         if ($m > 1) {
             $prevmonth = $m - 1;
         } else {
             $prevmonth = 12;
             $prevyear--;
         }
         $dim = get_dim($y, $m);
         $start = sprintf('%d-%d-%d %d:%d:%d', $y, $m, 1, 0, 0, 0);
         $finish = sprintf('%d-%d-%d %d:%d:%d', $y, $m, $dim, 23, 59, 59);
         if (argv(1) === 'json') {
             if (x($_GET, 'start')) {
                 $start = $_GET['start'];
             }
             if (x($_GET, 'end')) {
                 $finish = $_GET['end'];
             }
         }
         $start = datetime_convert('UTC', 'UTC', $start);
         $finish = datetime_convert('UTC', 'UTC', $finish);
         $adjust_start = datetime_convert('UTC', date_default_timezone_get(), $start);
         $adjust_finish = datetime_convert('UTC', date_default_timezone_get(), $finish);
         if (x($_GET, 'id')) {
             $r = q("SELECT event.*, item.plink, item.item_flags, item.author_xchan, item.owner_xchan\n\t                                from event left join item on resource_id = event_hash where resource_type = 'event' and event.uid = %d and event.id = %d limit 1", intval(local_channel()), intval($_GET['id']));
         } elseif ($export) {
             $r = q("SELECT * from event where uid = %d\n\t\t\t\t\tAND (( `adjust` = 0 AND ( `dtend` >= '%s' or nofinish = 1 ) AND `dtstart` <= '%s' ) \n\t\t\t\t\tOR  (  `adjust` = 1 AND ( `dtend` >= '%s' or nofinish = 1 ) AND `dtstart` <= '%s' )) ", intval(local_channel()), dbesc($start), dbesc($finish), dbesc($adjust_start), dbesc($adjust_finish));
         } else {
             // fixed an issue with "nofinish" events not showing up in the calendar.
             // There's still an issue if the finish date crosses the end of month.
             // Noting this for now - it will need to be fixed here and in Friendica.
             // Ultimately the finish date shouldn't be involved in the query.
             $r = q("SELECT event.*, item.plink, item.item_flags, item.author_xchan, item.owner_xchan\n\t                              from event left join item on event_hash = resource_id \n\t\t\t\t\twhere resource_type = 'event' and event.uid = %d {$ignored} \n\t\t\t\t\tAND (( adjust = 0 AND ( dtend >= '%s' or nofinish = 1 ) AND dtstart <= '%s' ) \n\t\t\t\t\tOR  (  adjust = 1 AND ( dtend >= '%s' or nofinish = 1 ) AND dtstart <= '%s' )) ", intval(local_channel()), dbesc($start), dbesc($finish), dbesc($adjust_start), dbesc($adjust_finish));
         }
         $links = array();
         if ($r && !$export) {
             xchan_query($r);
             $r = fetch_post_tags($r, true);
             $r = sort_by_date($r);
         }
         if ($r) {
             foreach ($r as $rr) {
                 $j = $rr['adjust'] ? datetime_convert('UTC', date_default_timezone_get(), $rr['dtstart'], 'j') : datetime_convert('UTC', 'UTC', $rr['dtstart'], 'j');
                 if (!x($links, $j)) {
                     $links[$j] = z_root() . '/' . \App::$cmd . '#link-' . $j;
                 }
             }
         }
         $events = array();
         $last_date = '';
         $fmt = t('l, F j');
         if ($r) {
             foreach ($r as $rr) {
                 $j = $rr['adjust'] ? datetime_convert('UTC', date_default_timezone_get(), $rr['dtstart'], 'j') : datetime_convert('UTC', 'UTC', $rr['dtstart'], 'j');
                 $d = $rr['adjust'] ? datetime_convert('UTC', date_default_timezone_get(), $rr['dtstart'], $fmt) : datetime_convert('UTC', 'UTC', $rr['dtstart'], $fmt);
                 $d = day_translate($d);
                 $start = $rr['adjust'] ? datetime_convert('UTC', date_default_timezone_get(), $rr['dtstart'], 'c') : datetime_convert('UTC', 'UTC', $rr['dtstart'], 'c');
                 if ($rr['nofinish']) {
                     $end = null;
                 } else {
                     $end = $rr['adjust'] ? datetime_convert('UTC', date_default_timezone_get(), $rr['dtend'], 'c') : datetime_convert('UTC', 'UTC', $rr['dtend'], 'c');
                 }
                 $is_first = $d !== $last_date;
                 $last_date = $d;
                 $edit = local_channel() && $rr['author_xchan'] == get_observer_hash() ? array(z_root() . '/events/' . $rr['event_hash'] . '?expandform=1', t('Edit event'), '', '') : false;
                 $drop = array(z_root() . '/events/drop/' . $rr['event_hash'], t('Delete event'), '', '');
                 $title = strip_tags(html_entity_decode(bbcode($rr['summary']), ENT_QUOTES, 'UTF-8'));
                 if (!$title) {
                     list($title, $_trash) = explode("<br", bbcode($rr['desc']), 2);
                     $title = strip_tags(html_entity_decode($title, ENT_QUOTES, 'UTF-8'));
                 }
                 $html = format_event_html($rr);
                 $rr['desc'] = bbcode($rr['desc']);
                 $rr['location'] = bbcode($rr['location']);
                 $events[] = array('id' => $rr['id'], 'hash' => $rr['event_hash'], 'start' => $start, 'end' => $end, 'drop' => $drop, 'allDay' => false, 'title' => $title, 'j' => $j, 'd' => $d, 'edit' => $edit, 'is_first' => $is_first, 'item' => $rr, 'html' => $html, 'plink' => array($rr['plink'], t('Link to Source'), '', ''));
             }
         }
         if ($export) {
             header('Content-type: text/calendar');
             header('content-disposition: attachment; filename="' . t('calendar') . '-' . $channel['channel_address'] . '.ics"');
             echo ical_wrapper($r);
             killme();
         }
         if (\App::$argv[1] === 'json') {
             echo json_encode($events);
             killme();
         }
         // links: array('href', 'text', 'extra css classes', 'title')
         if (x($_GET, 'id')) {
             $tpl = get_markup_template("event.tpl");
         } else {
             $tpl = get_markup_template("events-js.tpl");
         }
         $o = replace_macros($tpl, array('$baseurl' => z_root(), '$new_event' => array(z_root() . '/events', $event_id ? t('Edit Event') : t('Create Event'), '', ''), '$previus' => array(z_root() . "/events/{$prevyear}/{$prevmonth}", t('Previous'), '', ''), '$next' => array(z_root() . "/events/{$nextyear}/{$nextmonth}", t('Next'), '', ''), '$export' => array(z_root() . "/events/{$y}/{$m}/export", t('Export'), '', ''), '$calendar' => cal($y, $m, $links, ' eventcal'), '$events' => $events, '$view_label' => t('View'), '$month' => t('Month'), '$week' => t('Week'), '$day' => t('Day'), '$prev' => t('Previous'), '$next' => t('Next'), '$today' => t('Today'), '$form' => $form, '$expandform' => x($_GET, 'expandform') ? true : false));
         if (x($_GET, 'id')) {
             echo $o;
             killme();
         }
         return $o;
     }
     if ($mode === 'drop' && $event_id) {
         $r = q("SELECT * FROM `event` WHERE event_hash = '%s' AND `uid` = %d LIMIT 1", dbesc($event_id), intval(local_channel()));
         $sync_event = $r[0];
         if ($r) {
             $r = q("delete from event where event_hash = '%s' and uid = %d limit 1", dbesc($event_id), intval(local_channel()));
             if ($r) {
                 $r = q("update item set resource_type = '', resource_id = '' where resource_type = 'event' and resource_id = '%s' and uid = %d", dbesc($event_id), intval(local_channel()));
                 $sync_event['event_deleted'] = 1;
                 build_sync_packet(0, array('event' => array($sync_event)));
                 info(t('Event removed') . EOL);
             } else {
                 notice(t('Failed to remove event') . EOL);
             }
             goaway(z_root() . '/events');
         }
     }
 }