コード例 #1
0
function forum_icon($instance, $temp)
{
    $icon = '';
    $return = '';
    /* Set the forum Icon */
    if (isset($_COOKIE['forums'])) {
        //$forums				= $_COOKIE['forums'] != NULL && $_COOKIE['forums'] != '' ? (!unserialize($_COOKIE['forums']) ? array() : unserialize($_COOKIE['forums'])) : array();
        $forums = array();
        if (isset($forums[$temp['id']])) {
            /* Get the value of the forum cookie */
            $cookie_val = $forums[$temp['id']];
            /* If there are threads stored in this forum or not */
            if (is_array($cookie_val) && !empty($cookie_val)) {
                $icon = 'on';
            } else {
                $icon = 'off';
            }
        } else {
            if (strftime("%m%d%y", $temp['topic_created']) == strftime("%m%d%y", bbtime()) && $temp['topic_uid'] != $instance->user['id']) {
                $icon = 'on';
            } else {
                $icon = 'off';
            }
            $forums[$temp['id']] = array();
            $forums = serialize($forums);
            $return = $temp['id'];
        }
    } else {
        /* If the last thread post time is equal to today */
        if (strftime("%m%d%y", $temp['topic_created']) == strftime("%m%d%y", bbtime())) {
            $icon = 'on';
        } else {
            $icon = 'off';
        }
        $forums = array($temp['id'] => $temp);
        $forums = serialize($forums);
        $return = $temp['id'];
    }
    /* Check if this user's perms are less than is needed to post in this forum */
    if (@$instance->user['maps']['forums'][$temp['id']]['can_add'] > $instance->user['perms']) {
        $icon .= '_lock';
    }
    /* Return the icon text to add to the IMG tag */
    return array($icon, $return);
}
コード例 #2
0
ファイル: calendar.php プロジェクト: BackupTheBerlios/k4bb
 /**
  * month_array
  * @author Peter Goodman
  * @param month int 1-12 month
  * @param year int year of whatever month the person is looking at
  */
 function month_array($month, $year)
 {
     $prev_month = bbtime(mktime(0, 0, 0, $month - 1, 0, $year));
     $this_month = bbtime(mktime(0, 0, 0, $month, 0, $year));
     $next_month = bbtime(mktime(0, 0, 0, $month + 1, 0, $year));
     $days = array();
     $num_days = date("t", $month);
     $num_days_prev_month = date("t", $prev_month);
     $num_days_next_month = date("t", $next_month);
     /* Pad the start of the days array with the last days of the previous month */
     if (strftime("%w", $this_month) > 0) {
         for ($i = $num_days_prev_month - (strftime("%w", $this_month) + 1); $i <= strftime("%w", $this_month) + 1; $i++) {
             $days[] = array('day' => strftime("%d", bbtime(mktime(0, 0, 0, $month - 1, $i, $year))), 'week' => strftime("%U", $prev_month), 'month' => strftime("%m", $prev_month), 'year' => strftime("%Y", $prev_month));
         }
     }
     /* Go through the normal days of our month */
     for ($i = 1; $i <= $num_days; $i++) {
         for ($i = 1; $i <= $num_days; $i++) {
             $days[] = array('day' => strftime("%d", bbtime(mktime(0, 0, 0, $month, $i, $year))), 'week' => strftime("%U", $this_month), 'month' => strftime("%m", $this_month), 'year' => strftime("%Y", $this_month));
         }
     }
     /* Pad the end of the days array with the first days of the next month */
     if (strftime("%w", bbtime(mktime(0, 0, 0, $month, $num_days, $year))) < 6) {
         for ($i = 1; $i <= 7 - (strftime("%w", $next_month) + 1); $i++) {
             $days[] = array('day' => strftime("%d", bbtime(mktime(0, 0, 0, $month + 1, $i, $year))), 'week' => strftime("%U", $next_month), 'month' => strftime("%m", $next_month), 'year' => strftime("%Y", $next_month));
         }
     }
     return $days;
 }
コード例 #3
0
ファイル: index.php プロジェクト: BackupTheBerlios/k4bb
 function Execute(&$template, $request, &$dba, &$session, &$user)
 {
     //$dba->executeUpdate("UPDATE ". USERINFO ." SET msn = '*****@*****.**' WHERE user_id = 1");
     global $_DATASTORE, $_USERGROUPS, $_SESS;
     //$str = "[poll][question=hello?][answer]maybe[/answer][answer]good[/answer][/question][question=yes][answer]maybe[/answer][answer]good[/answer][/question][/poll]";
     //$dba->executeUpdate("UPDATE k4_topics set display=1");
     /*
     
     //echo str_replace('"','\"', serialize(array('spiderstrings'=>'googlebot|lycos|ask jeeves|scooter|fast-webcrawler|slurp@inktomi|turnitinbot','spidernames'=>array('googlebot' => 'Google','lycos' => 'Lycos','ask jeeves' => 'Ask Jeeves','scooter' => 'Altavista','fast-webcrawler' => 'AllTheWeb','slurp@inktomi' => 'Inktomi','turnitinbot' => 'Turnitin.com'))));
     
     
     $bbcode	= &new BBCodex(&$user, $text, 2, TRUE, TRUE, TRUE, TRUE);
     
     $text = $bbcode->parse();
     
     echo $text;
     echo '<br />';
     $bbcode	= &new BBCodex(&$user, $text, 2, TRUE, TRUE, TRUE, TRUE);
     
     $text = $bbcode->revert();
     
     echo '<textarea rows="5" cols="100">'. $text .'</textarea>';
     */
     /* Set the breadcrumbs bit */
     $template = BreadCrumbs($template, $template->getVar('L_HOME'));
     //$dba->executeUpdate("update k4_information set row_level = 3 where row_type = 2 and parent_id = 2");
     /*$dba->executeQuery("delete from k4_information");
     		$dba->executeQuery("delete from k4_categories");
     		$dba->executeQuery("delete from k4_forums");
     		$dba->executeQuery("delete from k4_topics");
     		$dba->executeQuery("delete from k4_replies");
     		$dba->executeQuery("delete from k4_maps");
     		$dba->executeQuery("delete from k4_topicqueue");
     		$dba->executeQuery("delete from k4_mailqueue");
     		$dba->executeUpdate("UPDATE ". USERINFO ." SET num_posts = 0");*/
     //print_r($dba->getRow("SELECT sql, name, type FROM sqlite_master WHERE tbl_name = '". USERINFO ."' ORDER BY type DESC"));
     //$dba->executeQuery("delete from ". PROFILEFIELDS ." where name = 'field6'");
     /* Set the Categories list */
     $categories =& new CategoriesIterator(NULL);
     $template->setList('categories', $categories);
     if (!is_a($session['user'], 'Member')) {
         $template->setVar('welcome_title', sprintf($template->getVar('L_WELCOMETITLE'), $template->getVar('bbtitle')));
         $template->show('welcome_msg');
         $template->setFile('quick_login', 'login_form_quick.html');
     }
     /* Set the online users list */
     $online_users =& new OnlineUsersIterator(NULL);
     $template->setList('online_users', $online_users);
     $newest_user = $dba->getRow("SELECT name, id FROM " . USERS . " ORDER BY id DESC LIMIT 1");
     $expired = time() - ini_get('session.gc_maxlifetime');
     $stats = array('num_online_members' => Globals::getGlobal('num_online_members'), 'num_invisible' => Globals::getGlobal('num_online_invisible'), 'num_topics' => intval($_DATASTORE['forumstats']['num_topics']), 'num_replies' => intval($_DATASTORE['forumstats']['num_replies']), 'num_members' => intval($_DATASTORE['forumstats']['num_members']), 'num_online_total' => $dba->getValue("SELECT COUNT(*) FROM " . SESSIONS . " WHERE seen >= {$expired}") + iif(is_a($session['user'], 'Guest') && $_SESS->is_new, 1, 0), 'newest_uid' => $newest_user['id'], 'newest_user' => $newest_user['name']);
     $stats['num_guests'] = $stats['num_online_total'] - $stats['num_online_members'] - $stats['num_invisible'];
     $template->setVar('num_online_members', $stats['num_online_members']);
     $template->setVar('newest_member', sprintf($template->getVar('L_NEWESTMEMBER'), $stats['newest_uid'], $stats['newest_user']));
     $template->setVar('total_users', sprintf($template->getVar('L_TOTALUSERS'), $stats['num_members']));
     $template->setVar('total_posts', sprintf($template->getVar('L_TOTALPOSTS'), $stats['num_topics'] + $stats['num_replies'], $stats['num_topics'], $stats['num_replies']));
     $template->setVar('online_stats', sprintf($template->getVar('L_ONLINEUSERSTATS'), $stats['num_online_total'], $stats['num_online_members'], $stats['num_guests'], $stats['num_invisible']));
     $template->setVar('most_users_ever', sprintf($template->getVar('L_MOSTUSERSEVERONLINE'), $_DATASTORE['maxloggedin']['maxonline'], date("n/j/Y", bbtime($_DATASTORE['maxloggedin']['maxonlinedate'])), date("g:ia", bbtime($_DATASTORE['maxloggedin']['maxonlinedate']))));
     if ($stats['num_online_total'] >= $_DATASTORE['maxloggedin']['maxonline']) {
         $maxloggedin = array('maxonline' => $stats['num_online_total'], 'maxonlinedate' => time());
         $query = $dba->prepareStatement("UPDATE " . DATASTORE . " SET data = ? WHERE varname = ?");
         $query->setString(1, serialize($maxloggedin));
         $query->setString(2, 'maxloggedin');
         $query->executeUpdate();
         if (!@touch(CACHE_FILE, time() - 86460)) {
             @unlink(CACHE_FILE);
         }
     }
     /* Show the forum status icons */
     $template->show('forum_status_icons');
     $groups = array();
     /* Set the usergroups legend list */
     foreach ($_USERGROUPS as $group) {
         if ($group['display_legend'] == 1) {
             $groups[] = $group;
         }
     }
     $groups =& new FAArrayIterator($groups);
     $template->setList('usergroups_legend', $groups);
     /* Set the forums template to content variable */
     $template->setFile('content', 'forums.html');
     $template->setFile('forum_info', 'forum_info.html');
     return TRUE;
 }
コード例 #4
0
function bbendofday()
{
    $timenow = bbtime();
    $hour_now = (23 - date("G", $timenow)) * 3600;
    $min_now = (59 - date("i", $timenow)) * 60;
    $sec_now = 59 - date("s", $timenow);
    $endofday = $hour_now + $min_now + $sec_now;
    return time() + $endofday;
}
コード例 #5
0
ファイル: global.php プロジェクト: BackupTheBerlios/k4bb-svn
 function execute(&$action, &$request)
 {
     global $_LANG, $_BANNEDUSERIDS, $_BANNEDUSERIPS;
     $banned = FALSE;
     /**
      * User ID banning
      */
     if ($request['user']->isMember()) {
         // this user is banned
         if (in_array($request['user']->get('id'), is_array($_BANNEDUSERIDS) ? $_BANNEDUSERIDS : array()) || $request['user']->get('banned') == 1) {
             $ban = $request['dba']->getRow("SELECT * FROM " . K4BANNEDUSERS . " WHERE user_id = " . intval($request['user']->get('id')));
             if (is_array($ban) && !empty($ban)) {
                 if ($ban['expiry'] > time()) {
                     $action = new K4InformationAction(new K4LanguageElement('L_BANNEDUSERID', $request['user']->get('name'), $ban['reason'], $ban['expiry'] == 0 ? $_LANG['L_YOURDEATH'] : strftime("%m/%d/%Y", bbtime($ban['expiry']))), 'content', FALSE);
                     $banned = TRUE;
                 } else {
                     $request['dba']->executeUpdate("DELETE FROM " . K4BANNEDUSERS . " WHERE user_id = " . intval($request['user']->get('id')));
                 }
             } else {
                 // TODO: should I put anything here...?
             }
         }
     }
     /**
      * User IP banning
      */
     //if(in_array(USER_IP, $_BANNEDUSERIPS) && !$banned) {
     if (is_array($_BANNEDUSERIPS)) {
         foreach ($_BANNEDUSERIPS as $ip) {
             if (preg_match('~' . preg_quote($ip) . '~', USER_IP)) {
                 $ban = $request['dba']->getRow("SELECT * FROM " . K4BANNEDUSERS . " WHERE user_ip = '" . $request['dba']->quote(USER_IP) . "'");
                 $action = new K4InformationAction(new K4LanguageElement('L_BANNEDUSERIP', $ban['reason'], $ban['expiry'] == 0 ? $_LANG['L_YOURDEATH'] : strftime("%m/%d/%Y", bbtime($ban['expiry']))), 'content', FALSE);
             }
         }
     }
 }
コード例 #6
0
ファイル: index.php プロジェクト: BackupTheBerlios/k4bb-svn
 function execute(&$request)
 {
     //$action = new AdminCSSRequestAction();
     //return $action->execute($request);
     global $_DATASTORE, $_USERGROUPS, $_QUERYPARAMS;
     // Member/Guest specifics
     if (!$request['user']->isMember()) {
         $request['template']->setVar('welcome_title', sprintf($request['template']->getVar('L_WELCOMETITLE'), $request['template']->getVar('bbtitle')));
         $request['template']->setFile('quick_login', 'login_form_quick.html');
         $request['template']->setVisibility('welcome_msg', TRUE);
     }
     // The content panel
     $request['template']->setFile('content', 'forums.html');
     $forums =& new K4ForumsIterator($request['dba'], "SELECT * FROM " . K4FORUMS . " WHERE parent_id=0 ORDER BY row_order ASC");
     //$categories	= &new K4ForumsIterator($request['dba'], "SELECT * FROM ". K4FORUMS ." WHERE row_type=". CATEGORY ." AND parent_id = 0 ORDER BY row_order ASC");
     $request['template']->setVisibility('no_forums', !$forums->hasNext() ? TRUE : FALSE);
     $request['template']->setList('tlforums', $forums);
     //$request['template']->setList('categories', $categories);
     // Set the online users list
     $user_extra = $request['user']->isMember() ? ' OR (seen > 0 AND user_id = ' . intval($request['user']->get('id')) . ')' : '';
     $expired = time() - ini_get('session.gc_maxlifetime');
     $online_users = $request['dba']->executeQuery("SELECT * FROM " . K4SESSIONS . " WHERE ((seen >= {$expired}) {$user_extra}) AND ((user_id > 0) OR (user_id = 0 AND name <> '')) GROUP BY name ORDER BY seen DESC");
     $online_users =& new K4OnlineUsersIterator($request['dba'], '', $online_users);
     $request['template']->setList('online_users', $online_users);
     //$newest_user						= $request['dba']->getRow("SELECT name, id FROM ". K4USERS ." ORDER BY id DESC LIMIT 1");
     $expired = time() - ini_get('session.gc_maxlifetime');
     //print_r($_DATASTORE); exit;
     $stats = array('num_online_members' => intval(Globals::getGlobal('num_online_members')), 'num_invisible' => intval(Globals::getGlobal('num_online_invisible')), 'num_topics' => intval($_DATASTORE['forumstats']['num_topics']), 'num_replies' => intval($_DATASTORE['forumstats']['num_replies']), 'num_members' => intval($_DATASTORE['forumstats']['num_members']), 'num_guests' => $request['dba']->getValue("SELECT COUNT(*) FROM " . K4SESSIONS . " WHERE seen >= {$expired} AND user_id=0"), 'newest_uid' => $_DATASTORE['forumstats']['newest_user_id'], 'newest_user' => $_DATASTORE['forumstats']['newest_user_name']);
     $stats['num_online_total'] = $stats['num_online_members'] + $stats['num_invisible'] + $stats['num_guests'];
     $request['template']->setVar('num_online_members', $stats['num_online_members']);
     $request['template']->setVar('newest_member', sprintf($request['template']->getVar('L_NEWESTMEMBER'), $stats['newest_uid'], $stats['newest_user']));
     $request['template']->setVar('total_users', sprintf($request['template']->getVar('L_TOTALUSERS'), $stats['num_members']));
     $request['template']->setVar('total_posts', sprintf($request['template']->getVar('L_TOTALPOSTS'), $stats['num_topics'] + $stats['num_replies'], $stats['num_topics'], $stats['num_replies']));
     $request['template']->setVar('online_stats', sprintf($request['template']->getVar('L_ONLINEUSERSTATS'), $stats['num_online_total'], $stats['num_online_members'], $stats['num_guests'], $stats['num_invisible']));
     $request['template']->setVar('most_users_ever', sprintf($request['template']->getVar('L_MOSTUSERSEVERONLINE'), $_DATASTORE['maxloggedin']['maxonline'], date("n/j/Y", bbtime($_DATASTORE['maxloggedin']['maxonlinedate'])), date("g:ia", bbtime($_DATASTORE['maxloggedin']['maxonlinedate']))));
     if ($stats['num_online_total'] >= $_DATASTORE['maxloggedin']['maxonline']) {
         $maxloggedin = array('maxonline' => $stats['num_online_total'], 'maxonlinedate' => time());
         $query = $request['dba']->prepareStatement("UPDATE " . K4DATASTORE . " SET data = ? WHERE varname = ?");
         $query->setString(1, serialize($maxloggedin));
         $query->setString(2, 'maxloggedin');
         $query->executeUpdate();
         reset_cache('datastore');
     }
     // Show the forum status icons
     $request['template']->setVisibility('forum_status_icons', TRUE);
     $request['template']->setFile('content_extra', 'forum_status_icons.html');
     if ($request['user']->get('perms') >= get_map('can_see_board', 'can_add', array())) {
         $request['template']->setVisibility('forum_midsection', TRUE);
         $groups = array();
         // Set the usergroups legend list
         if (is_array($_USERGROUPS) && !empty($_USERGROUPS)) {
             foreach ($_USERGROUPS as $group) {
                 if ($group['display_legend'] == 1) {
                     $group['U_USERGROUPURL'] = K4Url::getUserGroupUrl($group['id']);
                     $groups[] = $group;
                 }
             }
         }
     }
     $groups =& new FAArrayIterator($groups);
     $request['template']->setList('usergroups_legend', $groups);
     /* Set the forum stats */
     $request['template']->setFile('forum_info', 'forum_info.html');
     $request['template']->setVar('can_see_board', get_map('can_see_board', 'can_view', array()));
     k4_bread_crumbs($request['template'], $request['dba'], 'L_HOME');
 }