';
if (!$news['is_last'])
echo '
';
}
}
// Show the most recent events.
function ssi_recentEvents($max_events = 7, $output_method = 'echo')
{
global $db_prefix, $user_info, $scripturl, $modSettings, $txt, $sc, $ID_MEMBER;
// Find all events which are happening in the near future that the member can see.
$request = db_query("
SELECT
cal.ID_EVENT, cal.startDate, cal.endDate, cal.title, cal.ID_MEMBER, cal.ID_TOPIC,
cal.ID_BOARD, t.ID_FIRST_MSG
FROM {$db_prefix}calendar AS cal
LEFT JOIN {$db_prefix}boards AS b ON (b.ID_BOARD = cal.ID_BOARD)
LEFT JOIN {$db_prefix}topics AS t ON (t.ID_TOPIC = cal.ID_TOPIC)
WHERE cal.startDate <= '" . strftime('%Y-%m-%d', forum_time(false)) . "'
AND cal.endDate >= '" . strftime('%Y-%m-%d', forum_time(false)) . "'
AND (cal.ID_BOARD = 0 OR $user_info[query_see_board])
ORDER BY cal.startDate DESC
LIMIT $max_events", __FILE__, __LINE__);
$return = array();
$duplicates = array();
while ($row = mysql_fetch_assoc($request))
{
// Check if we've already come by an event linked to this same topic with the same title... and don't display it if we have.
if (!empty($duplicates[$row['title'] . $row['ID_TOPIC']]))
continue;
// Censor the title.
censorText($row['title']);
if ($row['startDate'] < strftime('%Y-%m-%d', forum_time(false)))
$date = strftime('%Y-%m-%d', forum_time(false));
else
$date = $row['startDate'];
$return[$date][] = array(
'id' => $row['ID_EVENT'],
'title' => $row['title'],
'can_edit' => allowedTo('calendar_edit_any') || ($row['ID_MEMBER'] == $ID_MEMBER && allowedTo('calendar_edit_own')),
'modify_href' => $scripturl . '?action=' . ($row['ID_BOARD'] == 0 ? 'calendar;sa=post;' : 'post;msg=' . $row['ID_FIRST_MSG'] . ';topic=' . $row['ID_TOPIC'] . '.0;calendar;') . 'eventid=' . $row['ID_EVENT'] . ';sesc=' . $sc,
'href' => $row['ID_BOARD'] == 0 ? '' : $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0',
'link' => $row['ID_BOARD'] == 0 ? $row['title'] : '' . $row['title'] . '',
'start_date' => $row['startDate'],
'end_date' => $row['endDate'],
'is_last' => false
);
// Let's not show this one again, huh?
$duplicates[$row['title'] . $row['ID_TOPIC']] = true;
}
mysql_free_result($request);
foreach ($return as $mday => $array)
$return[$mday][count($array) - 1]['is_last'] = true;
if ($output_method != 'echo' || empty($return))
return $return;
// Well the output method is echo.
echo '
' . $txt['calendar4'] . ' ';
foreach ($return as $mday => $array)
foreach ($array as $event)
{
if ($event['can_edit'])
echo '
* ';
echo '
' . $event['link'] . (!$event['is_last'] ? ', ' : '');
}
}
// Load the calendar information. (internal...)
function smf_loadCalendarInfo()
{
global $modSettings, $context, $user_info, $scripturl, $sc, $ID_MEMBER;
// Get the current forum time and check whether the statistics are up to date.
if (!isset($modSettings['cal_today_updated']) || $modSettings['cal_today_updated'] != strftime('%Y%m%d', forum_time(false)))
updateStats('calendar');
// Load the holidays for today...
if (isset($modSettings['cal_today_holiday']))
$holidays = unserialize($modSettings['cal_today_holiday']);
// ... the birthdays for today...
if (isset($modSettings['cal_today_birthday']))
$bday = unserialize($modSettings['cal_today_birthday']);
// ... and the events for today.
if (isset($modSettings['cal_today_event']))
$events = unserialize($modSettings['cal_today_event']);
// No events, birthdays, or holidays... don't show anything.
if (empty($holidays) && empty($bday) && empty($events))
return false;
// This shouldn't be less than one!
if (empty($modSettings['cal_days_for_index']) || $modSettings['cal_days_for_index'] < 1)
$days_for_index = 86400;
else
$days_for_index = $modSettings['cal_days_for_index'] * 86400;
$context['calendar_only_today'] = $modSettings['cal_days_for_index'] == 1;
// Get the current member time/date.
$now = forum_time();
// This is used to show the "how-do-I-edit" help.
$context['calendar_can_edit'] = allowedTo('calendar_edit_any');
// Holidays between now and now + days.
$context['calendar_holidays'] = array();
for ($i = $now; $i < $now + $days_for_index; $i += 86400)
{
if (isset($holidays[strftime('%Y-%m-%d', $i)]))
$context['calendar_holidays'] = array_merge($context['calendar_holidays'], $holidays[strftime('%Y-%m-%d', $i)]);
}
// Happy Birthday, guys and gals!
$context['calendar_birthdays'] = array();
for ($i = $now; $i < $now + $days_for_index; $i += 86400)
{
if (isset($bday[strftime('%Y-%m-%d', $i)]))
{
foreach ($bday[strftime('%Y-%m-%d', $i)] as $index => $dummy)
$bday[strftime('%Y-%m-%d', $i)][$index]['is_today'] = (strftime('%Y-%m-%d', $i)) == strftime('%Y-%m-%d', forum_time());
$context['calendar_birthdays'] = array_merge($context['calendar_birthdays'], $bday[strftime('%Y-%m-%d', $i)]);
}
}
$context['calendar_events'] = array();
$duplicates = array();
for ($i = $now; $i < $now + $days_for_index; $i += 86400)
{
if (isset($events[strftime('%Y-%m-%d', $i)]))
foreach ($events[strftime('%Y-%m-%d', $i)] as $ev => $event)
{
if (empty($event['topic']) || (count(array_intersect($user_info['groups'], $event['allowed_groups'])) != 0 || allowedTo('admin_forum')))
{
if (isset($duplicates[$events[strftime('%Y-%m-%d', $i)][$ev]['topic'] . $events[strftime('%Y-%m-%d', $i)][$ev]['title']]))
{
unset($events[strftime('%Y-%m-%d', $i)][$ev]);
continue;
}
$this_event = &$events[strftime('%Y-%m-%d', $i)][$ev];
$this_event['href'] = $this_event['topic'] == 0 ? '' : $scripturl . '?topic=' . $this_event['topic'] . '.0';
$this_event['link'] = $this_event['topic'] == 0 ? $this_event['title'] : '' . $this_event['title'] . '';
$this_event['modify_href'] = $scripturl . '?action=' . ($this_event['topic'] == 0 ? 'calendar;sa=post;' : 'post;msg=' . $this_event['msg'] . ';topic=' . $this_event['topic'] . '.0;calendar;') . 'eventid=' . $this_event['id'] . ';sesc=' . $sc;
$this_event['can_edit'] = allowedTo('calendar_edit_any') || ($this_event['poster'] == $ID_MEMBER && allowedTo('calendar_edit_own'));
$this_event['is_today'] = (strftime('%Y-%m-%d', $i)) == strftime('%Y-%m-%d', forum_time());
$this_event['date'] = strftime('%Y-%m-%d', $i);
$duplicates[$this_event['topic'] . $this_event['title']] = true;
}
else
unset($events[strftime('%Y-%m-%d', $i)][$ev]);
}
if (isset($events[strftime('%Y-%m-%d', $i)]))
$context['calendar_events'] = array_merge($context['calendar_events'], $events[strftime('%Y-%m-%d', $i)]);
}
for ($i = 0, $n = count($context['calendar_birthdays']); $i < $n; $i++)
$context['calendar_birthdays'][$i]['is_last'] = !isset($context['calendar_birthdays'][$i + 1]);
for ($i = 0, $n = count($context['calendar_events']); $i < $n; $i++)
$context['calendar_events'][$i]['is_last'] = !isset($context['calendar_events'][$i + 1]);
return !empty($context['calendar_holidays']) || !empty($context['calendar_birthdays']) || !empty($context['calendar_events']);
}
// Check the passed ID_MEMBER/password. If $is_username is true, treats $id as a username.
function ssi_checkPassword($id = null, $password = null, $is_username = false)
{
global $db_prefix, $sourcedir;
// If $id is null, this was most likely called from a query string and should do nothing.
if ($id === null)
return;
$request = db_query("
SELECT passwd, memberName, is_activated
FROM {$db_prefix}members
WHERE " . ($is_username ? 'memberName' : 'ID_MEMBER') . " = '$id'
LIMIT 1", __FILE__, __LINE__);
list ($pass, $user, $active) = mysql_fetch_row($request);
mysql_free_result($request);
return sha1(strtolower($user) . $password) == $pass && $active == 1;
}
?>
<< :: SMF SSI.php 1.1 :: >>
SMF SSI.php Functions
Current Version: 1.1
This file is used to demonstrate the capabilities of SSI.php using PHP include functions.
The examples show the include tag, then the results of it. Examples are separated by horizontal rules.
To use SSI.php in your page add at the very top of your page before the <html> tag on line 1: