mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-31 14:00:31 +02:00
Well, here are all my changes ... don't blame me if things break :D
git-svn-id: file:///svn/phpbb/trunk@2923 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
//
|
||||
// Authentication plug-ins is largely down to
|
||||
// Sergey Kanareykin, our thanks to him.
|
||||
// Sergey Kanareykin, our thanks to him.
|
||||
//
|
||||
function login_ldap(&$username, &$password)
|
||||
{
|
||||
@@ -13,7 +13,7 @@ function login_ldap(&$username, &$password)
|
||||
return 'LDAP extension not available';
|
||||
}
|
||||
|
||||
if ( !($ldap = @ldap_connect($board_config['ldap_server'])) )
|
||||
if ( !($ldap = @ldap_connect($board_config['ldap_server'])) )
|
||||
{
|
||||
return 'Could not connect to LDAP server';
|
||||
}
|
||||
@@ -21,26 +21,30 @@ function login_ldap(&$username, &$password)
|
||||
$search = @ldap_search($ldap, $board_config['ldap_base_dn'], $board_config['ldap_uid'] . '=' . $username, array($board_config['ldap_uid']));
|
||||
$result = @ldap_get_entries($ldap, $search);
|
||||
|
||||
if ( is_array($result) && count($result) > 1 )
|
||||
if ( is_array($result) && count($result) > 1 )
|
||||
{
|
||||
if ( @ldap_bind($ldap, $result[0]['dn'], $password) )
|
||||
if ( @ldap_bind($ldap, $result[0]['dn'], $password) )
|
||||
{
|
||||
@ldap_close($ldap);
|
||||
|
||||
$sql = "SELECT user_id, username, user_password, user_email, user_active
|
||||
$sql = "SELECT user_id, username, user_password, user_email, user_active
|
||||
FROM " . USERS_TABLE . "
|
||||
WHERE username = '" . str_replace("\'", "''", $username) . "'";
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
return ( $row = $db->sql_fetchrow($result) ) ? $row : false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ldap_close($ldap);
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//
|
||||
// This function is used to output any required fields in the authentication
|
||||
// admin panel. It also defines any required configuration table fields.
|
||||
//
|
||||
function admin_ldap(&$new)
|
||||
{
|
||||
global $lang;
|
||||
@@ -59,7 +63,7 @@ function admin_ldap(&$new)
|
||||
<td class="row2"><input type="text" size="40" name="ldap_uid" value="<?php echo $new['ldap_uid']; ?>" /></td>
|
||||
</tr>
|
||||
<?php
|
||||
|
||||
|
||||
//
|
||||
// These are fields required in the config table
|
||||
//
|
||||
@@ -67,4 +71,16 @@ function admin_ldap(&$new)
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// Would be nice to allow syncing of 'appropriate' data when user updates
|
||||
// their username, password, etc. ... should be up to the plugin what data
|
||||
// is updated.
|
||||
//
|
||||
// $mode perhaps being one of NEW, UPDATE, DELETE
|
||||
//
|
||||
function usercp_ldap($mode)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
?>
|
@@ -88,7 +88,7 @@ class emailer
|
||||
$template_lang = $board_config['default_lang'];
|
||||
}
|
||||
|
||||
$this->tpl_file = $phpbb_root_path . 'language/lang_' . $template_lang . '/email/' . $template_file . '.tpl';
|
||||
$this->tpl_file = $phpbb_root_path . 'language/lang_' . $template_lang . '/email/' . $template_file . '.txt';
|
||||
if ( !file_exists($this->tpl_file) )
|
||||
{
|
||||
message_die(ERROR, 'Could not find email template file ' . $template_file);
|
||||
@@ -177,7 +177,7 @@ class emailer
|
||||
// Add date and encoding type
|
||||
//
|
||||
$universal_extra = "MIME-Version: 1.0\nContent-type: text/plain; charset=" . $this->encoding . "\nContent-transfer-encoding: 8bit\nDate: " . gmdate('D, d M Y H:i:s', time()) . " UT\n";
|
||||
$this->extra_headers = $universal_extra . $this->extra_headers;
|
||||
$this->extra_headers = $universal_extra . $this->extra_headers;
|
||||
|
||||
$result = ( $this->use_smtp ) ? smtpmail($this->address, $this->subject, $this->msg, $this->extra_headers) : @mail($this->address, $this->subject, $this->msg, $this->extra_headers);
|
||||
|
||||
@@ -295,24 +295,24 @@ class emailer
|
||||
|
||||
//
|
||||
// This function has been modified as provided
|
||||
// by SirSir to allow multiline responses when
|
||||
// by SirSir to allow multiline responses when
|
||||
// using SMTP Extensions
|
||||
//
|
||||
function server_parse($socket, $response)
|
||||
{
|
||||
while ( substr($server_response,3,1) != ' ' )
|
||||
{
|
||||
if( !( $server_response = fgets($socket, 256) ) )
|
||||
{
|
||||
message_die(ERROR, 'Could not get mail server response codes');
|
||||
}
|
||||
}
|
||||
function server_parse($socket, $response)
|
||||
{
|
||||
while ( substr($server_response,3,1) != ' ' )
|
||||
{
|
||||
if( !( $server_response = fgets($socket, 256) ) )
|
||||
{
|
||||
message_die(ERROR, 'Could not get mail server response codes');
|
||||
}
|
||||
}
|
||||
|
||||
if( !( substr($server_response, 0, 3) == $response ) )
|
||||
{
|
||||
message_die(ERROR, "Ran into problems sending Mail. Response: $server_response");
|
||||
}
|
||||
}
|
||||
if( !( substr($server_response, 0, 3) == $response ) )
|
||||
{
|
||||
message_die(ERROR, "Ran into problems sending Mail. Response: $server_response");
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Function: smtpmail
|
||||
@@ -403,25 +403,25 @@ function smtpmail($mail_to, $subject, $message, $headers = '')
|
||||
server_parse($socket, "220");
|
||||
|
||||
if( !empty($board_config['smtp_username']) && !empty($board_config['smtp_password']) )
|
||||
{
|
||||
// Send the RFC2554 specified EHLO.
|
||||
{
|
||||
// Send the RFC2554 specified EHLO.
|
||||
// This improved as provided by SirSir to accomodate
|
||||
// both SMTP AND ESMTP capable servers
|
||||
fputs($socket, "EHLO " . $board_config['smtp_host'] . "\r\n");
|
||||
server_parse($socket, "250");
|
||||
fputs($socket, "EHLO " . $board_config['smtp_host'] . "\r\n");
|
||||
server_parse($socket, "250");
|
||||
|
||||
fputs($socket, "AUTH LOGIN\r\n");
|
||||
server_parse($socket, "334");
|
||||
fputs($socket, base64_encode($board_config['smtp_username']) . "\r\n");
|
||||
server_parse($socket, "334");
|
||||
fputs($socket, base64_encode($board_config['smtp_password']) . "\r\n");
|
||||
server_parse($socket, "235");
|
||||
}
|
||||
else
|
||||
{
|
||||
// Send the RFC821 specified HELO.
|
||||
fputs($socket, "HELO " . $board_config['smtp_host'] . "\r\n");
|
||||
server_parse($socket, "250");
|
||||
fputs($socket, "AUTH LOGIN\r\n");
|
||||
server_parse($socket, "334");
|
||||
fputs($socket, base64_encode($board_config['smtp_username']) . "\r\n");
|
||||
server_parse($socket, "334");
|
||||
fputs($socket, base64_encode($board_config['smtp_password']) . "\r\n");
|
||||
server_parse($socket, "235");
|
||||
}
|
||||
else
|
||||
{
|
||||
// Send the RFC821 specified HELO.
|
||||
fputs($socket, "HELO " . $board_config['smtp_host'] . "\r\n");
|
||||
server_parse($socket, "250");
|
||||
}
|
||||
|
||||
// From this point onward most server response codes should be 250
|
||||
|
@@ -44,8 +44,8 @@ foreach ($forum_rows as $row)
|
||||
));
|
||||
unset($stored_cat);
|
||||
}
|
||||
|
||||
if ($acl->get_acl($forum_id, 'forum', 'list'))
|
||||
|
||||
if ($auth->get_acl($forum_id, 'forum', 'list'))
|
||||
{
|
||||
switch ($forum_status)
|
||||
{
|
||||
|
@@ -165,15 +165,15 @@ function get_moderators(&$forum_moderators, $forum_id = false)
|
||||
//
|
||||
function get_forum_rules($mode, &$rules, &$forum_id)
|
||||
{
|
||||
global $SID, $acl, $lang, $phpEx;
|
||||
global $SID, $auth, $lang, $phpEx;
|
||||
|
||||
$rules .= ( ( $acl->get_acl($forum_id, 'forum', 'post') ) ? $lang['Rules_post_can'] : $lang['Rules_post_cannot'] ) . '<br />';
|
||||
$rules .= ( ( $acl->get_acl($forum_id, 'forum', 'reply') ) ? $lang['Rules_reply_can'] : $lang['Rules_reply_cannot'] ) . '<br />';
|
||||
$rules .= ( ( $acl->get_acl($forum_id, 'forum', 'edit') ) ? $lang['Rules_edit_can'] : $lang['Rules_edit_cannot'] ) . '<br />';
|
||||
$rules .= ( ( $acl->get_acl($forum_id, 'forum', 'delete') || $acl->get_acl($forum_id, 'mod', 'delete') ) ? $lang['Rules_delete_can'] : $lang['Rules_delete_cannot'] ) . '<br />';
|
||||
$rules .= ( ( $acl->get_acl($forum_id, 'forum', 'attach') ) ? $lang['Rules_attach_can'] : $lang['Rules_attach_cannot'] ) . '<br />';
|
||||
$rules .= ( ( $auth->get_acl($forum_id, 'forum', 'post') ) ? $lang['Rules_post_can'] : $lang['Rules_post_cannot'] ) . '<br />';
|
||||
$rules .= ( ( $auth->get_acl($forum_id, 'forum', 'reply') ) ? $lang['Rules_reply_can'] : $lang['Rules_reply_cannot'] ) . '<br />';
|
||||
$rules .= ( ( $auth->get_acl($forum_id, 'forum', 'edit') ) ? $lang['Rules_edit_can'] : $lang['Rules_edit_cannot'] ) . '<br />';
|
||||
$rules .= ( ( $auth->get_acl($forum_id, 'forum', 'delete') || $auth->get_acl($forum_id, 'mod', 'delete') ) ? $lang['Rules_delete_can'] : $lang['Rules_delete_cannot'] ) . '<br />';
|
||||
$rules .= ( ( $auth->get_acl($forum_id, 'forum', 'attach') ) ? $lang['Rules_attach_can'] : $lang['Rules_attach_cannot'] ) . '<br />';
|
||||
|
||||
if ( $acl->get_acl($forum_id, 'mod') )
|
||||
if ( $auth->get_acl($forum_id, 'mod') )
|
||||
{
|
||||
$rules .= sprintf($lang['Rules_moderate'], '<a href="modcp.' . $phpEx . $SID . '&f=' . $forum_id . '">', '</a>');
|
||||
}
|
||||
@@ -183,7 +183,7 @@ function get_forum_rules($mode, &$rules, &$forum_id)
|
||||
|
||||
function make_jumpbox($action, $match_forum_id = 0)
|
||||
{
|
||||
global $SID, $acl, $template, $lang, $db, $nav_links, $phpEx;
|
||||
global $SID, $auth, $template, $lang, $db, $nav_links, $phpEx;
|
||||
|
||||
// $sql = "SELECT f.*, p.post_time, p.post_username, u.username, u.user_id
|
||||
// FROM (( " . FORUMS_TABLE . " f
|
||||
@@ -209,7 +209,7 @@ function make_jumpbox($action, $match_forum_id = 0)
|
||||
{
|
||||
if ( $row['forum_left_id'] > $last_forum_right_id )
|
||||
{
|
||||
if ( $acl->get_acl($row['forum_id'], 'forum', 'list') )
|
||||
if ( $auth->get_acl($row['forum_id'], 'forum', 'list') )
|
||||
{
|
||||
$selected = ( $row['forum_id'] == $match_forum_id ) ? 'selected="selected"' : '';
|
||||
$boxstring .= '<option value="' . $row['forum_id'] . '"' . $selected . '>' . $row['forum_name'] . '</option>';
|
||||
@@ -496,80 +496,41 @@ function generate_pagination($base_url, $num_items, $per_page, $start_item, $add
|
||||
|
||||
$on_page = floor($start_item / $per_page) + 1;
|
||||
|
||||
$page_string = '';
|
||||
if ( $total_pages > 10 )
|
||||
{
|
||||
$init_page_max = ( $total_pages > 3 ) ? 3 : $total_pages;
|
||||
$page_string = ( $on_page == 1 ) ? '<b>1</b>' : '<a href="' . $base_url . "&start=" . ( ( $on_page - 2 ) * $per_page ) . '">' . $lang['Previous'] . '</a> <a href="' . $base_url . '">1</a>';
|
||||
|
||||
for($i = 1; $i < $init_page_max + 1; $i++)
|
||||
if ( $total_pages > 5 )
|
||||
{
|
||||
$start_cnt = min(max(1, $on_page - 4), $total_pages - 5);
|
||||
$end_cnt = max(min($total_pages, $on_page + 4), 6);
|
||||
|
||||
$page_string .= ( $start_cnt > 1 ) ? ' ... ' : ', ';
|
||||
|
||||
for($i = $start_cnt + 1; $i < $end_cnt; $i++)
|
||||
{
|
||||
$page_string .= ( $i == $on_page ) ? '<b>' . $i . '</b>' : '<a href="' . $base_url . "&start=" . ( ( $i - 1 ) * $per_page ) . '">' . $i . '</a>';
|
||||
if ( $i < $init_page_max )
|
||||
if ( $i < $end_cnt - 1 )
|
||||
{
|
||||
$page_string .= ", ";
|
||||
$page_string .= ', ';
|
||||
}
|
||||
}
|
||||
|
||||
if ( $total_pages > 3 )
|
||||
{
|
||||
if ( $on_page > 1 && $on_page < $total_pages )
|
||||
{
|
||||
$page_string .= ( $on_page > 5 ) ? ' ... ' : ', ';
|
||||
|
||||
$init_page_min = ( $on_page > 4 ) ? $on_page : 5;
|
||||
$init_page_max = ( $on_page < $total_pages - 4 ) ? $on_page : $total_pages - 4;
|
||||
|
||||
for($i = $init_page_min - 1; $i < $init_page_max + 2; $i++)
|
||||
{
|
||||
$page_string .= ($i == $on_page) ? '<b>' . $i . '</b>' : '<a href="' . $base_url . "&start=" . ( ( $i - 1 ) * $per_page ) . '">' . $i . '</a>';
|
||||
if ( $i < $init_page_max + 1 )
|
||||
{
|
||||
$page_string .= ', ';
|
||||
}
|
||||
}
|
||||
|
||||
$page_string .= ( $on_page < $total_pages - 4 ) ? ' ... ' : ', ';
|
||||
}
|
||||
else
|
||||
{
|
||||
$page_string .= ' ... ';
|
||||
}
|
||||
|
||||
for($i = $total_pages - 2; $i < $total_pages + 1; $i++)
|
||||
{
|
||||
$page_string .= ( $i == $on_page ) ? '<b>' . $i . '</b>' : '<a href="' . $base_url . "&start=" . ( ( $i - 1 ) * $per_page ) . '">' . $i . '</a>';
|
||||
if( $i < $total_pages )
|
||||
{
|
||||
$page_string .= ", ";
|
||||
}
|
||||
}
|
||||
}
|
||||
$page_string .= ( $end_cnt < $total_pages ) ? ' ... ' : ', ';
|
||||
}
|
||||
else
|
||||
{
|
||||
for($i = 1; $i < $total_pages + 1; $i++)
|
||||
$page_string .= ', ';
|
||||
|
||||
for($i = 2; $i < $total_pages; $i++)
|
||||
{
|
||||
$page_string .= ( $i == $on_page ) ? '<b>' . $i . '</b>' : '<a href="' . $base_url . "&start=" . ( ( $i - 1 ) * $per_page ) . '">' . $i . '</a>';
|
||||
if ( $i < $total_pages )
|
||||
if ( $i < $total_pages )
|
||||
{
|
||||
$page_string .= ', ';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( $add_prevnext_text )
|
||||
{
|
||||
if ( $on_page > 1 )
|
||||
{
|
||||
$page_string = ' <a href="' . $base_url . "&start=" . ( ( $on_page - 2 ) * $per_page ) . '">' . $lang['Previous'] . '</a> ' . $page_string;
|
||||
}
|
||||
|
||||
if ( $on_page < $total_pages )
|
||||
{
|
||||
$page_string .= ' <a href="' . $base_url . "&start=" . ( $on_page * $per_page ) . '">' . $lang['Next'] . '</a>';
|
||||
}
|
||||
|
||||
}
|
||||
$page_string .= ( $on_page == $total_pages ) ? '<b>' . $total_pages . '</b>' : '<a href="' . $base_url . '&start=' . ( ( $total_pages - 1 ) * $per_page ) . '">' . $total_pages . '</a> <a href="' . $base_url . "&start=" . ( $on_page * $per_page ) . '">' . $lang['Next'] . '</a>';
|
||||
|
||||
$page_string = $lang['Goto_page'] . ' ' . $page_string;
|
||||
|
||||
@@ -640,9 +601,10 @@ function obtain_word_list(&$orig_word, &$replacement_word)
|
||||
// failures, etc.
|
||||
// -> ERROR : Use for any error, a simple page will be output
|
||||
//
|
||||
// $errno, $errstr, $errfile, $errline
|
||||
function message_die($msg_code, $msg_text = '', $msg_title = '')
|
||||
{
|
||||
global $db, $session, $acl, $template, $board_config, $theme, $lang, $userdata, $user_ip;
|
||||
global $db, $session, $auth, $template, $board_config, $theme, $lang, $userdata, $user_ip;
|
||||
global $phpEx, $phpbb_root_path, $nav_links, $starttime;
|
||||
|
||||
switch ( $msg_code )
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -26,9 +26,7 @@ if ( !defined('IN_PHPBB') )
|
||||
|
||||
define('HEADER_INC', TRUE);
|
||||
|
||||
//
|
||||
// gzip_compression
|
||||
//
|
||||
if ( $board_config['gzip_compress'] )
|
||||
{
|
||||
if ( extension_loaded('zlib') && strstr($HTTP_USER_AGENT,'compatible') && !headers_sent() )
|
||||
@@ -37,35 +35,25 @@ if ( $board_config['gzip_compress'] )
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Generate logged in/logged out status
|
||||
//
|
||||
if ( $userdata['user_id'] != ANONYMOUS )
|
||||
if ( $userdata['user_id'] )
|
||||
{
|
||||
$u_login_logout = 'login.'.$phpEx.'?logout=true';
|
||||
$u_login_logout = 'login.'.$phpEx. $SID . '&logout=true';
|
||||
$l_login_logout = $lang['Logout'] . ' [ ' . $userdata['username'] . ' ]';
|
||||
}
|
||||
else
|
||||
{
|
||||
$u_login_logout = 'login.'.$phpEx;
|
||||
$u_login_logout = 'login.'.$phpEx . $SID;
|
||||
$l_login_logout = $lang['Login'];
|
||||
}
|
||||
|
||||
$s_last_visit = ( $userdata['user_id'] != ANONYMOUS ) ? create_date($board_config['default_dateformat'], $userdata['user_lastvisit'], $board_config['board_timezone']) : '';
|
||||
// Last visit date/time
|
||||
$s_last_visit = ( $userdata['user_id'] ) ? create_date($board_config['default_dateformat'], $userdata['session_last_visit'], $board_config['board_timezone']) : '';
|
||||
|
||||
//
|
||||
// Get basic (usernames + totals) online
|
||||
// situation
|
||||
//
|
||||
$user_forum_sql = ( !empty($forum_id) ) ? "AND s.session_page LIKE '%f=$forum_id%'" : '';
|
||||
$sql = "SELECT u.username, u.user_id, u.user_allow_viewonline, u.user_colour, s.session_ip
|
||||
FROM " . USERS_TABLE . " u, " . SESSIONS_TABLE ." s
|
||||
WHERE u.user_id = s.session_user_id
|
||||
AND s.session_time >= ".( time() - 300 ) . "
|
||||
$user_forum_sql
|
||||
ORDER BY u.username ASC, s.session_ip ASC";
|
||||
$result = $db->sql_query($sql);
|
||||
// Timezone : $user->dst
|
||||
$s_timezone = ( $userdata['user_dst'] ) ? sprintf($lang['All_times'], $lang[floatval($board_config['board_timezone'])], $lang['tz']['dst']) : sprintf($lang['All_times'], $lang[floatval($board_config['board_timezone'])], '');
|
||||
|
||||
// Get users online list
|
||||
$userlist_ary = array();
|
||||
$userlist_visible = array();
|
||||
|
||||
@@ -76,11 +64,20 @@ $online_userlist = '';
|
||||
|
||||
$prev_user_id = 0;
|
||||
$prev_user_ip = '';
|
||||
// && $auth->get_acl('forum', 'read', $forum_id)
|
||||
$user_forum_sql = ( is_int($forum_id)) ? '' : "AND s.session_page LIKE '%f=$forum_id%'";
|
||||
$sql = "SELECT u.username, u.user_id, u.user_allow_viewonline, u.user_colour, s.session_ip
|
||||
FROM " . USERS_TABLE . " u, " . SESSIONS_TABLE ." s
|
||||
WHERE s.session_time >= ".( time() - 300 ) . "
|
||||
$user_forum_sql
|
||||
AND u.user_id = s.session_user_id
|
||||
ORDER BY u.username ASC, s.session_ip ASC";
|
||||
$result = $db->sql_query($sql, false);
|
||||
|
||||
while( $row = $db->sql_fetchrow($result) )
|
||||
{
|
||||
// User is logged in and therefor not a guest
|
||||
if ( $row['user_id'] != ANONYMOUS )
|
||||
if ( $row['user_id'] )
|
||||
{
|
||||
// Skip multiple sessions for one user
|
||||
if ( $row['user_id'] != $prev_user_id )
|
||||
@@ -101,7 +98,7 @@ while( $row = $db->sql_fetchrow($result) )
|
||||
$logged_hidden_online++;
|
||||
}
|
||||
|
||||
if ( $row['user_allow_viewonline'] || $acl->get_acl_admin() )
|
||||
if ( $row['user_allow_viewonline'] || $auth->get_acl_admin() )
|
||||
{
|
||||
$online_userlist .= ( $online_userlist != '' ) ? ', ' . $user_online_link : $user_online_link;
|
||||
}
|
||||
@@ -215,17 +212,17 @@ $l_online_users .= sprintf($l_g_user_s, $guests_online);
|
||||
// Obtain number of new private messages
|
||||
// if user is logged in
|
||||
//
|
||||
if ( $userdata['user_id'] != ANONYMOUS )
|
||||
if ( $userdata['user_id'] )
|
||||
{
|
||||
if ( $userdata['user_new_privmsg'] )
|
||||
{
|
||||
$l_message_new = ( $userdata['user_new_privmsg'] == 1 ) ? $lang['New_pm'] : $lang['New_pms'];
|
||||
$l_privmsgs_text = sprintf($l_message_new, $userdata['user_new_privmsg']);
|
||||
|
||||
if ( $userdata['user_last_privmsg'] > $userdata['user_lastvisit'] )
|
||||
if ( $userdata['user_last_privmsg'] > $userdata['session_last_visit'] )
|
||||
{
|
||||
$sql = "UPDATE " . USERS_TABLE . "
|
||||
SET user_last_privmsg = " . $userdata['user_lastvisit'] . "
|
||||
SET user_last_privmsg = " . $userdata['session_last_visit'] . "
|
||||
WHERE user_id = " . $userdata['user_id'];
|
||||
$db->sql_query($sql);
|
||||
|
||||
@@ -341,14 +338,14 @@ $template->assign_vars(array(
|
||||
'U_MEMBERSLIST' => 'memberlist.'.$phpEx.$SID,
|
||||
'U_GROUP_CP' => 'groupcp.'.$phpEx.$SID,
|
||||
|
||||
'S_USER_LOGGED_IN' => ( $userdata['user_id'] == ANONYMOUS ) ? false : true,
|
||||
'S_USER_LOGGED_IN' => ( $userdata['user_id'] ) ? true : false,
|
||||
'S_USER_PM_POPUP' => ( !empty($userdata['user_popup_pm']) ) ? true : false,
|
||||
'S_USER_BROWSER' => $userdata['session_browser'],
|
||||
'S_CONTENT_DIRECTION' => $lang['DIRECTION'],
|
||||
'S_CONTENT_ENCODING' => $lang['ENCODING'],
|
||||
'S_CONTENT_DIR_LEFT' => $lang['LEFT'],
|
||||
'S_CONTENT_DIR_RIGHT' => $lang['RIGHT'],
|
||||
'S_TIMEZONE' => sprintf($lang['All_times'], $lang[floatval($board_config['board_timezone'])]),
|
||||
'S_TIMEZONE' => $s_timezone,
|
||||
'S_LOGIN_ACTION' => 'login.'.$phpEx.$SID,
|
||||
|
||||
'T_STYLESHEET_DATA' => $theme['css_data'],
|
||||
|
@@ -40,12 +40,12 @@ if (defined('DEBUG'))
|
||||
exit;
|
||||
}
|
||||
|
||||
$debug_output = sprintf('<br /><br />[ Time : %.3fs | ' . $db->sql_num_queries() . ' Queries | GZIP : ' . ( ( $board_config['gzip_compress'] ) ? 'On' : 'Off' ) . ' | Load : ' . ( ( $session->load ) ? $session->load : 'N/A') . ' | <a href="' . $_SERVER['REQUEST_URI'] . '&explain=1">Explain</a> ]', $totaltime);
|
||||
$debug_output = sprintf('<br /><br />[ Time : %.3fs | ' . $db->sql_num_queries() . ' Queries | GZIP : ' . ( ( $board_config['gzip_compress'] ) ? 'On' : 'Off' ) . ' | Load : ' . ( ( $session->load ) ? $session->load : 'N/A') . ' | <a href="' . $_SERVER['REQUEST_URI'] . '&explain=1">Explain</a> ]', $totaltime);
|
||||
}
|
||||
|
||||
$template->assign_vars(array(
|
||||
'PHPBB_VERSION' => $board_config['version'],
|
||||
'ADMIN_LINK' => ( $acl->get_acl_admin() ) ? '<a href="' . "admin/index.$phpEx$SID" . '">' . $lang['Admin_panel'] . '</a><br /><br />' : '',
|
||||
'ADMIN_LINK' => ( $auth->get_acl_admin() ) ? '<a href="' . "admin/index.$phpEx$SID" . '">' . $lang['Admin_panel'] . '</a><br /><br />' : '',
|
||||
'DEBUG_OUTPUT' => ( defined('DEBUG') ) ? $debug_output : '')
|
||||
);
|
||||
|
||||
|
@@ -22,34 +22,34 @@
|
||||
class session {
|
||||
|
||||
var $session_id = '';
|
||||
var $browser = '';
|
||||
var $page = '';
|
||||
var $load;
|
||||
|
||||
// Called at each page start ... checks for, updates and/or creates a session
|
||||
function start($update = true)
|
||||
{
|
||||
global $SID, $db, $board_config, $user_ip;
|
||||
global $HTTP_SERVER_VARS, $HTTP_ENV_VARS, $HTTP_COOKIE_VARS, $HTTP_GET_VARS;
|
||||
|
||||
$user_browser = ( !empty($HTTP_SERVER_VARS['HTTP_USER_AGENT']) ) ? $HTTP_SERVER_VARS['HTTP_USER_AGENT'] : $HTTP_ENV_VARS['HTTP_USER_AGENT'];
|
||||
$user_page = ( !empty($HTTP_SERVER_VARS['PHP_SELF']) ) ? $HTTP_SERVER_VARS['PHP_SELF'] : $HTTP_ENV_VARS['PHP_SELF'];
|
||||
$user_page .= '&' . ( ( !empty($HTTP_SERVER_VARS['QUERY_STRING']) ) ? $HTTP_SERVER_VARS['QUERY_STRING'] : $HTTP_ENV_VARS['QUERY_STRING'] );
|
||||
$current_time = time();
|
||||
$this->browser = ( !empty($_SERVER['HTTP_USER_AGENT']) ) ? $_SERVER['HTTP_USER_AGENT'] : $_ENV['HTTP_USER_AGENT'];
|
||||
$this->page = ( !empty($_SERVER['PHP_SELF']) ) ? $_SERVER['PHP_SELF'] : $_ENV['PHP_SELF'];
|
||||
$this->page .= '&' . ( ( !empty($_SERVER['QUERY_STRING']) ) ? $_SERVER['QUERY_STRING'] : $_ENV['QUERY_STRING'] );
|
||||
|
||||
if ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_sid']) || isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_data']) )
|
||||
if ( isset($_COOKIE[$board_config['cookie_name'] . '_sid']) || isset($_COOKIE[$board_config['cookie_name'] . '_data']) )
|
||||
{
|
||||
$sessiondata = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_data']) ) ? unserialize(stripslashes($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_data'])) : '';
|
||||
$this->session_id = ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_sid']) ) ? $HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_sid'] : '';
|
||||
$sessiondata = ( isset($_COOKIE[$board_config['cookie_name'] . '_data']) ) ? unserialize(stripslashes($_COOKIE[$board_config['cookie_name'] . '_data'])) : '';
|
||||
$this->session_id = ( isset($_COOKIE[$board_config['cookie_name'] . '_sid']) ) ? $_COOKIE[$board_config['cookie_name'] . '_sid'] : '';
|
||||
$SID = '?sid=';
|
||||
}
|
||||
else
|
||||
{
|
||||
$sessiondata = '';
|
||||
$this->session_id = ( isset($HTTP_GET_VARS['sid']) ) ? $HTTP_GET_VARS['sid'] : '';
|
||||
$this->session_id = ( isset($_GET['sid']) ) ? $_GET['sid'] : '';
|
||||
$SID = '?sid=' . $this->session_id;
|
||||
}
|
||||
|
||||
//
|
||||
// Load limit check (if applicable)
|
||||
//
|
||||
if ( !empty($board_config['limit_load']) && file_exists('/proc/loadavg') )
|
||||
{
|
||||
if ( $load = @file('/proc/loadavg') )
|
||||
@@ -63,18 +63,7 @@ class session {
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Garbage collection ... remove old sessions updating user information
|
||||
// if necessary. It means (potentially) lots of queries but only infrequently
|
||||
//
|
||||
if ( $current_time - $board_config['session_gc'] > $board_config['session_last_gc'] )
|
||||
{
|
||||
$this->gc($current_time);
|
||||
}
|
||||
|
||||
//
|
||||
// session_id exists so go ahead and attempt to grab all data in preparation
|
||||
//
|
||||
if ( !empty($this->session_id) )
|
||||
{
|
||||
$sql = "SELECT u.*, s.*
|
||||
@@ -86,28 +75,27 @@ class session {
|
||||
$userdata = $db->sql_fetchrow($result);
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
//
|
||||
// Did the session exist in the DB?
|
||||
//
|
||||
if ( isset($userdata['user_id']) )
|
||||
{
|
||||
//
|
||||
// Do not check IP assuming equivalence, if IPv4 we'll check only first 24
|
||||
// bits ... I've been told (by vHiker) this should alleviate problems with
|
||||
// load balanced et al proxies while retaining some reliance on IP security.
|
||||
//
|
||||
// Validate IP length according to admin ... has no effect on IPv6
|
||||
$ip_check_s = explode('.', $userdata['session_ip']);
|
||||
$ip_check_u = explode('.', $user_ip);
|
||||
|
||||
if ( $ip_check_s[0].'.'.$ip_check_s[1].'.'.$ip_check_s[2] == $ip_check_u[0].'.'.$ip_check_u[1].'.'.$ip_check_u[2] )
|
||||
$u_ip = $s_ip = '';
|
||||
for($i = 0; $i < $board_config['ip_check']; $i++)
|
||||
{
|
||||
$u_ip .= $ip_check_u[$i] . '.';
|
||||
$s_ip .= $ip_check_s[$i] . '.';
|
||||
}
|
||||
|
||||
if ( $u_ip == $s_ip )
|
||||
{
|
||||
//
|
||||
// Only update session DB a minute or so after last update or if page changes
|
||||
//
|
||||
if ( ( $current_time - $userdata['session_time'] > 60 || $userdata['session_page'] != $user_page ) && $update )
|
||||
{
|
||||
$sql = "UPDATE " . SESSIONS_TABLE . "
|
||||
SET session_time = $current_time, session_page = '$user_page'
|
||||
SET session_time = $current_time, session_page = '$this->page'
|
||||
WHERE session_id = '" . $this->session_id . "'";
|
||||
$db->sql_query($sql);
|
||||
}
|
||||
@@ -117,29 +105,23 @@ class session {
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// If we reach here then no (valid) session exists. So we'll create a new one,
|
||||
// using the cookie user_id if available to pull basic user prefs.
|
||||
//
|
||||
$autologin = ( isset($sessiondata['autologinid']) ) ? $sessiondata['autologinid'] : '';
|
||||
$user_id = ( isset($sessiondata['userid']) ) ? intval($sessiondata['userid']) : ANONYMOUS;
|
||||
|
||||
return $this->create($user_id, $autologin, $user_page, $user_browser);
|
||||
return $this->create($user_id, $autologin);
|
||||
}
|
||||
|
||||
//
|
||||
// Create a new session
|
||||
//
|
||||
function create(&$user_id, &$autologin, &$user_page, &$user_browser)
|
||||
function create(&$user_id, &$autologin)
|
||||
{
|
||||
global $SID, $db, $board_config, $user_ip;
|
||||
|
||||
$sessiondata = array();
|
||||
$current_time = time();
|
||||
|
||||
//
|
||||
// Limit sessions in 1 minute period
|
||||
//
|
||||
$sql = "SELECT COUNT(*) AS sessions
|
||||
FROM " . SESSIONS_TABLE . "
|
||||
WHERE session_time >= " . ( $current_time - 60 );
|
||||
@@ -153,9 +135,14 @@ class session {
|
||||
message_die(MESSAGE, 'Board_unavailable');
|
||||
}
|
||||
|
||||
//
|
||||
// Garbage collection ... remove old sessions updating user information
|
||||
// if necessary. It means (potentially) 22 queries but only infrequently
|
||||
if ( $current_time - $board_config['session_gc'] > $board_config['session_last_gc'] )
|
||||
{
|
||||
$this->gc($current_time);
|
||||
}
|
||||
|
||||
// Grab user data
|
||||
//
|
||||
$sql = "SELECT *
|
||||
FROM " . USERS_TABLE . "
|
||||
WHERE user_id = $user_id";
|
||||
@@ -164,9 +151,7 @@ class session {
|
||||
$userdata = $db->sql_fetchrow($result);
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
//
|
||||
// Check autologin request, is it valid?
|
||||
//
|
||||
if ( $userdata['user_password'] != $autologin || !$userdata['user_active'] || $user_id == ANONYMOUS )
|
||||
{
|
||||
$autologin = '';
|
||||
@@ -195,13 +180,11 @@ class session {
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
//
|
||||
// Create or update the session
|
||||
//
|
||||
$db->sql_return_on_error(true);
|
||||
|
||||
$sql = "UPDATE " . SESSIONS_TABLE . "
|
||||
SET session_user_id = $user_id, session_start = $current_time, session_time = $current_time, session_browser = '$user_browser', session_page = '$user_page'
|
||||
SET session_user_id = $user_id, session_last_visit = " . $userdata['user_lastvisit'] . ", session_start = $current_time, session_time = $current_time, session_browser = '$this->browser', session_page = '$this->page'
|
||||
WHERE session_id = '" . $this->session_id . "'";
|
||||
if ( !($result = $db->sql_query($sql)) || !$db->sql_affectedrows() )
|
||||
{
|
||||
@@ -209,8 +192,8 @@ class session {
|
||||
$this->session_id = md5(uniqid($user_ip));
|
||||
|
||||
$sql = "INSERT INTO " . SESSIONS_TABLE . "
|
||||
(session_id, session_user_id, session_start, session_time, session_ip, session_browser, session_page)
|
||||
VALUES ('" . $this->session_id . "', $user_id, $current_time, $current_time, '$user_ip', '$user_browser', '$user_page')";
|
||||
(session_id, session_user_id, session_last_visit, session_start, session_time, session_ip, session_browser, session_page)
|
||||
VALUES ('" . $this->session_id . "', $user_id, " . $userdata['user_lastvisit'] . ", $current_time, $current_time, '$user_ip', '$this->browser', '$this->page')";
|
||||
$db->sql_query($sql);
|
||||
}
|
||||
$db->sql_return_on_error(false);
|
||||
@@ -220,29 +203,31 @@ class session {
|
||||
$sessiondata['autologinid'] = ( $autologin && $user_id != ANONYMOUS ) ? $autologin : '';
|
||||
$sessiondata['userid'] = $user_id;
|
||||
|
||||
setcookie($board_config['cookie_name'] . '_data', serialize($sessiondata), $current_time + 31536000, $board_config['cookie_path'], $board_config['cookie_domain'], $board_config['cookie_secure']);
|
||||
setcookie($board_config['cookie_name'] . '_sid', $this->session_id, 0, $board_config['cookie_path'], $board_config['cookie_domain'], $board_config['cookie_secure']);
|
||||
$this->set_cookie('data', serialize($sessiondata), $current_time + 31536000);
|
||||
$this->set_cookie('sid', $this->session_id, 0);
|
||||
$SID = '?sid=' . $this->session_id;
|
||||
|
||||
// Events ...
|
||||
if ( $userdata['user_id'] )
|
||||
{
|
||||
// do_events();
|
||||
}
|
||||
|
||||
return $userdata;
|
||||
}
|
||||
|
||||
//
|
||||
// Destroy a session
|
||||
//
|
||||
function destroy(&$userdata)
|
||||
{
|
||||
global $SID, $db, $board_config;
|
||||
global $HTTP_COOKIE_VARS, $HTTP_GET_VARS;
|
||||
|
||||
$current_time = time();
|
||||
|
||||
setcookie($board_config['cookie_name'] . '_data', '', $current_time - 31536000, $board_config['cookie_path'], $board_config['cookie_domain'], $board_config['cookie_secure']);
|
||||
setcookie($board_config['cookie_name'] . '_sid', '', $current_time - 31536000, $board_config['cookie_path'], $board_config['cookie_domain'], $board_config['cookie_secure']);
|
||||
$this->set_cookie('data', '', $current_time - 31536000);
|
||||
$this->set_cookie('sid', '', $current_time - 31536000);
|
||||
$SID = '?sid=';
|
||||
|
||||
//
|
||||
// Delete existing session, update last visit info first!
|
||||
//
|
||||
$sql = "UPDATE " . USERS_TABLE . "
|
||||
SET user_lastvisit = " . $userdata['session_time'] . ", user_session_page = '" . $userdata['session_page'] . "'
|
||||
WHERE user_id = " . $userdata['user_id'];
|
||||
@@ -253,15 +238,34 @@ class session {
|
||||
AND session_user_id = " . $userdata['user_id'];
|
||||
$db->sql_query($sql);
|
||||
|
||||
$SID = '?sid=';
|
||||
$this->session_id = '';
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Set a cookie
|
||||
function set_cookie($name, $cookiedata, $cookietime)
|
||||
{
|
||||
global $board_config;
|
||||
|
||||
setcookie($board_config['cookie_name'] . '_' . $name, $cookiedata, $cookietime, $board_config['cookie_path'], $board_config['cookie_domain'], $board_config['cookie_secure']);
|
||||
}
|
||||
|
||||
// This just won't work correctly as it stands ... if a user has more than one session in
|
||||
// the DB and gc subsequently runs, updating their user_lastvisit time it will screw up
|
||||
// marking of forums, etc. since it will be reflected immediately in the users current session
|
||||
//
|
||||
// One way around this would be to store the last visit time within each session and use
|
||||
// that rather than user_lastvisit in the relevant places. However, the 'problem' still
|
||||
// persists of a user creating a new session (after leaving the board) before gc has run
|
||||
// and not having their "true" last visit time be used (i.e. their user_lastvisit won't
|
||||
// have yet been updated). This behaviour seems to be that of vB and our users seemed to
|
||||
// dislike this approach when a similar issue arose during 2.0.0 development ... could
|
||||
// possibly check sessions table before creating new session to see if user is already
|
||||
// listed ... if they are then use the last session_time from there ... adds another
|
||||
// query during create though
|
||||
|
||||
// Garbage collection
|
||||
//
|
||||
function gc(&$current_time)
|
||||
{
|
||||
global $db, $board_config, $user_ip;
|
||||
@@ -269,6 +273,7 @@ class session {
|
||||
$sql = "SELECT *
|
||||
FROM " . SESSIONS_TABLE . "
|
||||
WHERE session_time < " . ( $current_time - $board_config['session_length'] ) . "
|
||||
ORDER BY session_user_id, session_time
|
||||
LIMIT 10";
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
@@ -290,9 +295,7 @@ class session {
|
||||
|
||||
if ( $del_session_id != '' )
|
||||
{
|
||||
//
|
||||
// Delete expired sessions
|
||||
//
|
||||
$sql = "DELETE FROM " . SESSIONS_TABLE . "
|
||||
WHERE session_id IN ($del_session_id)";
|
||||
$db->sql_query($sql);
|
||||
@@ -300,10 +303,8 @@ class session {
|
||||
|
||||
if ( $del_sessions < 10 )
|
||||
{
|
||||
//
|
||||
// Less than 10 sessions, update gc timer ... else we want gc
|
||||
// called again to delete other sessions
|
||||
//
|
||||
$sql = "UPDATE " . CONFIG_TABLE . "
|
||||
SET config_value = '$current_time'
|
||||
WHERE config_name = 'session_last_gc'";
|
||||
@@ -313,9 +314,7 @@ class session {
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
//
|
||||
// Taken over by user class ... for now at least
|
||||
function configure($userdata, $lang_set = false)
|
||||
{
|
||||
global $db, $template, $lang, $board_config, $theme, $images;
|
||||
@@ -323,25 +322,14 @@ class session {
|
||||
|
||||
if ( $userdata['user_id'] )
|
||||
{
|
||||
$board_config['default_lang'] = $userdata['user_lang'];
|
||||
$board_config['default_lang'] = ( file_exists($phpbb_root_path . 'language/lang_' . $userdata['user_lang']) ) ? $userdata['user_lang'] : $board_config['default_lang'];
|
||||
$board_config['default_dateformat'] = $userdata['user_dateformat'];
|
||||
$board_config['board_timezone'] = $userdata['user_timezone'];
|
||||
}
|
||||
|
||||
if ( !file_exists($phpbb_root_path . 'language/lang_' . $board_config['default_lang'] . '/lang_main.' . $phpEx) )
|
||||
{
|
||||
$board_config['default_lang'] = 'english';
|
||||
}
|
||||
|
||||
include($phpbb_root_path . 'language/lang_' . $board_config['default_lang'] . '/lang_main.' . $phpEx);
|
||||
|
||||
if ( defined('IN_ADMIN') )
|
||||
{
|
||||
if ( !file_exists($phpbb_root_path . 'language/lang_' . $board_config['default_lang'] . '/lang_admin.'.$phpEx) )
|
||||
{
|
||||
$board_config['default_lang'] = 'english';
|
||||
}
|
||||
|
||||
include($phpbb_root_path . 'language/lang_' . $board_config['default_lang'] . '/lang_admin.' . $phpEx);
|
||||
}
|
||||
|
||||
@@ -369,22 +357,128 @@ class session {
|
||||
|
||||
$i10n = array('post_new', 'post_locked', 'post_pm', 'reply_new', 'reply_pm', 'reply_locked', 'icon_quote', 'icon_edit', 'icon_search', 'icon_profile', 'icon_pm', 'icon_email', 'icon_www', 'icon_icq', 'icon_aim', 'icon_yim', 'icon_msnm', 'icon_delete', 'icon_ip', 'icon_no_email', 'icon_no_www', 'icon_no_icq', 'icon_no_aim', 'icon_no_yim', 'icon_no_msnm');
|
||||
|
||||
for($i = 0; $i < sizeof($i10n); $i++)
|
||||
foreach ( $i10n as $icon )
|
||||
{
|
||||
$theme[$i10n[$i]] = str_replace('{LANG}', 'lang_' . $img_lang, $theme[$i10n[$i]]);
|
||||
$theme[$icon] = str_replace('{LANG}', 'lang_' . $img_lang, $theme[$icon]);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Contains (at present) basic user methods such as configuration
|
||||
// creating date/time ... keep this?
|
||||
class user
|
||||
{
|
||||
var $lang_name;
|
||||
var $lang_path;
|
||||
|
||||
var $date_format;
|
||||
var $timezone;
|
||||
var $dst;
|
||||
|
||||
function user(&$userdata, $lang_set = false, $style = false)
|
||||
{
|
||||
global $db, $template, $lang, $board_config, $theme, $images;
|
||||
global $phpEx, $phpbb_root_path;
|
||||
|
||||
if ( $userdata['user_id'] )
|
||||
{
|
||||
$this->lang_name = ( file_exists($phpbb_root_path . 'language/' . $userdata['user_lang']) ) ? $userdata['user_lang'] : $board_config['default_lang'];
|
||||
$this->lang_path = $phpbb_root_path . 'language/' . $this->lang_name;
|
||||
|
||||
$this->date_format = $userdata['user_dateformat'];
|
||||
$this->timezone = $userdata['user_timezone'];
|
||||
$this->dst = $userdata['user_dst'] * 3600;
|
||||
}
|
||||
else if ( isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) )
|
||||
{
|
||||
$accept_lang_ary = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
|
||||
foreach ( $accept_lang_ary as $accept_lang )
|
||||
{
|
||||
// Set correct format ... guess full xx_YY form
|
||||
$accept_lang = substr($accept_lang, 0, 2) . '_' . strtoupper(substr($accept_lang, 3, 2));
|
||||
if ( file_exists($phpbb_root_path . 'language/' . $accept_lang) )
|
||||
{
|
||||
$this->lang_name = $accept_lang;
|
||||
$this->lang_path = $phpbb_root_path . 'language/' . $accept_lang;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
// No match on xx_YY so try xx
|
||||
$accept_lang = substr($accept_lang, 0, 2);
|
||||
if ( file_exists($phpbb_root_path . 'language/' . $accept_lang) )
|
||||
{
|
||||
$this->lang_name = $accept_lang;
|
||||
$this->lang_path = $phpbb_root_path . 'language/' . $accept_lang;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->date_format = $board_config['default_dateformat'];
|
||||
$this->timezone = $board_config['board_timezone'];
|
||||
$this->dst = 0;
|
||||
}
|
||||
|
||||
include($this->lang_path . '/lang_main.' . $phpEx);
|
||||
if ( defined('IN_ADMIN') )
|
||||
{
|
||||
include($this->lang_path . '/lang_admin.' . $phpEx);
|
||||
}
|
||||
|
||||
// Set up style
|
||||
$style = ( $style ) ? $style : ( ( !$board_config['override_user_style'] && $userdata['user_id'] ) ? $userdata['user_style'] : $board_config['default_style'] );
|
||||
|
||||
$sql = "SELECT t.template_path, t.poll_length, t.pm_box_length, c.css_data, c.css_external, i.*
|
||||
FROM " . STYLES_TABLE . " s, " . STYLES_TPL_TABLE . " t, " . STYLES_CSS_TABLE . " c, " . STYLES_IMAGE_TABLE . " i
|
||||
WHERE s.style_id = $style
|
||||
AND t.template_id = s.template_id
|
||||
AND c.theme_id = s.style_id
|
||||
AND i.imageset_id = s.imageset_id";
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
if ( !($theme = $db->sql_fetchrow($result)) )
|
||||
{
|
||||
message_die(ERROR, 'Could not get style data');
|
||||
}
|
||||
|
||||
$template->set_template($theme['template_path']);
|
||||
|
||||
$img_lang = ( file_exists('imageset/' . $theme['imageset_path'] . '/' . $this->lang_name) ) ? $this->lang_name : $board_config['default_lang'];
|
||||
|
||||
$i10n = array('post_new', 'post_locked', 'post_pm', 'reply_new', 'reply_pm', 'reply_locked', 'icon_quote', 'icon_edit', 'icon_search', 'icon_profile', 'icon_pm', 'icon_email', 'icon_www', 'icon_icq', 'icon_aim', 'icon_yim', 'icon_msnm', 'icon_delete', 'icon_ip', 'icon_no_email', 'icon_no_www', 'icon_no_icq', 'icon_no_aim', 'icon_no_yim', 'icon_no_msnm');
|
||||
|
||||
foreach ( $i10n as $icon )
|
||||
{
|
||||
$theme[$icon] = str_replace('{LANG}', $img_lang, $theme[$icon]);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
function format_date($gmepoch)
|
||||
{
|
||||
global $lang;
|
||||
static $lang_dates;
|
||||
|
||||
if ( empty($lang_dates) )
|
||||
{
|
||||
foreach ( $lang['datetime'] as $match => $replace )
|
||||
{
|
||||
$lang_dates[$match] = $replace;
|
||||
}
|
||||
}
|
||||
|
||||
return strtr(@gmdate($this->date_format, $gmepoch + (3600 * $this->timezone) + $this->dst), $lang_dates);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// Will be keeping my eye of 'other products' to ensure these things don't
|
||||
// mysteriously appear elsewhere, think up your own solutions!
|
||||
//
|
||||
class acl
|
||||
class auth
|
||||
{
|
||||
var $founder = false;
|
||||
var $acl = false;
|
||||
@@ -636,22 +730,11 @@ class acl
|
||||
$auth_sql";
|
||||
$db->sql_query($sql);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Authentication plug-ins is largely down to
|
||||
// Sergey Kanareykin, our thanks to him.
|
||||
//
|
||||
class login
|
||||
{
|
||||
// Authentication plug-ins is largely down to Sergey Kanareykin, our thanks to him.
|
||||
function login($username, $password, $autologin = false)
|
||||
{
|
||||
global $SID, $db, $board_config, $lang, $user_ip, $session;
|
||||
global $HTTP_SERVER_VARS, $HTTP_ENV_VARS, $phpEx;
|
||||
|
||||
$user_page = ( !empty($HTTP_SERVER_VARS['PHP_SELF']) ) ? $HTTP_SERVER_VARS['PHP_SELF'] : $HTTP_ENV_VARS['PHP_SELF'];
|
||||
$user_page .= '&' . ( ( !empty($HTTP_SERVER_VARS['QUERY_STRING']) ) ? $HTTP_SERVER_VARS['QUERY_STRING'] : $HTTP_ENV_VARS['QUERY_STRING'] );
|
||||
$this_browser = ( !empty($HTTP_SERVER_VARS['HTTP_USER_AGENT']) ) ? $HTTP_SERVER_VARS['HTTP_USER_AGENT'] : $HTTP_ENV_VARS['HTTP_USER_AGENT'];
|
||||
global $board_config, $session, $phpEx;
|
||||
|
||||
$method = trim($board_config['auth_method']);
|
||||
|
||||
@@ -669,7 +752,7 @@ class login
|
||||
|
||||
$autologin = ( isset($autologin) ) ? md5($password) : '';
|
||||
|
||||
return ( $user['user_active'] ) ? $session->create($user['user_id'], $autologin, $user_page, $this_browser) : false;
|
||||
return ( $user['user_active'] ) ? $session->create($user['user_id'], $autologin) : false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -138,11 +138,7 @@ class Template {
|
||||
}
|
||||
|
||||
$str = '';
|
||||
while ( !feof($fp) )
|
||||
{
|
||||
$str .= fread($fp, 4096);
|
||||
}
|
||||
|
||||
$str = fread($fp, filesize($this->files[$handle]));
|
||||
@fclose($fp);
|
||||
|
||||
$this->uncompiled_code[$handle] = trim($str);
|
||||
@@ -177,6 +173,7 @@ class Template {
|
||||
echo $db->sql_report;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
$_str = '';
|
||||
|
||||
if (!$this->compile_load($_str, $handle, true))
|
||||
@@ -186,9 +183,7 @@ class Template {
|
||||
message_die("Template->pparse(): Couldn't load template file for handle $handle");
|
||||
}
|
||||
|
||||
//
|
||||
// Actually compile the code now.
|
||||
//
|
||||
$this->compiled_code[$handle] = $this->compile($this->uncompiled_code[$handle]);
|
||||
$this->compile_write($handle, $this->compiled_code[$handle]);
|
||||
|
||||
@@ -561,9 +556,7 @@ class Template {
|
||||
return "include('" . $this->root . '/' . $tag_args . "');\n";
|
||||
}
|
||||
|
||||
//
|
||||
// This is from Smarty
|
||||
//
|
||||
function _parse_is_expr($is_arg, $tokens)
|
||||
{
|
||||
$expr_end = 0;
|
||||
@@ -697,9 +690,7 @@ class Template {
|
||||
|
||||
$filename = $this->cachedir . $this->filename[$handle] . '.' . $phpEx;
|
||||
|
||||
//
|
||||
// Recompile page if the original template is newer, otherwise load the compiled version
|
||||
//
|
||||
if ( file_exists($filename) && @filemtime($filename) >= @filemtime($this->files[$handle]) )
|
||||
{
|
||||
$_str = '';
|
||||
|
@@ -113,7 +113,7 @@ else
|
||||
}
|
||||
}
|
||||
|
||||
if ( $profiledata['user_viewemail'] || $acl->get_acl_admin() )
|
||||
if ( $profiledata['user_viewemail'] || $auth->get_acl_admin() )
|
||||
{
|
||||
$email_uri = ( $board_config['board_email_form'] ) ? "profile.$phpEx$SID&mode=email&u=" . $profiledata['user_id'] : 'mailto:' . $profiledata['user_email'];
|
||||
|
||||
@@ -177,9 +177,9 @@ $template->assign_vars(array(
|
||||
'RANK_IMAGE' => $rank_image,
|
||||
'POSTS_PER_DAY' => $posts_per_day,
|
||||
'POSTS' => $profiledata['user_posts'],
|
||||
'PERCENTAGE' => $percentage . '%',
|
||||
'POST_DAY_STATS' => sprintf($lang['User_post_day_stats'], $posts_per_day),
|
||||
'POST_PERCENT_STATS' => sprintf($lang['User_post_pct_stats'], $percentage),
|
||||
'PERCENTAGE' => $percentage . '%',
|
||||
'POST_DAY_STATS' => sprintf($lang['User_post_day_stats'], $posts_per_day),
|
||||
'POST_PERCENT_STATS' => sprintf($lang['User_post_pct_stats'], $percentage),
|
||||
|
||||
'SEARCH_IMG' => $search_img,
|
||||
'SEARCH' => $search,
|
||||
@@ -190,8 +190,8 @@ $template->assign_vars(array(
|
||||
'WWW_IMG' => $www_img,
|
||||
'WWW' => $www,
|
||||
'ICQ_STATUS_IMG' => $icq_status_img,
|
||||
'ICQ_IMG' => $icq_img,
|
||||
'ICQ' => $icq,
|
||||
'ICQ_IMG' => $icq_img,
|
||||
'ICQ' => $icq,
|
||||
'AIM_IMG' => $aim_img,
|
||||
'AIM' => $aim,
|
||||
'MSN_IMG' => $msn_img,
|
||||
@@ -204,13 +204,13 @@ $template->assign_vars(array(
|
||||
'INTERESTS' => ( $profiledata['user_interests'] ) ? $profiledata['user_interests'] : ' ',
|
||||
'AVATAR_IMG' => $avatar_img,
|
||||
|
||||
'L_VIEWING_PROFILE' => sprintf($lang['Viewing_user_profile'], $profiledata['username']),
|
||||
'L_ABOUT_USER' => sprintf($lang['About_user'], $profiledata['username']),
|
||||
'L_AVATAR' => $lang['Avatar'],
|
||||
'L_POSTER_RANK' => $lang['Poster_rank'],
|
||||
'L_JOINED' => $lang['Joined'],
|
||||
'L_TOTAL_POSTS' => $lang['Total_posts'],
|
||||
'L_SEARCH_USER_POSTS' => sprintf($lang['Search_user_posts'], $profiledata['username']),
|
||||
'L_VIEWING_PROFILE' => sprintf($lang['Viewing_user_profile'], $profiledata['username']),
|
||||
'L_ABOUT_USER' => sprintf($lang['About_user'], $profiledata['username']),
|
||||
'L_AVATAR' => $lang['Avatar'],
|
||||
'L_POSTER_RANK' => $lang['Poster_rank'],
|
||||
'L_JOINED' => $lang['Joined'],
|
||||
'L_TOTAL_POSTS' => $lang['Total_posts'],
|
||||
'L_SEARCH_USER_POSTS' => sprintf($lang['Search_user_posts'], $profiledata['username']),
|
||||
'L_CONTACT' => $lang['Contact'],
|
||||
'L_EMAIL_ADDRESS' => $lang['Email_address'],
|
||||
'L_EMAIL' => $lang['Email'],
|
||||
|
Reference in New Issue
Block a user