/** Display widget instance
  * 
  * using extract(), it seems, to me, not be a good idea, 
  * but also seems very conventional.
  * echo() from this method is rendered on the page.
  *
  * @param array $args displaying arguments name, id, [before|after]_[widget|title], widget_[id, name]
  * @param array $inst setting of each instance
  */
 function widget($args, $inst)
 {
     //error_log('MeetupEverywhere::widget');
     /*
     $is_tag_exists = function_exists('is_tag');
     $mega_tags     = array();
     if (is_single()) {
       $the_tags = get_the_tags(get_the_ID());
       foreach ($the_tags as $tag) {
         array_push($mega_tags, $tag->term_id);
       }
     }
     
     extract($args);
     $tags       = get_tags(array('orderby' => '', 'hide_empty' => false));
     $tag_length = count($tags);
     $i          = 1;
     //error_log(print_r($tags, true));
     if (strlen($inst['title'])) {
       echo $before_title . $inst['title'] . $after_title;
     }
     */
     echo $before_widget;
     if (self::$is_showable) {
         $events = get_events(self::$settings['api_key'], self::$settings['container_id']);
         include 'html/widget.php';
     } else {
         echo "NOT configured";
     }
     echo $after_widget;
 }
Exemple #2
0
    function get_content() {
        global $CFG;
        if ($this->content !== NULL) {
            return $this->content;
        }
		if(!isloggedin()){
			return $this->content;
		}
		//if(is_siteadmin()){
		//	return $this->content;
		//}
		//if(has_capability('local_collegestructure:manage', context_system::instance())){
		//	return $this->content;
		//}

      
        // Prep the content
        $this->content = new stdClass();
		require_once('events.php');
		$events = get_events();
        $this->content->text = $events;
        return $this->content;
        // Prepare the footer for this block
        // No footer to display
        $this->content->footer = '';
		// Return the content object
        return $this->content;
    }
Exemple #3
0
function submit_date()
{
    $newdate1 = $_POST['sendDate1'];
    $newdate2 = $_POST['sendDate2'];
    $args = array('post_type' => 'epsa_events', 'posts_per_page' => 5, 'order' => 'ASC', 'meta_query' => array(array('key' => 'start_time', 'value' => array($newdate1, $newdate2), 'compare' => 'BETWEEN')));
    get_events($args);
    wp_die();
}
Exemple #4
0
function admin_calendar()
{
    global $db, $countries;
    $tpl = new smarty();
    $tpl->assign('events', get_events());
    $tpl->assign('lang', get_languages());
    $tpl->assign('rights', get_form_rights());
    ob_start();
    $tpl->display(DESIGN . '/tpl/admin/calendar.html');
    $content = ob_get_contents();
    ob_end_clean();
    main_content(CALENDAR, $content, '', 1);
}
function create_month($month, $year)
{
    global $phpcdb, $phpc_cal, $phpcid;
    $weeks = weeks_in_month($month, $year);
    $first_day = 1 - day_of_week($month, 1, $year);
    $from_stamp = mktime(0, 0, 0, $month, $first_day, $year);
    $last_day = $weeks * 7 - day_of_week($month, 1, $year);
    $to_stamp = mktime(23, 59, 59, $month, $last_day, $year);
    $days_events = get_events($from_stamp, $to_stamp);
    $week_list = array();
    for ($week_of_month = 1; $week_of_month <= $weeks; $week_of_month++) {
        // We could be showing a week from the previous or next year
        $days = ($week_of_month - 1) * 7;
        $start_stamp = strtotime("+{$days} day", $from_stamp);
        $week_list[] = create_week($start_stamp, $year, $days_events);
    }
    return $week_list;
}
function display_week()
{
    global $vars, $phpc_home_url, $phpcid, $phpc_year, $phpc_month, $phpc_day;
    if (!isset($vars['week'])) {
        $week_of_year = week_of_year($phpc_month, $phpc_day, $phpc_year);
    } else {
        if (!is_numeric($vars['week'])) {
            soft_error(__('Invalid date.'));
        }
        $week_of_year = $vars['week'];
    }
    $day_of_year = 1 + ($week_of_year - 1) * 7 - day_of_week(1, 1, $phpc_year);
    $from_stamp = mktime(0, 0, 0, 1, $day_of_year, $phpc_year);
    $start_day = date("j", $from_stamp);
    $start_month = date("n", $from_stamp);
    $start_year = date("Y", $from_stamp);
    $last_day = $day_of_year + 6;
    $to_stamp = mktime(23, 59, 59, 1, $last_day, $phpc_year);
    $end_day = date("j", $to_stamp);
    $end_month = date("n", $to_stamp);
    $end_year = date("Y", $to_stamp);
    $title = month_name($start_month) . " {$start_year}";
    if ($end_month != $start_month) {
        $title .= " - " . month_name($end_month) . " {$end_year}";
    }
    $prev_week = $week_of_year - 1;
    $prev_year = $phpc_year;
    if ($prev_week < 1) {
        $prev_year--;
        $prev_week = week_of_year($start_month, $start_day - 7, $start_year);
    }
    $next_week = $week_of_year + 1;
    $next_year = $phpc_year;
    if ($next_week > weeks_in_year($phpc_year)) {
        $next_week = week_of_year($end_month, $end_day + 1, $end_year);
        $next_year++;
    }
    $heading = tag('', tag('a', attrs('class="phpc-icon-link"', "href=\"{$phpc_home_url}?action=display_week&amp;phpcid={$phpcid}&amp;week={$prev_week}&amp;year={$prev_year}\""), tag('span', attrs('class="fa fa-chevron-left"'), '')), $title, tag('a', attrs('class="phpc-icon-link"', "href=\"{$phpc_home_url}?action=display_week&amp;phpcid={$phpcid}&amp;week={$next_week}&amp;year={$next_year}\""), tag('span', attrs('class="fa fa-chevron-right"'), '')));
    return create_display_table($heading, create_week($from_stamp, $phpc_year, get_events($from_stamp, $to_stamp)));
}
Exemple #7
0
 function area_notifs()
 {
     global $user, $fs, $page, $db;
     require_once BASEDIR . '/includes/events.inc.php';
     $events_since = strtotime(Get::val('events_since', '-1 week'));
     $tasks = $db->x->getAll('SELECT h.task_id, t.*, p.project_prefix
                            FROM {history} h
                       LEFT JOIN {tasks} t ON h.task_id = t.task_id
                       LEFT JOIN {projects} p ON t.project_id = p.project_id
                       LEFT JOIN {notifications} n ON t.task_id = n.task_id
                           WHERE h.event_date > ? AND h.task_id > 0 AND n.user_id = ?
                                 AND event_type NOT IN (9,10,5,6,8,17,18)
                        GROUP BY h.task_id
                        ORDER BY h.event_date DESC', null, array($events_since, $user->id));
     $task_events = array();
     foreach ($tasks as $task) {
         $task_events[$task['task_id']] = get_events($task['task_id'], 'AND event_type NOT IN (9,10,5,6,8,17,18) AND h.event_date > ' . $events_since, 'DESC');
     }
     $page->assign('task_events', $task_events);
     $page->assign('tasks', $tasks);
     $page->setTitle($fs->prefs['page_title'] . L('mynotifications'));
 }
Exemple #8
0
function network_content(&$a, $update = 0)
{
    require_once 'include/conversation.php';
    if (!local_user()) {
        $_SESSION['return_url'] = $a->query_string;
        return login(false);
    }
    // TODO:is this really necessary? $a is already available to hooks
    $arr = array('query' => $a->query_string);
    call_hooks('network_content_init', $arr);
    $datequery = $datequery2 = '';
    $group = 0;
    $nouveau = false;
    if ($a->argc > 1) {
        for ($x = 1; $x < $a->argc; $x++) {
            if (is_a_date_arg($a->argv[$x])) {
                if ($datequery) {
                    $datequery2 = escape_tags($a->argv[$x]);
                } else {
                    $datequery = escape_tags($a->argv[$x]);
                    $_GET['order'] = 'post';
                }
            } elseif ($a->argv[$x] === 'new') {
                $nouveau = true;
            } elseif (intval($a->argv[$x])) {
                $group = intval($a->argv[$x]);
                $def_acl = array('allow_gid' => '<' . $group . '>');
            }
        }
    }
    $o = '';
    // item filter tabs
    // TODO: fix this logic, reduce duplication
    //$a->page['content'] .= '<div class="tabs-wrapper">';
    list($no_active, $all_active, $postord_active, $conv_active, $new_active, $starred_active, $bookmarked_active, $spam_active) = network_query_get_sel_tab($a);
    // if no tabs are selected, defaults to comments
    if ($no_active == 'active') {
        $all_active = 'active';
    }
    $cmd = $datequery ? '' : $a->cmd;
    $len_naked_cmd = strlen(str_replace('/new', '', $cmd));
    // tabs
    $tabs = array(array('label' => t('Commented Order'), 'url' => $a->get_baseurl(true) . '/' . str_replace('/new', '', $cmd) . '?f=&order=comment' . (x($_GET, 'cid') ? '&cid=' . $_GET['cid'] : ''), 'sel' => $all_active, 'title' => t('Sort by Comment Date')), array('label' => t('Posted Order'), 'url' => $a->get_baseurl(true) . '/' . str_replace('/new', '', $cmd) . '?f=&order=post' . (x($_GET, 'cid') ? '&cid=' . $_GET['cid'] : ''), 'sel' => $postord_active, 'title' => t('Sort by Post Date')));
    if (feature_enabled(local_user(), 'personal_tab')) {
        $tabs[] = array('label' => t('Personal'), 'url' => $a->get_baseurl(true) . '/' . str_replace('/new', '', $cmd) . (x($_GET, 'cid') ? '/?f=&cid=' . $_GET['cid'] : '/?f=') . '&conv=1', 'sel' => $conv_active, 'title' => t('Posts that mention or involve you'));
    }
    if (feature_enabled(local_user(), 'new_tab')) {
        $tabs[] = array('label' => t('New'), 'url' => $a->get_baseurl(true) . '/' . str_replace('/new', '', $cmd) . ($len_naked_cmd ? '/' : '') . 'new' . (x($_GET, 'cid') ? '/?f=&cid=' . $_GET['cid'] : ''), 'sel' => $new_active, 'title' => t('Activity Stream - by date'));
    }
    if (feature_enabled(local_user(), 'link_tab')) {
        $tabs[] = array('label' => t('Shared Links'), 'url' => $a->get_baseurl(true) . '/' . str_replace('/new', '', $cmd) . (x($_GET, 'cid') ? '/?f=&cid=' . $_GET['cid'] : '/?f=') . '&bmark=1', 'sel' => $bookmarked_active, 'title' => t('Interesting Links'));
    }
    if (feature_enabled(local_user(), 'star_posts')) {
        $tabs[] = array('label' => t('Starred'), 'url' => $a->get_baseurl(true) . '/' . str_replace('/new', '', $cmd) . (x($_GET, 'cid') ? '/?f=&cid=' . $_GET['cid'] : '/?f=') . '&star=1', 'sel' => $starred_active, 'title' => t('Favourite Posts'));
    }
    // save selected tab, but only if not in search or file mode
    if (!x($_GET, 'search') && !x($_GET, 'file')) {
        set_pconfig(local_user(), 'network.view', 'tab.selected', array($all_active, $postord_active, $conv_active, $new_active, $starred_active, $bookmarked_active, $spam_active));
    }
    $arr = array('tabs' => $tabs);
    call_hooks('network_tabs', $arr);
    $o .= replace_macros(get_markup_template('common_tabs.tpl'), array('$tabs' => $arr['tabs']));
    // --- end item filter tabs
    $contact_id = $a->cid;
    require_once 'include/acl_selectors.php';
    $cid = x($_GET, 'cid') ? intval($_GET['cid']) : 0;
    $star = x($_GET, 'star') ? intval($_GET['star']) : 0;
    $bmark = x($_GET, 'bmark') ? intval($_GET['bmark']) : 0;
    $order = x($_GET, 'order') ? notags($_GET['order']) : 'comment';
    $liked = x($_GET, 'liked') ? intval($_GET['liked']) : 0;
    $conv = x($_GET, 'conv') ? intval($_GET['conv']) : 0;
    $spam = x($_GET, 'spam') ? intval($_GET['spam']) : 0;
    $nets = x($_GET, 'nets') ? $_GET['nets'] : '';
    $cmin = x($_GET, 'cmin') ? intval($_GET['cmin']) : 0;
    $cmax = x($_GET, 'cmax') ? intval($_GET['cmax']) : 99;
    $file = x($_GET, 'file') ? $_GET['file'] : '';
    if (x($_GET, 'search') || x($_GET, 'file')) {
        $nouveau = true;
    }
    if ($cid) {
        $def_acl = array('allow_cid' => '<' . intval($cid) . '>');
    }
    if ($nets) {
        $r = q("select id from contact where uid = %d and network = '%s' and self = 0", intval(local_user()), dbesc($nets));
        $str = '';
        if (count($r)) {
            foreach ($r as $rr) {
                $str .= '<' . $rr['id'] . '>';
            }
        }
        if (strlen($str)) {
            $def_acl = array('allow_cid' => $str);
        }
    }
    set_pconfig(local_user(), 'network.view', 'net.selected', $nets ? $nets : 'all');
    if (!$update) {
        if ($group) {
            if (($t = group_public_members($group)) && !get_pconfig(local_user(), 'system', 'nowarn_insecure')) {
                notice(sprintf(tt('Warning: This group contains %s member from an insecure network.', 'Warning: This group contains %s members from an insecure network.', $t), $t) . EOL);
                notice(t('Private messages to this group are at risk of public disclosure.') . EOL);
            }
        }
        nav_set_selected('network');
        $content = "";
        if ($cid) {
            $contact = q("SELECT `nick` FROM `contact` WHERE `id` = %d AND `uid` = %d AND `forum`", intval($cid), intval(local_user()));
            if ($contact) {
                $content = "@" . $contact[0]["nick"] . "+" . $cid;
            }
        }
        $x = array('is_owner' => true, 'allow_location' => $a->user['allow_location'], 'default_location' => $a->user['default-location'], 'nickname' => $a->user['nickname'], 'lockstate' => $group || $cid || $nets || is_array($a->user) && (strlen($a->user['allow_cid']) || strlen($a->user['allow_gid']) || strlen($a->user['deny_cid']) || strlen($a->user['deny_gid'])) ? 'lock' : 'unlock', 'default_perms' => get_acl_permissions($a->user), 'acl' => populate_acl($group || $cid || $nets ? $def_acl : $a->user, true), 'bang' => $group || $cid || $nets ? '!' : '', 'visitor' => 'block', 'profile_uid' => local_user(), 'acl_data' => construct_acl_data($a, $a->user), 'content' => $content);
        $o .= status_editor($a, $x);
    }
    // We don't have to deal with ACLs on this page. You're looking at everything
    // that belongs to you, hence you can see all of it. We will filter by group if
    // desired.
    $sql_post_table = "";
    $sql_options = $star ? " and starred = 1 " : '';
    $sql_options .= $bmark ? " and bookmark = 1 " : '';
    $sql_extra = $sql_options;
    $sql_extra2 = "";
    $sql_extra3 = "";
    $sql_table = "`thread`";
    $sql_parent = "`iid`";
    if ($nouveau or strlen($file) or $update) {
        $sql_table = "`item`";
        $sql_parent = "`parent`";
    }
    $sql_nets = $nets ? sprintf(" and {$sql_table}.`network` = '%s' ", dbesc($nets)) : '';
    if ($group) {
        $r = q("SELECT `name`, `id` FROM `group` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($group), intval($_SESSION['uid']));
        if (!count($r)) {
            if ($update) {
                killme();
            }
            notice(t('No such group') . EOL);
            goaway($a->get_baseurl(true) . '/network/0');
            // NOTREACHED
        }
        $contacts = expand_groups(array($group));
        $contact_str_self = "";
        if (is_array($contacts) && count($contacts)) {
            $contact_str = implode(',', $contacts);
            $self = q("SELECT `id` FROM `contact` WHERE `uid` = %d AND `self`", intval($_SESSION['uid']));
            if (count($self)) {
                $contact_str_self = "," . $self[0]["id"];
            }
        } else {
            $contact_str = ' 0 ';
            info(t('Group is empty'));
        }
        //$sql_post_table = " INNER JOIN (SELECT DISTINCT(`parent`) FROM `item` WHERE (`contact-id` IN ($contact_str) OR `allow_gid` like '".protect_sprintf('%<'.intval($group).'>%')."') and deleted = 0 ORDER BY `created` DESC) AS `temp1` ON $sql_table.$sql_parent = `temp1`.`parent` ";
        $sql_extra3 .= " AND `contact-id` IN ({$contact_str}{$contact_str_self}) ";
        $sql_extra3 .= " AND EXISTS (SELECT id FROM `item` WHERE (`contact-id` IN ({$contact_str}) \n\t\t\t\tOR `allow_gid` like '" . protect_sprintf('%<' . intval($group) . '>%') . "') and deleted = 0 \n\t\t\t\tAND parent = {$sql_table}.{$sql_parent}) ";
        $o = replace_macros(get_markup_template("section_title.tpl"), array('$title' => sprintf(t('Group: %s'), $r[0]['name']))) . $o;
    } elseif ($cid) {
        $r = q("SELECT `id`,`name`,`network`,`writable`,`nurl` FROM `contact` WHERE `id` = %d\n\t\t\t\tAND `blocked` = 0 AND `pending` = 0 LIMIT 1", intval($cid));
        if (count($r)) {
            $sql_post_table = " INNER JOIN (SELECT DISTINCT(`parent`) FROM `item` \n\t\t\t\t\t    WHERE 1 {$sql_options} AND `contact-id` = " . intval($cid) . " and deleted = 0 \n\t\t\t\t\t    ORDER BY `item`.`received` DESC) AS `temp1` \n\t\t\t\t\t    ON {$sql_table}.{$sql_parent} = `temp1`.`parent` ";
            $sql_extra = "";
            $o = replace_macros(get_markup_template("section_title.tpl"), array('$title' => sprintf(t('Contact: %s'), $r[0]['name']))) . $o;
            if ($r[0]['network'] === NETWORK_OSTATUS && $r[0]['writable'] && !get_pconfig(local_user(), 'system', 'nowarn_insecure')) {
                notice(t('Private messages to this person are at risk of public disclosure.') . EOL);
            }
        } else {
            notice(t('Invalid contact.') . EOL);
            goaway($a->get_baseurl(true) . '/network');
            // NOTREACHED
        }
    }
    if (!$group && !$cid && !$update && !get_config('theme', 'hide_eventlist')) {
        $o .= get_birthdays();
        $o .= get_events();
    }
    if ($datequery) {
        $sql_extra3 .= protect_sprintf(sprintf(" AND {$sql_table}.created <= '%s' ", dbesc(datetime_convert(date_default_timezone_get(), '', $datequery))));
    }
    if ($datequery2) {
        $sql_extra3 .= protect_sprintf(sprintf(" AND {$sql_table}.created >= '%s' ", dbesc(datetime_convert(date_default_timezone_get(), '', $datequery2))));
    }
    //$sql_extra2 = (($nouveau) ? '' : " AND `item`.`parent` = `item`.`id` ");
    $sql_extra2 = $nouveau ? '' : $sql_extra2;
    $sql_extra3 = $nouveau ? '' : $sql_extra3;
    $sql_order = "";
    $order_mode = "received";
    $tag = false;
    if (x($_GET, 'search')) {
        $search = escape_tags($_GET['search']);
        if (strpos($search, '#') === 0) {
            $tag = true;
            $search = substr($search, 1);
        }
        if (get_config('system', 'only_tag_search')) {
            $tag = true;
        }
        if ($tag) {
            $sql_extra = "";
            $sql_post_table = sprintf("INNER JOIN (SELECT `oid` FROM `term` WHERE `term` = '%s' AND `otype` = %d AND `type` = %d AND `uid` = %d ORDER BY `tid` DESC) AS `term` ON `item`.`id` = `term`.`oid` ", dbesc(protect_sprintf($search)), intval(TERM_OBJ_POST), intval(TERM_HASHTAG), intval(local_user()));
            $sql_order = "`item`.`id`";
            $order_mode = "id";
        } else {
            if (get_config('system', 'use_fulltext_engine')) {
                $sql_extra = sprintf(" AND MATCH (`item`.`body`, `item`.`title`) AGAINST ('%s' in boolean mode) ", dbesc(protect_sprintf($search)));
            } else {
                $sql_extra = sprintf(" AND `item`.`body` REGEXP '%s' ", dbesc(protect_sprintf(preg_quote($search))));
            }
            $sql_order = "`item`.`received`";
            $order_mode = "received";
        }
    }
    if (strlen($file)) {
        $sql_post_table = sprintf("INNER JOIN (SELECT `oid` FROM `term` WHERE `term` = '%s' AND `otype` = %d AND `type` = %d AND `uid` = %d ORDER BY `tid` DESC) AS `term` ON `item`.`id` = `term`.`oid` ", dbesc(protect_sprintf($file)), intval(TERM_OBJ_POST), intval(TERM_FILE), intval(local_user()));
        $sql_order = "`item`.`id`";
        $order_mode = "id";
    }
    if ($conv) {
        $sql_extra3 .= " AND `mention`";
    }
    if ($update) {
        // only setup pagination on initial page view
        $pager_sql = '';
    } else {
        if (get_config('system', 'old_pager')) {
            $r = q("SELECT COUNT(*) AS `total`\n\t\t\t        FROM {$sql_table} {$sql_post_table} INNER JOIN `contact` ON `contact`.`id` = {$sql_table}.`contact-id`\n\t\t\t        AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0\n\t\t\t        WHERE {$sql_table}.`uid` = %d AND {$sql_table}.`visible` = 1 AND {$sql_table}.`deleted` = 0\n\t\t\t        {$sql_extra2} {$sql_extra3}\n\t\t\t        {$sql_extra} {$sql_nets} ", intval($_SESSION['uid']));
            if (count($r)) {
                $a->set_pager_total($r[0]['total']);
            }
        }
        //  check if we serve a mobile device and get the user settings
        //  accordingly
        if ($a->is_mobile) {
            $itemspage_network = get_pconfig(local_user(), 'system', 'itemspage_mobile_network');
            $itemspage_network = intval($itemspage_network) ? $itemspage_network : 20;
        } else {
            $itemspage_network = get_pconfig(local_user(), 'system', 'itemspage_network');
            $itemspage_network = intval($itemspage_network) ? $itemspage_network : 40;
        }
        //  now that we have the user settings, see if the theme forces
        //  a maximum item number which is lower then the user choice
        if ($a->force_max_items > 0 && $a->force_max_items < $itemspage_network) {
            $itemspage_network = $a->force_max_items;
        }
        $a->set_pager_itemspage($itemspage_network);
        $pager_sql = sprintf(" LIMIT %d, %d ", intval($a->pager['start']), intval($a->pager['itemspage']));
    }
    if ($nouveau) {
        $simple_update = $update ? " and `item`.`unseen` = 1 " : '';
        if ($sql_order == "") {
            $sql_order = "`item`.`received`";
        }
        // "New Item View" - show all items unthreaded in reverse created date order
        $items = q("SELECT `item`.*, `item`.`id` AS `item_id`, `item`.`network` AS `item_network`,\n\t\t\t`contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`, `contact`.`writable`,\n\t\t\t`contact`.`network`, `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`,\n\t\t\t`contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`\n\t\t\tFROM {$sql_table} {$sql_post_table} INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id`\n\t\t\tAND `contact`.`blocked` = 0 AND `contact`.`pending` = 0\n\t\t\tWHERE `item`.`uid` = %d AND `item`.`visible` = 1\n\t\t\tAND `item`.`deleted` = 0 and `item`.`moderated` = 0\n\t\t\t{$simple_update}\n\t\t\t{$sql_extra} {$sql_nets}\n\t\t\tORDER BY {$sql_order} DESC {$pager_sql} ", intval($_SESSION['uid']));
        $update_unseen = ' WHERE uid = ' . intval($_SESSION['uid']) . " AND unseen = 1 {$sql_extra} {$sql_nets}";
    } else {
        // Normal conversation view
        if ($order === 'post') {
            $ordering = "`created`";
            if ($sql_order == "") {
                $order_mode = "created";
            }
        } else {
            $ordering = "`commented`";
            if ($sql_order == "") {
                $order_mode = "commented";
            }
        }
        if ($sql_order == "") {
            $sql_order = "{$sql_table}.{$ordering}";
        }
        if ($_GET["offset"] != "") {
            $sql_extra3 .= sprintf(" AND {$sql_order} <= '%s'", dbesc($_GET["offset"]));
        }
        // Fetch a page full of parent items for this page
        if ($update) {
            if (!get_config("system", "like_no_comment")) {
                $sql_extra4 = "(`item`.`deleted` = 0 OR `item`.`verb` = '" . ACTIVITY_LIKE . "' OR `item`.`verb` = '" . ACTIVITY_DISLIKE . "')";
            } else {
                $sql_extra4 = "`item`.`deleted` = 0 AND `item`.`verb` = '" . ACTIVITY_POST . "'";
            }
            $r = q("SELECT `item`.`parent` AS `item_id`, `item`.`network` AS `item_network`, `contact`.`uid` AS `contact_uid`\n\t\t\t\tFROM {$sql_table} {$sql_post_table} INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id`\n\t\t\t\tAND `contact`.`blocked` = 0 AND `contact`.`pending` = 0\n\t\t\t\tWHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND {$sql_extra4}\n\t\t\t\tAND `item`.`moderated` = 0 AND `item`.`unseen` = 1\n\t\t\t\t{$sql_extra3} {$sql_extra} {$sql_nets} ORDER BY `item_id` DESC LIMIT 100", intval(local_user()));
        } else {
            $r = q("SELECT `thread`.`iid` AS `item_id`, `thread`.`network` AS `item_network`, `contact`.`uid` AS `contact_uid`\n\t\t\t\tFROM {$sql_table} {$sql_post_table} STRAIGHT_JOIN `contact` ON `contact`.`id` = `thread`.`contact-id`\n\t\t\t\tAND `contact`.`blocked` = 0 AND `contact`.`pending` = 0\n\t\t\t\tWHERE `thread`.`uid` = %d AND `thread`.`visible` = 1 AND `thread`.`deleted` = 0\n\t\t\t\tAND `thread`.`moderated` = 0\n\t\t\t\t{$sql_extra2} {$sql_extra3} {$sql_extra} {$sql_nets}\n\t\t\t\tORDER BY {$sql_order} DESC {$pager_sql} ", intval(local_user()));
        }
        // Then fetch all the children of the parents that are on this page
        $parents_arr = array();
        $parents_str = '';
        $date_offset = "";
        if (count($r)) {
            foreach ($r as $rr) {
                if (!in_array($rr['item_id'], $parents_arr)) {
                    $parents_arr[] = $rr['item_id'];
                }
            }
            $parents_str = implode(", ", $parents_arr);
            // splitted into separate queries to avoid the problem with very long threads
            // so always the last X comments are loaded
            // This problem can occur expecially with imported facebook posts
            $max_comments = get_config("system", "max_comments");
            if ($max_comments == 0) {
                $max_comments = 100;
            }
            $items = array();
            foreach ($parents_arr as $parents) {
                //					$sql_extra ORDER BY `item`.`commented` DESC LIMIT %d",
                $thread_items = q("SELECT `item`.*, `item`.`id` AS `item_id`, `item`.`network` AS `item_network`,\n\t\t\t\t\t`contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`alias`, `contact`.`rel`, `contact`.`writable`,\n\t\t\t\t\t`contact`.`network`, `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`,\n\t\t\t\t\t`contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`\n\t\t\t\t\tFROM `item` INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id`\n\t\t\t\t\tAND `contact`.`blocked` = 0 AND `contact`.`pending` = 0\n\t\t\t\t\tWHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0\n\t\t\t\t\tAND `item`.`moderated` = 0\n\t\t\t\t\tAND `item`.`parent` = %d\n\t\t\t\t\tORDER BY `item`.`commented` DESC LIMIT %d", intval(local_user()), intval($parents), intval($max_comments + 1));
                $items = array_merge($items, $thread_items);
            }
            $items = conv_sort($items, $ordering);
        } else {
            $items = array();
        }
        if ($_GET["offset"] == "") {
            $date_offset = $items[0][$order_mode];
        } else {
            $date_offset = $_GET["offset"];
        }
        $a->page_offset = $date_offset;
        if ($parents_str) {
            $update_unseen = ' WHERE uid = ' . intval(local_user()) . ' AND unseen = 1 AND parent IN ( ' . dbesc($parents_str) . ' )';
        }
    }
    // We aren't going to try and figure out at the item, group, and page
    // level which items you've seen and which you haven't. If you're looking
    // at the top level network page just mark everything seen.
    // The $update_unseen is a bit unreliable if you have stuff coming into your stream from a new contact -
    // and other feeds that bring in stuff from the past. One can't find it all.
    // I'm reviving this block to mark everything seen on page 1 of the network as a temporary measure.
    // The correct solution is to implement a network notifications box just like the system notifications popup
    // with the ability in the popup to "mark all seen".
    // Several people are complaining because there are unseen messages they can't find and as time goes
    // on they just get buried deeper. It has happened to me a couple of times also.
    if (!$group && !$cid && !$star) {
        $r = q("UPDATE `item` SET `unseen` = 0\n\t\t\tWHERE `unseen` = 1 AND `uid` = %d", intval(local_user()));
    } else {
        if ($update_unseen) {
            $r = q("UPDATE `item` SET `unseen` = 0 {$update_unseen}");
        }
    }
    // Set this so that the conversation function can find out contact info for our wall-wall items
    $a->page_contact = $a->contact;
    $mode = $nouveau ? 'network-new' : 'network';
    $o .= conversation($a, $items, $mode, $update);
    if (!$update) {
        if (get_pconfig(local_user(), 'system', 'infinite_scroll')) {
            $o .= scroll_loader();
        } elseif (!get_config('system', 'old_pager')) {
            $o .= alt_pager($a, count($items));
        } else {
            $o .= paginate($a);
        }
    }
    return $o;
}
if (check_id_exists($facebook_id, $conn) == 0) {
    echo "-1";
    return;
}
$A_perm = get_events_attended($facebook_id, $conn);
$N_perm = get_events_not_attended($facebook_id, $conn);
$user_ids = get_user_ids($facebook_id, $conn);
//echo "count : ", count($user_ids), "<br>";
$similarity_indices = array();
foreach ($user_ids as $id) {
    $A_2 = get_events_attended($id, $conn);
    $N_2 = get_events_attended($id, $conn);
    $similarity_indices["{$id}"] = calculate_similarity_index($A_perm, $N_perm, $A_2, $N_2);
    //echo $id, " ------ ", $similarity_indices["$id"], "<br>";
}
$event_ids = get_events($conn);
$event_probablity = array();
foreach ($event_ids as $event_id) {
    //echo $event_id, " : ";
    $users_attending = get_attendance($event_id, $facebook_id, $conn);
    $sum_similarity;
    settype($sum_similarity, "float");
    $sum_similarity = 0.0;
    foreach ($users_attending as $user) {
        //echo "sim of user_index(" , $user, ") is ---", $similarity_indices["$user"], "<br>";
        $sum_similarity += $similarity_indices["{$user}"];
    }
    if (count($users_attending) != 0) {
        $event_probablity["{$event_id}"] = floatval($sum_similarity / count($users_attending));
    } else {
        $event_probablity["{$event_id}"] = 0.0;
<?php

include_once 'database.php';
$json = get_events();
$arr = array();
foreach ($json as $value) {
    $arr[] = array('id' => $value['eventID'], 'title' => $value['title'], 'start' => $value['event_date']);
}
echo json_encode($arr);
Exemple #11
0
<!DOCTYPE html "-//W3C//DTD XHTML 1.0 Transitional//EN" 
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<?php 
// get db login
require '../include/db_login.php';
require '../include/yahoo_geocoding.php';
// make empty arrays
$latitudes = generate_coordinate_array();
$longitudes = generate_coordinate_array();
// get existing events along with locations
try {
    // get all the coordinates available
    $conn = get_db_connection($db_user, $db_passwd, $db_name);
    $events_query_results = get_events();
    $row_count = mysql_num_rows($events_query_results);
    //
    for ($row = 0; $row < $row_count; $row++) {
        $event_row = mysql_fetch_array($events_query_results);
        extract($event_row);
        $latitudes[$event_id] = $latitude;
        $longitudes[$event_id] = $longitude;
    }
    $event_id = 0;
    $db_status_close = close_db_connection($conn);
} catch (exception $e) {
    $event_query_exception = $e;
}
// get the remote IP
$ip = getenv('REMOTE_ADDR');
// find location posted by user
if ($_POST) {
 function widget($args, $instance)
 {
     global $wp_query;
     extract($args);
     /* User-selected settings. */
     $title = apply_filters('widget_title', $instance['title']);
     $limit = $instance['limit'];
     $noUpcomingEvents = $instance['no_upcoming_events'];
     $start = $instance['start'];
     $startTime = $instance['start-time'];
     $end = $instance['end'];
     $endTime = $instance['end-time'];
     $venue = $instance['venue'];
     $address = $instance['address'];
     $city = $instance['city'];
     $state = $instance['state'];
     $province = $instance['province'];
     $zip = $instance['zip'];
     $country = $instance['country'];
     $phone = $instance['phone'];
     $cost = $instance['cost'];
     if (eventsGetOptionValue('viewOption') == 'upcoming') {
         $event_url = events_get_listview_link();
     } else {
         $event_url = events_get_gridview_link();
     }
     if (function_exists('get_events')) {
         $old_display = $wp_query->get('eventDisplay');
         $wp_query->set('eventDisplay', 'upcoming');
         $posts = get_events($limit, The_Events_Calendar::CATEGORYNAME);
     }
     /* Before widget (defined by themes). */
     /* Title of widget (before and after defined by themes). */
     if ($title && !$noUpcomingEvents) {
         echo $before_widget . $before_title . $title . $after_title;
     }
     if ($posts) {
         /* Display list of events. */
         if (function_exists('get_events')) {
             echo '<ul class="upcoming">';
             $templateOverride = locate_template(array('events/events-list-load-widget-display.php'));
             $templateLoc = $templateOverride ? $templateOverride : dirname(__FILE__) . '/views/events-list-load-widget-display.php';
             foreach ($posts as $post) {
                 setup_postdata($post);
                 include $templateLoc;
             }
             echo "</ul>";
             $wp_query->set('eventDisplay', $old_display);
         }
         /* Display link to all events */
         echo '<div class="dig-in"><a href="' . $event_url . '">' . __('View All Events', $this->pluginDomain) . '</a></div>';
     } else {
         if (!$noUpcomingEvents) {
             _e('There are no upcoming events at this time.', $this->pluginDomain);
         }
     }
     /* After widget (defined by themes). */
     if (!$noUpcomingEvents) {
         echo $after_widget;
     }
 }
function add_event($event_name)
{
    debugger("Memory: Usage add_event: " . memory_get_usage() . "\n");
    $db = db_connect();
    $sql = "INSERT INTO lookups.l_event(event_name) VALUES ('" . strtolower($event_name) . "'); COMMIT; ";
    $results = run_sql($db, $sql);
    echo "NOTE: New event added : {$event_name}.\n";
    $latest_events = get_events();
    mysqli_close($db);
    return $latest_events;
}
Exemple #14
0
function display_events($header = 'h2')
{
    ?>
	<?php 
    $options = get_option(THEME_OPTIONS_NAME);
    ?>
	<?php 
    $count = $options['events_max_items'];
    ?>
	<?php 
    $events = get_events(0, $count ? $count : 3);
    ?>
	<?php 
    if (count($events)) {
        ?>
		<<?php 
        echo $header;
        ?>
><a href="<?php 
        echo $events[0]->get_feed()->get_link();
        ?>
"><?php 
        echo $events[0]->get_feed()->get_title();
        ?>
</a></<?php 
        echo $header;
        ?>
>
		<table class="events">
			<?php 
        foreach ($events as $item) {
            ?>
			<tr class="item">
				<td class="date">
					<?php 
            $month = $item->get_date("M");
            $day = $item->get_date("j");
            ?>
					<div class="month"><?php 
            echo $month;
            ?>
</div>
					<div class="day"><?php 
            echo $day;
            ?>
</div>
				</td>
				<td class="title">
					<a href="<?php 
            echo $item->get_link();
            ?>
" class="wrap ignore-external"><?php 
            echo $item->get_title();
            ?>
</a>
				</td>
			</tr>
			<?php 
        }
        ?>
		</table>
	<?php 
    } else {
        ?>
		<p>Unable to fetch events</p>
	<?php 
    }
}
<?php

$events = get_events();
if (empty($events)) {
    echo '<p>Currently no events available. Please contact us for more information</p>';
    include 'inc.form.contact.php';
} else {
    foreach ($events as $event) {
        echo '<div class="event-listing"><a href="' . SITE_URL . '/event/' . $event['sefURL'] . '">';
        echo '<div class="event-listing-top"><img src="' . $event['smallPic'] . '" alt="' . $event['title'] . '" /></div>';
        echo '<div class="event-listing-bottom"><span class="event-listing-title">' . $event['title'] . '</span><span class="event-listing-date">' . date('D m/d/y :: h:iA', $event['start']) . '</span></div>';
        echo '</a></div>';
    }
}
Exemple #16
0
function display_footer_events()
{
    $max_events = get_theme_mod_or_default('events_max_items');
    $items = get_events(0, $max_events);
    ob_start();
    ?>
    <div class="footer-events">
    <?php 
    foreach ($items as $item) {
        ?>
        <?php 
        $month = $item->get_date('M');
        $day = $item->get_date('j');
        $start_date = $item->get_item_tags('http://events.ucf.edu', 'startdate');
        $end_date = $item->get_item_tags('http://events.ucf.edu', 'enddate');
        $start_time = date('g:i a', strtotime($start_date[0]['data']));
        $end_time = date('g:i a', strtotime($end_date[0]['data']));
        $time_string = '';
        if ($start_time == $end_time) {
            $time_string = $start_time;
        } else {
            $time_string = $start_time . ' - ' . $end_time;
        }
        ?>
        <a href="<?php 
        echo $item->get_link();
        ?>
" target="_blank">
        	<div class="row event">
	        	<div class="col-xs-2 col-sm-4 col-md-3">
	        		<div class="event-date">
	        			<span class="month"><?php 
        echo $month;
        ?>
</span>
	                	<span class="day"><?php 
        echo $day;
        ?>
</span>
	               	</div>
	        	</div>
	        	<div class="col-xs-10 col-sm-8 col-md-9">
	        		<div class="event-details">
		                <h4><?php 
        echo $item->get_title();
        ?>
</h4>
		                <?php 
        ?>
		                <p class="time"><?php 
        echo $time_string;
        ?>
</p>
		            </div>
	        	</div>
	    	</div>
	    </a>
    <?php 
    }
    ?>
    </div>
<?php 
    echo ob_get_clean();
}
Exemple #17
0
 echo '<td class="month"';
 $requests = array('sidebar' => 'true', 'year' => $cset['year'], 'month' => $cset['month'], 'day' => sprintf('%02d', $i));
 if (date('d') == $requests['day'] && date('Y') == $requests['year'] && date('m') == $requests['month']) {
     echo ' id="today"';
 }
 // Get rid of event for awhile if it exists
 // Double click event
 $location = pend_requests($requests, false);
 $location = preg_replace("|(\\&event\\=)(\\d*)|", '', $location);
 echo " ondblclick=\"window.location='{$location}'\"";
 echo '>';
 echo '<span class="icons"><a href="' . preg_replace("|(\\&event\\=)(\\d*)|", '', pend_requests($requests)) . '" title="Open Sidebar"><img src="images/edit-trans.png" alt="+"></a></span>' . $i;
 // Take care of events
 $timestamp1 = mktime(0, 0, 0, $requests['month'], $requests['day'], $requests['year']);
 $timestamp2 = mktime(23, 59, 59, $requests['month'], $requests['day'], $requests['year']);
 $events = get_events($timestamp1, $timestamp2);
 foreach ($events as $event) {
     echo '<div class="event"';
     // Take care of event status stuff
     echo ' id="status_' . $event['status'] . '"';
     echo '><span class="event_sum">' . $event['summary'];
     echo '<span class="menu">';
     $requests['event'] = $event['id'];
     echo '<a href="' . pend_requests($requests) . '">Edit Event</a>';
     $requests['rmevent'] = 'true';
     echo '<a href="' . pend_requests($requests) . '">Delete Event</a>';
     echo '</span>';
     echo '</span>' . $event['notes'];
     echo '</div>';
     // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! DAY ENDS HERE FOREVER !!!!!!!!!!!!!!!!!!!!!!!! until next time
 }
Exemple #18
0
    }
    // Массив событий
    $events = array();
    // Выполним запрос
    if ($result = $mysqli->query($query)) {
        // Убедимся что получена как минимум одна строка
        if ($result->num_rows > 0) {
            // Переберем все полученные датчики
            while ($row = $result->fetch_assoc()) {
                // Поместим в массив
                $events[] = $row;
            }
        }
        $result->close();
    }
    // Вернем события
    return array_reverse($events);
}
/*--------- Тело программы ---------*/
// Создадим пакован с данными
$pack = array();
// Запишем текущее серверное время
$pack["servertime"] = date("Y-m-d H:i:s");
// Запишем собранные датчики
$pack["sensors"] = get_cur_sensors($mysqli, $_POST['LAST_INQ']);
// События на квитирование
$pack["confirm"] = get_confirm($mysqli);
// События в список событий
$pack["events"] = get_events($mysqli, $_POST['LAST_EVENT']);
// Выведем результат
echo json_encode($pack);
<?php

$get = filter_input_array(INPUT_GET);
if (!isset($get['title']) || empty($get['title'])) {
    header("Location: http://www.ievents.com/development/eventfeedsite/events/");
    die;
}
?>
<!DOCTYPE html>
<html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<?php 
include "../includes/inc.head.html.php";
$event = get_events($get['title']);
//Meta input
$meta_title = $event['title'] . " - " . $event['venue'] . " - " . SITE_NAME;
$meta_keywords = $event['title'] . " Tickets, " . $event['title'] . " Group Rates, " . $event['title'] . " VIP Tickets, " . $event['title'] . " Party, " . $event['venueCity'];
$meta_description = $event['title'] . " at " . $event['venue'] . " in " . $event['venueCity'] . ". Buy Tickets for " . $event['title'] . ".";
?>
    <title><?php 
echo $meta_title;
?>
</title>    
    <meta name="keywords" content="<?php 
echo $meta_keywords;
?>
" />
    <meta name="description" content="<?php 
echo $meta_description;
?>
" />        
<?php

// dummy check
if (empty($CFG)) {
    die;
}
require $CFG->comdir . 'register_flag_check.php';
if (Context == 'asistente') {
    $workshops = get_events(0, 0, '', 0, true);
    $workshops_limit = count_records('inscribe', 'id_asistente', $USER->id);
}
if (!empty($workshops)) {
    // show warning if reached workshops limit
    if ($workshops_limit > $CFG->max_inscripcionTA) {
        show_error('Has llegado al límite de talleres/tutoriales inscritos.', false);
    }
    $table_data = array();
    // initialize old date;
    $last_date = '';
    if (Context == 'asistente') {
        $headers = array(__('Taller/Tutorial'), __('Orientación'), __('Lugar'), __('Hora'), __('Disp.'), '');
    }
    $table_data[] = $headers;
    foreach ($workshops as $workshop) {
        // hold date
        $current_date = $workshop->fecha;
        // check if start table
        if (!empty($last_date) && $last_date != $current_date) {
            $human_date = friendly_date($last_date);
            ?>
Exemple #21
0
 // So now we fetch events for this month (nb, cache events for past month, current month and next month for mini calendars too)
 $start_timestamp = gmmktime(0, 0, 0, $calendar_month, $day, $calendar_year);
 $num_days = gmdate("t", gmmktime(0, 0, 0, $month, 1, $year));
 $month_end_weekday = gmdate("w", gmmktime(0, 0, 0, $month, $num_days, $year));
 $next_days = 6 - $month_end_weekday + $calendar['startofweek'];
 // More than a week? Go one week back
 if ($next_days >= 7) {
     $next_days -= 7;
 }
 if ($next_days > 0) {
     $end_timestamp = gmmktime(23, 59, 59, $next_month['month'], $next_days, $next_month['year']);
 } else {
     // We don't need days from the next month
     $end_timestamp = gmmktime(23, 59, 59, $month, $num_days, $year);
 }
 $events_cache = get_events($calendar, $start_timestamp, $end_timestamp, $calendar_permissions['canmoderateevents']);
 // Fetch birthdays
 if ($calendar['showbirthdays']) {
     $bday_months = array($month, $prev_month['month'], $next_month['month']);
     $birthdays = get_birthdays($bday_months);
 }
 $today = my_date("dnY");
 // Build weekday headers
 foreach ($weekdays as $weekday) {
     $weekday_name = fetch_weekday_name($weekday);
     eval("\$weekday_headers .= \"" . $templates->get("calendar_weekdayheader") . "\";");
 }
 for ($row = 0; $row < 6; ++$row) {
     foreach ($weekdays as $weekday_id => $weekday) {
         // Current month always starts on 1st row
         if ($row == 0 && $day == $calendar['startofweek'] + 1) {
Exemple #22
0
function profile_content(&$a, $update = 0)
{
    $category = $datequery = $datequery2 = '';
    if ($a->argc > 2) {
        for ($x = 2; $x < $a->argc; $x++) {
            if (is_a_date_arg($a->argv[$x])) {
                if ($datequery) {
                    $datequery2 = escape_tags($a->argv[$x]);
                } else {
                    $datequery = escape_tags($a->argv[$x]);
                }
            } else {
                $category = $a->argv[$x];
            }
        }
    }
    if (!x($category)) {
        $category = x($_GET, 'category') ? $_GET['category'] : '';
    }
    if (get_config('system', 'block_public') && !local_user() && !remote_user()) {
        return login();
    }
    require_once "include/bbcode.php";
    require_once 'include/security.php';
    require_once 'include/conversation.php';
    require_once 'include/acl_selectors.php';
    require_once 'include/items.php';
    $groups = array();
    $tab = 'posts';
    $o = '';
    if ($update) {
        // Ensure we've got a profile owner if updating.
        $a->profile['profile_uid'] = $update;
    } else {
        if ($a->profile['profile_uid'] == local_user()) {
            nav_set_selected('home');
        }
    }
    $contact = null;
    $remote_contact = false;
    $contact_id = 0;
    if (is_array($_SESSION['remote'])) {
        foreach ($_SESSION['remote'] as $v) {
            if ($v['uid'] == $a->profile['profile_uid']) {
                $contact_id = $v['cid'];
                break;
            }
        }
    }
    if ($contact_id) {
        $groups = init_groups_visitor($contact_id);
        $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($contact_id), intval($a->profile['profile_uid']));
        if (count($r)) {
            $contact = $r[0];
            $remote_contact = true;
        }
    }
    if (!$remote_contact) {
        if (local_user()) {
            $contact_id = $_SESSION['cid'];
            $contact = $a->contact;
        }
    }
    $is_owner = local_user() && local_user() == $a->profile['profile_uid'] ? true : false;
    if ($a->profile['hidewall'] && !$is_owner && !$remote_contact) {
        notice(t('Access to this profile has been restricted.') . EOL);
        return;
    }
    if (!$update) {
        if (x($_GET, 'tab')) {
            $tab = notags(trim($_GET['tab']));
        }
        $o .= profile_tabs($a, $is_owner, $a->profile['nickname']);
        if ($tab === 'profile') {
            $o .= advanced_profile($a);
            call_hooks('profile_advanced', $o);
            return $o;
        }
        $o .= common_friends_visitor_widget($a->profile['profile_uid']);
        if (x($_SESSION, 'new_member') && $_SESSION['new_member'] && $is_owner) {
            $o .= '<a href="newmember" id="newmember-tips" style="font-size: 1.2em;"><b>' . t('Tips for New Members') . '</b></a>' . EOL;
        }
        $commpage = $a->profile['page-flags'] == PAGE_COMMUNITY ? true : false;
        $commvisitor = $commpage && $remote_contact == true ? true : false;
        $a->page['aside'] .= posted_date_widget($a->get_baseurl(true) . '/profile/' . $a->profile['nickname'], $a->profile['profile_uid'], true);
        $a->page['aside'] .= categories_widget($a->get_baseurl(true) . '/profile/' . $a->profile['nickname'], x($category) ? xmlify($category) : '');
        if (can_write_wall($a, $a->profile['profile_uid'])) {
            $x = array('is_owner' => $is_owner, 'allow_location' => ($is_owner || $commvisitor) && $a->profile['allow_location'] ? true : false, 'default_location' => $is_owner ? $a->user['default-location'] : '', 'nickname' => $a->profile['nickname'], 'lockstate' => is_array($a->user) && (strlen($a->user['allow_cid']) || strlen($a->user['allow_gid']) || strlen($a->user['deny_cid']) || strlen($a->user['deny_gid'])) ? 'lock' : 'unlock', 'acl' => $is_owner ? populate_acl($a->user, true) : '', 'bang' => '', 'visitor' => $is_owner || $commvisitor ? 'block' : 'none', 'profile_uid' => $a->profile['profile_uid'], 'acl_data' => $is_owner ? construct_acl_data($a, $a->user) : '');
            $o .= status_editor($a, $x);
        }
    }
    /**
     * Get permissions SQL - if $remote_contact is true, our remote user has been pre-verified and we already have fetched his/her groups
     */
    $sql_extra = item_permissions_sql($a->profile['profile_uid'], $remote_contact, $groups);
    if ($update) {
        $r = q("SELECT distinct(parent) AS `item_id`, `item`.`network` AS `item_network`,\n\t\t\t`contact`.`uid` AS `contact-uid`\n\t\t\tFROM `item` INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id`\n\t\t\tAND `contact`.`blocked` = 0 AND `contact`.`pending` = 0\n\t\t\tWHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND\n\t\t\t(`item`.`deleted` = 0 OR item.verb = '" . ACTIVITY_LIKE . "' OR item.verb = '" . ACTIVITY_DISLIKE . "')\n\t\t\tand `item`.`moderated` = 0 and `item`.`unseen` = 1\n\t\t\tAND `item`.`wall` = 1\n\t\t\t{$sql_extra}\n\t\t\tORDER BY `item`.`created` DESC", intval($a->profile['profile_uid']));
    } else {
        $sql_post_table = "";
        if (x($category)) {
            $sql_post_table = sprintf("INNER JOIN (SELECT `oid` FROM `term` WHERE `term` = '%s' AND `otype` = %d AND `type` = %d AND `uid` = %d ORDER BY `tid` DESC) AS `term` ON `item`.`id` = `term`.`oid` ", dbesc(protect_sprintf($category)), intval(TERM_OBJ_POST), intval(TERM_CATEGORY), intval($a->profile['profile_uid']));
            //$sql_extra .= protect_sprintf(file_tag_file_query('item',$category,'category'));
        }
        if ($datequery) {
            $sql_extra2 .= protect_sprintf(sprintf(" AND `thread`.`created` <= '%s' ", dbesc(datetime_convert(date_default_timezone_get(), '', $datequery))));
        }
        if ($datequery2) {
            $sql_extra2 .= protect_sprintf(sprintf(" AND `thread`.`created` >= '%s' ", dbesc(datetime_convert(date_default_timezone_get(), '', $datequery2))));
        }
        if (get_config('system', 'old_pager')) {
            $r = q("SELECT COUNT(*) AS `total`\n\t\t\t    FROM `thread` INNER JOIN `item` ON `item`.`id` = `thread`.`iid`\n\t\t\t    {$sql_post_table} INNER JOIN `contact` ON `contact`.`id` = `thread`.`contact-id`\n\t\t\t    AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0\n\t\t\t    WHERE `thread`.`uid` = %d AND `thread`.`visible` = 1 AND `thread`.`deleted` = 0\n\t\t\t    and `thread`.`moderated` = 0\n\t\t\t    AND `thread`.`wall` = 1\n\t\t\t    {$sql_extra} {$sql_extra2} ", intval($a->profile['profile_uid']));
            if (count($r)) {
                $a->set_pager_total($r[0]['total']);
            }
        }
        //  check if we serve a mobile device and get the user settings
        //  accordingly
        if ($a->is_mobile) {
            $itemspage_network = get_pconfig(local_user(), 'system', 'itemspage_mobile_network');
            $itemspage_network = intval($itemspage_network) ? $itemspage_network : 20;
        } else {
            $itemspage_network = get_pconfig(local_user(), 'system', 'itemspage_network');
            $itemspage_network = intval($itemspage_network) ? $itemspage_network : 40;
        }
        //  now that we have the user settings, see if the theme forces
        //  a maximum item number which is lower then the user choice
        if ($a->force_max_items > 0 && $a->force_max_items < $itemspage_network) {
            $itemspage_network = $a->force_max_items;
        }
        $a->set_pager_itemspage($itemspage_network);
        $pager_sql = sprintf(" LIMIT %d, %d ", intval($a->pager['start']), intval($a->pager['itemspage']));
        $r = q("SELECT `thread`.`iid` AS `item_id`, `thread`.`network` AS `item_network`,\n\t\t\t`thread`.`uid` AS `contact-uid`\n\t\t\tFROM `thread` INNER JOIN `item` ON `item`.`id` = `thread`.`iid`\n\t\t\t{$sql_post_table} INNER JOIN `contact` ON `contact`.`id` = `thread`.`contact-id`\n\t\t\tAND `contact`.`blocked` = 0 AND `contact`.`pending` = 0\n\t\t\tWHERE `thread`.`uid` = %d AND `thread`.`visible` = 1 AND `thread`.`deleted` = 0\n\t\t\tand `thread`.`moderated` = 0\n\t\t\tAND `thread`.`wall` = 1\n\t\t\t{$sql_extra} {$sql_extra2}\n\t\t\tORDER BY `thread`.`created` DESC {$pager_sql} ", intval($a->profile['profile_uid']));
    }
    $parents_arr = array();
    $parents_str = '';
    if (count($r)) {
        foreach ($r as $rr) {
            $parents_arr[] = $rr['item_id'];
        }
        $parents_str = implode(', ', $parents_arr);
        $items = q("SELECT `item`.*, `item`.`id` AS `item_id`, `item`.`network` AS `item_network`,\n\t\t\t`contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`alias`, `contact`.`network`, `contact`.`rel`,\n\t\t\t`contact`.`thumb`, `contact`.`self`, `contact`.`writable`,\n\t\t\t`contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`\n\t\t\tFROM `item`, `contact`\n\t\t\tWHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0\n\t\t\tand `item`.`moderated` = 0\n\t\t\tAND `contact`.`id` = `item`.`contact-id`\n\t\t\tAND `contact`.`blocked` = 0 AND `contact`.`pending` = 0\n\t\t\tAND `item`.`parent` IN ( %s )\n\t\t\t{$sql_extra} ", intval($a->profile['profile_uid']), dbesc($parents_str));
        $items = conv_sort($items, 'created');
    } else {
        $items = array();
    }
    if ($is_owner && !$update && !get_config('theme', 'hide_eventlist')) {
        $o .= get_birthdays();
        $o .= get_events();
    }
    if ($is_owner) {
        $r = q("UPDATE `item` SET `unseen` = 0\n\t\t\tWHERE `wall` = 1 AND `unseen` = 1 AND `uid` = %d", intval(local_user()));
    }
    $o .= conversation($a, $items, 'profile', $update);
    if (!$update) {
        if (!get_config('system', 'old_pager')) {
            $o .= alt_pager($a, count($items));
        } else {
            $o .= paginate($a);
        }
    }
    return $o;
}
Exemple #23
0
         $app->get('', $check_token_exists, function ($calendar_id, $username) {
             get_member($username, $calendar_id);
         });
         $app->put('', $check_token_exists, $decode_body, function ($calendar_id, $username) {
             edit_member($username, $calendar_id);
         });
         $app->delete('', $check_token_exists, function ($calendar_id, $username) {
             delete_member($username, $calendar_id);
         });
     });
 });
 $app->group('/events', function () use($app) {
     global $check_token_exists;
     global $decode_body;
     $app->get('', $check_token_exists, function ($calendar_id) {
         get_events($calendar_id);
     });
     $app->post('', $check_token_exists, $decode_body, function ($calendar_id) {
         create_event($calendar_id);
     });
     $app->group('/:event_id', function () use($app) {
         global $check_token_exists;
         global $decode_body;
         $app->get('', $check_token_exists, function ($calendar_id, $event_id) {
             get_event($calendar_id, $event_id);
         });
         $app->put('', $check_token_exists, $decode_body, function ($calendar_id, $event_id) {
             edit_event($calendar_id, $event_id);
         });
         $app->delete('', $check_token_exists, function ($calendar_id, $event_id) {
             delete_event($calendar_id, $event_id);
Exemple #24
0
function update_status_function()
{
    /**
     * data will be empty if something fails on the server side.
     *
     * The first 8 lines are the following status of tor:
     * 	version
     * 	network-liveness
     * 	status/bootstrap-phase
     * 	status/circuit-established
     * 	status/enough-dir-info
     * 	status/good-server-descriptor
     * 	status/accepted-server-descriptor
     * 	status/reachability-succeeded
     * The next line is a number num in decimal meaning the lines for stream
     * status.
     * The next num lines are stream status, with " " at the end of each line.
     * The next line is a number num in decimal meaning the number of lines for
     * OR connection status.
     * The next num lines are OR connection status, with " " at the end of each
     * line.
     * The next line is a number num in decimal meaning the lines for circuit
     * status.
     * The next num lines are circuit status. Each entry is
     * 	id
     * 	status
     * 	build flag
     * 	time created
     * 	path
     * Seperators are " ".
     * The next line is a number num in decimal meaning the entries for OR
     * status.
     * The next num lines are OR status. Each entry is
     * 	nickname
     * 	identity
     * 	digest
     * 	publication
     * 	ip
     * 	ORPort
     * 	DIRPort
     * 	IPv6 addresses, each ending with ';'
     * 	flags
     * 	version
     * 	bandwidth
     * 	portlist
     * Seperators are "\t".
     * Each of the next lines is a timestamp in miliseconds in decimal followed
     * by a line of response for one of the following asynchronous events
     * without "650" at the beginning of the line.
     * 	bw
     * 	info
     * 	notice
     * 	warn
     * 	err
     * Line breaks are "\n".
     */
    global $tor_version_string, $tc, $event_names_string, $now;
    $output_lines = array();
    header('Content-type: text/plain');
    $output_lines[] = $tor_version_string;
    $getinfo_values = parse_getinfo_array(array('network-liveness', 'status/bootstrap-phase', 'status/circuit-established', 'status/enough-dir-info', 'status/good-server-descriptor', 'status/accepted-server-descriptor', 'status/reachability-succeeded', 'stream-status', 'orconn-status', 'circuit-status'));
    // for network-liveness, status/bootstrap-phase, status/circuit-established,
    // status/enough-dir-info, status/good-server-descriptior,
    // status/accepted-server-descriptor, and status/reachability-succeeded
    for ($index = 0; $index < 7; $index++) {
        $output_lines[] = $getinfo_values[$index]->lines[0];
    }
    // for stream-status
    $output_lines[] = $getinfo_values[7]->num;
    foreach ($getinfo_values[7]->lines as $line) {
        $output_lines[] = "{$line} ";
    }
    // for orconn-status
    $output_lines[] = $getinfo_values[8]->num;
    foreach ($getinfo_values[8]->lines as $line) {
        $a = explode(' ', $line);
        for ($b = 0; $b < 2; $b++) {
            if (!isset($a[$b])) {
                $a[$b] = '';
            }
        }
        $output_lines[] = "{$a['1']} {$a['0']} ";
    }
    // for circuit-status
    $output_lines[] = $getinfo_values[9]->num;
    foreach ($getinfo_values[9]->lines as $line) {
        $output_lines[] = output_circuit_status($line);
    }
    // for ns/all
    $num = 0;
    $output_lines_ns = array();
    if (compare_version(array(0, 1, 2, 3))) {
        $getinfo_values = parse_getinfo('ns/all');
        if ($getinfo_values->num) {
            foreach ($getinfo_values->lines as $line) {
                if ($result = parse_dir($line)) {
                    $output_lines_ns[] = $result;
                    $num++;
                }
            }
            $output_lines_ns[] = output_parse_dir();
            $num++;
        }
    } else {
        $getinfo_values = parse_getinfo('network-status');
        if ($getinfo_values->num) {
            foreach ($getinfo_values->lines as $line) {
                if ($result = parse_dir_v1($line)) {
                    $output_lines_ns[] = $result;
                    $num++;
                }
            }
            $output_lines_ns[] = output_parse_dir();
            $num++;
        }
    }
    $output_lines[] = $num;
    foreach ($output_lines_ns as $line) {
        $output_lines[] = $line;
    }
    // for asynchronous events
    exec_command_no_response("setevents {$event_names_string}");
    stream_set_blocking($tc, 0);
    $now = (int) (microtime(1) * 1000000);
    // to wait for asynchronous
    $time_check = $now + update_status_initial_wait;
    $event_cache = array();
    while ($now < $time_check) {
        foreach (get_events() as $event) {
            $event_cache[] = $event;
        }
    }
    session_restart_configure();
    session_start();
    $serial = $_SESSION['php_tor_controller_last_event_capture'] + 1 & 0xffff;
    $_SESSION['php_tor_controller_last_event_capture'] = $serial;
    $_SESSION['php_tor_controller_last_event_capture_time'] = $now;
    $_SESSION['php_tor_controller_last_event_capture_events'] = $event_cache;
    session_write_close();
    $event_cache = array();
    while (1) {
        $time_check += update_status_check_interval;
        while ($now < $time_check) {
            foreach (get_events() as $event) {
                $event_cache[] = $event;
            }
        }
        // to check for another instance of this script capturing asynchronous
        // events
        session_start();
        if ($_SESSION['php_tor_controller_last_event_capture'] != $serial) {
            stream_set_blocking($tc, 1);
            close_tc();
            $last_capture_time = $_SESSION['php_tor_controller_last_event_capture_time'];
            $last_capture_events = $_SESSION['php_tor_controller_last_event_capture_events'];
            session_write_close();
            // all the output
            foreach ($output_lines as $line) {
                echo $line, "\n";
            }
            /*
             * If $_SESSION['php_tor_controller_last_event_capture_events'] is
             * empty or it matches no part of $event_cache, all events that are
             * received earlier than
             * $_SESSION['php_tor_controller_last_event_capture_time'] will be
             * sent. Otherwise, all events received earlier than the part that
             * match and the part that match are sent.
             */
            $num = count($last_capture_events);
            if ($num) {
                $a = 0;
                $last_pos = count($event_cache) - 1;
                $latest = $last_capture_events[$num - 1]->time + event_received_time_difference;
                while ($last_pos > $a) {
                    $c = $a + $last_pos >> 1;
                    if ($event_cache[$c]->time > $latest) {
                        $last_pos = $c - 1;
                    } else {
                        $a = $c + 1;
                    }
                }
                for ($last_pos++; $last_pos >= $num; $last_pos--) {
                    $start_pos = $last_pos - $num;
                    $a = $num;
                    while (1) {
                        $eventa = $last_capture_events[--$a];
                        $eventb = $event_cache[$a + $start_pos];
                        if ($eventa->time - event_received_time_difference > $eventb->time) {
                            goto events_no_match;
                        }
                        if ($eventa->line !== $eventb->line || $eventa->time + event_received_time_difference < $eventb->time) {
                            break;
                        }
                        if (!$a) {
                            for ($a = 0; $a < $last_pos; $a++) {
                                output_event($event_cache[$a]);
                            }
                            exit;
                        }
                    }
                }
            } else {
                events_no_match:
            }
            for ($a = 0; isset($event_cache[$a]) && $event_cache[$a]->time < $last_capture_time; $a++) {
                output_event($event_cache[$a]);
            }
            exit;
        }
        session_write_close();
    }
}
Exemple #25
0
 $page->assign('votes', $db->fetchAllArray($get_votes));
 $page->assign('penreqs', $db->fetchAllArray($get_pending));
 $page->assign('d_open', $db->fetchOne($open_deps));
 $page->assign('watched', $db->fetchOne($watching));
 $page->assign('reopened', $db->fetchOne($reopened));
 $page->pushTpl('details.view.tpl');
 ///////////////
 // tabbed area
 // Comments + cache
 $sql = $db->Query('SELECT * FROM {comments} c
               LEFT JOIN {cache} ca ON (c.comment_id = ca.topic AND ca.type = ?)
                   WHERE task_id = ?
                ORDER BY date_added ASC', array('comm', $task_id));
 $page->assign('comments', $db->fetchAllArray($sql));
 // Comment events
 $sql = get_events($task_id, ' AND (event_type = 3 OR event_type = 14)');
 $comment_changes = array();
 while ($row = $db->FetchRow($sql)) {
     $comment_changes[$row['event_date']][] = $row;
 }
 $page->assign('comment_changes', $comment_changes);
 // Comment attachments
 $attachments = array();
 $sql = $db->Query('SELECT *
                  FROM {attachments} a, {comments} c
                 WHERE c.task_id = ? AND a.comment_id = c.comment_id', array($task_id));
 while ($row = $db->FetchRow($sql)) {
     $attachments[$row['comment_id']][] = $row;
 }
 $page->assign('comment_attachments', $attachments);
 // Comment links
Exemple #26
0
function profile_content(&$a, $update = 0)
{
    if (get_config('system', 'block_public') && !local_user() && !remote_user()) {
        return login();
    }
    require_once "include/bbcode.php";
    require_once 'include/security.php';
    require_once 'include/conversation.php';
    require_once 'include/acl_selectors.php';
    $groups = array();
    $tab = 'posts';
    $o = '';
    if ($update) {
        // Ensure we've got a profile owner if updating.
        $a->profile['profile_uid'] = $update;
    } else {
        if ($a->profile['profile_uid'] == local_user()) {
            nav_set_selected('home');
        }
    }
    $contact = null;
    $remote_contact = false;
    if (remote_user()) {
        $contact_id = $_SESSION['visitor_id'];
        $groups = init_groups_visitor($contact_id);
        $r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($contact_id), intval($a->profile['profile_uid']));
        if (count($r)) {
            $contact = $r[0];
            $remote_contact = true;
        }
    }
    if (!$remote_contact) {
        if (local_user()) {
            $contact_id = $_SESSION['cid'];
            $contact = $a->contact;
        }
    }
    $is_owner = local_user() && local_user() == $a->profile['profile_uid'] ? true : false;
    if ($a->profile['hidewall'] && !$is_owner && !$remote_contact) {
        notice(t('Access to this profile has been restricted.') . EOL);
        return;
    }
    if (!$update) {
        if (x($_GET, 'tab')) {
            $tab = notags(trim($_GET['tab']));
        }
        $o .= profile_tabs($a, $is_owner, $a->profile['nickname']);
        if ($tab === 'profile') {
            require_once 'include/profile_advanced.php';
            $o .= advanced_profile($a);
            call_hooks('profile_advanced', $o);
            return $o;
        }
        if (x($_SESSION, 'new_member') && $_SESSION['new_member'] && $is_owner) {
            $o .= '<a href="newmember">' . t('Tips for New Members') . '</a>' . EOL;
        }
        $commpage = $a->profile['page-flags'] == PAGE_COMMUNITY ? true : false;
        $commvisitor = $commpage && $remote_contact == true ? true : false;
        $celeb = $a->profile['page-flags'] == PAGE_SOAPBOX || $a->profile['page-flags'] == PAGE_COMMUNITY ? true : false;
        if (can_write_wall($a, $a->profile['profile_uid'])) {
            $x = array('is_owner' => $is_owner, 'allow_location' => ($is_owner || $commvisitor) && $a->profile['allow_location'] ? true : false, 'default_location' => $is_owner ? $a->user['default-location'] : '', 'nickname' => $a->profile['nickname'], 'lockstate' => is_array($a->user) && (strlen($a->user['allow_cid']) || strlen($a->user['allow_gid']) || strlen($a->user['deny_cid']) || strlen($a->user['deny_gid'])) ? 'lock' : 'unlock', 'acl' => $is_owner ? populate_acl($a->user, $celeb) : '', 'bang' => '', 'visitor' => $is_owner || $commvisitor ? 'block' : 'none', 'profile_uid' => $a->profile['profile_uid']);
            $o .= status_editor($a, $x);
        }
    }
    if ($is_owner) {
        $r = q("UPDATE `item` SET `unseen` = 0 \n\t\t\tWHERE `wall` = 1 AND `unseen` = 1 AND `uid` = %d", intval(local_user()));
    }
    /**
     * Get permissions SQL - if $remote_contact is true, our remote user has been pre-verified and we already have fetched his/her groups
     */
    $sql_extra = permissions_sql($a->profile['profile_uid'], $remote_contact, $groups);
    $r = q("SELECT COUNT(*) AS `total`\n\t\tFROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`\n\t\tWHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0\n\t\tAND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 \n\t\tAND `item`.`id` = `item`.`parent` AND `item`.`wall` = 1\n\t\t{$sql_extra} ", intval($a->profile['profile_uid']));
    if (count($r)) {
        $a->set_pager_total($r[0]['total']);
        $a->set_pager_itemspage(40);
    }
    $r = q("SELECT `item`.`id` AS `item_id`, `contact`.`uid` AS `contact-uid`\n\t\tFROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`\n\t\tWHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0\n\t\tAND `contact`.`blocked` = 0 AND `contact`.`pending` = 0\n\t\tAND `item`.`id` = `item`.`parent` AND `item`.`wall` = 1\n\t\t{$sql_extra}\n\t\tORDER BY `item`.`created` DESC LIMIT %d ,%d ", intval($a->profile['profile_uid']), intval($a->pager['start']), intval($a->pager['itemspage']));
    $parents_arr = array();
    $parents_str = '';
    if (count($r)) {
        foreach ($r as $rr) {
            $parents_arr[] = $rr['item_id'];
        }
        $parents_str = implode(', ', $parents_arr);
        $r = q("SELECT `item`.*, `item`.`id` AS `item_id`, \n\t\t\t`contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`network`, `contact`.`rel`, \n\t\t\t`contact`.`thumb`, `contact`.`self`, `contact`.`writable`, \n\t\t\t`contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`\n\t\t\tFROM `item`, (SELECT `p`.`id`,`p`.`created` FROM `item` AS `p` WHERE `p`.`parent` = `p`.`id`) AS `parentitem`, `contact`\n\t\t\tWHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0\n\t\t\tAND `contact`.`id` = `item`.`contact-id`\n\t\t\tAND `contact`.`blocked` = 0 AND `contact`.`pending` = 0\n\t\t\tAND `item`.`parent` = `parentitem`.`id` AND `item`.`parent` IN ( %s )\n\t\t\t{$sql_extra}\n\t\t\tORDER BY `parentitem`.`created` DESC, `gravity` ASC, `item`.`created` ASC ", intval($a->profile['profile_uid']), dbesc($parents_str));
    }
    if ($is_owner && !$update) {
        $o .= get_birthdays();
        $o .= get_events();
    }
    if (!$update && $tab === 'posts') {
        // This is ugly, but we can't pass the profile_uid through the session to the ajax updater,
        // because browser prefetching might change it on us. We have to deliver it with the page.
        $o .= '<div id="live-profile"></div>' . "\r\n";
        $o .= "<script> var profile_uid = " . $a->profile['profile_uid'] . "; var netargs = '/?f='; var profile_page = " . $a->pager['page'] . "; </script>\r\n";
    }
    $o .= conversation($a, $r, 'profile', $update);
    if (!$update) {
        $o .= paginate($a);
    }
    return $o;
}
Exemple #27
0
<?php

global $spEvents;
$eventPosts = get_events();
$startOfWeek = get_option('start_of_week', 0);
list($year, $month) = split('-', $spEvents->date);
$date = mktime(12, 0, 0, $month, 1, $year);
// 1st day of month as unix stamp
$daysInMonth = date("t", $date);
$monthView = events_by_month($eventPosts, $spEvents->date);
$rawOffset = date("w", $date) - $startOfWeek;
$offset = $rawOffset < 0 ? $rawOffset + 7 : $rawOffset;
// month begins on day x
$rows = 1;
$monthView = events_by_month($eventPosts, $spEvents->date);
?>
<table class="tec-calendar" id="big">
	<thead>
			<tr>
				<?php 
for ($n = $startOfWeek; $n < count($spEvents->daysOfWeek) + $startOfWeek; $n++) {
    $dayOfWeek = $n >= 7 ? $n - 7 : $n;
    echo '<th id="tec-' . strtolower($spEvents->daysOfWeek[$dayOfWeek]) . '">' . $spEvents->daysOfWeekShort[$dayOfWeek] . '</th>';
}
?>
			</tr>
	</thead>

	<tbody>
		<tr>
		<?php 
Exemple #28
0
<?php

$private = true;
$alive = false;
$quickstat = false;
$page_title = "Events";
include SERVER_ROOT . "interface/header.php";
$user_id = get_user_id();
$events = get_events($user_id);
read_events($user_id);
// mark events as viewed.
$event_list = '';
if (!empty($events)) {
    foreach ($events as $loop_event) {
        $loop_event['message'] = out($loop_event['message']);
        $event_list .= render_template('single_event.tpl', array('event' => $loop_event));
    }
}
if (!$event_list) {
    $event_list = 'You have not been attacked recently.';
}
$parts = get_certain_vars(get_defined_vars());
echo render_template('events.tpl', $parts);
include SERVER_ROOT . "interface/footer.php";
/**
 * Build a mini calendar for a specific month
 *
 * @param array The calendar array for the calendar
 * @param int The month of the year
 * @param int The year
 * @param array Optional events cache for this calendar
 * @return string The built mini calendar
 */
function build_mini_calendar($calendar, $month, $year, &$events_cache)
{
    global $events_cache, $mybb, $templates, $theme, $monthnames;
    // Incoming month/year?
    if (!$year || $year > my_date("Y") + 5) {
        $year = my_date("Y");
    }
    // Then the month
    if ($month < 1 || $month > 12) {
        $month = my_date("n");
    }
    $weekdays = fetch_weekday_structure($calendar['startofweek']);
    $calendar_permissions = get_calendar_permissions($calendar['cid']);
    $month_link = get_calendar_link($calendar['cid'], $year, $month);
    $next_month = get_next_month($month, $year);
    $prev_month = get_prev_month($month, $year);
    $month_start_weekday = gmdate("w", gmmktime(0, 0, 0, $month, $calendar['startofweek'] + 1, $year));
    if ($month_start_weekday != $weekdays[0] || $calendar['startofweek'] != 0) {
        $day = gmdate("t", gmmktime(0, 0, 0, $prev_month['month'], 1, $prev_month['year']));
        $day -= array_search($month_start_weekday, $weekdays);
        $day += $calendar['startofweek'] + 1;
        $calendar_month = $prev_month['month'];
        $calendar_year = $prev_month['year'];
        if ($day > 31 && $calendar['startofweek'] == 1 && $prev_month_days == 30) {
            // We need to fix it for these days
            $day = 25;
        }
    } else {
        $day = $calendar['startofweek'] + 1;
        $calendar_month = $month;
        $calendar_year = $year;
    }
    $prev_month_days = gmdate("t", gmmktime(0, 0, 0, $prev_month['month'], 1, $prev_month['year']));
    // So now we fetch events for this month
    $start_timestamp = gmmktime(0, 0, 0, $calendar_month, $day, $year);
    $num_days = gmdate("t", gmmktime(0, 0, 0, $month, 1, $year));
    $end_timestamp = gmmktime(23, 59, 59, $month, $num_days, $year);
    if (!$events_cache) {
        $events_cache = get_events($calendar, $start_timestamp, $end_timestamp, $calendar_permissions['canmoderateevents']);
    }
    $today = my_date("dnY");
    // Build weekday headers
    $weekday_headers = '';
    foreach ($weekdays as $weekday) {
        $weekday_name = fetch_weekday_name($weekday, true);
        eval("\$weekday_headers .= \"" . $templates->get("calendar_mini_weekdayheader") . "\";");
    }
    $in_month = 0;
    $day_bits = $calendar_rows = '';
    for ($row = 0; $row < 6; ++$row) {
        foreach ($weekdays as $weekday_id => $weekday) {
            // Current month always starts on 1st row
            if ($row == 0 && $day == $calendar['startofweek'] + 1) {
                $in_month = 1;
                $calendar_month = $month;
                $calendar_year = $year;
            } else {
                if ($calendar_month == $prev_month['month'] && $day > $prev_month_days) {
                    $day = 1;
                    $in_month = 1;
                    $calendar_month = $month;
                    $calendar_year = $year;
                } else {
                    if ($day > $num_days && $calendar_month != $prev_month['month']) {
                        $in_month = 0;
                        $calendar_month = $next_month['month'];
                        $calendar_year = $next_month['year'];
                        $day = 1;
                        if ($calendar_month == $month) {
                            $in_month = 1;
                        }
                    }
                }
            }
            if ($weekday_id == 0) {
                $week_stamp = gmmktime(0, 0, 0, $calendar_month, $day, $calendar_year);
                $week_link = get_calendar_week_link($calendar['cid'], $week_stamp);
            }
            if ($weekday_id == 0 && $calendar_month == $next_month['month']) {
                break;
            }
            $link_to_day = false;
            // Any events on this specific day?
            if (@count($events_cache["{$day}-{$calendar_month}-{$calendar_year}"]) > 0) {
                $link_to_day = true;
            }
            // Is the current day
            if ($day . $calendar_month . $year == $today && $month == $calendar_month) {
                $day_class = "trow_sep";
            } else {
                if ($in_month == 0) {
                    $day_class = "trow1";
                } else {
                    $day_class = "trow2";
                }
            }
            if ($link_to_day) {
                $day_link = "<a href=\"" . get_calendar_link($calendar['cid'], $calendar_year, $calendar_month, $day) . "\">{$day}</a>";
            } else {
                $day_link = $day;
            }
            eval("\$day_bits .= \"" . $templates->get("calendar_mini_weekrow_day") . "\";");
            ++$day;
        }
        if ($day_bits) {
            eval("\$calendar_rows .= \"" . $templates->get("calendar_mini_weekrow") . "\";");
        }
        $day_bits = "";
    }
    eval("\$mini_calendar = \"" . $templates->get("calendar_mini") . "\";");
    return $mini_calendar;
}
Exemple #30
0
function network_content(&$a, $update = 0)
{
    require_once 'include/conversation.php';
    if (!local_user()) {
        return login(false);
    }
    $o = '';
    // item filter tabs
    // TODO: fix this logic, reduce duplication
    //$a->page['content'] .= '<div class="tabs-wrapper">';
    $starred_active = '';
    $new_active = '';
    $bookmarked_active = '';
    $all_active = '';
    $search_active = '';
    $conv_active = '';
    if ($a->argc > 1 && $a->argv[1] === 'new' || $a->argc > 2 && $a->argv[2] === 'new') {
        $new_active = 'active';
    }
    if (x($_GET, 'search')) {
        $search_active = 'active';
    }
    if (x($_GET, 'star')) {
        $starred_active = 'active';
    }
    if ($_GET['bmark']) {
        $bookmarked_active = 'active';
    }
    if ($_GET['conv']) {
        $conv_active = 'active';
    }
    if ($new_active == '' && $starred_active == '' && $bookmarked_active == '' && $conv_active == '' && $search_active == '') {
        $all_active = 'active';
    }
    $postord_active = '';
    if ($all_active && x($_GET, 'order') && $_GET['order'] !== 'comment') {
        $all_active = '';
        $postord_active = 'active';
    }
    // tabs
    $tabs = array(array('label' => t('Commented Order'), 'url' => $a->get_baseurl() . '/' . str_replace('/new', '', $a->cmd) . (x($_GET, 'cid') ? '?cid=' . $_GET['cid'] : ''), 'sel' => $all_active), array('label' => t('Posted Order'), 'url' => $a->get_baseurl() . '/' . str_replace('/new', '', $a->cmd) . '?order=post' . (x($_GET, 'cid') ? '&cid=' . $_GET['cid'] : ''), 'sel' => $postord_active), array('label' => t('Personal'), 'url' => $a->get_baseurl() . '/' . str_replace('/new', '', $a->cmd) . (x($_GET, 'cid') ? '/?cid=' . $_GET['cid'] : '') . '&conv=1', 'sel' => $conv_active), array('label' => t('New'), 'url' => $a->get_baseurl() . '/' . str_replace('/new', '', $a->cmd) . '/new' . (x($_GET, 'cid') ? '/?cid=' . $_GET['cid'] : ''), 'sel' => $new_active), array('label' => t('Starred'), 'url' => $a->get_baseurl() . '/' . str_replace('/new', '', $a->cmd) . (x($_GET, 'cid') ? '/?cid=' . $_GET['cid'] : '') . '&star=1', 'sel' => $starred_active), array('label' => t('Bookmarks'), 'url' => $a->get_baseurl() . '/' . str_replace('/new', '', $a->cmd) . (x($_GET, 'cid') ? '/?cid=' . $_GET['cid'] : '') . '&bmark=1', 'sel' => $bookmarked_active));
    $tpl = get_markup_template('common_tabs.tpl');
    $o .= replace_macros($tpl, array('$tabs' => $tabs));
    // --- end item filter tabs
    $contact_id = $a->cid;
    $group = 0;
    $nouveau = false;
    require_once 'include/acl_selectors.php';
    $cid = x($_GET, 'cid') ? intval($_GET['cid']) : 0;
    $star = x($_GET, 'star') ? intval($_GET['star']) : 0;
    $bmark = x($_GET, 'bmark') ? intval($_GET['bmark']) : 0;
    $order = x($_GET, 'order') ? notags($_GET['order']) : 'comment';
    $liked = x($_GET, 'liked') ? intval($_GET['liked']) : 0;
    $conv = x($_GET, 'conv') ? intval($_GET['conv']) : 0;
    if ($a->argc > 2 && $a->argv[2] === 'new') {
        $nouveau = true;
    }
    if ($a->argc > 1) {
        if ($a->argv[1] === 'new') {
            $nouveau = true;
        } else {
            $group = intval($a->argv[1]);
            $def_acl = array('allow_gid' => '<' . $group . '>');
        }
    }
    if (x($_GET, 'search')) {
        $nouveau = true;
    }
    if ($cid) {
        $def_acl = array('allow_cid' => '<' . intval($cid) . '>');
    }
    if (!$update) {
        if (group) {
            if (($t = group_public_members($group)) && !get_pconfig(local_user(), 'system', 'nowarn_insecure')) {
                notice(sprintf(tt('Warning: This group contains %s member from an insecure network.', 'Warning: This group contains %s members from an insecure network.', $t), $t) . EOL);
                notice(t('Private messages to this group are at risk of public disclosure.') . EOL);
            }
        }
        nav_set_selected('network');
        $_SESSION['return_url'] = $a->cmd;
        $celeb = $a->user['page-flags'] == PAGE_SOAPBOX || $a->user['page-flags'] == PAGE_COMMUNITY ? true : false;
        $x = array('is_owner' => true, 'allow_location' => $a->user['allow_location'], 'default_location' => $a->user['default_location'], 'nickname' => $a->user['nickname'], 'lockstate' => $group || is_array($a->user) && (strlen($a->user['allow_cid']) || strlen($a->user['allow_gid']) || strlen($a->user['deny_cid']) || strlen($a->user['deny_gid'])) ? 'lock' : 'unlock', 'acl' => populate_acl($group || $cid ? $def_acl : $a->user, $celeb), 'bang' => $group || $cid ? '!' : '', 'visitor' => 'block', 'profile_uid' => local_user());
        $o .= status_editor($a, $x);
    }
    // We aren't going to try and figure out at the item, group, and page
    // level which items you've seen and which you haven't. If you're looking
    // at the top level network page just mark everything seen.
    if (!$group && !$cid && !$star) {
        $r = q("UPDATE `item` SET `unseen` = 0 \n\t\t\tWHERE `unseen` = 1 AND `uid` = %d", intval($_SESSION['uid']));
    }
    // We don't have to deal with ACL's on this page. You're looking at everything
    // that belongs to you, hence you can see all of it. We will filter by group if
    // desired.
    $star_sql = $star ? " AND `starred` = 1 " : '';
    if ($bmark) {
        $star_sql .= " AND `bookmark` = 1 ";
    }
    $sql_extra = " AND `item`.`parent` IN ( SELECT `parent` FROM `item` WHERE `id` = `parent` {$star_sql} ) ";
    if ($group) {
        $r = q("SELECT `name`, `id` FROM `group` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($group), intval($_SESSION['uid']));
        if (!count($r)) {
            if ($update) {
                killme();
            }
            notice(t('No such group') . EOL);
            goaway($a->get_baseurl() . '/network');
            // NOTREACHED
        }
        $contacts = expand_groups(array($group));
        if (is_array($contacts) && count($contacts)) {
            $contact_str = implode(',', $contacts);
        } else {
            $contact_str = ' 0 ';
            info(t('Group is empty'));
        }
        $sql_extra = " AND `item`.`parent` IN ( SELECT `parent` FROM `item` WHERE `id` = `parent` {$star_sql} AND ( `contact-id` IN ( {$contact_str} ) OR `allow_gid` REGEXP '<" . intval($group) . ">' )) ";
        $o = '<h2>' . t('Group: ') . $r[0]['name'] . '</h2>' . $o;
    } elseif ($cid) {
        $r = q("SELECT `id`,`name`,`network`,`writable` FROM `contact` WHERE `id` = %d \n\t\t\t\tAND `blocked` = 0 AND `pending` = 0 LIMIT 1", intval($cid));
        if (count($r)) {
            $sql_extra = " AND `item`.`parent` IN ( SELECT `parent` FROM `item` WHERE `id` = `parent` {$star_sql} AND `contact-id` IN ( " . intval($cid) . " )) ";
            $o = '<h2>' . t('Contact: ') . $r[0]['name'] . '</h2>' . $o;
            if ($r[0]['network'] !== NETWORK_MAIL && $r[0]['network'] !== NETWORK_DFRN && $r[0]['network'] !== NETWORK_FACEBOOK && $r[0]['network'] !== NETWORK_DIASPORA && $r[0]['writable'] && !get_pconfig(local_user(), 'system', 'nowarn_insecure')) {
                notice(t('Private messages to this person are at risk of public disclosure.') . EOL);
            }
        } else {
            notice(t('Invalid contact.') . EOL);
            goaway($a->get_baseurl() . '/network');
            // NOTREACHED
        }
    }
    if (!$group && !$cid && !$update) {
        $o .= get_birthdays();
        $o .= get_events();
    }
    if (!$update) {
        // The special div is needed for liveUpdate to kick in for this page.
        // We only launch liveUpdate if you aren't filtering in some incompatible
        // way and also you aren't writing a comment (discovered in javascript).
        $o .= '<div id="live-network"></div>' . "\r\n";
        $o .= "<script> var profile_uid = " . $_SESSION['uid'] . "; var netargs = '" . substr($a->cmd, 8) . '?f=' . (x($_GET, 'cid') ? '&cid=' . $_GET['cid'] : '') . (x($_GET, 'search') ? '&search=' . $_GET['search'] : '') . (x($_GET, 'star') ? '&star=' . $_GET['star'] : '') . (x($_GET, 'order') ? '&order=' . $_GET['order'] : '') . (x($_GET, 'bmark') ? '&bmark=' . $_GET['bmark'] : '') . (x($_GET, 'liked') ? '&liked=' . $_GET['liked'] : '') . (x($_GET, 'conv') ? '&conv=' . $_GET['conv'] : '') . "'; var profile_page = " . $a->pager['page'] . "; </script>\r\n";
    }
    $sql_extra2 = $nouveau ? '' : " AND `item`.`parent` = `item`.`id` ";
    if (x($_GET, 'search')) {
        $search = escape_tags($_GET['search']);
        $sql_extra .= sprintf(" AND ( `item`.`body` REGEXP '%s' OR `item`.`tag` REGEXP '%s' ) ", dbesc(preg_quote($search)), dbesc('\\]' . preg_quote($search) . '\\['));
    }
    if ($conv) {
        $myurl = $a->get_baseurl() . '/profile/' . $a->user['nickname'];
        $myurl = substr($myurl, strpos($myurl, '://') + 3);
        $myurl = str_replace(array('www.', '.'), array('', '\\.'), $myurl);
        $diasp_url = str_replace('/profile/', '/u/', $myurl);
        $sql_extra .= sprintf(" AND `item`.`parent` IN (SELECT distinct(`parent`) from item where ( `author-link` regexp '%s' or `tag` regexp '%s' or tag regexp '%s' )) ", dbesc($myurl . '$'), dbesc($myurl . '\\]'), dbesc($diasp_url . '\\]'));
    }
    $r = q("SELECT COUNT(*) AS `total`\n\t\tFROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`\n\t\tWHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0\n\t\tAND `contact`.`blocked` = 0 AND `contact`.`pending` = 0\n\t\t{$sql_extra2}\n\t\t{$sql_extra} ", intval($_SESSION['uid']));
    if (count($r)) {
        $a->set_pager_total($r[0]['total']);
        $a->set_pager_itemspage(40);
    }
    if ($nouveau) {
        // "New Item View" - show all items unthreaded in reverse created date order
        $r = q("SELECT `item`.*, `item`.`id` AS `item_id`, \n\t\t\t`contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`, `contact`.`writable`,\n\t\t\t`contact`.`network`, `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`,\n\t\t\t`contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`\n\t\t\tFROM `item`, `contact`\n\t\t\tWHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0\n\t\t\tAND `contact`.`id` = `item`.`contact-id`\n\t\t\tAND `contact`.`blocked` = 0 AND `contact`.`pending` = 0\n\t\t\t{$sql_extra}\n\t\t\tORDER BY `item`.`received` DESC LIMIT %d ,%d ", intval($_SESSION['uid']), intval($a->pager['start']), intval($a->pager['itemspage']));
    } else {
        // Normal conversation view
        if ($order === 'post') {
            $ordering = "`created`";
        } else {
            $ordering = "`commented`";
        }
        // Fetch a page full of parent items for this page
        $r = q("SELECT `item`.`id` AS `item_id`, `contact`.`uid` AS `contact_uid`\n\t\t\tFROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`\n\t\t\tWHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0\n\t\t\tAND `contact`.`blocked` = 0 AND `contact`.`pending` = 0\n\t\t\tAND `item`.`parent` = `item`.`id`\n\t\t\t{$sql_extra}\n\t\t\tORDER BY `item`.{$ordering} DESC LIMIT %d ,%d ", intval(local_user()), intval($a->pager['start']), intval($a->pager['itemspage']));
        // Then fetch all the children of the parents that are on this page
        $parents_arr = array();
        $parents_str = '';
        if (count($r)) {
            foreach ($r as $rr) {
                $parents_arr[] = $rr['item_id'];
            }
            $parents_str = implode(', ', $parents_arr);
            $r = q("SELECT `item`.*, `item`.`id` AS `item_id`,\n\t\t\t\t`contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`, `contact`.`writable`,\n\t\t\t\t`contact`.`network`, `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`,\n\t\t\t\t`contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`\n\t\t\t\tFROM `item`, (SELECT `p`.`id`,`p`.`created`,`p`.`commented` FROM `item` AS `p` WHERE `p`.`parent`=`p`.`id`) as `parentitem`, `contact`\n\t\t\t\tWHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0\n\t\t\t\tAND `contact`.`id` = `item`.`contact-id`\n\t\t\t\tAND `contact`.`blocked` = 0 AND `contact`.`pending` = 0\n\t\t\t\tAND `item`.`parent` = `parentitem`.`id` AND `item`.`parent` IN ( %s )\n\t\t\t\t{$sql_extra}\n\t\t\t\tORDER BY `parentitem`.{$ordering} DESC, `parentitem`.`id` ASC, `item`.`gravity` ASC, `item`.`created` ASC ", intval(local_user()), dbesc($parents_str));
        }
    }
    // Set this so that the conversation function can find out contact info for our wall-wall items
    $a->page_contact = $a->contact;
    $mode = $nouveau ? 'network-new' : 'network';
    $o .= conversation($a, $r, $mode, $update);
    if (!$update) {
        $o .= paginate($a);
    }
    return $o;
}