/** * Shows a profile for a user * * This grabs the user profile for a given user and displays it * * @return string HTML for user profile page * */ function userprofile() { global $_CONF, $_TABLES, $_USER, $LANG01, $LANG04, $LANG09, $LANG28, $LANG_LOGIN; // @param int $user User ID of profile to get // @param int $msg Message to display (if != 0) // @param string $plugin optional plugin name for message $retval = ''; if (COM_isAnonUser() && ($_CONF['loginrequired'] == 1 || $_CONF['profileloginrequired'] == 1)) { $retval .= SEC_loginRequiredForm(); return $retval; } if (isset($_GET['uid'])) { $user = COM_applyFilter($_GET['uid'], true); if (!is_numeric($user) || $user < 2) { echo COM_refresh($_CONF['site_url'] . '/index.php'); } } else { if (isset($_GET['username'])) { $username = $_GET['username']; if (!USER_validateUsername($username, 1)) { echo COM_refresh($_CONF['site_url'] . '/index.php'); } if (empty($username) || $username == '') { echo COM_refresh($_CONF['site_url'] . '/index.php'); } $username = DB_escapeString($username); $user = DB_getItem($_TABLES['users'], 'uid', "username = '******'"); if ($user < 2) { echo COM_refresh($_CONF['site_url'] . '/index.php'); } } else { echo COM_refresh($_CONF['site_url'] . '/index.php'); } } $msg = 0; if (isset($_GET['msg'])) { $msg = COM_applyFilter($_GET['msg'], true); } $plugin = ''; if ($msg > 0 && isset($_GET['plugin'])) { $plugin = COM_applyFilter($_GET['plugin']); } $result = DB_query("SELECT {$_TABLES['users']}.uid,username,fullname,regdate,lastlogin,homepage,about,location,pgpkey,photo,email,status,emailfromadmin,emailfromuser,showonline FROM {$_TABLES['userinfo']},{$_TABLES['userprefs']},{$_TABLES['users']} WHERE {$_TABLES['userinfo']}.uid = {$_TABLES['users']}.uid AND {$_TABLES['userinfo']}.uid = {$_TABLES['userprefs']}.uid AND {$_TABLES['users']}.uid = " . (int) $user); $nrows = DB_numRows($result); if ($nrows == 0) { // no such user echo COM_refresh($_CONF['site_url'] . '/index.php'); } $A = DB_fetchArray($result); if ($A['status'] == USER_ACCOUNT_DISABLED && !SEC_hasRights('user.edit')) { COM_displayMessageAndAbort(30, '', 403, 'Forbidden'); } $display_name = @htmlspecialchars(COM_getDisplayName($user, $A['username'], $A['fullname']), ENT_COMPAT, COM_getEncodingt()); if ($msg > 0) { $retval .= COM_showMessage($msg, $plugin, '', 0, 'info'); } // format date/time to user preference $curtime = COM_getUserDateTimeFormat($A['regdate']); $A['regdate'] = $curtime[0]; $user_templates = new Template($_CONF['path_layout'] . 'users'); $user_templates->set_file(array('profile' => 'profile.thtml', 'email' => 'email.thtml', 'row' => 'commentrow.thtml', 'strow' => 'storyrow.thtml')); $user_templates->set_var('layout_url', $_CONF['layout_url']); $user_templates->set_var('start_block_userprofile', COM_startBlock($LANG04[1] . ' ' . $display_name)); $user_templates->set_var('end_block', COM_endBlock()); $user_templates->set_var('lang_username', $LANG04[2]); $user_templates->set_var('tooltip', COM_getTooltipStyle()); if ($_CONF['show_fullname'] == 1) { if (empty($A['fullname'])) { $username = $A['username']; $fullname = ''; } else { $username = $A['fullname']; $fullname = $A['username']; } } else { $username = $A['username']; $fullname = ''; } $username = @htmlspecialchars($username, ENT_COMPAT, COM_getEncodingt()); $fullname = @htmlspecialchars($fullname, ENT_COMPAT, COM_getEncodingt()); if ($A['status'] == USER_ACCOUNT_DISABLED) { $username = sprintf('%s - %s', $username, $LANG28[42]); if (!empty($fullname)) { $fullname = sprintf('% - %s', $fullname, $LANG28[42]); } } $user_templates->set_var('username', $username); $user_templates->set_var('user_fullname', $fullname); if (SEC_hasRights('user.edit') || isset($_USER['uid']) && $_USER['uid'] == $A['uid']) { global $_IMAGE_TYPE, $LANG_ADMIN; $edit_icon = '<img src="' . $_CONF['layout_url'] . '/images/edit.' . $_IMAGE_TYPE . '" alt="' . $LANG_ADMIN['edit'] . '" title="' . $LANG_ADMIN['edit'] . '" />'; if ($_USER['uid'] == $A['uid']) { $edit_url = "{$_CONF['site_url']}/usersettings.php"; } else { $edit_url = "{$_CONF['site_admin_url']}/user.php?edit=x&uid={$A['uid']}"; } $edit_link_url = COM_createLink($edit_icon, $edit_url); $user_templates->set_var('edit_icon', $edit_icon); $user_templates->set_var('edit_link', $edit_link_url); $user_templates->set_var('user_edit', $edit_url); } else { $user_templates->set_var('user_edit', ''); } if (isset($A['photo']) && empty($A['photo'])) { $A['photo'] = '(none)'; // user does not have a photo } $lastlogin = $A['lastlogin']; $lasttime = COM_getUserDateTimeFormat($lastlogin); $photo = USER_getPhoto($user, $A['photo'], $A['email'], -1, 0); $user_templates->set_var('user_photo', $photo); $user_templates->set_var('lang_membersince', $LANG04[67]); $user_templates->set_var('user_regdate', $A['regdate']); if ($_CONF['lastlogin'] && $A['showonline']) { $user_templates->set_var('lang_lastlogin', $LANG28[35]); if (!empty($lastlogin)) { $user_templates->set_var('user_lastlogin', $lasttime[0]); } else { $user_templates->set_var('user_lastlogin', $LANG28[36]); } } if ($A['showonline']) { if (DB_count($_TABLES['sessions'], 'uid', (int) $user)) { $user_templates->set_var('online', 'online'); } } $user_templates->set_var('lang_email', $LANG04[5]); $user_templates->set_var('user_id', $user); if ($A['email'] == '' || $A['emailfromuser'] == 0) { $user_templates->set_var('email_option', ''); } else { $user_templates->set_var('lang_sendemail', $LANG04[81]); $user_templates->parse('email_option', 'email', true); } $user_templates->set_var('lang_homepage', $LANG04[6]); $user_templates->set_var('user_homepage', COM_killJS($A['homepage'])); $user_templates->set_var('lang_location', $LANG04[106]); $user_templates->set_var('user_location', strip_tags($A['location'])); $user_templates->set_var('lang_online', $LANG04[160]); $user_templates->set_var('lang_bio', $LANG04[7]); $user_templates->set_var('user_bio', nl2br($A['about'])); $user_templates->set_var('follow_me', SOC_getFollowMeIcons($user, 'follow_user_profile.thtml')); $user_templates->set_var('lang_pgpkey', $LANG04[8]); $user_templates->set_var('user_pgp', nl2br($A['pgpkey'])); $user_templates->set_var('start_block_last10stories', COM_startBlock($LANG04[82] . ' ' . $display_name)); if (!isset($_CONF['comment_engine']) || $_CONF['comment_engine'] == 'internal') { $user_templates->set_var('start_block_last10comments', COM_startBlock($LANG04[10] . ' ' . $display_name)); } $user_templates->set_var('start_block_postingstats', COM_startBlock($LANG04[83] . ' ' . $display_name)); $user_templates->set_var('lang_title', $LANG09[16]); $user_templates->set_var('lang_date', $LANG09[17]); // for alternative layouts: use these as headlines instead of block titles $user_templates->set_var('headline_last10stories', $LANG04[82] . ' ' . $display_name); if (!isset($_CONF['comment_engine']) || $_CONF['comment_engine'] == 'internal') { $user_templates->set_var('headline_last10comments', $LANG04[10] . ' ' . $display_name); } $user_templates->set_var('headline_postingstats', $LANG04[83] . ' ' . $display_name); $result = DB_query("SELECT tid FROM {$_TABLES['topics']}" . COM_getPermSQL()); $nrows = DB_numRows($result); $tids = array(); for ($i = 0; $i < $nrows; $i++) { $T = DB_fetchArray($result); $tids[] = $T['tid']; } $topics = "'" . implode("','", $tids) . "'"; // list of last 10 stories by this user if (sizeof($tids) > 0) { $sql = "SELECT sid,title,UNIX_TIMESTAMP(date) AS unixdate FROM {$_TABLES['stories']} WHERE (uid = '" . (int) $user . "') AND (draft_flag = 0) AND (date <= NOW()) AND (tid IN ({$topics}))" . COM_getPermSQL('AND'); $sql .= " ORDER BY unixdate DESC LIMIT 10"; $result = DB_query($sql); $nrows = DB_numRows($result); } else { $nrows = 0; } if ($nrows > 0) { for ($i = 0; $i < $nrows; $i++) { $C = DB_fetchArray($result); $user_templates->set_var('cssid', $i % 2 + 1); $user_templates->set_var('row_number', $i + 1 . '.'); $articleUrl = COM_buildUrl($_CONF['site_url'] . '/article.php?story=' . $C['sid']); $user_templates->set_var('article_url', $articleUrl); $C['title'] = str_replace('$', '$', $C['title']); $user_templates->set_var('story_title', COM_createLink($C['title'], $articleUrl, array('class' => ''))); $storytime = COM_getUserDateTimeFormat($C['unixdate']); $user_templates->set_var('story_date', $storytime[0]); $user_templates->parse('story_row', 'strow', true); } } else { $user_templates->set_var('story_row', '<tr><td>' . $LANG01[37] . '</td></tr>'); } if (!isset($_CONF['comment_engine']) || $_CONF['comment_engine'] == 'internal') { // list of last 10 comments by this user $sidArray = array(); if (sizeof($tids) > 0) { // first, get a list of all stories the current visitor has access to $sql = "SELECT sid FROM {$_TABLES['stories']} WHERE (draft_flag = 0) AND (date <= NOW()) AND (tid IN ({$topics}))" . COM_getPermSQL('AND'); $result = DB_query($sql); $numsids = DB_numRows($result); for ($i = 1; $i <= $numsids; $i++) { $S = DB_fetchArray($result); $sidArray[] = $S['sid']; } } $sidList = implode("', '", $sidArray); $sidList = "'{$sidList}'"; // then, find all comments by the user in those stories $sql = "SELECT sid,title,cid,UNIX_TIMESTAMP(date) AS unixdate FROM {$_TABLES['comments']} WHERE (uid = '" . (int) $user . "') GROUP BY sid,title,cid,UNIX_TIMESTAMP(date)"; // SQL NOTE: Using a HAVING clause is usually faster than a where if the // field is part of the select // if (!empty ($sidList)) { // $sql .= " AND (sid in ($sidList))"; // } if (!empty($sidList)) { $sql .= " HAVING sid in ({$sidList})"; } $sql .= " ORDER BY unixdate DESC LIMIT 10"; $result = DB_query($sql); $nrows = DB_numRows($result); if ($nrows > 0) { for ($i = 0; $i < $nrows; $i++) { $C = DB_fetchArray($result); $user_templates->set_var('cssid', $i % 2 + 1); $user_templates->set_var('row_number', $i + 1 . '.'); $C['title'] = str_replace('$', '$', $C['title']); $comment_url = $_CONF['site_url'] . '/comment.php?mode=view&cid=' . $C['cid']; $user_templates->set_var('comment_title', COM_createLink($C['title'], $comment_url, array('class' => ''))); $commenttime = COM_getUserDateTimeFormat($C['unixdate']); $user_templates->set_var('comment_date', $commenttime[0]); $user_templates->parse('comment_row', 'row', true); } } else { $user_templates->set_var('comment_row', '<tr><td>' . $LANG01[29] . '</td></tr>'); } } // posting stats for this user $user_templates->set_var('lang_number_stories', $LANG04[84]); $sql = "SELECT COUNT(*) AS count FROM {$_TABLES['stories']} WHERE (uid = " . (int) $user . ") AND (draft_flag = 0) AND (date <= NOW())" . COM_getPermSQL('AND'); $result = DB_query($sql); $N = DB_fetchArray($result); $user_templates->set_var('number_stories', COM_numberFormat($N['count'])); if (!isset($_CONF['comment_engine']) || $_CONF['comment_engine'] == 'internal') { $user_templates->set_var('lang_number_comments', $LANG04[85]); $sql = "SELECT COUNT(*) AS count FROM {$_TABLES['comments']} WHERE (uid = " . (int) $user . ")"; if (!empty($sidList)) { $sql .= " AND (sid in ({$sidList}))"; } $result = DB_query($sql); $N = DB_fetchArray($result); $user_templates->set_var('number_comments', COM_numberFormat($N['count'])); $user_templates->set_var('lang_all_postings_by', $LANG04[86] . ' ' . $display_name); } // hook to the profile icon display $profileIcons = PLG_profileIconDisplay($user); if (is_array($profileIcons) && count($profileIcons) > 0) { $user_templates->set_block('profile', 'profileicon', 'pi'); for ($x = 0; $x < count($profileIcons); $x++) { if (isset($profileIcons[$x]['url']) && $profileIcons[$x]['url'] != '' && isset($profileIcons[$x]['icon']) && $profileIcons[$x]['icon'] != '') { $user_templates->set_var('profile_icon_url', $profileIcons[$x]['url']); $user_templates->set_var('profile_icon_icon', $profileIcons[$x]['icon']); $user_templates->set_var('profile_icon_text', $profileIcons[$x]['text']); $user_templates->parse('pi', 'profileicon', true); } } } // Call custom registration function if enabled and exists if ($_CONF['custom_registration'] && function_exists('CUSTOM_userDisplay')) { $user_templates->set_var('customfields', CUSTOM_userDisplay($user)); } PLG_profileVariablesDisplay($user, $user_templates); $user_templates->parse('output', 'profile'); $retval .= $user_templates->finish($user_templates->get_var('output')); $retval .= PLG_profileBlocksDisplay($user); return $retval; }
/** * Shows the user edit form * * @param int $uid User to edit * @param int $msg Error message to display * @return string HTML for user edit form * */ function edituser($uid = '', $msg = '') { global $_CONF, $_TABLES, $_USER, $LANG28, $LANG_ACCESS, $LANG_ADMIN, $MESSAGE; require_once $_CONF['path_system'] . 'lib-admin.php'; $retval = ''; if (!empty($msg)) { $retval .= COM_showMessageText($MESSAGE[$msg], $LANG28[22]); } if (!empty($msg) && !empty($uid) && $uid > 1) { // an error occured while editing a user - if it was a new account, // don't bother trying to read the user's data from the database ... $cnt = DB_count($_TABLES['users'], 'uid', $uid); if ($cnt == 0) { $uid = ''; } } if (!empty($uid) && $uid > 1) { $result = DB_query("SELECT * FROM {$_TABLES['users']} WHERE uid = '{$uid}'"); $A = DB_fetchArray($result); if (empty($A['uid'])) { return COM_refresh($_CONF['site_admin_url'] . '/user.php'); } if (SEC_inGroup('Root', $uid) and !SEC_inGroup('Root')) { // the current admin user isn't Root but is trying to change // a root account. Deny them and log it. $retval .= COM_showMessageText($LANG_ACCESS['editrootmsg'], $LANG28[1]); COM_accessLog("User {$_USER['username']} tried to edit a Root account with insufficient privileges."); return $retval; } $curtime = COM_getUserDateTimeFormat($A['regdate']); $lastlogin = DB_getItem($_TABLES['userinfo'], 'lastlogin', "uid = '{$uid}'"); $lasttime = COM_getUserDateTimeFormat($lastlogin); } else { $A['uid'] = ''; $uid = ''; $curtime = COM_getUserDateTimeFormat(); $lastlogin = ''; $lasttime = ''; $A['status'] = USER_ACCOUNT_ACTIVE; } // POST data can override, in case there was an error while editing a user if (isset($_POST['username'])) { $A['username'] = strip_tags($_POST['username']); } if (isset($_POST['fullname'])) { $A['fullname'] = strip_tags($_POST['fullname']); } if (isset($_POST['email'])) { $A['email'] = strip_tags($_POST['email']); } if (isset($_POST['homepage'])) { $A['homepage'] = strip_tags($_POST['homepage']); } if (isset($_POST['userstatus'])) { $A['status'] = COM_applyFilter($_POST['userstatus'], true); } $token = SEC_createToken(); $retval .= COM_startBlock($LANG28[1], '', COM_getBlockTemplate('_admin_block', 'header')); $retval .= SEC_getTokenExpiryNotice($token); $user_templates = COM_newTemplate($_CONF['path_layout'] . 'admin/user'); $user_templates->set_file(array('form' => 'edituser.thtml', 'password' => 'password.thtml', 'groupedit' => 'groupedit.thtml')); $user_templates->set_var('lang_save', $LANG_ADMIN['save']); if (!empty($uid) && $A['uid'] != $_USER['uid'] && SEC_hasRights('user.delete')) { $delbutton = '<input type="submit" value="' . $LANG_ADMIN['delete'] . '" name="mode"%s' . XHTML . '>'; $jsconfirm = ' onclick="return confirm(\'' . $MESSAGE[76] . '\');"'; $user_templates->set_var('delete_option', sprintf($delbutton, $jsconfirm)); $user_templates->set_var('delete_option_no_confirmation', sprintf($delbutton, '')); } $user_templates->set_var('lang_cancel', $LANG_ADMIN['cancel']); $user_templates->set_var('lang_userid', $LANG28[2]); if (empty($A['uid'])) { $user_templates->set_var('user_id', $LANG_ADMIN['na']); } else { $user_templates->set_var('user_id', $A['uid']); } $user_templates->set_var('lang_regdate', $LANG28[14]); $user_templates->set_var('regdate_timestamp', $curtime[1]); $user_templates->set_var('user_regdate', $curtime[0]); $user_templates->set_var('lang_lastlogin', $LANG28[35]); if (empty($lastlogin)) { $user_templates->set_var('user_lastlogin', $LANG28[36]); } else { $user_templates->set_var('user_lastlogin', $lasttime[0]); } $user_templates->set_var('lang_username', $LANG28[3]); if (isset($A['username'])) { $user_templates->set_var('username', $A['username']); } else { $user_templates->set_var('username', ''); } $remoteservice = ''; if ($_CONF['show_servicename']) { if (!empty($A['remoteservice'])) { $remoteservice = '@' . $A['remoteservice']; } } $user_templates->set_var('remoteservice', $remoteservice); if ($_CONF['allow_user_photo'] && $A['uid'] > 0) { $photo = USER_getPhoto($A['uid'], $A['photo'], $A['email'], -1); $user_templates->set_var('user_photo', $photo); if (empty($A['photo'])) { $user_templates->set_var('lang_delete_photo', ''); $user_templates->set_var('delete_photo_option', ''); } else { $user_templates->set_var('lang_delete_photo', $LANG28[28]); $user_templates->set_var('delete_photo_option', '<input type="checkbox" name="delete_photo"' . XHTML . '>'); } } else { $user_templates->set_var('user_photo', ''); $user_templates->set_var('lang_delete_photo', ''); $user_templates->set_var('delete_photo_option', ''); } $user_templates->set_var('lang_fullname', $LANG28[4]); if (isset($A['fullname'])) { $user_templates->set_var('user_fullname', htmlspecialchars($A['fullname'])); } else { $user_templates->set_var('user_fullname', ''); } if (empty($A['remoteservice'])) { $user_templates->set_var('lang_password', $LANG28[5]); $user_templates->set_var('lang_password_conf', $LANG28[39]); $user_templates->parse('password_option', 'password', true); } else { $user_templates->set_var('password_option', ''); } $user_templates->set_var('lang_emailaddress', $LANG28[7]); if (isset($A['email'])) { $user_templates->set_var('user_email', htmlspecialchars($A['email'])); } else { $user_templates->set_var('user_email', ''); } $user_templates->set_var('lang_homepage', $LANG28[8]); if (isset($A['homepage'])) { $user_templates->set_var('user_homepage', htmlspecialchars($A['homepage'])); } else { $user_templates->set_var('user_homepage', ''); } $user_templates->set_var('do_not_use_spaces', ''); $statusarray = array(USER_ACCOUNT_AWAITING_ACTIVATION => $LANG28[43], USER_ACCOUNT_ACTIVE => $LANG28[45]); $allow_ban = true; if (!empty($uid)) { if ($A['uid'] == $_USER['uid']) { $allow_ban = false; // do not allow to ban yourself } elseif (SEC_inGroup('Root', $A['uid'])) { // editing a Root user? $count_root_sql = "SELECT COUNT(ug_uid) AS root_count FROM {$_TABLES['group_assignments']} WHERE ug_main_grp_id = 1 GROUP BY ug_uid;"; $count_root_result = DB_query($count_root_sql); $C = DB_fetchArray($count_root_result); // how many are left? if ($C['root_count'] < 2) { $allow_ban = false; // prevent banning the last root user } } } if ($allow_ban) { $statusarray[USER_ACCOUNT_DISABLED] = $LANG28[42]; } if ($_CONF['usersubmission'] == 1 && !empty($uid)) { $statusarray[USER_ACCOUNT_AWAITING_APPROVAL] = $LANG28[44]; } asort($statusarray); $statusselect = '<select name="userstatus">'; foreach ($statusarray as $key => $value) { $statusselect .= '<option value="' . $key . '"'; if ($key == $A['status']) { $statusselect .= ' selected="selected"'; } $statusselect .= '>' . $value . '</option>' . LB; } $statusselect .= '</select><input type="hidden" name="oldstatus" value="' . $A['status'] . '"' . XHTML . '>'; $user_templates->set_var('user_status', $statusselect); $user_templates->set_var('lang_user_status', $LANG28[46]); if ($_CONF['custom_registration'] and function_exists('CUSTOM_userEdit')) { if (!empty($uid) && $uid > 1) { $user_templates->set_var('customfields', CUSTOM_userEdit($uid)); } else { $user_templates->set_var('customfields', CUSTOM_userEdit($A['uid'])); } } if (SEC_hasRights('group.assign')) { $user_templates->set_var('lang_securitygroups', $LANG_ACCESS['securitygroups']); $user_templates->set_var('lang_groupinstructions', $LANG_ACCESS['securitygroupsmsg']); if (!empty($uid)) { $usergroups = SEC_getUserGroups($uid); if (is_array($usergroups) && !empty($uid)) { $selected = implode(' ', $usergroups); } else { $selected = ''; } } else { $selected = DB_getItem($_TABLES['groups'], 'grp_id', "grp_name = 'All Users'") . ' '; $selected .= DB_getItem($_TABLES['groups'], 'grp_id', "grp_name = 'Logged-in Users'"); // add default groups, if any $result = DB_query("SELECT grp_id FROM {$_TABLES['groups']} WHERE grp_default = 1"); $num_defaults = DB_numRows($result); for ($i = 0; $i < $num_defaults; $i++) { list($def_grp) = DB_fetchArray($result); $selected .= ' ' . $def_grp; } } // in case of an error we may have previously selected a different // mix of groups already - reconstruct those from the POST data if (isset($_POST['groups']) && count($_POST['groups']) > 0) { $selected = implode(' ', $_POST['groups']); } $thisUsersGroups = SEC_getUserGroups(); $remoteGroup = DB_getItem($_TABLES['groups'], 'grp_id', "grp_name = 'Remote Users'"); if (!empty($remoteGroup)) { $thisUsersGroups[] = $remoteGroup; } $whereGroups = 'grp_id IN (' . implode(',', $thisUsersGroups) . ')'; $header_arr = array(array('text' => $LANG28[86], 'field' => 'checkbox', 'sort' => false), array('text' => $LANG_ACCESS['groupname'], 'field' => 'grp_name', 'sort' => true), array('text' => $LANG_ACCESS['description'], 'field' => 'grp_descr', 'sort' => true)); $defsort_arr = array('field' => 'grp_name', 'direction' => 'asc'); $form_url = $_CONF['site_admin_url'] . '/user.php?mode=edit&uid=' . $uid; $text_arr = array('has_menu' => false, 'title' => '', 'instructions' => '', 'icon' => '', 'form_url' => $form_url, 'inline' => true); $sql = "SELECT grp_id, grp_name, grp_descr FROM {$_TABLES['groups']} WHERE " . $whereGroups; $query_arr = array('table' => 'groups', 'sql' => $sql, 'query_fields' => array('grp_name'), 'default_filter' => '', 'query' => '', 'query_limit' => 0); $groupoptions = ADMIN_list('usergroups', 'ADMIN_getListField_usergroups', $header_arr, $text_arr, $query_arr, $defsort_arr, '', explode(' ', $selected)); $user_templates->set_var('group_options', $groupoptions); $user_templates->parse('group_edit', 'groupedit', true); } else { // user doesn't have the rights to edit a user's groups so set to -1 // so we know not to handle the groups array when we save $user_templates->set_var('group_edit', '<input type="hidden" name="groups" value="-1"' . XHTML . '>'); } $user_templates->set_var('gltoken_name', CSRF_TOKEN); $user_templates->set_var('gltoken', $token); $user_templates->parse('output', 'form'); $retval .= $user_templates->finish($user_templates->get_var('output')); $retval .= COM_endBlock(COM_getBlockTemplate('_admin_block', 'footer')); return $retval; }
/** * Shows a profile for a user * * This grabs the user profile for a given user and displays it * * @param int $user User ID of profile to get * @param int $msg Message to display (if != 0) * @return string HTML for user profile page * */ function userprofile($user, $msg = 0) { global $_CONF, $_TABLES, $_USER, $LANG01, $LANG04, $LANG09, $LANG_LOGIN; $retval = ''; if (empty($_USER['username']) && ($_CONF['loginrequired'] == 1 || $_CONF['profileloginrequired'] == 1)) { $retval .= COM_siteHeader('menu'); $retval .= COM_startBlock($LANG_LOGIN[1], '', COM_getBlockTemplate('_msg_block', 'header')); $login = new Template($_CONF['path_layout'] . 'submit'); $login->set_file(array('login' => 'submitloginrequired.thtml')); $login->set_var('xhtml', XHTML); $login->set_var('login_message', $LANG_LOGIN[2]); $login->set_var('site_url', $_CONF['site_url']); $login->set_var('site_admin_url', $_CONF['site_admin_url']); $login->set_var('layout_url', $_CONF['layout_url']); $login->set_var('lang_login', $LANG_LOGIN[3]); $login->set_var('lang_newuser', $LANG_LOGIN[4]); $login->parse('output', 'login'); $retval .= $login->finish($login->get_var('output')); $retval .= COM_endBlock(COM_getBlockTemplate('_msg_block', 'footer')); $retval .= COM_siteFooter(); return $retval; } $result = DB_query("SELECT {$_TABLES['users']}.uid,username,fullname,regdate,homepage,about,location,pgpkey,photo,email FROM {$_TABLES['userinfo']},{$_TABLES['users']} WHERE {$_TABLES['userinfo']}.uid = {$_TABLES['users']}.uid AND {$_TABLES['users']}.uid = {$user}"); $nrows = DB_numRows($result); if ($nrows == 0) { // no such user return COM_refresh($_CONF['site_url'] . '/index.php'); } $A = DB_fetchArray($result); $display_name = COM_getDisplayName($user, $A['username'], $A['fullname']); // format date/time to user preference $curtime = COM_getUserDateTimeFormat($A['regdate']); $A['regdate'] = $curtime[0]; $user_templates = new Template($_CONF['path_layout'] . 'users'); $user_templates->set_file(array('profile' => 'profile.thtml', 'row' => 'commentrow.thtml', 'strow' => 'storyrow.thtml')); $user_templates->set_var('xhtml', XHTML); $user_templates->set_var('site_url', $_CONF['site_url']); $user_templates->set_var('start_block_userprofile', COM_startBlock($LANG04[1] . ' ' . $display_name)); $user_templates->set_var('end_block', COM_endBlock()); $user_templates->set_var('lang_username', $LANG04[2]); if ($_CONF['show_fullname'] == 1) { $user_templates->set_var('username', $A['fullname']); $user_templates->set_var('user_fullname', $A['username']); } else { $user_templates->set_var('username', $A['username']); $user_templates->set_var('user_fullname', $A['fullname']); } if (SEC_hasRights('user.edit')) { global $_IMAGE_TYPE, $LANG_ADMIN; $edit_icon = '<img src="' . $_CONF['layout_url'] . '/images/edit.' . $_IMAGE_TYPE . '" alt="' . $LANG_ADMIN['edit'] . '" title="' . $LANG_ADMIN['edit'] . '"' . XHTML . '>'; $edit_link_url = COM_createLink($edit_icon, "{$_CONF['site_admin_url']}/user.php?mode=edit&uid={$A['uid']}"); $user_templates->set_var('edit_link', $edit_link_url); } $photo = USER_getPhoto($user, $A['photo'], $A['email'], -1); $user_templates->set_var('user_photo', $photo); $user_templates->set_var('lang_membersince', $LANG04[67]); $user_templates->set_var('user_regdate', $A['regdate']); $user_templates->set_var('lang_email', $LANG04[5]); $user_templates->set_var('user_id', $user); $user_templates->set_var('lang_sendemail', $LANG04[81]); $user_templates->set_var('lang_homepage', $LANG04[6]); $user_templates->set_var('user_homepage', COM_killJS($A['homepage'])); $user_templates->set_var('lang_location', $LANG04[106]); $user_templates->set_var('user_location', strip_tags($A['location'])); $user_templates->set_var('lang_bio', $LANG04[7]); $user_templates->set_var('user_bio', nl2br(stripslashes($A['about']))); $user_templates->set_var('lang_pgpkey', $LANG04[8]); $user_templates->set_var('user_pgp', nl2br($A['pgpkey'])); $user_templates->set_var('start_block_last10stories', COM_startBlock($LANG04[82] . ' ' . $display_name)); $user_templates->set_var('start_block_last10comments', COM_startBlock($LANG04[10] . ' ' . $display_name)); $user_templates->set_var('start_block_postingstats', COM_startBlock($LANG04[83] . ' ' . $display_name)); $user_templates->set_var('lang_title', $LANG09[16]); $user_templates->set_var('lang_date', $LANG09[17]); // for alternative layouts: use these as headlines instead of block titles $user_templates->set_var('headline_last10stories', $LANG04[82]); $user_templates->set_var('headline_last10comments', $LANG04[10]); $user_templates->set_var('headline_postingstats', $LANG04[83]); $result = DB_query("SELECT tid FROM {$_TABLES['topics']}" . COM_getPermSQL()); $nrows = DB_numRows($result); $tids = array(); for ($i = 0; $i < $nrows; $i++) { $T = DB_fetchArray($result); $tids[] = $T['tid']; } $topics = "'" . implode("','", $tids) . "'"; // list of last 10 stories by this user if (count($tids) > 0) { $sql = "SELECT sid,title,UNIX_TIMESTAMP(date) AS unixdate FROM {$_TABLES['stories']} WHERE (uid = {$user}) AND (draft_flag = 0) AND (date <= NOW()) AND (tid IN ({$topics}))" . COM_getPermSQL('AND'); $sql .= " ORDER BY unixdate DESC LIMIT 10"; $result = DB_query($sql); $nrows = DB_numRows($result); } else { $nrows = 0; } if ($nrows > 0) { for ($i = 0; $i < $nrows; $i++) { $C = DB_fetchArray($result); $user_templates->set_var('cssid', $i % 2 + 1); $user_templates->set_var('row_number', $i + 1 . '.'); $articleUrl = COM_buildUrl($_CONF['site_url'] . '/article.php?story=' . $C['sid']); $user_templates->set_var('article_url', $articleUrl); $C['title'] = str_replace('$', '$', $C['title']); $user_templates->set_var('story_title', COM_createLink(stripslashes($C['title']), $articleUrl, array('class' => 'b'))); $storytime = COM_getUserDateTimeFormat($C['unixdate']); $user_templates->set_var('story_date', $storytime[0]); $user_templates->parse('story_row', 'strow', true); } } else { $user_templates->set_var('story_row', '<tr><td>' . $LANG01[37] . '</td></tr>'); } // list of last 10 comments by this user $sidArray = array(); if (count($tids) > 0) { // first, get a list of all stories the current visitor has access to $sql = "SELECT sid FROM {$_TABLES['stories']} WHERE (draft_flag = 0) AND (date <= NOW()) AND (tid IN ({$topics}))" . COM_getPermSQL('AND'); $result = DB_query($sql); $numsids = DB_numRows($result); for ($i = 1; $i <= $numsids; $i++) { $S = DB_fetchArray($result); $sidArray[] = $S['sid']; } } $sidList = implode("', '", $sidArray); $sidList = "'{$sidList}'"; // then, find all comments by the user in those stories $sql = "SELECT sid,title,cid,UNIX_TIMESTAMP(date) AS unixdate FROM {$_TABLES['comments']} WHERE (uid = {$user}) GROUP BY sid,title,cid,UNIX_TIMESTAMP(date)"; // SQL NOTE: Using a HAVING clause is usually faster than a where if the // field is part of the select // if (!empty ($sidList)) { // $sql .= " AND (sid in ($sidList))"; // } if (!empty($sidList)) { $sql .= " HAVING sid in ({$sidList})"; } $sql .= " ORDER BY unixdate DESC LIMIT 10"; $result = DB_query($sql); $nrows = DB_numRows($result); if ($nrows > 0) { for ($i = 0; $i < $nrows; $i++) { $C = DB_fetchArray($result); $user_templates->set_var('cssid', $i % 2 + 1); $user_templates->set_var('row_number', $i + 1 . '.'); $comment_url = $_CONF['site_url'] . '/comment.php?mode=view&cid=' . $C['cid']; $C['title'] = str_replace('$', '$', $C['title']); $user_templates->set_var('comment_title', COM_createLink(stripslashes($C['title']), $comment_url, array('class' => 'b'))); $commenttime = COM_getUserDateTimeFormat($C['unixdate']); $user_templates->set_var('comment_date', $commenttime[0]); $user_templates->parse('comment_row', 'row', true); } } else { $user_templates->set_var('comment_row', '<tr><td>' . $LANG01[29] . '</td></tr>'); } // posting stats for this user $user_templates->set_var('lang_number_stories', $LANG04[84]); $sql = "SELECT COUNT(*) AS count FROM {$_TABLES['stories']} WHERE (uid = {$user}) AND (draft_flag = 0) AND (date <= NOW())" . COM_getPermSQL('AND'); $result = DB_query($sql); $N = DB_fetchArray($result); $user_templates->set_var('number_stories', COM_numberFormat($N['count'])); $user_templates->set_var('lang_number_comments', $LANG04[85]); $sql = "SELECT COUNT(*) AS count FROM {$_TABLES['comments']} WHERE (uid = {$user})"; if (!empty($sidList)) { $sql .= " AND (sid in ({$sidList}))"; } $result = DB_query($sql); $N = DB_fetchArray($result); $user_templates->set_var('number_comments', COM_numberFormat($N['count'])); $user_templates->set_var('lang_all_postings_by', $LANG04[86] . ' ' . $display_name); // Call custom registration function if enabled and exists if ($_CONF['custom_registration'] && function_exists('CUSTOM_userDisplay')) { $user_templates->set_var('customfields', CUSTOM_userDisplay($user)); } PLG_profileVariablesDisplay($user, $user_templates); $user_templates->parse('output', 'profile'); $retval .= $user_templates->finish($user_templates->get_var('output')); $retval .= PLG_profileBlocksDisplay($user); return $retval; }
/** * Takes an article class and renders HTML in the specified template and style. * Formats the given article into HTML. Called by index.php, article.php, * submit.php and admin/story.php (Preview mode for the last two). * * @param Story $story The story to display, an instance of the Story class. * @param string $index n = Full display of article. p = 'Preview' mode. Else introtext only. * @param string $storyTpl The template to use to render the story. * @param string $query A search query, if one was specified. * @return string Article as formatted HTML. * Note: Formerly named COM_Article, and re-written totally since then. */ function STORY_renderArticle($story, $index = '', $storyTpl = 'storytext.thtml', $query = '') { global $_CONF, $_TABLES, $_USER, $LANG01, $LANG05, $LANG11, $LANG_TRB, $_IMAGE_TYPE, $mode; static $storyCounter = 0; if ($story->DisplayElements('featured') == 1) { $article_filevar = 'featuredarticle'; } elseif ($story->DisplayElements('statuscode') == STORY_ARCHIVE_ON_EXPIRE && $story->DisplayElements('expire') <= time()) { $article_filevar = 'archivearticle'; } else { $article_filevar = 'article'; } if (empty($storyTpl)) { $storyTpl = 'storytext.thtml'; } // Change article template file with the topic (feature request #275) $templateDir = $_CONF['path_layout']; $topicDir = $templateDir . 'topics/' . $story->DisplayElements('tid') . '/'; if (is_dir($topicDir) && file_exists($topicDir . $storyTpl)) { $templateDir = $topicDir; } $article = COM_newTemplate($templateDir); $article->set_file(array('article' => $storyTpl, 'bodytext' => 'storybodytext.thtml', 'featuredarticle' => 'featuredstorytext.thtml', 'featuredbodytext' => 'featuredstorybodytext.thtml', 'archivearticle' => 'archivestorytext.thtml', 'archivebodytext' => 'archivestorybodytext.thtml')); // begin instance caching... $cache_time = $story->DisplayElements('cache_time'); $current_article_tid = $story->DisplayElements('tid'); $retval = false; // If stays false will rebuild article and not used cache (checks done below) if ($cache_time > 0 || $cache_time == -1) { $hash = CACHE_security_hash(); $cacheInstance = 'article__' . $story->getSid() . '_' . $index . $mode . '_' . $article_filevar . '_' . $current_article_tid . '_' . $hash . '_' . $_USER['theme']; if ($_CONF['cache_templates']) { $retval = $article->check_instance($cacheInstance, $article_filevar); } else { $retval = CACHE_check_instance($cacheInstance); } if ($retval && $cache_time == -1) { // Cache file found so use it since no time limit set to recreate } elseif ($retval && $cache_time > 0) { $lu = CACHE_get_instance_update($cacheInstance); $now = time(); if ($now - $lu < $cache_time) { // Cache file found so use it since under time limit set to recreate } else { // generate article and create cache file // Cache time is not built into template caching so need to delete it manually and reset $retval if ($_CONF['cache_templates']) { // Need to close and recreate template class since issues arise when theme templates are cached unset($article); // Close template class CACHE_remove_instance($cacheInstance); $article = COM_newTemplate($_CONF['path_layout']); $article->set_file(array('article' => $storyTpl, 'bodytext' => 'storybodytext.thtml', 'featuredarticle' => 'featuredstorytext.thtml', 'featuredbodytext' => 'featuredstorybodytext.thtml', 'archivearticle' => 'archivestorytext.thtml', 'archivebodytext' => 'archivestorybodytext.thtml')); } else { // theme templates are not cache so can go ahead and delete story cache CACHE_remove_instance($cacheInstance); } $retval = false; } } else { // Need to reset especially if caching is disabled for a certain story but template caching has been enabled for the theme $retval = false; } } $articleUrl = COM_buildURL($_CONF['site_url'] . '/article.php?story=' . $story->getSid()); $article->set_var('article_url', $articleUrl); $article->set_var('story_title', $story->DisplayElements('title')); // Date formatting set by user therefore cannot be cached $article->set_var('story_date', $story->DisplayElements('date'), false, true); $article->set_var('story_datetime', $story->DisplayElements('datetime'), false, true); // Story views increase with every visit so cannot be cached if ($_CONF['hideviewscount'] != 1) { $article->set_var('lang_views', $LANG01[106], false, true); $article->set_var('story_hits', $story->DisplayElements('hits'), false, true); } // Topic Icon is user configurable so do not cache $topicname = $story->DisplayElements('topic'); $topicurl = COM_buildURL($_CONF['site_url'] . '/index.php?topic=' . $story->DisplayElements('tid')); if ((!isset($_USER['noicons']) || $_USER['noicons'] != 1) && $story->DisplayElements('show_topic_icon') == 1) { $imageurl = $story->DisplayElements('imageurl'); if (!empty($imageurl)) { $imageurl = COM_getTopicImageUrl($imageurl); $article->set_var('story_topic_image_url', $imageurl, false, true); $topicimage = '<img src="' . $imageurl . '" class="float' . $_CONF['article_image_align'] . '" alt="' . $topicname . '" title="' . $topicname . '"' . XHTML . '>'; $article->set_var('story_anchortag_and_image', COM_createLink($topicimage, $topicurl, array()), false, true); $article->set_var('story_topic_image', $topicimage, false, true); $topicimage_noalign = '<img src="' . $imageurl . '" alt="' . $topicname . '" title="' . $topicname . '"' . XHTML . '>'; $article->set_var('story_anchortag_and_image_no_align', COM_createLink($topicimage_noalign, $topicurl, array()), false, true); $article->set_var('story_topic_image_no_align', $topicimage_noalign, false, true); } } // Main article content if ($index == 'p') { $introtext = $story->getPreviewText('introtext'); $bodytext = $story->getPreviewText('bodytext'); } else { $introtext = $story->displayElements('introtext'); $bodytext = $story->displayElements('bodytext'); } $readmore = empty($bodytext) ? 0 : 1; $numwords = COM_numberFormat(count(explode(' ', COM_getTextContent($bodytext)))); if (COM_onFrontpage()) { $bodytext = ''; } if (!empty($query)) { $introtext = COM_highlightQuery($introtext, $query); $bodytext = COM_highlightQuery($bodytext, $query); } // Create article only if preview, or query not empty, or if no cache version or cache version is not required if ($index == 'p' || !empty($query) || !$retval) { $article->set_var('article_filevar', ''); $article->set_var('site_name', $_CONF['site_name']); //$article->set_var( 'story_date', $story->DisplayElements('date') ); $article->set_var('story_date_short', $story->DisplayElements('shortdate')); $article->set_var('story_date_only', $story->DisplayElements('dateonly')); $article->set_var('story_id', $story->getSid()); if ($_CONF['contributedbyline'] == 1) { $article->set_var('lang_contributed_by', $LANG01[1]); $article->set_var('contributedby_uid', $story->DisplayElements('uid')); $fullname = $story->DisplayElements('fullname'); $username = $story->DisplayElements('username'); $article->set_var('contributedby_user', $username); if (empty($fullname)) { $article->set_var('contributedby_fullname', $username); } else { $article->set_var('contributedby_fullname', $fullname); } $authorname = COM_getDisplayName($story->DisplayElements('uid'), $username, $fullname); $article->set_var('contributedby_author', $authorname); $article->set_var('author', $authorname); $profileUrl = ''; if ($story->DisplayElements('uid') > 1) { $profileUrl = $_CONF['site_url'] . '/users.php?mode=profile&uid=' . $story->DisplayElements('uid'); $article->set_var('start_contributedby_anchortag', '<a class="storybyline" href="' . $profileUrl . '" rel="author">'); $article->set_var('end_contributedby_anchortag', '</a>'); $article->set_var('contributedby_url', $profileUrl); } $photo = ''; if ($_CONF['allow_user_photo'] == 1) { $authphoto = $story->DisplayElements('photo'); if (empty($authphoto)) { $authphoto = '(none)'; // user does not have a photo } $photo = USER_getPhoto($story->DisplayElements('uid'), $authphoto, $story->DisplayElements('email')); } if (!empty($photo)) { $article->set_var('contributedby_photo', $photo); $article->set_var('author_photo', $photo); $camera_icon = '<img src="' . $_CONF['layout_url'] . '/images/smallcamera.' . $_IMAGE_TYPE . '" alt=""' . XHTML . '>'; $article->set_var('camera_icon', COM_createLink($camera_icon, $profileUrl)); } else { $article->set_var('contributedby_photo', ''); $article->set_var('author_photo', ''); $article->set_var('camera_icon', ''); } } $article->set_var('story_topic_id', $story->DisplayElements('tid')); $article->set_var('story_topic_name', $topicname); $article->set_var('story_topic_url', $topicurl); $recent_post_anchortag = ''; $article->set_var('lang_permalink', $LANG01[127]); $show_comments = true; // n = Full display of article. p = 'Preview' mode. if ($index != 'n' && $index != 'p' || !empty($query)) { $attributes = ' class="non-ul"'; $attr_array = array('class' => 'non-ul'); if (!empty($query)) { $attributes .= ' rel="bookmark"'; $attr_array['rel'] = 'bookmark'; } $article->set_var('start_storylink_anchortag', '<a href="' . $articleUrl . '"' . $attributes . '>'); $article->set_var('end_storylink_anchortag', '</a>'); $article->set_var('story_title_link', COM_createLink($story->DisplayElements('title'), $articleUrl, $attr_array)); } else { $article->set_var('story_title_link', $story->DisplayElements('title')); } $related_topics = ''; if ($index == 'n') { if ($_CONF['supported_version_theme'] == '1.8.1') { $article->set_var('breadcrumb_trail', TOPIC_breadcrumbs('article', $story->getSid())); } if ($_CONF['related_topics'] > 0) { $related_topics = TOPIC_relatedTopics('article', $story->getSid(), $_CONF['related_topics_max']); $article->set_var('related_topics', $related_topics); } } elseif ($index != 'p') { if ($_CONF['related_topics'] > 1) { $related_topics = TOPIC_relatedTopics('article', $story->getSid(), $_CONF['related_topics_max']); $article->set_var('related_topics', $related_topics); } } $page_selector = ''; $readmore_link = ''; $post_comment_link = ''; $plugin_itemdisplay = ''; $comments_with_count = ''; $trackbacks_with_count = ''; if ($index == 'n' || $index == 'p') { if (empty($bodytext)) { $article->set_var('story_introtext', $introtext); $article->set_var('story_text_no_br', $introtext); } else { if ($_CONF['allow_page_breaks'] == 1 && $index == 'n') { $story_page = 1; // page selector if (is_numeric($mode)) { $story_page = $mode; if ($story_page <= 0) { $story_page = 1; $mode = 0; } elseif ($story_page > 1) { $introtext = ''; } } $article_array = explode('[page_break]', $bodytext); $page_break_count = count($article_array); if ($story_page > $page_break_count) { // Can't have page count greater than actual number of pages $story_page = $page_break_count; } $page_selector = COM_printPageNavigation($articleUrl, $story_page, $page_break_count, 'mode=', $_CONF['url_rewrite'], $LANG01[118]); if (count($article_array) > 1) { $bodytext = $article_array[$story_page - 1]; } $article->set_var('page_selector', $page_selector); if ($_CONF['page_break_comments'] == 'last' && $story_page < count($article_array) || $_CONF['page_break_comments'] == 'first' && $story_page != 1) { $show_comments = false; } $article->set_var('story_page', $story_page); } $article->set_var('story_introtext', $introtext . '<br' . XHTML . '><br' . XHTML . '>' . $bodytext); $article->set_var('story_text_no_br', $introtext . ' ' . $bodytext); } $article->set_var('story_introtext_only', $introtext); $article->set_var('story_bodytext_only', $bodytext); if (($_CONF['trackback_enabled'] || $_CONF['pingback_enabled']) && SEC_hasRights('story.ping')) { $url = $_CONF['site_admin_url'] . '/trackback.php?mode=sendall&id=' . $story->getSid(); $article->set_var('send_trackback_link', COM_createLink($LANG_TRB['send_trackback'], $url)); $pingico = '<img src="' . $_CONF['layout_url'] . '/images/sendping.' . $_IMAGE_TYPE . '" alt="' . $LANG_TRB['send_trackback'] . '" title="' . $LANG_TRB['send_trackback'] . '"' . XHTML . '>'; $article->set_var('send_trackback_icon', COM_createLink($pingico, $url)); $article->set_var('send_trackback_url', $url); $article->set_var('lang_send_trackback_text', $LANG_TRB['send_trackback']); } $article->set_var('story_display', $index == 'p' ? 'preview' : 'article'); $article->set_var('story_counter', 0); } else { $article->set_var('story_introtext', $introtext); $article->set_var('story_text_no_br', $introtext); $article->set_var('story_introtext_only', $introtext); if ($readmore) { $article->set_var('lang_readmore', $LANG01[2]); $article->set_var('lang_readmore_words', $LANG01[62]); $article->set_var('readmore_words', $numwords); $readmore_link = COM_createLink($LANG01[2], $articleUrl, array('class' => 'story-read-more-link')) . ' (' . $numwords . ' ' . $LANG01[62] . ') '; $article->set_var('readmore_link', $readmore_link); $article->set_var('start_readmore_anchortag', '<a href="' . $articleUrl . '" class="story-read-more-link">'); $article->set_var('end_readmore_anchortag', '</a>'); $article->set_var('read_more_class', 'class="story-read-more-link"'); } if ($story->DisplayElements('commentcode') >= 0 && $show_comments) { $commentsUrl = COM_buildUrl($_CONF['site_url'] . '/article.php?story=' . $story->getSid()) . '#comments'; $article->set_var('comments_url', $commentsUrl); $article->set_var('comments_text', COM_numberFormat($story->DisplayElements('comments')) . ' ' . $LANG01[3]); $article->set_var('comments_count', COM_numberFormat($story->DisplayElements('comments'))); $article->set_var('lang_comments', $LANG01[3]); $comments_with_count = sprintf($LANG01[121], COM_numberFormat($story->DisplayElements('comments'))); if ($story->DisplayElements('comments') > 0) { $result = DB_query("SELECT UNIX_TIMESTAMP(date) AS day,username,fullname,{$_TABLES['comments']}.uid as cuid FROM {$_TABLES['comments']},{$_TABLES['users']} WHERE {$_TABLES['users']}.uid = {$_TABLES['comments']}.uid AND sid = '" . $story->getSid() . "' ORDER BY date DESC LIMIT 1"); $C = DB_fetchArray($result); $recent_post_anchortag = '<span class="storybyline">' . $LANG01[27] . ': ' . strftime($_CONF['daytime'], $C['day']) . ' ' . $LANG01[104] . ' ' . COM_getDisplayName($C['cuid'], $C['username'], $C['fullname']) . '</span>'; $comments_with_count = COM_createLink($comments_with_count, $commentsUrl); $article->set_var('comments_with_count', $comments_with_count); $article->set_var('start_comments_anchortag', '<a href="' . $commentsUrl . '">'); $article->set_var('end_comments_anchortag', '</a>'); } else { $article->set_var('comments_with_count', $comments_with_count); if ($_CONF['comment_on_same_page'] == true) { $recent_post_anchortag = COM_createLink($LANG01[60], $_CONF['site_url'] . '/article.php?story=' . $story->getSid() . '#commenteditform'); } else { $recent_post_anchortag = COM_createLink($LANG01[60], $_CONF['site_url'] . '/comment.php?sid=' . $story->getSid() . '&pid=0&type=article'); if ($_CONF['show_comments_at_replying'] == true) { $recent_post_anchortag .= '#commenteditform'; } } } if ($story->DisplayElements('commentcode') == 0) { if ($_CONF['comment_on_same_page'] == true) { $postCommentUrl = $_CONF['site_url'] . '/article.php?story=' . $story->getSid() . '#commenteditform'; } else { $postCommentUrl = $_CONF['site_url'] . '/comment.php?sid=' . $story->getSid() . '&pid=0&type=article'; if ($_CONF['show_comments_at_replying'] == true) { $postCommentUrl .= '#commenteditform'; } } $post_comment_link = COM_createLink($LANG01[60], $postCommentUrl, array('rel' => 'nofollow')); $article->set_var('post_comment_link', $post_comment_link); /* $article->set_var( 'subscribe_link', COM_createLink('Nubbies', '', array('rel' => 'nofollow')) ); */ $article->set_var('lang_post_comment', $LANG01[60]); $article->set_var('start_post_comment_anchortag', '<a href="' . $postCommentUrl . '" rel="nofollow">'); $article->set_var('end_post_comment_anchortag', '</a>'); } } if (($_CONF['trackback_enabled'] || $_CONF['pingback_enabled']) && $story->DisplayElements('trackbackcode') >= 0 && $show_comments) { $num_trackbacks = COM_numberFormat($story->DisplayElements('trackbacks')); $trackbacksUrl = COM_buildUrl($_CONF['site_url'] . '/article.php?story=' . $story->getSid()) . '#trackback'; $article->set_var('trackbacks_url', $trackbacksUrl); $article->set_var('trackbacks_text', $num_trackbacks . ' ' . $LANG_TRB['trackbacks']); $article->set_var('trackbacks_count', $num_trackbacks); $article->set_var('lang_trackbacks', $LANG_TRB['trackbacks']); if (SEC_hasRights('story.ping')) { $pingurl = $_CONF['site_admin_url'] . '/trackback.php?mode=sendall&id=' . $story->getSid(); $pingico = '<img src="' . $_CONF['layout_url'] . '/images/sendping.' . $_IMAGE_TYPE . '" alt="' . $LANG_TRB['send_trackback'] . '" title="' . $LANG_TRB['send_trackback'] . '"' . XHTML . '>'; $article->set_var('send_trackback_icon', COM_createLink($pingico, $pingurl)); } $trackbacks_with_count = sprintf($LANG01[122], $num_trackbacks); if ($story->DisplayElements('trackbacks') > 0) { $trackbacks_with_count = COM_createLink($trackbacks_with_count, $trackbacksUrl); } $article->set_var('trackbacks_with_count', $trackbacks_with_count); } if ($_CONF['hideemailicon'] == 1 || COM_isAnonUser() && ($_CONF['loginrequired'] == 1 || $_CONF['emailstoryloginrequired'] == 1)) { $article->set_var('email_icon', ''); } else { $emailUrl = $_CONF['site_url'] . '/profiles.php?sid=' . $story->getSid() . '&what=emailstory'; $emailicon = '<img src="' . $_CONF['layout_url'] . '/images/mail.' . $_IMAGE_TYPE . '" alt="' . $LANG01[64] . '" title="' . $LANG11[2] . '"' . XHTML . '>'; $article->set_var('email_icon', COM_createLink($emailicon, $emailUrl)); $article->set_var('email_story_url', $emailUrl); $article->set_var('lang_email_story', $LANG11[2]); $article->set_var('lang_email_story_alt', $LANG01[64]); } $printUrl = COM_buildUrl($_CONF['site_url'] . '/article.php?story=' . $story->getSid() . '&mode=print'); if ($_CONF['hideprintericon'] == 1) { $article->set_var('print_icon', ''); } else { $printicon = '<img src="' . $_CONF['layout_url'] . '/images/print.' . $_IMAGE_TYPE . '" alt="' . $LANG01[65] . '" title="' . $LANG11[3] . '"' . XHTML . '>'; $article->set_var('print_icon', COM_createLink($printicon, $printUrl, array('rel' => 'nofollow'))); $article->set_var('print_story_url', $printUrl); $article->set_var('lang_print_story', $LANG11[3]); $article->set_var('lang_print_story_alt', $LANG01[65]); } $article->set_var('story_display', 'index'); $storyCounter++; $article->set_var('story_counter', $storyCounter); } $article->set_var('recent_post_anchortag', $recent_post_anchortag); if ($index != 'p' && SEC_hasRights('story.edit') && $story->checkAccess() == 3 && TOPIC_hasMultiTopicAccess('article', $story->DisplayElements('sid')) == 3) { $editUrl = $_CONF['site_admin_url'] . '/story.php?mode=edit&sid=' . $story->getSid(); $editiconhtml = '<img src="' . $_CONF['layout_url'] . '/images/edit.' . $_IMAGE_TYPE . '" alt="' . $LANG01[4] . '" title="' . $LANG01[4] . '"' . XHTML . '>'; $article->set_var('edit_link', COM_createLink($LANG01[4], $editUrl)); $article->set_var('edit_url', $editUrl); $article->set_var('lang_edit_text', $LANG01[4]); $article->set_var('edit_icon', COM_createLink($editiconhtml, $editUrl, array('class' => 'editlink'))); $article->set_var('edit_image', $editiconhtml); } $navi_list = true; $feedback_list = true; if ($index == 'p') { $navi_list = false; $feedback_list = false; } else { $navi_list = $page_selector !== '' || $readmore_link !== '' || $post_comment_link !== ''; $feedback_list = $plugin_itemdisplay !== '' || $comments_with_count !== '' || $trackbacks_with_count !== ''; } $story_footer = $navi_list || $feedback_list || $related_topics !== ''; $article->set_var('navi_list', $navi_list); $article->set_var('feedback_list', $feedback_list); $article->set_var('story_footer', $story_footer); if ($story->DisplayElements('featured') == 1) { $article->set_var('lang_todays_featured_article', $LANG05[4]); $article->parse('story_bodyhtml', 'featuredbodytext', true); PLG_templateSetVars('featuredstorytext', $article); } elseif ($story->DisplayElements('statuscode') == STORY_ARCHIVE_ON_EXPIRE && $story->DisplayElements('expire') <= time()) { $article->parse('story_bodyhtml', 'archivestorybodytext', true); PLG_templateSetVars('archivestorytext', $article); } else { $article->parse('story_bodyhtml', 'bodytext', true); PLG_templateSetVars('storytext', $article); } // Add related articles if ($index === 'n') { $article->set_var('related_articles_by_keyword', Story::getRelatedArticlesByKeywords($story->getSid(), $story->DisplayElements('meta_keywords'))); } PLG_templateSetVars($article_filevar, $article); if ($index != 'p' && ($cache_time > 0 || $cache_time == -1)) { $article->create_instance($cacheInstance, $article_filevar); // CACHE_create_instance($cacheInstance, $article); } } else { PLG_templateSetVars($article_filevar, $article); if (!$_CONF['cache_templates']) { // Hack (see Geeklog Bug Tracker issue #0001817): Cannot set the template variable directly with set_var since // this template variable was set with set_file which uses the templatecode array (set_var uses varvals array) // so have to update the templatecode array directly. This array really shouldn't be accessed this way // and this hack should be changed in the future: either set_var or set_file functions need to allow update of the file template variable found in templatecode // $article->set_var($article_filevar, $retval); $article->templateCode[$article_filevar] = $retval; } } $article->parse('finalstory', $article_filevar); return $article->finish($article->get_var('finalstory')); }
/** * Takes an article class and renders HTML in the specified template and style. * * Formats the given article into HTML. Called by index.php, article.php, * submit.php and admin/story.php (Preview mode for the last two). * * @param object $story The story to display, an instance of the Story class. * @param string $index n = 'Compact display' for list of stories. p = 'Preview' mode. Else full display of article. * @param string $storytpl The template to use to render the story. * @param string $query A search query, if one was specified. * * @return string Article as formated HTML. * * Note: Formerly named COM_Article, and re-written totally since then. */ function STORY_renderArticle(&$story, $index = '', $storytpl = 'storytext.thtml', $query = '') { global $_CONF, $_TABLES, $_USER, $LANG01, $LANG05, $LANG11, $LANG_TRB, $_IMAGE_TYPE, $mode; static $storycounter = 0; if (empty($storytpl)) { $storytpl = 'storytext.thtml'; } $introtext = $story->displayElements('introtext'); $bodytext = $story->displayElements('bodytext'); if (!empty($query)) { $introtext = COM_highlightQuery($introtext, $query); $bodytext = COM_highlightQuery($bodytext, $query); } $article = new Template($_CONF['path_layout']); $article->set_file(array('article' => $storytpl, 'bodytext' => 'storybodytext.thtml', 'featuredarticle' => 'featuredstorytext.thtml', 'featuredbodytext' => 'featuredstorybodytext.thtml', 'archivearticle' => 'archivestorytext.thtml', 'archivebodytext' => 'archivestorybodytext.thtml')); $article->set_var('xhtml', XHTML); $article->set_var('layout_url', $_CONF['layout_url']); $article->set_var('site_url', $_CONF['site_url']); $article->set_var('site_admin_url', $_CONF['site_admin_url']); $article->set_var('site_name', $_CONF['site_name']); $article->set_var('story_date', $story->DisplayElements('date')); $article->set_var('story_date_short', $story->DisplayElements('shortdate')); $article->set_var('story_date_only', $story->DisplayElements('dateonly')); if ($_CONF['hideviewscount'] != 1) { $article->set_var('lang_views', $LANG01[106]); $article->set_var('story_hits', $story->DisplayElements('hits')); } $article->set_var('story_id', $story->getSid()); if ($_CONF['contributedbyline'] == 1) { $article->set_var('lang_contributed_by', $LANG01[1]); $article->set_var('contributedby_uid', $story->DisplayElements('uid')); $fullname = $story->DisplayElements('fullname'); $username = $story->DisplayElements('username'); $article->set_var('contributedby_user', $username); if (empty($fullname)) { $article->set_var('contributedby_fullname', $username); } else { $article->set_var('contributedby_fullname', $fullname); } $authorname = COM_getDisplayName($story->DisplayElements('uid'), $username, $fullname); $article->set_var('contributedby_author', $authorname); $article->set_var('author', $authorname); if ($story->DisplayElements('uid') > 1) { $profileUrl = $_CONF['site_url'] . '/users.php?mode=profile&uid=' . $story->DisplayElements('uid'); $article->set_var('start_contributedby_anchortag', '<a class="storybyline" href="' . $profileUrl . '">'); $article->set_var('end_contributedby_anchortag', '</a>'); $article->set_var('contributedby_url', $profileUrl); } $photo = ''; if ($_CONF['allow_user_photo'] == 1) { $authphoto = $story->DisplayElements('photo'); if (empty($authphoto)) { $authphoto = '(none)'; // user does not have a photo } $photo = USER_getPhoto($story->DisplayElements('uid'), $authphoto, $story->DisplayElements('email')); } if (!empty($photo)) { $article->set_var('contributedby_photo', $photo); $article->set_var('author_photo', $photo); $camera_icon = '<img src="' . $_CONF['layout_url'] . '/images/smallcamera.' . $_IMAGE_TYPE . '" alt=""' . XHTML . '>'; $article->set_var('camera_icon', COM_createLink($camera_icon, $profileUrl)); } else { $article->set_var('contributedby_photo', ''); $article->set_var('author_photo', ''); $article->set_var('camera_icon', ''); } } $topicname = $story->DisplayElements('topic'); $article->set_var('story_topic_id', $story->DisplayElements('tid')); $article->set_var('story_topic_name', $topicname); $topicurl = $_CONF['site_url'] . '/index.php?topic=' . $story->DisplayElements('tid'); if ((!isset($_USER['noicons']) or $_USER['noicons'] != 1) and $story->DisplayElements('show_topic_icon') == 1) { $imageurl = $story->DisplayElements('imageurl'); if (!empty($imageurl)) { $imageurl = COM_getTopicImageUrl($imageurl); $article->set_var('story_topic_image_url', $imageurl); $topicimage = '<img src="' . $imageurl . '" class="float' . $_CONF['article_image_align'] . '" alt="' . $topicname . '" title="' . $topicname . '"' . XHTML . '>'; $article->set_var('story_anchortag_and_image', COM_createLink($topicimage, $topicurl, array('rel' => "category"))); $article->set_var('story_topic_image', $topicimage); $topicimage_noalign = '<img src="' . $imageurl . '" alt="' . $topicname . '" title="' . $topicname . '"' . XHTML . '>'; $article->set_var('story_anchortag_and_image_no_align', COM_createLink($topicimage_noalign, $topicurl, array('rel' => "category"))); $article->set_var('story_topic_image_no_align', $topicimage_noalign); } } $article->set_var('story_topic_url', $topicurl); $recent_post_anchortag = ''; $articleUrl = COM_buildUrl($_CONF['site_url'] . '/article.php?story=' . $story->getSid()); $article->set_var('story_title', $story->DisplayElements('title')); $article->set_var('lang_permalink', $LANG01[127]); $show_comments = true; // n = 'Compact display' for list of stories. p = 'Preview' mode. if ($index != 'n' && $index != 'p' || !empty($query)) { $attributes = ' class="non-ul"'; $attr_array = array('class' => 'non-ul'); if (!empty($query)) { $attributes .= ' rel="bookmark"'; $attr_array['rel'] = 'bookmark'; } $article->set_var('start_storylink_anchortag', '<a href="' . $articleUrl . '"' . $attributes . '>'); $article->set_var('end_storylink_anchortag', '</a>'); $article->set_var('story_title_link', COM_createLink($story->DisplayElements('title'), $articleUrl, $attr_array)); } else { $article->set_var('story_title_link', $story->DisplayElements('title')); } if ($index == 'n' || $index == 'p') { if (empty($bodytext)) { $article->set_var('story_introtext', $introtext); $article->set_var('story_text_no_br', $introtext); } else { if ($_CONF['allow_page_breaks'] == 1 and $index == 'n') { $story_page = 1; // page selector if (is_numeric($mode)) { $story_page = $mode; if ($story_page <= 0) { $story_page = 1; $mode = 0; } elseif ($story_page > 1) { $introtext = ''; } } $article_array = explode('[page_break]', $bodytext); $pagelinks = COM_printPageNavigation($articleUrl, $story_page, count($article_array), 'mode=', $_CONF['url_rewrite'], $LANG01[118]); if (count($article_array) > 1) { $bodytext = $article_array[$story_page - 1]; } $article->set_var('page_selector', $pagelinks); if ($_CONF['page_break_comments'] == 'last' and $story_page < count($article_array) or $_CONF['page_break_comments'] == 'first' and $story_page != 1) { $show_comments = false; } $article->set_var('story_page', $story_page); } $article->set_var('story_introtext', $introtext . '<br' . XHTML . '><br' . XHTML . '>' . $bodytext); $article->set_var('story_text_no_br', $introtext . ' ' . $bodytext); } $article->set_var('story_introtext_only', $introtext); $article->set_var('story_bodytext_only', $bodytext); if (($_CONF['trackback_enabled'] || $_CONF['pingback_enabled']) && SEC_hasRights('story.ping')) { $url = $_CONF['site_admin_url'] . '/trackback.php?mode=sendall&id=' . $story->getSid(); $article->set_var('send_trackback_link', COM_createLink($LANG_TRB['send_trackback'], $url)); $pingico = '<img src="' . $_CONF['layout_url'] . '/images/sendping.' . $_IMAGE_TYPE . '" alt="' . $LANG_TRB['send_trackback'] . '" title="' . $LANG_TRB['send_trackback'] . '"' . XHTML . '>'; $article->set_var('send_trackback_icon', COM_createLink($pingico, $url)); $article->set_var('send_trackback_url', $url); $article->set_var('lang_send_trackback_text', $LANG_TRB['send_trackback']); } $article->set_var('story_display', $index == 'p' ? 'preview' : 'article'); $article->set_var('story_counter', 0); } else { $article->set_var('story_introtext', $introtext); $article->set_var('story_text_no_br', $introtext); $article->set_var('story_introtext_only', $introtext); if (!empty($bodytext)) { $article->set_var('lang_readmore', $LANG01[2]); $article->set_var('lang_readmore_words', $LANG01[62]); $numwords = COM_numberFormat(count(explode(' ', COM_getTextContent($bodytext)))); $article->set_var('readmore_words', $numwords); $article->set_var('readmore_link', COM_createLink($LANG01[2], $articleUrl, array('class' => 'story-read-more-link')) . ' (' . $numwords . ' ' . $LANG01[62] . ') '); $article->set_var('start_readmore_anchortag', '<a href="' . $articleUrl . '" class="story-read-more-link">'); $article->set_var('end_readmore_anchortag', '</a>'); $article->set_var('read_more_class', 'class="story-read-more-link"'); } if ($story->DisplayElements('commentcode') >= 0 and $show_comments) { $commentsUrl = COM_buildUrl($_CONF['site_url'] . '/article.php?story=' . $story->getSid()) . '#comments'; $article->set_var('comments_url', $commentsUrl); $article->set_var('comments_text', COM_numberFormat($story->DisplayElements('comments')) . ' ' . $LANG01[3]); $article->set_var('comments_count', COM_numberFormat($story->DisplayElements('comments'))); $article->set_var('lang_comments', $LANG01[3]); $comments_with_count = sprintf($LANG01[121], COM_numberFormat($story->DisplayElements('comments'))); if ($story->DisplayElements('comments') > 0) { $result = DB_query("SELECT UNIX_TIMESTAMP(date) AS day,username,fullname,{$_TABLES['comments']}.uid as cuid FROM {$_TABLES['comments']},{$_TABLES['users']} WHERE {$_TABLES['users']}.uid = {$_TABLES['comments']}.uid AND sid = '" . $story->getsid() . "' ORDER BY date desc LIMIT 1"); $C = DB_fetchArray($result); $recent_post_anchortag = '<span class="storybyline">' . $LANG01[27] . ': ' . strftime($_CONF['daytime'], $C['day']) . ' ' . $LANG01[104] . ' ' . COM_getDisplayName($C['cuid'], $C['username'], $C['fullname']) . '</span>'; $article->set_var('comments_with_count', COM_createLink($comments_with_count, $commentsUrl)); $article->set_var('start_comments_anchortag', '<a href="' . $commentsUrl . '">'); $article->set_var('end_comments_anchortag', '</a>'); } else { $article->set_var('comments_with_count', $comments_with_count); $recent_post_anchortag = COM_createLink($LANG01[60], $_CONF['site_url'] . '/comment.php?sid=' . $story->getsid() . '&pid=0&type=article'); } if ($story->DisplayElements('commentcode') == 0) { $postCommentUrl = $_CONF['site_url'] . '/comment.php?sid=' . $story->getSid() . '&pid=0&type=article'; $article->set_var('post_comment_link', COM_createLink($LANG01[60], $postCommentUrl, array('rel' => 'nofollow'))); /* $article->set_var( 'subscribe_link', COM_createLink('Nubbies', '', array('rel' => 'nofollow')) ); */ $article->set_var('lang_post_comment', $LANG01[60]); $article->set_var('start_post_comment_anchortag', '<a href="' . $postCommentUrl . '" rel="nofollow">'); $article->set_var('end_post_comment_anchortag', '</a>'); } } if (($_CONF['trackback_enabled'] || $_CONF['pingback_enabled']) && $story->DisplayElements('trackbackcode') >= 0 && $show_comments) { $num_trackbacks = COM_numberFormat($story->DisplayElements('trackbacks')); $trackbacksUrl = COM_buildUrl($_CONF['site_url'] . '/article.php?story=' . $story->getSid()) . '#trackback'; $article->set_var('trackbacks_url', $trackbacksUrl); $article->set_var('trackbacks_text', $num_trackbacks . ' ' . $LANG_TRB['trackbacks']); $article->set_var('trackbacks_count', $num_trackbacks); $article->set_var('lang_trackbacks', $LANG_TRB['trackbacks']); $article->set_var('trackbacks_with_count', COM_createLink(sprintf($LANG01[122], $num_trackbacks), $trackbacksUrl)); if (SEC_hasRights('story.ping')) { $pingurl = $_CONF['site_admin_url'] . '/trackback.php?mode=sendall&id=' . $story->getSid(); $pingico = '<img src="' . $_CONF['layout_url'] . '/images/sendping.' . $_IMAGE_TYPE . '" alt="' . $LANG_TRB['send_trackback'] . '" title="' . $LANG_TRB['send_trackback'] . '"' . XHTML . '>'; $article->set_var('send_trackback_icon', COM_createLink($pingico, $pingurl)); } if ($story->DisplayElements('trackbacks') > 0) { $article->set_var('trackbacks_with_count', COM_createLink(sprintf($LANG01[122], $num_trackbacks), $trackbacksUrl)); } else { $article->set_var('trackbacks_with_count', sprintf($LANG01[122], $num_trackbacks)); } } if ($_CONF['hideemailicon'] == 1 || empty($_USER['username']) && ($_CONF['loginrequired'] == 1 || $_CONF['emailstoryloginrequired'] == 1)) { $article->set_var('email_icon', ''); } else { $emailUrl = $_CONF['site_url'] . '/profiles.php?sid=' . $story->getSid() . '&what=emailstory'; $emailicon = '<img src="' . $_CONF['layout_url'] . '/images/mail.' . $_IMAGE_TYPE . '" alt="' . $LANG01[64] . '" title="' . $LANG11[2] . '"' . XHTML . '>'; $article->set_var('email_icon', COM_createLink($emailicon, $emailUrl)); $article->set_var('email_story_url', $emailUrl); $article->set_var('lang_email_story', $LANG11[2]); $article->set_var('lang_email_story_alt', $LANG01[64]); } $printUrl = COM_buildUrl($_CONF['site_url'] . '/article.php?story=' . $story->getSid() . '&mode=print'); if ($_CONF['hideprintericon'] == 1) { $article->set_var('print_icon', ''); } else { $printicon = '<img src="' . $_CONF['layout_url'] . '/images/print.' . $_IMAGE_TYPE . '" alt="' . $LANG01[65] . '" title="' . $LANG11[3] . '"' . XHTML . '>'; $article->set_var('print_icon', COM_createLink($printicon, $printUrl, array('rel' => 'nofollow'))); $article->set_var('print_story_url', $printUrl); $article->set_var('lang_print_story', $LANG11[3]); $article->set_var('lang_print_story_alt', $LANG01[65]); } $article->set_var('story_display', 'index'); $storycounter++; $article->set_var('story_counter', $storycounter); } $article->set_var('article_url', $articleUrl); $article->set_var('recent_post_anchortag', $recent_post_anchortag); if ($story->checkAccess() == 3 and SEC_hasrights('story.edit') and $index != 'p') { $article->set_var('edit_link', COM_createLink($LANG01[4], $_CONF['site_admin_url'] . '/story.php?mode=edit&sid=' . $story->getSid())); $article->set_var('edit_url', $_CONF['site_admin_url'] . '/story.php?mode=edit&sid=' . $story->getSid()); $article->set_var('lang_edit_text', $LANG01[4]); $editicon = $_CONF['layout_url'] . '/images/edit.' . $_IMAGE_TYPE; $editiconhtml = '<img src="' . $editicon . '" alt="' . $LANG01[4] . '" title="' . $LANG01[4] . '"' . XHTML . '>'; $article->set_var('edit_icon', COM_createLink($editiconhtml, $_CONF['site_admin_url'] . '/story.php?mode=edit&sid=' . $story->getSid())); $article->set_var('edit_image', $editiconhtml); } if ($story->DisplayElements('featured') == 1) { $article->set_var('lang_todays_featured_article', $LANG05[4]); $article->parse('story_bodyhtml', 'featuredbodytext', true); PLG_templateSetVars('featuredstorytext', $article); $article->parse('finalstory', 'featuredarticle'); } elseif ($story->DisplayElements('statuscode') == STORY_ARCHIVE_ON_EXPIRE and $story->DisplayElements('expire') <= time()) { $article->parse('story_bodyhtml', 'archivestorybodytext', true); PLG_templateSetVars('archivestorytext', $article); $article->parse('finalstory', 'archivearticle'); } else { $article->parse('story_bodyhtml', 'bodytext', true); PLG_templateSetVars('storytext', $article); $article->parse('finalstory', 'article'); } return $article->finish($article->get_var('finalstory')); }
function showtopic($showtopic, $mode = '', $onetwo = 1, $page = 1) { global $CONF_FORUM, $_CONF, $_TABLES, $_USER, $LANG_GF01, $LANG_GF02; global $fromblock, $highlight; global $oldPost, $forumfiles; $oldPost = 0; //$mytimer = new timerobject(); //$mytimer->setPercision(2); //$mytimer->startTimer(); //$intervalTime = $mytimer->stopTimer(); //COM_errorLog("Show Topic Display Time1: $intervalTime"); if (!class_exists('StringParser')) { require_once $_CONF['path_html'] . 'forum/include/bbcode/stringparser_bbcode.class.php'; } $topictemplate = new Template($_CONF['path_layout'] . 'forum/layout'); $topictemplate->set_file(array('topictemplate' => 'topic.thtml', 'profile' => 'links/profile.thtml', 'pm' => 'links/pm.thtml', 'email' => 'links/email.thtml', 'website' => 'links/website.thtml', 'quote' => 'links/quotetopic.thtml', 'edit' => 'links/edittopic.thtml')); // if preview, only stripslashes is gpc=on, else assume from db so strip if ($mode == 'preview') { $showtopic['subject'] = COM_stripslashes($showtopic['subject']); $topictemplate->set_var('show_topicrow1', 'none'); $topictemplate->set_var('show_topicrule', 'none'); $topictemplate->set_var('lang_postpreview', $LANG_GF01['PREVIEW_HEADER']); } else { $showtopic['subject'] = stripslashes($showtopic['subject']); $topictemplate->set_var('show_topicrow2', 'none'); } $min_height = 50; // Base minimum height of topic - will increase if avatar or sig is used $date = strftime($CONF_FORUM['default_Topic_Datetime_format'], $showtopic['date']); $userQuery = DB_query("SELECT * FROM {$_TABLES['users']} WHERE uid='{$showtopic['uid']}'"); if ($showtopic['uid'] > 1 and DB_numRows($userQuery) == 1) { $userarray = DB_fetchArray($userQuery); $username = COM_getDisplayName($showtopic['uid']); $userlink = "<a href=\"{$_CONF['site_url']}/users.php?mode=profile&uid={$showtopic['uid']}\" "; $userlink .= "class=\"authorname {$onetwo}\"><b>{$username}</b></a>"; $uservalid = true; $postcount = DB_query("SELECT * FROM {$_TABLES['gf_topic']} WHERE uid='{$showtopic['uid']}'"); $posts = DB_numRows($postcount); // STARS CODE $starimage = "<IMG SRC=\"%s\" ALT=\"{$LANG_GF01['FORUM']} %s\" TITLE=\"{$LANG_GF01['FORUM']} %s\">"; if ($posts < $CONF_FORUM['level2']) { $user_level = sprintf($starimage, gf_getImage('rank1', 'ranks'), $CONF_FORUM['level1name'], $CONF_FORUM['level1name']); $user_levelname = $CONF_FORUM['level1name']; } elseif ($posts >= $CONF_FORUM['level2'] && $posts < $CONF_FORUM['level3']) { $user_level = sprintf($starimage, gf_getImage('rank2', 'ranks'), $CONF_FORUM['level2name'], $CONF_FORUM['level2name']); $user_levelname = $CONF_FORUM['level2name']; } elseif ($posts >= $CONF_FORUM['level3'] && $posts < $CONF_FORUM['level4']) { $user_level = sprintf($starimage, gf_getImage('rank3', 'ranks'), $CONF_FORUM['level3name'], $CONF_FORUM['level3name']); $user_levelname = $CONF_FORUM['level3name']; } elseif ($posts >= $CONF_FORUM['level4'] && $posts < $CONF_FORUM['level5']) { $user_level = sprintf($starimage, gf_getImage('rank4', 'ranks'), $CONF_FORUM['level4name'], $CONF_FORUM['level4name']); $user_levelname = $CONF_FORUM['level4name']; } elseif ($posts > $CONF_FORUM['level5']) { $user_level = sprintf($starimage, gf_getImage('rank5', 'ranks'), $CONF_FORUM['level5name'], $CONF_FORUM['level5name']); $user_levelname = $CONF_FORUM['level5name']; } if (forum_modPermission($showtopic['forum'], $showtopic['uid'])) { $user_level = sprintf($starimage, gf_getImage('rank_mod', 'ranks'), $LANG_GF01['moderator'], $LANG_GF01['moderator']); $user_levelname = $LANG_GF01['moderator']; } if (SEC_inGroup(1, $showtopic['uid'])) { $user_level = sprintf($starimage, gf_getImage('rank_admin', 'ranks'), $LANG_GF01['admin'], $LANG_GF01['admin']); $user_levelname = $LANG_GF01['admin']; } if ($userarray['photo'] != "") { $avatar = USER_getPhoto($showtopic['uid'], '', '', $CONF_FORUM['avatar_width']); $min_height = $min_height + 50; } $regdate = $LANG_GF01['REGISTERED'] . ': ' . strftime('%m/%d/%y', strtotime($userarray['regdate'])) . '<br>'; $numposts = $LANG_GF01['POSTS'] . ': ' . $posts; if (DB_count($_TABLES['sessions'], 'uid', $showtopic['uid']) > 0 and DB_getItem($_TABLES['userprefs'], 'showonline', "uid={$showtopic['uid']}") == 1) { $avatar .= '<br>' . $LANG_GF01['STATUS'] . ' ' . $LANG_GF01['ONLINE']; } else { $avatar .= '<br>' . $LANG_GF01['STATUS'] . ' ' . $LANG_GF01['OFFLINE']; } if ($userarray['sig'] != '') { $sig = '<hr width="95%" size="1" style="color=:black; text-align:left; margin-left:0; margin-bottom:5;padding:0" noshade>'; $sig .= '<B>' . $userarray['sig'] . '</B>'; $min_height = $min_height + 30; } } else { $uservalid = false; $userlink = '<b>' . $showtopic['name'] . '</b>'; $userlink = '<font size="-2">' . $LANG_GF01['ANON'] . '</font>' . $showtopic['name']; } if ($CONF_FORUM['show_moods'] && $showtopic['mood'] != "") { $moodimage = '<img align="absmiddle" src="' . gf_getImage($showtopic['mood'], 'moods') . '" title="' . $showtopic['mood'] . '"><br>'; $min_height = $min_height + 30; } //$intervalTime = $mytimer->stopTimer(); //COM_errorLog("Show Topic Display Time3: $intervalTime"); // Handle Pre ver 2.5 quoting and New Line Formatting - consider adding this to a migrate function if ($CONF_FORUM['pre2.5_mode']) { // try to determine if we have an old post... if (strstr($showtopic['comment'], '<pre class="forumCode">') !== false) { $oldPost = 1; } if (strstr($showtopic['comment'], "[code]<code>") !== false) { $oldPost = 1; } if (strstr($showtopic['comment'], "<pre>") !== false) { $oldPost = 1; } if (stristr($showtopic['comment'], '[code') == false || stristr($showtopic['comment'], '[code]<code>') == true) { if (strstr($showtopic['comment'], "<pre>") !== false) { $oldPost = 1; } $showtopic['comment'] = str_replace('<pre>', '[code]', $showtopic['comment']); $showtopic['comment'] = str_replace('</pre>', '[/code]', $showtopic['comment']); } $showtopic['comment'] = str_ireplace("[code]<code>", '[code]', $showtopic['comment']); $showtopic['comment'] = str_ireplace("</code>[/code]", '[/code]', $showtopic['comment']); $showtopic['comment'] = str_replace(array("<br />\r\n", "<br />\n\r", "<br />\r", "<br />\n"), '<br />', $showtopic['comment']); $showtopic['comment'] = preg_replace("/\\[QUOTE\\sBY=\\s(.+?)\\]/i", "[QUOTE] Quote by \$1:", $showtopic['comment']); /* Reformat code blocks - version 2.3.3 and prior */ $showtopic['comment'] = str_replace('<pre class="forumCode">', '[code]', $showtopic['comment']); $showtopic['comment'] = preg_replace("/\\[QUOTE\\sBY=(.+?)\\]/i", "[QUOTE] Quote by \$1:", $showtopic['comment']); if ($oldPost) { if (strstr($showtopic['comment'], "\\'") !== false) { $showtopic['comment'] = stripslashes($showtopic['comment']); } } } // Check and see if there are now no [file] bbcode tags in content and reset the show_inline value // This is needed in case user had used the file bbcode tag and then removed it if ($mode == 'preview' and strpos($showtopic['comment'], '[file]') === false) { $usql = "UPDATE {$_TABLES['gf_attachments']} SET show_inline = 0 "; if (isset($_POST['uniqueid']) and $_POST['uniqueid'] > 0) { // User is previewing a new post $usql .= "WHERE topic_id = {$_POST['uniqueid']} AND tempfile=1 "; } else { if (isset($showtopic['id'])) { $usql .= "WHERE topic_id = {$showtopic['id']} "; } } DB_query($usql); } $showtopic['comment'] = gf_formatTextBlock($showtopic['comment'], $showtopic['postmode'], $mode); $showtopic['subject'] = gf_formatTextBlock($showtopic['subject'], 'text', $mode); if (strlen($showtopic['subject']) > $CONF_FORUM['show_subject_length']) { $showtopic['subject'] = substr("{$showtopic['subject']}", 0, $CONF_FORUM['show_subject_length']); $showtopic['subject'] .= "..."; } //$intervalTime = $mytimer->stopTimer(); //COM_errorLog("Show Topic Display Time2: $intervalTime"); if ($mode != 'preview' && $uservalid && $_USER['uid'] > 1 && $_USER['uid'] == $showtopic['uid']) { /* Check if user can still edit this post - within allowed edit timeframe */ $editAllowed = false; if ($CONF_FORUM['allowed_editwindow'] > 0) { $t1 = $showtopic['date']; $t2 = $CONF_FORUM['allowed_editwindow']; if (time() - $t2 < $t1) { $editAllowed = true; } } else { $editAllowed = true; } if ($editAllowed) { $editlink = "{$_CONF['site_url']}/forum/createtopic.php?method=edit&forum={$showtopic['forum']}&id={$showtopic['id']}&editid={$showtopic['id']}&page={$page}"; $editlinkimg = '<img src="' . gf_getImage('edit_button') . '" border="0" align="absmiddle" alt="' . $LANG_GF01['EDITICON'] . '" TITLE="' . $LANG_GF01['EDITICON'] . '">'; $topictemplate->set_var('editlink', $editlink); $topictemplate->set_var('editlinkimg', $editlinkimg); $topictemplate->set_var('LANG_edit', $LANG_GF01['EDITICON']); $topictemplate->parse('edittopic_link', 'edit'); } } if ($highlight != '') { $showtopic['subject'] = str_replace("{$highlight}", "<font class=highlight>{$highlight}</font>", $showtopic['subject']); $showtopic['comment'] = str_replace("{$highlight}", "<font class=highlight>{$highlight}</font>", $showtopic['comment']); } if ($showtopic['pid'] == 0) { $replytopicid = $showtopic['id']; $is_lockedtopic = $showtopic['locked']; $views = $showtopic['views']; $topictemplate->set_var('read_msg', sprintf($LANG_GF02['msg49'], $views)); if ($is_lockedtopic) { $topictemplate->set_var('locked_icon', '<img src="' . gf_getImage('padlock') . '" TITLE="' . $LANG_GF02['msg114'] . '">'); } } else { $replytopicid = $showtopic['pid']; $is_lockedtopic = DB_getItem($_TABLES['gf_topic'], 'locked', "id={$showtopic['pid']}"); $topictemplate->set_var('read_msg', ''); } // Bookmark feature if ($_USER['uid'] > 1) { if (DB_count($_TABLES['gf_bookmarks'], array('uid', 'topic_id'), array($_USER['uid'], $showtopic['id']))) { $topictemplate->set_var('bookmark_icon', '<img src="' . gf_getImage('star_on_sm') . '" TITLE="' . $LANG_GF02['msg204'] . '">'); } else { $topictemplate->set_var('bookmark_icon', '<img src="' . gf_getImage('star_off_sm') . '" TITLE="' . $LANG_GF02['msg203'] . '">'); } } if ($CONF_FORUM['allow_user_dateformat']) { $date = COM_getUserDateTimeFormat($showtopic['date']); $topictemplate->set_var('posted_date', $date[0]); } else { $date = strftime($CONF_FORUM['default_Topic_Datetime_format'], $showtopic['date']); $topictemplate->set_var('posted_date', $date); } if ($mode != 'preview') { if ($is_lockedtopic == 0) { $is_readonly = DB_getItem($_TABLES['gf_forums'], 'is_readonly', 'forum_id=' . $showtopic['forum']); if ($is_readonly == 0 or forum_modPermission($showtopic['forum'], $_USER['uid'], 'mod_edit')) { $quotelink = "{$_CONF['site_url']}/forum/createtopic.php?method=postreply&forum={$showtopic['forum']}&id={$replytopicid}"eid={$showtopic['id']}"; $quotelinkimg = '<img src="' . gf_getImage('quote_button') . '" border="0" align="absmiddle" alt="' . $LANG_GF01['QUOTEICON'] . '" TITLE="' . $LANG_GF01['QUOTEICON'] . '">'; $topictemplate->set_var('quotelink', $quotelink); $topictemplate->set_var('quotelinkimg', $quotelinkimg); $topictemplate->set_var('LANG_quote', $LANG_GF01['QUOTEICON']); $topictemplate->parse('quotetopic_link', 'quote'); } } //$topictemplate->set_var ('topic_post_link_begin', '<a name="'.$showtopic['id'].'">'); //$topictemplate->set_var ('topic_post_link_end', '</a>'); $mod_functions = forum_getmodFunctions($showtopic); if ($showtopic['uid'] > 1 && $uservalid) { $profile_link = "{$_CONF['site_url']}/users.php?mode=profile&uid={$showtopic['uid']}"; $profile_linkimg = '<img src="' . gf_getImage('profile_button') . '" border="0" align="absmiddle" alt="' . $LANG_GF01['ProfileLink'] . '" TITLE="' . $LANG_GF01['ProfileLink'] . '">'; $topictemplate->set_var('profilelink', $profile_link); $topictemplate->set_var('profilelinkimg', $profile_linkimg); $topictemplate->set_var('LANG_profile', $LANG_GF01['ProfileLink']); $topictemplate->parse('profile_link', 'profile'); if ($CONF_FORUM['use_pm_plugin']) { $pmusernmame = COM_getDisplayName($showtopic['uid']); $pmplugin_link = forumPLG_getPMlink($pmusernmame); if ($pmplugin_link != '') { $pm_link = $pmplugin_link; $pm_linkimg = '<img src="' . gf_getImage('pm_button') . '" border="0" align="absmiddle" alt="' . $LANG_GF01['PMLink'] . '" TITLE="' . $LANG_GF01['PMLink'] . '">'; $topictemplate->set_var('pmlink', $pm_link); $topictemplate->set_var('pmlinkimg', $pm_linkimg); $topictemplate->set_var('LANG_pm', $LANG_GF01['PMLink']); $topictemplate->parse('pm_link', 'pm'); } } } if ($userarray['email'] != '' && $showtopic["uid"] > 1) { $email_link = "{$_CONF['site_url']}/profiles.php?uid={$showtopic['uid']}"; $email_linkimg = '<img src="' . gf_getImage('email_button') . '" border="0" align="absmiddle" alt="' . $LANG_GF01['EmailLink'] . '" TITLE="' . $LANG_GF01['EmailLink'] . '">'; $topictemplate->set_var('emaillink', $email_link); $topictemplate->set_var('emaillinkimg', $email_linkimg); $topictemplate->set_var('LANG_email', $LANG_GF01['EmailLink']); $topictemplate->parse('email_link', 'email'); } if ($userarray['homepage'] != '') { $homepage = $userarray['homepage']; if (!eregi("http", $homepage)) { $homepage = 'http://' . $homepage; } $homepageimg = '<img src="' . gf_getImage('website_button') . '" border="0" align="absmiddle" alt="' . $LANG_GF01['WebsiteLink'] . '" TITLE="' . $LANG_GF01['WebsiteLink'] . '">'; $topictemplate->set_var('websitelink', $homepage); $topictemplate->set_var('websitelinkimg', $homepageimg); $topictemplate->set_var('LANG_website', $LANG_GF01['WebsiteLink']); $topictemplate->parse('website_link', 'website'); } if ($fromblock != "") { $back2 = $LANG_GF01['back2parent']; } else { $back2 = $LANG_GF01['back2top']; } $backlink = '<center><a href="' . $_CONF['site_url'] . '/forum/viewtopic.php?showtopic=' . $replytopicid . '">' . $back2 . '</a></center>'; } else { if ($_GET['onlytopic'] != 1) { $topictemplate->set_var('posted_date', ''); $topictemplate->set_var('preview_topic_subject', $showtopic['subject']); } else { $topictemplate->set_var('preview_topic_subject', ''); } $topictemplate->set_var('read_msg', ''); $topictemplate->set_var('locked_icon', ''); $topictemplate->set_var('preview_mode', 'none'); // Check and see if there are no [file] bbcode tags in content and reset the show_inline value // This is needed in case user had used the file bbcode tag and then removed it $imagerecs = ''; if (is_array($forumfiles)) { $imagerecs = implode(',', $forumfiles); } if (!empty($_POST['uniqueid'])) { $sql = "UPDATE {$_TABLES['gf_attachments']} SET show_inline = 0 WHERE topic_id={$_POST['uniqueid']} "; if ($imagerecs != '') { $sql .= "AND id NOT IN ({$imagerecs})"; } DB_query($sql); } else { if (isset($_POST['id'])) { $sql = "UPDATE {$_TABLES['gf_attachments']} SET show_inline = 0 WHERE topic_id={$_POST['id']} "; if ($imagerecs != '') { $sql .= "AND id NOT IN ({$imagerecs})"; } DB_query($sql); } } } //$intervalTime = $mytimer->stopTimer(); //COM_errorLog("Show Topic Display Time4: $intervalTime"); $showtopic['comment'] = str_replace('{', '{', $showtopic['comment']); $showtopic['comment'] = str_replace('}', '}', $showtopic['comment']); $uniqueid = COM_applyFilter($_POST['uniqueid'], true); if ($showtopic['id'] > 0) { $topictemplate->set_var('attachments', gf_showattachments($showtopic['id'])); } elseif ($uniqueid > 0) { $topictemplate->set_var('attachments', gf_showattachments($uniqueid)); } $topictemplate->set_var('layout_url', $_CONF['layout_url']); $topictemplate->set_var('csscode', $onetwo); $topictemplate->set_var('postmode', $showtopic['postmode']); $topictemplate->set_var('userlink', $userlink); $topictemplate->set_var('lang_forum', $LANG_GF01['FORUM']); $topictemplate->set_var('user_levelname', $user_levelname); $topictemplate->set_var('user_level', $user_level); $topictemplate->set_var('magical_image', $moodimage); $topictemplate->set_var('avatar', $avatar); $topictemplate->set_var('regdate', $regdate); $topictemplate->set_var('numposts', $numposts); $topictemplate->set_var('location', $location); $topictemplate->set_var('site_url', $_CONF['site_url']); $topictemplate->set_var('imgset', $CONF_FORUM['imgset']); $topictemplate->set_var('topic_subject', $showtopic['subject']); $topictemplate->set_var('LANG_ON2', $LANG_GF01['ON2']); $topictemplate->set_var('mod_functions', $mod_functions); $topictemplate->set_var('topic_comment', $showtopic['comment']); $topictemplate->set_var('comment_minheight', "min-height:{$min_height}px"); if (trim($sig) != '') { $topictemplate->set_var('sig', PLG_replaceTags($sig)); $topictemplate->set_var('show_sig', ''); } else { $topictemplate->set_var('sig', ''); $topictemplate->set_var('show_sig', 'none'); } $topictemplate->set_var('forumid', $showtopic['forum']); $topictemplate->set_var('topic_id', $showtopic['id']); $topictemplate->set_var('back_link', $backlink); $topictemplate->set_var('member_badge', forumPLG_getMemberBadge($showtopic['uid'])); $topictemplate->parse('output', 'topictemplate'); $retval .= $topictemplate->finish($topictemplate->get_var('output')); //$intervalTime = $mytimer->stopTimer(); //COM_errorLog("Show Topic Display Time5: $intervalTime"); return $retval; }
/** * Shows the user's current settings * */ function edituser() { global $_CONF, $_TABLES, $_USER, $LANG_MYACCOUNT, $LANG04, $LANG_ADMIN, $_SCRIPTS; $result = DB_query("SELECT fullname,cookietimeout,email,homepage,sig,emailstories,about,location,pgpkey,photo,remoteservice FROM {$_TABLES['users']},{$_TABLES['userprefs']},{$_TABLES['userinfo']} WHERE {$_TABLES['users']}.uid = {$_USER['uid']} AND {$_TABLES['userprefs']}.uid = {$_USER['uid']} AND {$_TABLES['userinfo']}.uid = {$_USER['uid']}"); $A = DB_fetchArray($result); $preferences = COM_newTemplate($_CONF['path_layout'] . 'preferences'); $preferences->set_file(array('profile' => 'profile.thtml', 'photo' => 'userphoto.thtml', 'username' => 'username.thtml', 'password' => 'password.thtml', 'current_password' => 'current_password.thtml', 'resynch' => 'resynch.thtml', 'deleteaccount' => 'deleteaccount.thtml')); include $_CONF['path_system'] . 'classes/navbar.class.php'; $navbar = new navbar(); $cnt = 0; foreach ($LANG_MYACCOUNT as $id => $label) { $navbar->add_menuitem($label, 'showhideProfileEditorDiv("' . $id . '",' . $cnt . ');return false;', true); $cnt++; } $navbar->set_selected($LANG_MYACCOUNT['pe_namepass']); $preferences->set_var('navbar', $navbar->generate()); //$preferences->set_var ('no_javascript_warning', $LANG04[150]); $preferences->set_var('noscript', COM_getNoScript()); $preferences->set_var('cssid1', 1); $preferences->set_var('cssid2', 2); $preferences->set_var('preview', USER_showProfile($_USER['uid'], true)); $preferences->set_var('prefs', editpreferences()); // Add JavaScript $_SCRIPTS->setJavaScriptFile('profile_editor', '/javascript/profile_editor.js'); $js = '<!-- JS Functions which will execute only if JS enabled will un-hide the special features that enhance the profile editor --> <script type="text/JavaScript"> //<![CDATA[ /* Initially the navbar is hidden - in case JS is disabled. Enable it now */ document.getElementById("pe_navbar").style.display=""; /* Now cycle through the profile tabs as the number in the template could have been modified (personalized) If you add custom panels, just ensure you use the class jsenabled_hide or jsenabled_show Build an object that can then be referenced in the functon showhideProfileEditorDiv */ var profilepanels = new Object; var el; el=document.getElementsByTagName("div"); for(i=0;i<el.length;i++) { var divname = el[i].id if(el[i].className == "jsenabled_show"){ el[i].style.display = ""; profilepanels[divname] = "show"; } else if(el[i].className == "jsenabled_hide"){ el[i].style.display = "none"; profilepanels[divname] = "hidden"; } } //]]> </script>'; $_SCRIPTS->setJavaScript($js); // some trickery to ensure alternating colors with the available options ... if ($_CONF['allow_username_change'] == 1) { $first = 1; $second = 2; } else { $first = 2; $second = 1; } $preferences->set_var('cssid1u', $first); $preferences->set_var('cssid2u', $second); if ($_CONF['allow_user_photo'] == 1) { $tmp = $first; $first = $second; $second = $tmp; } $preferences->set_var('cssid1p', $first); $preferences->set_var('cssid2p', $second); $preferences->set_var('lang_fullname', $LANG04[3]); $preferences->set_var('lang_fullname_text', $LANG04[34]); $preferences->set_var('lang_username', $LANG04[2]); $preferences->set_var('lang_username_text', $LANG04[87]); $preferences->set_var('lang_password_help_title', $LANG04[146]); $preferences->set_var('lang_password_help', $LANG04[147]); $preferences->set_var('lang_password', $LANG04[4]); $preferences->set_var('lang_password_text', $LANG04[35]); $preferences->set_var('lang_password_conf', $LANG04[108]); $preferences->set_var('lang_password_text_conf', $LANG04[109]); $preferences->set_var('lang_old_password', $LANG04[110]); $preferences->set_var('lang_old_password_text', $LANG04[111]); $preferences->set_var('lang_cooktime', $LANG04[68]); $preferences->set_var('lang_cooktime_text', $LANG04[69]); $preferences->set_var('lang_email', $LANG04[5]); $preferences->set_var('lang_email_text', $LANG04[33]); $preferences->set_var('lang_email_conf', $LANG04[124]); $preferences->set_var('lang_email_conf_text', $LANG04[126]); $preferences->set_var('lang_userinfo_help_title', $LANG04[148]); $preferences->set_var('lang_userinfo_help', $LANG04[149]); $preferences->set_var('lang_homepage', $LANG04[6]); $preferences->set_var('lang_homepage_text', $LANG04[36]); $preferences->set_var('lang_location', $LANG04[106]); $preferences->set_var('lang_location_text', $LANG04[107]); $preferences->set_var('lang_signature', $LANG04[32]); $preferences->set_var('lang_signature_text', $LANG04[37]); $preferences->set_var('lang_userphoto', $LANG04[77]); $preferences->set_var('lang_userphoto_text', $LANG04[78]); $preferences->set_var('lang_about', $LANG04[7]); $preferences->set_var('lang_about_text', $LANG04[38]); $preferences->set_var('lang_pgpkey', $LANG04[8]); $preferences->set_var('lang_pgpkey_text', $LANG04[39]); $preferences->set_var('lang_submit', $LANG04[9]); $preferences->set_var('lang_cancel', $LANG_ADMIN['cancel']); $preferences->set_var('lang_preview_title', $LANG04[145]); $preferences->set_var('lang_enter_current_password', $LANG04[127]); $preferences->set_var('lang_name_legend', $LANG04[128]); $preferences->set_var('lang_password_email_legend', $LANG04[129]); $preferences->set_var('lang_personal_info_legend', $LANG04[130]); $preferences->set_var('lang_resynch', $LANG04[166]); $display_name = COM_getDisplayName($_USER['uid']); //$preferences->set_var ('start_block_profile', // COM_startBlock ($LANG04[1] . ' ' . $display_name)); //$preferences->set_var ('end_block', COM_endBlock ()); $preferences->set_var('profile_headline', $LANG04[1] . ' ' . $display_name); if ($_CONF['allow_user_photo'] == 1) { $preferences->set_var('enctype', 'enctype="multipart/form-data"'); } else { $preferences->set_var('enctype', ''); } $preferences->set_var('fullname_value', htmlspecialchars($A['fullname'])); $preferences->set_var('new_username_value', htmlspecialchars($_USER['username'])); if ($A['remoteservice'] == '') { $preferences->set_var('password_value', ''); $preferences->parse('password_option', 'password', true); $preferences->parse('current_password_option', 'current_password', true); $preferences->set_var('resynch_option', ''); } else { $preferences->set_var('password_option', ''); $preferences->set_var('current_password_option', ''); if ($_CONF['user_login_method']['oauth'] && strpos($_USER['remoteservice'], 'oauth.') === 0) { // OAuth only supports re-synch at the moment $preferences->set_var('resynch_checked', ''); $preferences->parse('resynch_option', 'resynch', true); } else { $preferences->set_var('resynch_option', ''); } } if ($_CONF['allow_username_change'] == 1) { $preferences->parse('username_option', 'username', true); } else { $preferences->set_var('username_option', ''); } $selection = '<select id="cooktime" name="cooktime">' . LB; $selection .= COM_optionList($_TABLES['cookiecodes'], 'cc_value,cc_descr', $A['cookietimeout'], 0); $selection .= '</select>'; $preferences->set_var('cooktime_selector', $selection); $preferences->set_var('email_value', htmlspecialchars($A['email'])); $preferences->set_var('homepage_value', htmlspecialchars(COM_killJS($A['homepage']))); $preferences->set_var('location_value', htmlspecialchars(strip_tags($A['location']))); $preferences->set_var('signature_value', htmlspecialchars($A['sig'])); if ($_CONF['allow_user_photo'] == 1) { $photo = USER_getPhoto($_USER['uid'], $A['photo'], $A['email'], -1); if (empty($photo)) { $preferences->set_var('display_photo', ''); } else { if (empty($A['photo'])) { // external avatar $photo = '<br' . XHTML . '>' . $photo; } else { // uploaded photo - add delete option $photo = '<br' . XHTML . '>' . $photo . '<br' . XHTML . '>' . $LANG04[79] . ' <input type="checkbox" name="delete_photo"' . XHTML . '>' . LB; } $preferences->set_var('display_photo', $photo); } if (empty($_CONF['image_lib'])) { $scaling = $LANG04[162]; } else { $scaling = $LANG04[161]; } $preferences->set_var('photo_max_dimensions', sprintf($LANG04[160], $_CONF['max_photo_width'], $_CONF['max_photo_height'], $_CONF['max_photo_size'], $scaling)); $preferences->parse('userphoto_option', 'photo', true); } else { $preferences->set_var('userphoto_option', ''); } $result = DB_query("SELECT about,pgpkey FROM {$_TABLES['userinfo']} WHERE uid = {$_USER['uid']}"); $A = DB_fetchArray($result); $reqid = substr(md5(uniqid(rand(), 1)), 1, 16); DB_change($_TABLES['users'], 'pwrequestid', $reqid, 'uid', $_USER['uid']); $preferences->set_var('about_value', htmlspecialchars($A['about'])); $preferences->set_var('pgpkey_value', htmlspecialchars($A['pgpkey'])); $preferences->set_var('uid_value', $reqid); $preferences->set_var('username_value', htmlspecialchars($_USER['username'])); if ($_CONF['allow_account_delete'] == 1) { $preferences->set_var('lang_deleteaccount', $LANG04[156]); $preferences->set_var('delete_text', $LANG04[95]); $preferences->set_var('lang_button_delete', $LANG04[96]); $preferences->set_var('delete_mode', 'confirmdelete'); $preferences->set_var('account_id', $reqid); if (isset($LANG04[157])) { $preferences->set_var('lang_deleteoption', $LANG04[157]); } else { $preferences->set_var('lang_deleteoption', $LANG04[156]); } $preferences->parse('delete_account_option', 'deleteaccount', false); } else { $preferences->set_var('delete_account_option', ''); } // Call custom account form and edit function if enabled and exists if ($_CONF['custom_registration'] and function_exists('CUSTOM_userEdit')) { $preferences->set_var('customfields', CUSTOM_userEdit($_USER['uid'])); } PLG_profileVariablesEdit($_USER['uid'], $preferences); $retval = $preferences->finish($preferences->parse('output', 'profile')); $retval .= PLG_profileBlocksEdit($_USER['uid']); return $retval; }
/** * This function prints &$comments (db results set of comments) in comment format * -For previews, &$comments is assumed to be an associative array containing * data for a single comment. * * @param array &$comments Database result set of comments to be printed * @param string $mode 'flat', 'threaded', etc * @param string $type Type of item (article, poll, etc.) * @param string $order How to order the comments 'ASC' or 'DESC' * @param boolean $delete_option if current user can delete comments * @param boolean $preview Preview display (for edit) or not * @param int $ccode Comment code: -1=no comments, 0=allowed, 1=closed * @return string HTML Formated Comment * */ function CMT_getComment(&$comments, $mode, $type, $order, $delete_option = false, $preview = false, $ccode = 0) { global $_CONF, $_TABLES, $_USER, $LANG01, $LANG03, $MESSAGE, $_IMAGE_TYPE; $indent = 0; // begin with 0 indent $retval = ''; // initialize return value $template = new Template($_CONF['path_layout'] . 'comment'); $template->set_file(array('comment' => 'comment.thtml', 'thread' => 'thread.thtml')); // generic template variables $template->set_var('xhtml', XHTML); $template->set_var('site_url', $_CONF['site_url']); $template->set_var('site_admin_url', $_CONF['site_admin_url']); $template->set_var('layout_url', $_CONF['layout_url']); $template->set_var('lang_authoredby', $LANG01[42]); $template->set_var('lang_on', $LANG01[36]); $template->set_var('lang_permlink', $LANG01[120]); $template->set_var('order', $order); if ($ccode == 0) { $template->set_var('lang_replytothis', $LANG01[43]); $template->set_var('lang_reply', $LANG01[25]); } else { $template->set_var('lang_replytothis', ''); $template->set_var('lang_reply', ''); } // Make sure we have a default value for comment indentation if (!isset($_CONF['comment_indent'])) { $_CONF['comment_indent'] = 25; } if ($preview) { $A = $comments; if (empty($A['nice_date'])) { $A['nice_date'] = time(); } if (!isset($A['cid'])) { $A['cid'] = 0; } if (!isset($A['photo'])) { if (isset($_USER['photo'])) { $A['photo'] = $_USER['photo']; } else { $A['photo'] = ''; } } if (!isset($A['email'])) { if (isset($_USER['email'])) { $A['email'] = $_USER['email']; } else { $A['email'] = ''; } } $mode = 'flat'; } else { $A = DB_fetchArray($comments); } if (empty($A)) { return ''; } $token = ''; if ($delete_option && !$preview) { $token = SEC_createToken(); } // check for comment edit $row = 1; do { // check for comment edit $commentedit = DB_query("SELECT cid,uid,UNIX_TIMESTAMP(time) AS time FROM {$_TABLES['commentedits']} WHERE cid = {$A['cid']}"); $B = DB_fetchArray($commentedit); if ($B) { //comment edit present // get correct editor name if ($A['uid'] == $B['uid']) { $editname = $A['username']; } else { $editname = DB_getItem($_TABLES['users'], 'username', "uid={$B['uid']}"); } // add edit info to text $A['comment'] .= '<div class="comment-edit">' . $LANG03[30] . ' ' . strftime($_CONF['date'], $B['time']) . ' ' . $LANG03[31] . ' ' . $editname . '</div><!-- /COMMENTEDIT -->'; } // determines indentation for current comment if ($mode == 'threaded' || $mode == 'nested') { $indent = ($A['indent'] - $A['pindent']) * $_CONF['comment_indent']; } // comment variables $template->set_var('indent', $indent); $template->set_var('author_name', strip_tags($A['username'])); $template->set_var('author_id', $A['uid']); $template->set_var('cid', $A['cid']); $template->set_var('cssid', $row % 2); if ($A['uid'] > 1) { $fullname = ''; if (!empty($A['fullname'])) { $fullname = $A['fullname']; } $fullname = COM_getDisplayName($A['uid'], $A['username'], $fullname); $template->set_var('author_fullname', $fullname); $template->set_var('author', $fullname); $alttext = $fullname; $photo = ''; if ($_CONF['allow_user_photo']) { if (isset($A['photo']) && empty($A['photo'])) { $A['photo'] = '(none)'; } $photo = USER_getPhoto($A['uid'], $A['photo'], $A['email']); } if (!empty($photo)) { $template->set_var('author_photo', $photo); $camera_icon = '<img src="' . $_CONF['layout_url'] . '/images/smallcamera.' . $_IMAGE_TYPE . '" alt=""' . XHTML . '>'; $template->set_var('camera_icon', COM_createLink($camera_icon, $_CONF['site_url'] . '/users.php?mode=profile&uid=' . $A['uid'])); } else { $template->set_var('author_photo', ''); $template->set_var('camera_icon', ''); } $template->set_var('start_author_anchortag', '<a href="' . $_CONF['site_url'] . '/users.php?mode=profile&uid=' . $A['uid'] . '">'); $template->set_var('end_author_anchortag', '</a>'); $template->set_var('author_link', COM_createLink($fullname, $_CONF['site_url'] . '/users.php?mode=profile&uid=' . $A['uid'])); } else { //comment is from anonymous user if (isset($A['name'])) { $A['username'] = strip_tags($A['name']); } $template->set_var('author', $A['username']); $template->set_var('author_fullname', $A['username']); $template->set_var('author_link', $A['username']); $template->set_var('author_photo', ''); $template->set_var('camera_icon', ''); $template->set_var('start_author_anchortag', ''); $template->set_var('end_author_anchortag', ''); } // hide reply link from anonymous users if they can't post replies $hidefromanon = false; if (empty($_USER['username']) && ($_CONF['loginrequired'] == 1 || $_CONF['commentsloginrequired'] == 1)) { $hidefromanon = true; } // this will hide HTML that should not be viewed in preview mode if ($preview || $hidefromanon) { $template->set_var('hide_if_preview', 'style="display:none"'); } else { $template->set_var('hide_if_preview', ''); } // for threaded mode, add a link to comment parent if ($mode == 'threaded' && $A['pid'] != 0 && $indent == 0) { $result = DB_query("SELECT title,pid FROM {$_TABLES['comments']} WHERE cid = '{$A['pid']}'"); $P = DB_fetchArray($result); if ($P['pid'] != 0) { $plink = $_CONF['site_url'] . '/comment.php?mode=display&sid=' . $A['sid'] . '&title=' . urlencode(htmlspecialchars($P['title'])) . '&type=' . $type . '&order=' . $order . '&pid=' . $P['pid'] . '&format=threaded'; } else { $plink = $_CONF['site_url'] . '/comment.php?mode=view&sid=' . $A['sid'] . '&title=' . urlencode(htmlspecialchars($P['title'])) . '&type=' . $type . '&order=' . $order . '&cid=' . $A['pid'] . '&format=threaded'; } $parent_link = COM_createLink($LANG01[44], $plink) . ' | '; $template->set_var('parent_link', $parent_link); } else { $template->set_var('parent_link', ''); } $template->set_var('date', strftime($_CONF['date'], $A['nice_date'])); $template->set_var('sid', $A['sid']); $template->set_var('type', $A['type']); // COMMENT edit rights $edit_option = false; if (isset($A['uid']) && isset($_USER['uid']) && $_USER['uid'] == $A['uid'] && $_CONF['comment_edit'] == 1 && time() - $A['nice_date'] < $_CONF['comment_edittime'] && DB_getItem($_TABLES['comments'], 'COUNT(*)', "pid = {$A['cid']}") == 0) { $edit_option = true; if (empty($token)) { $token = SEC_createToken(); } } elseif (SEC_hasRights('comment.moderate')) { $edit_option = true; } // edit link $edit = ''; if ($edit_option) { $editlink = $_CONF['site_url'] . '/comment.php?mode=edit&cid=' . $A['cid'] . '&sid=' . $A['sid'] . '&type=' . $type; $edit = COM_createLink($LANG01[4], $editlink) . ' | '; } // unsubscribe link $unsubscribe = ''; if ($_CONF['allow_reply_notifications'] == 1 && !COM_isAnonUser() && isset($A['uid']) && isset($_USER['uid']) && $_USER['uid'] == $A['uid']) { $hash = DB_getItem($_TABLES['commentnotifications'], 'deletehash', "cid = {$A['cid']} AND uid = {$_USER['uid']}"); if (!empty($hash)) { $unsublink = $_CONF['site_url'] . '/comment.php?mode=unsubscribe&key=' . $hash; $unsubattr = array('title' => $LANG03[43]); $unsubscribe = COM_createLink($LANG03[42], $unsublink, $unsubattr) . ' | '; } } // if deletion is allowed, displays delete link if ($delete_option) { $deloption = ''; // always place edit option first, if available if (!empty($edit)) { $deloption .= $edit; } // actual delete option $dellink = $_CONF['site_url'] . '/comment.php?mode=delete&cid=' . $A['cid'] . '&sid=' . $A['sid'] . '&type=' . $type . '&' . CSRF_TOKEN . '=' . $token; $delattr = array('onclick' => "return confirm('{$MESSAGE[76]}');"); $deloption .= COM_createLink($LANG01[28], $dellink, $delattr) . ' | '; if (!empty($A['ipaddress'])) { if (empty($_CONF['ip_lookup'])) { $deloption .= $A['ipaddress'] . ' | '; } else { $iplookup = str_replace('*', $A['ipaddress'], $_CONF['ip_lookup']); $deloption .= COM_createLink($A['ipaddress'], $iplookup) . ' | '; } } if (!empty($unsubscribe)) { $deloption .= $unsubscribe; } $template->set_var('delete_option', $deloption); } elseif ($edit_option) { $template->set_var('delete_option', $edit . $unsubscribe); } elseif (!COM_isAnonUser()) { $reportthis = ''; if ($A['uid'] != $_USER['uid']) { $reportthis_link = $_CONF['site_url'] . '/comment.php?mode=report&cid=' . $A['cid'] . '&type=' . $type; $report_attr = array('title' => $LANG01[110]); $reportthis = COM_createLink($LANG01[109], $reportthis_link, $report_attr) . ' | '; } $template->set_var('delete_option', $reportthis . $unsubscribe); } else { $template->set_var('delete_option', ''); } //and finally: format the actual text of the comment, but check only the text, not sig or edit $text = str_replace('<!-- COMMENTSIG --><div class="comment-sig">', '', $A['comment']); $text = str_replace('</div><!-- /COMMENTSIG -->', '', $text); $text = str_replace('<div class="comment-edit">', '', $text); $text = str_replace('</div><!-- /COMMENTEDIT -->', '', $text); if (preg_match('/<.*>/', $text) == 0) { $A['comment'] = nl2br($A['comment']); } // highlight search terms if specified if (!empty($_REQUEST['query'])) { $A['comment'] = COM_highlightQuery($A['comment'], $_REQUEST['query']); } $A['comment'] = str_replace('$', '$', $A['comment']); $A['comment'] = str_replace('{', '{', $A['comment']); $A['comment'] = str_replace('}', '}', $A['comment']); // Replace any plugin autolink tags $A['comment'] = PLG_replaceTags($A['comment']); // create a reply to link $reply_link = ''; if ($ccode == 0) { $reply_link = $_CONF['site_url'] . '/comment.php?sid=' . $A['sid'] . '&pid=' . $A['cid'] . '&title=' . urlencode($A['title']) . '&type=' . $A['type']; $reply_option = COM_createLink($LANG01[43], $reply_link, array('rel' => 'nofollow')) . ' | '; $template->set_var('reply_option', $reply_option); } else { $template->set_var('reply_option', ''); } $template->set_var('reply_link', $reply_link); // format title for display, must happen after reply_link is created $A['title'] = htmlspecialchars($A['title']); $A['title'] = str_replace('$', '$', $A['title']); $template->set_var('title', $A['title']); $template->set_var('comments', $A['comment']); // parse the templates if ($mode == 'threaded' && $indent > 0) { $template->set_var('pid', $A['pid']); $retval .= $template->parse('output', 'thread'); } else { $template->set_var('pid', $A['cid']); $retval .= $template->parse('output', 'comment'); } $row++; } while ($A = DB_fetchArray($comments)); return $retval; }
function showtopic($showtopic, $mode = '', $onetwo = 1, $page = 1) { global $CONF_FORUM, $_CONF, $_TABLES, $_USER, $LANG_GF01, $LANG_GF02, $LANG_GF09; global $highlight; global $oldPost; $oldPost = 0; //$mytimer = new timerobject(); //$mytimer->setPercision(2); //$mytimer->startTimer(); //$intervalTime = $mytimer->stopTimer(); //COM_errorLog("Show Topic Display Time1: $intervalTime"); if (!class_exists('StringParser')) { require_once $CONF_FORUM['path_include'] . 'bbcode/stringparser_bbcode.class.php'; } $topictemplate = COM_newTemplate(CTL_plugin_templatePath('forum')); $topictemplate->set_file(array('topictemplate' => 'topic.thtml', 'forum_icons' => 'forum_icons.thtml', 'forum_links' => 'forum_links.thtml')); $topictemplate->set_block('topictemplate', 'block_user_information'); $topictemplate->set_block('topictemplate', 'block_anon_user_information'); $topictemplate->set_block('topictemplate', 'location'); $topictemplate->set_block('topictemplate', 'ip_address'); $topictemplate->set_block('topictemplate', 'anon_ip_address'); $topictemplate->set_block('topictemplate', 'user_signature'); $topictemplate->set_block('topictemplate', 'mod_functions'); $blocks = array('block_user_name', 'block_anon_user_name', 'block_user_information', 'block_anon_user_information', 'user_signature', 'mod_functions'); foreach ($blocks as $block) { $topictemplate->set_block('topictemplate', $block); } $topictemplate->set_block('forum_icons', 'topiclocked_icon'); $topictemplate->set_block('forum_icons', 'mood_icon'); $blocks = array('profile_link', 'pm_link', 'email_link', 'website_link', 'quotetopic_link', 'edittopic_link'); foreach ($blocks as $block) { $topictemplate->set_block('forum_links', $block); } // if preview, only stripslashes is gpc=on, else assume from db so strip if ($mode == 'preview') { $showtopic['subject'] = COM_stripslashes($showtopic['subject']); } else { $showtopic['subject'] = stripslashes($showtopic['subject']); } $min_height = 50; // Base minimum height of topic - will increase if avatar or sig is used $date = strftime($CONF_FORUM['default_Topic_Datetime_format'], $showtopic['date']); $sql = "SELECT u.*, ui.location FROM {$_TABLES['users']} u, {$_TABLES['userinfo']} ui \n \t\tWHERE u.uid = ui.uid \n \t\tAND u.uid = '{$showtopic['uid']}'"; $userQuery = DB_query($sql); if ($showtopic['uid'] > 1 and DB_numRows($userQuery) == 1) { $userarray = DB_fetchArray($userQuery); $username = COM_getDisplayName($showtopic['uid']); $userlink = "<a href=\"{$_CONF['site_url']}/users.php?mode=profile&uid={$showtopic['uid']}\" "; $userlink .= "class=\"authorname {$onetwo}\"><b>{$username}</b></a>"; $uservalid = true; $postcount = DB_query("SELECT * FROM {$_TABLES['forum_topic']} WHERE uid='{$showtopic['uid']}'"); $posts = DB_numRows($postcount); // STARS CODE if (SEC_inGroup(1, $showtopic['uid'])) { $user_level = showrank(7, $LANG_GF01['admin']); $user_levelname = $LANG_GF01['admin']; } else { if (forum_modPermission($showtopic['forum'], $showtopic['uid'])) { $user_level = showrank(6, $LANG_GF01['moderator']); $user_levelname = $LANG_GF01['moderator']; } else { if ($posts < $CONF_FORUM['level2']) { $user_level = showrank(1, $CONF_FORUM['level1name']); $user_levelname = $CONF_FORUM['level1name']; } elseif ($posts >= $CONF_FORUM['level2'] && $posts < $CONF_FORUM['level3']) { $user_level = showrank(2, $CONF_FORUM['level2name']); $user_levelname = $CONF_FORUM['level2name']; } elseif ($posts >= $CONF_FORUM['level3'] && $posts < $CONF_FORUM['level4']) { $user_level = showrank(3, $CONF_FORUM['level3name']); $user_levelname = $CONF_FORUM['level3name']; } elseif ($posts >= $CONF_FORUM['level4'] && $posts < $CONF_FORUM['level5']) { $user_level = showrank(4, $CONF_FORUM['level4name']); $user_levelname = $CONF_FORUM['level4name']; } elseif ($posts > $CONF_FORUM['level5']) { $user_level = showrank(5, $CONF_FORUM['level5name']); $user_levelname = $CONF_FORUM['level5name']; } } } // Still allow photo to be showen for users if ($showtopic['uid'] > 1 and ($userarray['photo'] != "" or !empty($_CONF['default_photo']))) { $avatar = USER_getPhoto($showtopic['uid'], '', '', $CONF_FORUM['avatar_width']); $min_height = $min_height + 50; } else { $avatar = ''; } $regdate = $LANG_GF01['REGISTERED'] . ': ' . strftime($_CONF['shortdate'], strtotime($userarray['regdate'])) . '<br' . XHTML . '>'; $numposts = $LANG_GF01['POSTS'] . ': ' . $posts; if (DB_count($_TABLES['sessions'], 'uid', $showtopic['uid']) > 0 and DB_getItem($_TABLES['userprefs'], 'showonline', "uid={$showtopic['uid']}") == 1) { $avatar .= '<br' . XHTML . '>' . $LANG_GF01['STATUS'] . ' ' . $LANG_GF01['ONLINE']; } else { $avatar .= '<br' . XHTML . '>' . $LANG_GF01['STATUS'] . ' ' . $LANG_GF01['OFFLINE']; } if ($userarray['sig'] != '') { $sig = $userarray['sig']; $min_height = $min_height + 30; } else { $sig = ''; } } else { $uservalid = false; $userlink = urldecode($showtopic['name']); } if ($CONF_FORUM['show_moods'] && $showtopic['mood'] != "") { $topictemplate->set_var('moodicon', gf_getImage($showtopic['mood'], 'moods')); $topictemplate->set_var('moodicontext', $showtopic['mood']); $topictemplate->parse('mood_icon', 'mood_icon'); $min_height = $min_height + 30; } else { $topictemplate->set_var('mood_icon', ''); } //$intervalTime = $mytimer->stopTimer(); //COM_errorLog("Show Topic Display Time3: $intervalTime"); // Handle Pre ver 2.5 quoting and New Line Formatting - consider adding this to a migrate function if ($CONF_FORUM['pre2.5_mode']) { // try to determine if we have an old post... if (strstr($showtopic['comment'], '<pre class="forumCode">') !== false) { $oldPost = 1; } if (strstr($showtopic['comment'], "[code]<code>") !== false) { $oldPost = 1; } if (strstr($showtopic['comment'], "<pre>") !== false) { $oldPost = 1; } if (stristr($showtopic['comment'], '[code') == false || stristr($showtopic['comment'], '[code]<code>') == true) { if (strstr($showtopic['comment'], "<pre>") !== false) { $oldPost = 1; } $showtopic['comment'] = str_replace('<pre>', '[code]', $showtopic['comment']); $showtopic['comment'] = str_replace('</pre>', '[/code]', $showtopic['comment']); } $showtopic['comment'] = str_ireplace("[code]<code>", '[code]', $showtopic['comment']); $showtopic['comment'] = str_ireplace("</code>[/code]", '[/code]', $showtopic['comment']); $showtopic['comment'] = str_replace(array("<br />\r\n", "<br />\n\r", "<br />\r", "<br />\n", "<br>\r\n", "<br>\n\r", "<br>\r", "<br>\n"), '<br' . XHTML . '>', $showtopic['comment']); $showtopic['comment'] = preg_replace("/\\[QUOTE\\sBY=\\s(.+?)\\]/i", "[QUOTE] Quote by \$1:", $showtopic['comment']); /* Reformat code blocks - version 2.3.3 and prior */ $showtopic['comment'] = str_replace('<pre class="forumCode">', '[code]', $showtopic['comment']); $showtopic['comment'] = preg_replace("/\\[QUOTE\\sBY=(.+?)\\]/i", "[QUOTE] Quote by \$1:", $showtopic['comment']); if ($oldPost) { if (strstr($showtopic['comment'], "\\'") !== false) { $showtopic['comment'] = stripslashes($showtopic['comment']); } } } $showtopic['comment'] = gf_formatTextBlock($showtopic['comment'], $showtopic['postmode'], $mode); $showtopic['subject'] = gf_formatTextBlock($showtopic['subject'], 'text', $mode); if ($CONF_FORUM['show_subject_length'] > 0 and strlen($showtopic['subject']) > $CONF_FORUM['show_subject_length']) { $showtopic['subject'] = COM_truncate("{$showtopic['subject']}", $CONF_FORUM['show_subject_length'], '...'); } //$intervalTime = $mytimer->stopTimer(); //COM_errorLog("Show Topic Display Time2: $intervalTime"); if ($mode != 'preview' && $uservalid && !COM_isAnonUser() && $_USER['uid'] == $showtopic['uid']) { /* Check if user can still edit this post - within allowed edit timeframe */ $editAllowed = false; if ($CONF_FORUM['allowed_editwindow'] > 0) { $t1 = $showtopic['date']; $t2 = $CONF_FORUM['allowed_editwindow']; if (time() - $t2 < $t1) { $editAllowed = true; } } else { $editAllowed = true; } if ($editAllowed) { $editlink = "{$_CONF['site_url']}/forum/createtopic.php?method=edit&forum={$showtopic['forum']}&id={$showtopic['id']}&editid={$showtopic['id']}&page={$page}"; $editlinktext = $LANG_GF09['edit']; $topictemplate->set_var('editlink', $editlink); $topictemplate->set_var('editlinktext', $editlinktext); $topictemplate->set_var('LANG_edit', $LANG_GF01['EDITICON']); $topictemplate->parse('edittopic_link', 'edittopic_link'); } } if ($highlight != '') { $showtopic['subject'] = str_replace("{$highlight}", "<span class=\"highlight\">{$highlight}</span>", $showtopic['subject']); $showtopic['comment'] = str_replace("{$highlight}", "<span class=\"highlight\">{$highlight}</span>", $showtopic['comment']); } if (!isset($showtopic['pid'])) { $showtopic['pid'] = 0; } if ($showtopic['pid'] == 0) { $replytopicid = $showtopic['id']; $is_lockedtopic = $showtopic['locked']; $views = $showtopic['views']; $topictemplate->set_var('read_msg', sprintf($LANG_GF02['msg49'], $views)); if ($is_lockedtopic) { $topictemplate->parse('topiclocked_icon', 'topiclocked_icon'); } } else { $replytopicid = $showtopic['pid']; $is_lockedtopic = DB_getItem($_TABLES['forum_topic'], 'locked', "id={$showtopic['pid']}"); $topictemplate->set_var('read_msg', ''); } if ($CONF_FORUM['allow_user_dateformat']) { $date = COM_getUserDateTimeFormat($showtopic['date']); $topictemplate->set_var('posted_date', $date[0]); } else { $date = strftime($CONF_FORUM['default_Topic_Datetime_format'], $showtopic['date']); $topictemplate->set_var('posted_date', $date); } if ($mode != 'preview') { if ($is_lockedtopic == 0) { $is_readonly = DB_getItem($_TABLES['forum_forums'], 'is_readonly', 'forum_id=' . $showtopic['forum']); if ($is_readonly == 0 or forum_modPermission($showtopic['forum'], $_USER['uid'], 'mod_edit')) { $quotelink = "{$_CONF['site_url']}/forum/createtopic.php?method=postreply&forum={$showtopic['forum']}&id={$replytopicid}&quoteid={$showtopic['id']}"; $quotelinktext = $LANG_GF09['quote']; $topictemplate->set_var('quotelink', $quotelink); $topictemplate->set_var('quotelinktext', $quotelinktext); $topictemplate->set_var('LANG_quote', $LANG_GF01['QUOTEICON']); $topictemplate->parse('quotetopic_link', 'quotetopic_link'); } } $topictemplate->set_var('topic_post_id', $showtopic['id']); if ($showtopic['uid'] > 1 && $uservalid) { $profile_link = "{$_CONF['site_url']}/users.php?mode=profile&uid={$showtopic['uid']}"; $profile_linktext = $LANG_GF09['profile']; $topictemplate->set_var('profilelink', $profile_link); $topictemplate->set_var('profilelinktext', $profile_linktext); $topictemplate->set_var('LANG_profile', $LANG_GF01['ProfileLink']); $topictemplate->parse('profile_link', 'profile_link'); if ($CONF_FORUM['use_pm_plugin']) { $pmusernmame = COM_getDisplayName($showtopic['uid']); $pmplugin_link = forumPLG_getPMlink($pmusernmame); if ($pmplugin_link != '') { $pm_link = $pmplugin_link; $pm_linktext = $LANG_GF09['pm']; $topictemplate->set_var('pmlink', $pm_link); $topictemplate->set_var('pmlinktext', $pm_linktext); $topictemplate->set_var('LANG_pm', $LANG_GF01['PMLink']); $topictemplate->parse('pm_link', 'pm_link'); } } } if ($userarray['email'] != '' && $showtopic["uid"] > 1) { $email_link = "{$_CONF['site_url']}/profiles.php?uid={$showtopic['uid']}"; $email_linktext = $LANG_GF09['email']; $topictemplate->set_var('emaillink', $email_link); $topictemplate->set_var('emaillinktext', $email_linktext); $topictemplate->set_var('LANG_email', $LANG_GF01['EmailLink']); $topictemplate->parse('email_link', 'email_link'); } if ($userarray['homepage'] != '') { $homepage = trim($userarray['homepage']); if (strtolower(substr($homepage, 0, 4)) != 'http') { $homepage = 'http://' . $homepage; } $homepagetext = $LANG_GF09['website']; $topictemplate->set_var('websitelink', $homepage); $topictemplate->set_var('websitelinktext', $homepagetext); $topictemplate->set_var('LANG_website', $LANG_GF01['WebsiteLink']); $topictemplate->parse('website_link', 'website_link'); } if ($userarray['location'] != '' && $showtopic["uid"] > 1) { $topictemplate->set_var('user_location', $userarray['location']); $topictemplate->parse('location', 'location'); } } else { if (isset($_GET['onlytopic']) and $_GET['onlytopic'] != 1) { $topictemplate->set_var('posted_date', ''); $topictemplate->set_var('preview_topic_subject', $showtopic['subject']); } else { $topictemplate->set_var('preview_topic_subject', ''); } $topictemplate->set_var('read_msg', ''); $topictemplate->set_var('topiclocked_icon', ''); $topictemplate->set_var('preview_mode', 'none'); } //$intervalTime = $mytimer->stopTimer(); //COM_errorLog("Show Topic Display Time4: $intervalTime"); $showtopic['comment'] = str_replace('{', '{', $showtopic['comment']); $showtopic['comment'] = str_replace('}', '}', $showtopic['comment']); // Temporary correspondence. You should cope in more roots. $showtopic['comment'] = str_replace(array("<br />", "<br>"), '<br' . XHTML . '>', $showtopic['comment']); $topictemplate->set_var('layout_url', $CONF_FORUM['layout_url']); $topictemplate->set_var('csscode', $onetwo); $topictemplate->set_var('postmode', $showtopic['postmode']); $topictemplate->set_var('userlink', $userlink); $topictemplate->set_var('lang_forum', $LANG_GF01['FORUM']); $topictemplate->set_var('user_levelname', $user_levelname); $topictemplate->set_var('user_level', $user_level); $topictemplate->set_var('avatar', $avatar); $topictemplate->set_var('regdate', $regdate); $topictemplate->set_var('numposts', $numposts); if (forum_modPermission($showtopic['forum'], $_USER['uid'], 'mod_ban')) { $topictemplate->set_var('ip', $showtopic['ip']); if ($showtopic['uid'] == 1) { $topictemplate->parse('ip_address', 'anon_ip_address'); } else { $topictemplate->parse('ip_address', 'ip_address'); } } else { $topictemplate->set_var('ip_address', ''); } $topictemplate->set_var('imgset', $CONF_FORUM['imgset']); $topictemplate->set_var('topic_subject', $showtopic['subject']); $topictemplate->set_var('LANG_ON2', $LANG_GF01['ON2']); if ($mode != 'preview') { $mod_functions = forum_getmodFunctions($showtopic); if (!empty($mod_functions)) { $topictemplate->set_var('mod_functions', $mod_functions); $topictemplate->parse('mod_functions', 'mod_functions'); } else { $topictemplate->set_var('mod_functions', ''); } } $topictemplate->set_var('topic_comment', $showtopic['comment']); $topictemplate->set_var('comment_minheight', "min-height:{$min_height}px"); if (trim($sig) != '') { $topictemplate->set_var('sig', PLG_replaceTags($sig)); $topictemplate->set_var('show_sig', ''); $topictemplate->parse('user_signature', 'user_signature'); } else { $topictemplate->set_var('sig', ''); $topictemplate->set_var('show_sig', 'none'); $topictemplate->set_var('user_signature', ''); } $topictemplate->set_var('forumid', $showtopic['forum']); $topictemplate->set_var('topic_id', $showtopic['id']); $topictemplate->set_var('member_badge', forumPLG_getMemberBadge($showtopic['uid'])); if ($uservalid) { $topictemplate->parse('user_name', 'block_user_name'); $topictemplate->parse('user_information', 'block_user_information'); } else { $topictemplate->parse('user_name', 'block_anon_user_name'); $topictemplate->parse('user_information', 'block_anon_user_information'); } $topictemplate->parse('output', 'topictemplate'); $retval = $topictemplate->finish($topictemplate->get_var('output')); //$intervalTime = $mytimer->stopTimer(); //COM_errorLog("Show Topic Display Time5: $intervalTime"); return $retval; }
function USER_userinfoPanel($U, $newuser = 0) { global $_CONF, $_SYSTEM, $_TABLES, $_USER, $LANG_MYACCOUNT, $LANG04; $uid = $U['uid']; // set template $userform = new Template($_CONF['path_layout'] . 'admin/user/'); $userform->set_file('user', 'userinfopanel.thtml'); $userform->set_var(array('lang_personal_info_legend' => $LANG04[130], 'lang_userinfo_help_title' => $LANG04[148], 'lang_userinfo_help' => $LANG04[149], 'lang_homepage' => $LANG04[6], 'lang_location' => $LANG04[106], 'lang_signature' => $LANG04[32], 'lang_about' => $LANG04[7], 'lang_pgpkey' => $LANG04[8], 'lang_social_follow' => $LANG04[198], 'lang_social_info' => $LANG04[199], 'lang_social_service' => $LANG04[200], 'lang_social_username' => $LANG04[201])); $follow_me = SOC_followMeProfile($uid); if (is_array($follow_me) && count($follow_me) > 0) { $userform->set_block('user', 'social_links', 'sl'); $userform->set_var('social_followme_enabled', true); foreach ($follow_me as $service) { $userform->set_var('service_display_name', $service['service_display_name']); $userform->set_var('service', $service['service']); $userform->set_var('service_username', $service['service_username']); $userform->parse('sl', 'social_links', true); } } else { $userform->unset_var('social_followme_enabled'); } if ($_CONF['allow_user_photo'] == 1) { $userform->set_var('lang_userphoto', $LANG04[77]); } $userform->set_var('homepage_value', @htmlspecialchars(COM_killJS($U['homepage']), ENT_NOQUOTES, COM_getEncodingt())); $userform->set_var('location_value', @htmlspecialchars(strip_tags($U['location']), ENT_NOQUOTES, COM_getEncodingt())); $userform->set_var('signature_value', @htmlspecialchars($U['sig'], ENT_NOQUOTES, COM_getEncodingt())); $userform->set_var('about_value', @htmlspecialchars($U['about'], ENT_NOQUOTES, COM_getEncodingt())); $userform->set_var('pgpkey_value', @htmlspecialchars($U['pgpkey'], ENT_NOQUOTES, COM_getEncodingt())); if ($_CONF['allow_user_photo'] == 1) { if (!empty($uid) && $uid > 1) { $photo = USER_getPhoto($uid, $U['photo'], $U['email'], -1); if (empty($photo)) { $userform->set_var('display_photo', ''); } else { if (empty($U['photo'])) { // external avatar $photo = '<br/>' . $photo; } else { // uploaded photo - add delete option $photo = '<br/>' . $photo . '<br/>' . $LANG04[79] . ' <input type="checkbox" name="delete_photo"/>' . LB; } $userform->set_var('display_photo', $photo); } } else { $userform->set_var('display_photo', ''); } } if (!empty($uid) && $uid > 1) { $userform->set_var('plugin_userinfo_personalinfo', PLG_profileEdit($uid, 'userinfo', 'personalinfo')); $userform->set_var('plugin_userinfo', PLG_profileEdit($uid, 'userinfo')); if ($_CONF['custom_registration'] && function_exists('CUSTOM_userEdit')) { $userform->set_var('customfields', CUSTOM_userEdit($uid)); } } $retval = $userform->finish($userform->parse('output', 'user')); return $retval; }
} $content .= "</form>"; break; case 'change_user_photo': //User id is set if ($_CONF['allow_user_photo'] == 1 && $uid > 0) { $username = DB_getItem($_TABLES['users'], 'username', "uid = {$uid}"); if ($username == '') { $T->set_var('title', 'Change photo of user ' . $A['fullname'] . ' (' . $uid . ')'); $content = 'This user does not exist'; } else { //Get user info $result = DB_query("SELECT fullname,cookietimeout,email,homepage,sig,emailstories,about,location,pgpkey,photo,remoteservice FROM {$_TABLES['users']},{$_TABLES['userprefs']},{$_TABLES['userinfo']} WHERE {$_TABLES['users']}.uid = {$uid} AND {$_TABLES['userprefs']}.uid = {$uid} AND {$_TABLES['userinfo']}.uid = {$uid}"); $A = DB_fetchArray($result); $T->set_var('title', 'Change photo of user ' . $A['fullname'] . ' (' . $uid . ')'); $photo = USER_getPhoto($uid, $A['photo'], $A['email'], -1); if (empty($photo)) { $display_photo = ''; } else { $display_photo = '<br' . XHTML . '>' . $photo; } if (empty($_CONF['image_lib'])) { $scaling = $LANG04[162]; } else { $scaling = $LANG04[161]; } $photo_max_dimensions = sprintf($LANG04[160], $_CONF['max_photo_width'], $_CONF['max_photo_height'], $_CONF['max_photo_size'], $scaling); //Form for new photo $content .= "<form method=\"post\" action=\"{$_CONF['site_admin_url']}/plugins/monitor/index.php\" enctype=\"multipart/form-data\">"; $content .= '<p>' . $display_photo . '</p><p>' . $photo_max_dimensions . '</p>'; $content .= '<p><input type="file" dir="ltr" id="photo" name="photo" size="30"' . XHTML . '></p>';
/** * Shows a profile for a user * This grabs the user profile for a given user and displays it * * @param int $uid User ID of profile to get * @param boolean $preview whether being called as preview from My Account * @param int $msg Message to display (if != 0) * @param string $plugin optional plugin name for message * @return string HTML for user profile page */ function USER_showProfile($uid, $preview = false, $msg = 0, $plugin = '') { global $_CONF, $_TABLES, $_USER, $_IMAGE_TYPE, $LANG01, $LANG04, $LANG09, $LANG28, $LANG_LOGIN, $LANG_ADMIN; $retval = ''; if (COM_isAnonUser() && ($_CONF['loginrequired'] == 1 || $_CONF['profileloginrequired'] == 1)) { $retval .= SEC_loginRequiredForm(); $retval = COM_createHTMLDocument($retval, array('pagetitle' => $LANG_LOGIN[1])); return $retval; } $result = DB_query("SELECT {$_TABLES['users']}.uid,username,fullname,regdate,homepage,about,location,pgpkey,photo,email,status FROM {$_TABLES['userinfo']},{$_TABLES['users']} WHERE {$_TABLES['userinfo']}.uid = {$_TABLES['users']}.uid AND {$_TABLES['users']}.uid = {$uid}"); $numRows = DB_numRows($result); if ($numRows == 0) { // no such user COM_handle404(); } $A = DB_fetchArray($result); if ($A['status'] == USER_ACCOUNT_DISABLED && !SEC_hasRights('user.edit')) { COM_displayMessageAndAbort(30, '', 403, 'Forbidden'); } if ($A['status'] != USER_ACCOUNT_ACTIVE && !SEC_hasRights('user.edit')) { COM_handle404(); } $display_name = COM_getDisplayName($uid, $A['username'], $A['fullname']); $display_name = htmlspecialchars($display_name); if (!$preview) { if ($msg > 0) { $retval .= COM_showMessage($msg, $plugin); } } // format date/time to user preference $currentTime = COM_getUserDateTimeFormat($A['regdate']); $A['regdate'] = $currentTime[0]; $user_templates = COM_newTemplate($_CONF['path_layout'] . 'users'); $user_templates->set_file(array('profile' => 'profile.thtml', 'email' => 'email.thtml', 'row' => 'commentrow.thtml', 'strow' => 'storyrow.thtml')); $user_templates->set_var('start_block_userprofile', COM_startBlock($LANG04[1] . ' ' . $display_name)); $user_templates->set_var('end_block', COM_endBlock()); $user_templates->set_var('lang_username', $LANG04[2]); if ($_CONF['show_fullname'] == 1) { if (empty($A['fullname'])) { $userName = $A['username']; $fullName = ''; } else { $userName = $A['fullname']; $fullName = $A['username']; } } else { $userName = $A['username']; $fullName = $A['fullname']; } $userName = htmlspecialchars($userName); $fullName = htmlspecialchars($fullName); if ($A['status'] == USER_ACCOUNT_DISABLED) { $userName = sprintf('<s title="%s">%s</s>', $LANG28[42], $userName); if (!empty($fullName)) { $fullName = sprintf('<s title="%s">%s</s>', $LANG28[42], $fullName); } } $user_templates->set_var('username', $userName); $user_templates->set_var('user_fullname', $fullName); if ($preview) { $user_templates->set_var('edit_icon', ''); $user_templates->set_var('edit_link', ''); $user_templates->set_var('user_edit', ''); } elseif (!COM_isAnonUser() && $_USER['uid'] == $uid) { $edit_icon = '<img src="' . $_CONF['layout_url'] . '/images/edit.' . $_IMAGE_TYPE . '" alt="' . $LANG01[48] . '" title="' . $LANG01[48] . '"' . XHTML . '>'; $edit_link_url = COM_createLink($edit_icon, $_CONF['site_url'] . '/usersettings.php'); $user_templates->set_var('edit_icon', $edit_icon); $user_templates->set_var('edit_link', $edit_link_url); $user_templates->set_var('user_edit', $edit_link_url); } elseif (SEC_hasRights('user.edit')) { $edit_icon = '<img src="' . $_CONF['layout_url'] . '/images/edit.' . $_IMAGE_TYPE . '" alt="' . $LANG_ADMIN['edit'] . '" title="' . $LANG_ADMIN['edit'] . '"' . XHTML . '>'; $edit_link_url = COM_createLink($edit_icon, "{$_CONF['site_admin_url']}/user.php?mode=edit&uid={$A['uid']}"); $user_templates->set_var('edit_icon', $edit_icon); $user_templates->set_var('edit_link', $edit_link_url); $user_templates->set_var('user_edit', $edit_link_url); } if (isset($A['photo']) && empty($A['photo'])) { $A['photo'] = '(none)'; // user does not have a photo } $photo = USER_getPhoto($uid, $A['photo'], $A['email'], -1); $user_templates->set_var('user_photo', $photo); $user_templates->set_var('lang_membersince', $LANG04[67]); $user_templates->set_var('user_regdate', $A['regdate']); $user_templates->set_var('lang_email', $LANG04[5]); $user_templates->set_var('user_id', $uid); $user_templates->set_var('uid', $uid); if ($A['email'] != '') { $user_templates->set_var('lang_sendemail', $LANG04[81]); $user_templates->parse('email_option', 'email', true); } else { $user_templates->set_var('email_option', ''); } $user_templates->set_var('lang_homepage', $LANG04[6]); $user_templates->set_var('user_homepage', COM_killJS($A['homepage'])); $user_templates->set_var('lang_location', $LANG04[106]); $user_templates->set_var('user_location', strip_tags($A['location'])); $user_templates->set_var('lang_bio', $LANG04[7]); $user_templates->set_var('user_bio', COM_nl2br(stripslashes($A['about']))); $user_templates->set_var('lang_pgpkey', $LANG04[8]); $user_templates->set_var('user_pgp', COM_nl2br($A['pgpkey'])); $user_templates->set_var('start_block_last10stories', COM_startBlock($LANG04[82] . ' ' . $display_name)); $user_templates->set_var('start_block_last10comments', COM_startBlock($LANG04[10] . ' ' . $display_name)); $user_templates->set_var('start_block_postingstats', COM_startBlock($LANG04[83] . ' ' . $display_name)); $user_templates->set_var('lang_title', $LANG09[16]); $user_templates->set_var('lang_date', $LANG09[17]); // for alternative layouts: use these as headlines instead of block titles $user_templates->set_var('headline_last10stories', $LANG04[82]); $user_templates->set_var('headline_last10comments', $LANG04[10]); $user_templates->set_var('headline_postingstats', $LANG04[83]); $tids = TOPIC_getList(0, true, false); $topics = "'" . implode("','", $tids) . "'"; // list of last 10 stories by this user if (count($tids) > 0) { $sql = "SELECT sid,title,UNIX_TIMESTAMP(date) AS unixdate\n FROM {$_TABLES['stories']}, {$_TABLES['topic_assignments']} ta\n WHERE (uid = {$uid}) AND (draft_flag = 0) AND (date <= NOW()) AND (tid IN ({$topics}))" . COM_getPermSQL('AND') . "\n AND ta.type = 'article' AND ta.id = sid AND ta.tdefault = 1\n ORDER BY unixdate DESC LIMIT 10"; $result = DB_query($sql); $numRows = DB_numRows($result); } else { $numRows = 0; } if ($numRows > 0) { for ($i = 0; $i < $numRows; $i++) { $C = DB_fetchArray($result); $user_templates->set_var('cssid', $i % 2 + 1); $user_templates->set_var('row_number', $i + 1 . '.'); $articleUrl = COM_buildURL($_CONF['site_url'] . '/article.php?story=' . $C['sid']); $user_templates->set_var('article_url', $articleUrl); $C['title'] = str_replace('$', '$', $C['title']); $user_templates->set_var('story_title', COM_createLink(stripslashes($C['title']), $articleUrl, array('class' => 'b'))); $storyTime = COM_getUserDateTimeFormat($C['unixdate']); $user_templates->set_var('story_date', $storyTime[0]); $user_templates->parse('story_row', 'strow', true); } } else { $story_row = $LANG01[37]; if ($_CONF['supported_version_theme'] == '1.8.1') { $story_row = '<tr><td>' . $story_row . '</td></tr>'; } $user_templates->set_var('story_row', $story_row); } // list of last 10 comments by this user $new_plugin_comments = PLG_getWhatsNewComment('', 10, $uid); if (!empty($new_plugin_comments)) { // Sort array by element lastdate newest to oldest foreach ($new_plugin_comments as $k => $v) { $b[$k] = strtolower($v['unixdate']); } arsort($b); foreach ($b as $key => $val) { $temp[] = $new_plugin_comments[$key]; } $new_plugin_comments = $temp; $i = 0; foreach ($new_plugin_comments as $C) { $i = $i + 1; $user_templates->set_var('cssid', $i % 2); $user_templates->set_var('row_number', $i . '.'); $C['title'] = str_replace('$', '$', $C['title']); $comment_url = $_CONF['site_url'] . '/comment.php?mode=view&cid=' . $C['cid']; $user_templates->set_var('comment_title', COM_createLink(stripslashes($C['title']), $comment_url, array('class' => 'b'))); $commentTime = COM_getUserDateTimeFormat($C['unixdate']); $user_templates->set_var('comment_date', $commentTime[0]); $user_templates->parse('comment_row', 'row', true); if ($i == 10) { break; } } } else { $comment_row = $LANG01[29]; if ($_CONF['supported_version_theme'] == '1.8.1') { $comment_row = '<tr><td>' . $comment_row . '</td></tr>'; } $user_templates->set_var('comment_row', $comment_row); } // posting stats for this user $user_templates->set_var('lang_number_stories', $LANG04[84]); $sql = "SELECT COUNT(*) AS count FROM {$_TABLES['stories']} WHERE (uid = {$uid}) AND (draft_flag = 0) AND (date <= NOW())" . COM_getPermSQL('AND'); $result = DB_query($sql); $N = DB_fetchArray($result); $user_templates->set_var('number_stories', COM_numberFormat($N['count'])); $user_templates->set_var('lang_number_comments', $LANG04[85]); $sql = "SELECT COUNT(*) AS count FROM {$_TABLES['comments']} WHERE (uid = {$uid})"; $result = DB_query($sql); $N = DB_fetchArray($result); $user_templates->set_var('number_comments', COM_numberFormat($N['count'])); $user_templates->set_var('lang_all_postings_by', $LANG04[86] . ' ' . $display_name); // Call custom registration function if enabled and exists if ($_CONF['custom_registration'] && function_exists('CUSTOM_userDisplay')) { $user_templates->set_var('customfields', CUSTOM_userDisplay($uid)); } PLG_profileVariablesDisplay($uid, $user_templates); $user_templates->parse('output', 'profile'); $retval .= $user_templates->finish($user_templates->get_var('output')); $retval .= PLG_profileBlocksDisplay($uid); if (!$preview) { $retval = COM_createHTMLDocument($retval, array('pagetitle' => $LANG04[1] . ' ' . $display_name)); } return $retval; }
/** * This function prints &$comments (db results set of comments) in comment format * -For previews, &$comments is assumed to be an associative array containing * data for a single comment. * * @param array &$comments Database result set of comments to be printed * @param string $mode 'flat', 'threaded', etc * @param string $type Type of item (article, polls, etc.) * @param string $order How to order the comments 'ASC' or 'DESC' * @param boolean $delete_option if current user can delete comments * @param boolean $preview Preview display (for edit) or not * @param int $ccode Comment code: -1=no comments, 0=allowed, 1=closed * @return string HTML Formated Comment * */ function CMT_getComment(&$comments, $mode, $type, $order, $delete_option = false, $preview = false, $ccode = 0, $sid_author_id = '') { global $_CONF, $_TABLES, $_USER, $LANG01, $LANG03, $MESSAGE, $_IMAGE_TYPE; $indent = 0; // begin with 0 indent $retval = ''; // initialize return value $filter = sanitizer::getInstance(); $AllowedElements = $filter->makeAllowedElements($_CONF['htmlfilter_comment']); $filter->setAllowedelements($AllowedElements); $filter->setNamespace('glfusion', 'comment'); if ($mode == 'threaded') { $mode = 'nested'; } $template = new Template($_CONF['path_layout'] . 'comment'); $template->set_file(array('comment' => 'comment.thtml', 'thread' => 'thread.thtml')); // generic template variables $template->set_var('lang_authoredby', $LANG01[42]); $template->set_var('lang_on', $LANG01[36]); $template->set_var('lang_permlink', $LANG01[120]); $template->set_var('order', $order); if ($ccode == 0 && ($_CONF['commentsloginrequired'] == 0 || !COM_isAnonUser())) { $template->set_var('lang_replytothis', $LANG01[43]); $template->set_var('lang_reply', $LANG01[25]); } else { $template->set_var('lang_replytothis', ''); $template->set_var('lang_reply', ''); } // Make sure we have a default value for comment indentation if (!isset($_CONF['comment_indent'])) { $_CONF['comment_indent'] = 25; } if ($preview) { $A = $comments; if (empty($A['nice_date'])) { $A['nice_date'] = time(); } if (!isset($A['cid'])) { $A['cid'] = 0; } if (!isset($A['photo'])) { if (isset($_USER['photo'])) { $A['photo'] = $_USER['photo']; } else { $A['photo'] = ''; } } if (!isset($A['email'])) { if (isset($_USER['email'])) { $A['email'] = $_USER['email']; } else { $A['email'] = ''; } } $A['name'] = $A['username']; $mode = 'flat'; $template->set_var('preview_mode', true); } else { $A = DB_fetchArray($comments); $template->unset_var('preview_mode'); } if (empty($A)) { return ''; } $token = ''; if ($delete_option && !$preview) { $token = SEC_createToken(); } $row = 1; do { $template->unset_var('delete_link'); $template->unset_var('ipaddress'); $template->unset_var('reply_link'); $template->unset_var('edit_link'); //check for comment edit $commentedit = DB_query("SELECT cid,uid,UNIX_TIMESTAMP(time) as time FROM {$_TABLES['commentedits']} WHERE cid = " . (int) $A['cid']); $B = DB_fetchArray($commentedit); if ($B) { //comment edit present //get correct editor name if ($A['uid'] == $B['uid']) { $editname = $A['username']; } else { $editname = DB_getItem($_TABLES['users'], 'username', "uid=" . (int) $B['uid']); } //add edit info to text $dtObject = new Date($B['time'], $_USER['tzid']); $A['comment'] .= LB . '<div class="comment-edit">' . $LANG03[30] . ' ' . $dtObject->format($_CONF['date'], true) . ' ' . $LANG03[31] . ' ' . $editname . '</div><!-- /COMMENTEDIT -->'; } // determines indentation for current comment if ($mode == 'threaded' || $mode == 'nested') { $indent = ($A['indent'] - $A['pindent']) * $_CONF['comment_indent']; } // comment variables if (!isset($A['uid']) || $A['uid'] == '') { $A['uid'] = 1; } $template->set_var('indent', $indent); $template->set_var('author_name', $filter->sanitizeUsername($A['username'])); $template->set_var('author_id', $A['uid']); $template->set_var('cid', $A['cid']); $template->set_var('cssid', $row % 2); if ($sid_author_id != '' && $sid_author_id != 1 && $sid_author_id == $A['uid']) { $template->set_var('author_match', '1'); } else { $template->set_var('author_match', ''); } if ($A['uid'] > 1) { $fullname = COM_getDisplayName($A['uid'], $A['username'], isset($A['fullname']) ? $A['fullname'] : ''); $template->set_var('author_fullname', $fullname); $template->set_var('author', $fullname); $alttext = $fullname; $photo = ''; if ($_CONF['allow_user_photo']) { if (isset($A['photo']) && empty($A['photo'])) { $A['photo'] = ''; } $photo = USER_getPhoto($A['uid'], $A['photo'], $A['email']); $photo_raw = USER_getPhoto($A['uid'], $A['photo'], $A['email'], 64, 0); if (!empty($photo)) { $template->set_var('author_photo', $photo); $template->set_var('author_photo_raw', $photo_raw); $camera_icon = '<img src="' . $_CONF['layout_url'] . '/images/smallcamera.' . $_IMAGE_TYPE . '" alt=""/>'; $template->set_var('camera_icon', COM_createLink($camera_icon, $_CONF['site_url'] . '/users.php?mode=profile&uid=' . $A['uid'])); } else { $template->set_var('author_photo', '<img src="' . $_CONF['default_photo'] . '" alt="" class="userphoto"/>'); $template->set_var('author_photo_raw', $_CONF['default_photo']); $template->set_var('camera_icon', ''); } } else { $template->set_var('author_photo_raw', ''); $template->set_var('author_photo', ''); $template->set_var('camera_icon', ''); } $template->set_var('start_author_anchortag', '<a href="' . $_CONF['site_url'] . '/users.php?mode=profile&uid=' . $A['uid'] . '">'); $template->set_var('end_author_anchortag', '</a>'); $template->set_var('author_link', COM_createLink($fullname, $_CONF['site_url'] . '/users.php?mode=profile&uid=' . $A['uid'])); } else { $username = $filter->sanitizeUsername($A['name']); if ($username == '') { $username = $LANG01[24]; } $template->set_var('author', $username); $template->set_var('author_fullname', $username); $template->set_var('author_link', @htmlspecialchars($username, ENT_COMPAT, COM_getEncodingt())); if ($_CONF['allow_user_photo']) { $template->set_var('author_photo_raw', $_CONF['default_photo']); $template->set_var('author_photo', '<img src="' . $_CONF['default_photo'] . '" alt="" class="userphoto"/>'); $template->set_var('camera_icon', ''); } else { $template->set_var('author_photo_raw', ''); $template->set_var('author_photo', ''); $template->set_var('camera_icon', ''); } $template->set_var('start_author_anchortag', ''); $template->set_var('end_author_anchortag', ''); } // hide reply link from anonymous users if they can't post replies $hidefromanon = false; if (COM_isAnonUser() && ($_CONF['loginrequired'] == 1 || $_CONF['commentsloginrequired'] == 1)) { $hidefromanon = true; } // this will hide HTML that should not be viewed in preview mode if ($preview || $hidefromanon) { $template->set_var('hide_if_preview', 'style="display:none"'); } else { $template->set_var('hide_if_preview', ''); } $dtObject = new Date($A['nice_date'], $_USER['tzid']); $template->set_var('date', $dtObject->format($_CONF['date'], true)); $template->set_var('sid', $A['sid']); $template->set_var('type', $A['type']); //COMMENT edit rights if (!COM_isAnonUser()) { if ($_USER['uid'] == $A['uid'] && $_CONF['comment_edit'] == 1 && ($_CONF['comment_edittime'] == 0 || time() - $A['nice_date'] < $_CONF['comment_edittime']) && $ccode == 0 && DB_getItem($_TABLES['comments'], 'COUNT(*)', "pid = " . (int) $A['cid']) == 0) { $edit_option = true; } else { if (SEC_inGroup('Root')) { $edit_option = true; } else { $edit_option = false; } } } else { $edit_option = false; } //edit link if ($edit_option) { if (empty($token)) { $token = SEC_createToken(); } $editlink = $_CONF['site_url'] . '/comment.php?mode=edit&cid=' . $A['cid'] . '&sid=' . $A['sid'] . '&type=' . $type . '&' . CSRF_TOKEN . '=' . $token . '#comment_entry'; $template->set_var('edit_link', $editlink); $template->set_var('lang_edit', $LANG01[4]); $edit = COM_createLink($LANG01[4], $editlink) . ' | '; } else { $editlink = ''; $edit = ''; } // If deletion is allowed, displays delete link if ($delete_option) { $deloption = ''; if (SEC_inGroup('Root')) { if (!empty($A['ipaddress'])) { if (empty($_CONF['ip_lookup'])) { $deloption = $A['ipaddress'] . ' | '; $template->set_var('ipaddress', $A['ipaddress']); } else { $iplookup = str_replace('*', $A['ipaddress'], $_CONF['ip_lookup']); $template->set_var('iplookup_link', $iplookup); $template->set_var('ipaddress', $A['ipaddress']); $deloption = COM_createLink($A['ipaddress'], $iplookup) . ' | '; } //insert re-que link here } } $dellink = $_CONF['site_url'] . '/comment.php?mode=delete&cid=' . $A['cid'] . '&sid=' . $A['sid'] . '&type=' . $type . '&' . CSRF_TOKEN . '=' . $token; $delattr = array('onclick' => "return confirm('{$MESSAGE[76]}');"); $delete_link = $dellink; $template->set_var('delete_link', $delete_link); $template->set_var('lang_delete_link_confirm', $MESSAGE[76]); $template->set_var('lang_delete', $LANG01[28]); $deloption .= COM_createLink($LANG01[28], $dellink, $delattr) . ' | '; $template->set_var('delete_option', $deloption . $edit); } else { if ($edit_option) { $template->set_var('delete_option', $edit); } elseif (!COM_isAnonUser()) { $reportthis = ''; if ($A['uid'] != $_USER['uid']) { $reportthis_link = $_CONF['site_url'] . '/comment.php?mode=report&cid=' . $A['cid'] . '&type=' . $type; $report_attr = array('title' => $LANG01[110]); $template->set_var('report_link', $reportthis_link); $template->set_var('lang_report', $LANG01[109]); $reportthis = COM_createLink($LANG01[109], $reportthis_link, $report_attr) . ' | '; } $template->set_var('delete_option', $reportthis); } else { $template->set_var('delete_option', ''); } } //and finally: format the actual text of the comment, but check only the text, not sig or edit $text = str_replace('<!-- COMMENTSIG --><div class="comment-sig">', '', $A['comment']); $text = str_replace('</div><!-- /COMMENTSIG -->', '', $text); $text = str_replace('<div class="comment-edit">', '', $text); $text = str_replace('</div><!-- /COMMENTEDIT -->', '', $text); $filter->setReplaceTags(true); $filter->setCensorData(true); if (preg_match('/<.*>/', $text) == 0) { $A['comment'] = nl2br($A['comment']); } $filter->setPostmode('html'); $A['comment'] = $filter->displayText($A['comment']); // highlight search terms if specified if (!empty($_REQUEST['query'])) { $A['comment'] = COM_highlightQuery($A['comment'], strip_tags($_REQUEST['query'])); } if (function_exists('msg_replaceEmoticons')) { $A['comment'] = msg_replaceEmoticons($A['comment']); } // create a reply to link $reply_link = ''; if ($ccode == 0 && ($_CONF['commentsloginrequired'] == 0 || !COM_isAnonUser())) { $reply_link = $_CONF['site_url'] . '/comment.php?sid=' . $A['sid'] . '&pid=' . $A['cid'] . '&title=' . urlencode($A['title']) . '&type=' . $A['type'] . '#comment_entry'; $template->set_var('reply_link', $reply_link); $template->set_var('lang_reply', $LANG01[43]); $reply_option = COM_createLink($LANG01[43], $reply_link, array('rel' => 'nofollow')) . ' | '; $template->set_var('reply_option', $reply_option); } else { $template->set_var('reply_option', ''); } $template->set_var('reply_link', $reply_link); // format title for display, must happen after reply_link is created $A['title'] = @htmlspecialchars($A['title'], ENT_COMPAT, COM_getEncodingt()); $template->set_var('title', $A['title']); $template->set_var('comments', $A['comment']); // parse the templates if ($mode == 'threaded' && $indent > 0) { $template->set_var('pid', $A['pid']); $retval .= $template->parse('output', 'thread'); } else { $template->set_var('pid', $A['cid']); $retval .= $template->parse('output', 'comment'); } if ($preview) { return $retval; } $row++; } while ($A = DB_fetchArray($comments)); return $retval; }
/** * Takes an article class and renders HTML in the specified template and style. * * Formats the given article into HTML. Called by index.php, article.php, * submit.php and admin/story.php (Preview mode for the last two). * * @param object $story The story to display, an instance of the Story class. * @param string $index n = 'Compact display' for list of stories. p = 'Preview' mode. Else full display of article. * @param string $storytpl The template to use to render the story. * @param string $query A search query, if one was specified. * * @return string Article as formated HTML. * * Note: Formerly named COM_Article, and re-written totally since then. */ function STORY_renderArticle(&$story, $index = '', $storytpl = 'storytext.thtml', $query = '') { global $_CONF, $_TABLES, $_USER, $LANG01, $LANG05, $LANG11, $LANG_TRB, $_IMAGE_TYPE, $mode, $_GROUPS, $ratedIds; static $storycounter = 0; if (empty($storytpl)) { $storytpl = 'storytext.thtml'; } $introtext = $story->displayElements('introtext'); $bodytext = $story->displayElements('bodytext'); if (!empty($query)) { $introtext = COM_highlightQuery($introtext, $query); $bodytext = COM_highlightQuery($bodytext, $query); } $article = new Template($_CONF['path_layout']); $article->set_file(array('article' => $storytpl, 'featuredarticle' => 'featuredstorytext.thtml', 'archivearticle' => 'archivestorytext.thtml')); if ($_CONF['hideviewscount'] != 1) { $article->set_var('lang_views', $LANG01[106]); $article->set_var('story_hits', $story->DisplayElements('hits'), false, true); } if ($_CONF['hidestorydate'] != 1) { $article->set_var('story_date', $story->DisplayElements('date'), false, true); // make sure date format is in user's preferred format } $articleUrl = COM_buildUrl($_CONF['site_url'] . '/article.php?story=' . $story->getSid()); $article->set_var('article_url', $articleUrl); $article->set_var('story_title', $story->DisplayElements('title')); // begin instance caching... if ($story->DisplayElements('featured') == 1) { $article_filevar = 'featuredarticle'; } elseif ($story->DisplayElements('statuscode') == STORY_ARCHIVE_ON_EXPIRE and $story->DisplayElements('expire') <= time()) { $article_filevar = 'archivearticle'; } else { $article_filevar = 'article'; } $hash = CACHE_security_hash(); $instance_id = 'story_' . $story->getSid() . '_' . $index . '_' . $article_filevar . '_' . $hash . '_' . $_USER['theme']; if ($index == 'p' || !empty($query) || !$article->check_instance($instance_id, $article_filevar)) { // end of instance cache $article->set_var('article_filevar', ''); $article->set_var('site_name', $_CONF['site_name']); if ($_CONF['hidestorydate'] != 1) { $article->set_var('story_date_short', $story->DisplayElements('shortdate')); $article->set_var('story_date_only', $story->DisplayElements('dateonly')); } $article->set_var('story_id', $story->getSid()); $article->set_var('lang_posted_in', $LANG01['posted_in']); if ($_CONF['contributedbyline'] == 1) { $article->set_var('lang_contributed_by', $LANG01[1]); $article->set_var('lang_by', $LANG01[95]); $article->set_var('contributedby_uid', $story->DisplayElements('uid')); $fullname = $story->DisplayElements('fullname'); $username = $story->DisplayElements('username'); $article->set_var('contributedby_user', $username); if (empty($fullname)) { $article->set_var('contributedby_fullname', $username); } else { $article->set_var('contributedby_fullname', $fullname); } $authorname = COM_getDisplayName($story->DisplayElements('uid'), $username, $fullname); $article->set_var('author', $authorname); $profileUrl = $_CONF['site_url'] . '/users.php?mode=profile&uid=' . $story->DisplayElements('uid'); if ($story->DisplayElements('uid') > 1) { $article->set_var('contributedby_url', $profileUrl); $authorname = COM_createLink($authorname, $profileUrl, array('class' => 'storybyline')); } $article->set_var('contributedby_author', $authorname); $photo = ''; if ($_CONF['allow_user_photo'] == 1) { $authphoto = $story->DisplayElements('photo'); if (empty($authphoto)) { $authphoto = '(none)'; // user does not have a photo } $photo = USER_getPhoto($story->DisplayElements('uid'), $authphoto, $story->DisplayElements('email')); } if (!empty($photo)) { $article->set_var('contributedby_photo', $photo); $article->set_var('author_photo', $photo); $camera_icon = '<img src="' . $_CONF['layout_url'] . '/images/smallcamera.' . $_IMAGE_TYPE . '" alt=""' . '/>'; $article->set_var('camera_icon', COM_createLink($camera_icon, $profileUrl)); } else { $article->set_var('contributedby_photo', ''); $article->set_var('author_photo', ''); $article->set_var('camera_icon', ''); } } $topicname = $story->DisplayElements('topic'); if ($story->DisplayElements('alternate_tid') != NULL) { $alttopic = DB_getItem($_TABLES['topics'], 'topic', "tid = '" . DB_escapeString($story->DisplayElements('alternate_tid')) . "'"); } else { $alttopic = ''; } $article->set_var('story_topic_id', $story->DisplayElements('tid')); $article->set_var('alt_story_topic_id', $story->DisplayElements('alternate_tid')); $article->set_var('story_topic_name', $topicname); $article->set_var('story_alternate_topic_name', $alttopic); $topicurl = $_CONF['site_url'] . '/index.php?topic=' . $story->DisplayElements('tid'); $alttopicurl = $_CONF['site_url'] . '/index.php?topic=' . $story->DisplayElements('alternate_tid'); if ((!isset($_USER['noicons']) or $_USER['noicons'] != 1) and $story->DisplayElements('show_topic_icon') == 1) { $imageurl = $story->DisplayElements('imageurl'); if (!empty($imageurl)) { $imageurl = COM_getTopicImageUrl($imageurl); $article->set_var('story_topic_image_url', $imageurl); $topicimage = '<img src="' . $imageurl . '" class="float' . $_CONF['article_image_align'] . '" alt="' . $topicname . '" title="' . $topicname . '" />'; $article->set_var('story_anchortag_and_image', COM_createLink($topicimage, $topicurl, array('rel' => "category tag"))); $article->set_var('story_topic_image', $topicimage); $topicimage_noalign = '<img src="' . $imageurl . '" alt="' . $topicname . '" title="' . $topicname . '" />'; $article->set_var('story_anchortag_and_image_no_align', COM_createLink($topicimage_noalign, $topicurl, array('rel' => "category tag"))); $article->set_var('story_topic_image_no_align', $topicimage_noalign); } } $article->set_var('story_topic_url', $topicurl); $article->set_var('alt_story_topic_url', $alttopicurl); $recent_post_anchortag = ''; $articleUrl = COM_buildUrl($_CONF['site_url'] . '/article.php?story=' . $story->getSid()); $article->set_var('story_title', $story->DisplayElements('title')); $article->set_var('lang_permalink', $LANG01[127]); $show_comments = true; // n = 'Compact display' for list of stories. p = 'Preview' mode. if ($index != 'n' && $index != 'p' || !empty($query)) { $attributes = ' class="non-ul"'; $attr_array = array('class' => 'non-ul'); if (!empty($query)) { $attributes .= ' rel="bookmark"'; $attr_array['rel'] = 'bookmark'; } $article->set_var('start_storylink_anchortag', '<a href="' . $articleUrl . '"' . $attributes . '>'); $article->set_var('end_storylink_anchortag', '</a>'); $article->set_var('story_title_link', COM_createLink($story->DisplayElements('title'), $articleUrl, $attr_array)); } else { $article->set_var('story_title_link', $story->DisplayElements('title')); } if ($index == 'n' || $index == 'p') { if (empty($bodytext)) { $article->set_var('story_introtext', $introtext); $article->set_var('story_text_no_br', $introtext); } else { if ($_CONF['allow_page_breaks'] == 1 and $index == 'n') { $story_page = 1; // page selector if (is_numeric($mode)) { $story_page = $mode; if ($story_page <= 0) { $story_page = 1; $mode = 0; } elseif ($story_page > 1) { $introtext = ''; } } $article_array = explode('[page_break]', $bodytext); $pagelinks = COM_printPageNavigation($articleUrl, $story_page, count($article_array), 'mode=', $_CONF['url_rewrite'], $LANG01[118]); if (count($article_array) > 1) { $bodytext = $article_array[$story_page - 1]; } $article->set_var('page_selector', $pagelinks); if ($_CONF['page_break_comments'] == 'last' and $story_page < count($article_array) or $_CONF['page_break_comments'] == 'first' and $story_page != 1) { $show_comments = false; } $article->set_var('story_page', $story_page); } $article->set_var('story_introtext', $introtext . '<br />' . $bodytext); $article->set_var('story_text_no_br', $introtext . $bodytext); } $article->set_var('story_introtext_only', $introtext); $article->set_var('story_bodytext_only', $bodytext); if (($_CONF['trackback_enabled'] || $_CONF['pingback_enabled']) && SEC_hasRights('story.ping')) { $url = $_CONF['site_admin_url'] . '/trackback.php?mode=sendall&id=' . $story->getSid(); $article->set_var('send_trackback_link', COM_createLink($LANG_TRB['send_trackback'], $url)); $pingico = '<img src="' . $_CONF['layout_url'] . '/images/sendping.' . $_IMAGE_TYPE . '" alt="' . $LANG_TRB['send_trackback'] . '" title="' . $LANG_TRB['send_trackback'] . '" />'; $article->set_var('send_trackback_icon', COM_createLink($pingico, $url)); $article->set_var('send_trackback_url', $url); $article->set_var('lang_send_trackback_text', $LANG_TRB['send_trackback']); } $article->set_var('story_display', $index == 'p' ? 'preview' : 'article'); $article->set_var('story_counter', 0); } else { $article->set_var('story_introtext', $introtext); $article->set_var('story_text_no_br', $introtext); $article->set_var('story_introtext_only', $introtext); if (!empty($bodytext)) { $article->set_var('lang_readmore', $LANG01[2]); $article->set_var('lang_readmore_words', $LANG01[62]); $numwords = COM_numberFormat(sizeof(explode(' ', strip_tags($bodytext)))); $article->set_var('readmore_words', $numwords); $article->set_var('readmore_link', COM_createLink($LANG01[2], $articleUrl, array('class' => 'story-read-more-link')) . ' (' . $numwords . ' ' . $LANG01[62] . ') '); $article->set_var('start_readmore_anchortag', '<a href="' . $articleUrl . '" class="story-read-more-link">'); $article->set_var('end_readmore_anchortag', '</a>'); $article->set_var('read_more_class', 'class="story-read-more-link"'); $article->set_var('readmore_url', $articleUrl); } if ($story->DisplayElements('commentcode') >= 0 and $show_comments) { $commentsUrl = COM_buildUrl($_CONF['site_url'] . '/article.php?story=' . $story->getSid()) . '#comments'; $article->set_var('comments_url', $commentsUrl); $article->set_var('comments_text', COM_numberFormat($story->DisplayElements('comments')) . ' ' . $LANG01[3]); $article->set_var('comments_count', COM_numberFormat($story->DisplayElements('comments'))); $article->set_var('lang_comments', $LANG01[3]); $comments_with_count = sprintf($LANG01[121], COM_numberFormat($story->DisplayElements('comments'))); if ($story->DisplayElements('comments') > 0) { $result = DB_query("SELECT UNIX_TIMESTAMP(date) AS day,username,fullname,{$_TABLES['comments']}.uid as cuid FROM {$_TABLES['comments']},{$_TABLES['users']} WHERE {$_TABLES['users']}.uid = {$_TABLES['comments']}.uid AND sid = '" . DB_escapeString($story->getsid()) . "' ORDER BY date desc LIMIT 1"); $C = DB_fetchArray($result); $recent_post_anchortag = '<span class="storybyline">' . $LANG01[27] . ': ' . strftime($_CONF['daytime'], $C['day']) . ' ' . $LANG01[104] . ' ' . COM_getDisplayName($C['cuid'], $C['username'], $C['fullname']) . '</span>'; $article->set_var('comments_with_count', COM_createLink($comments_with_count, $commentsUrl)); $article->set_var('start_comments_anchortag', '<a href="' . $commentsUrl . '">'); $article->set_var('end_comments_anchortag', '</a>'); } else { $article->set_var('comments_with_count', $comments_with_count); $recent_post_anchortag = COM_createLink($LANG01[60], $_CONF['site_url'] . '/comment.php?sid=' . $story->getsid() . '#comment_entry' . '&pid=0&type=article'); } if ($story->DisplayElements('commentcode') == 0 && ($_CONF['commentsloginrequired'] == 0 || !COM_isAnonUser())) { $postCommentUrl = $_CONF['site_url'] . '/comment.php?sid=' . $story->getSid() . '&pid=0&type=article#comment_entry'; $article->set_var('post_comment_link', COM_createLink($LANG01[60], $postCommentUrl, array('rel' => 'nofollow'))); $article->set_var('lang_post_comment', $LANG01[60]); $article->set_var('start_post_comment_anchortag', '<a href="' . $postCommentUrl . '" rel="nofollow">'); $article->set_var('end_post_comment_anchortag', '</a>'); $article->set_var('post_comment_url', $postCommentUrl); } } if (($_CONF['trackback_enabled'] || $_CONF['pingback_enabled']) && $story->DisplayElements('trackbackcode') >= 0 && $show_comments) { $num_trackbacks = COM_numberFormat($story->DisplayElements('trackbacks')); $trackbacksUrl = COM_buildUrl($_CONF['site_url'] . '/article.php?story=' . $story->getSid()) . '#trackback'; $article->set_var('trackbacks_url', $trackbacksUrl); $article->set_var('trackbacks_text', $num_trackbacks . ' ' . $LANG_TRB['trackbacks']); $article->set_var('trackbacks_count', $num_trackbacks); $article->set_var('lang_trackbacks', $LANG_TRB['trackbacks']); $article->set_var('trackbacks_with_count', COM_createLink(sprintf($LANG01[122], $num_trackbacks), $trackbacksUrl)); if (SEC_hasRights('story.ping')) { $pingurl = $_CONF['site_admin_url'] . '/trackback.php?mode=sendall&id=' . $story->getSid(); $pingico = '<img src="' . $_CONF['layout_url'] . '/images/sendping.' . $_IMAGE_TYPE . '" alt="' . $LANG_TRB['send_trackback'] . '" title="' . $LANG_TRB['send_trackback'] . '" />'; $article->set_var('send_trackback_icon', COM_createLink($pingico, $pingurl)); } if ($story->DisplayElements('trackbacks') > 0) { $article->set_var('trackbacks_with_count', COM_createLink(sprintf($LANG01[122], $num_trackbacks), $trackbacksUrl)); } else { $article->set_var('trackbacks_with_count', sprintf($LANG01[122], $num_trackbacks)); } } if ($_CONF['hideemailicon'] == 1 || COM_isAnonUser() && ($_CONF['loginrequired'] == 1 || $_CONF['emailstoryloginrequired'] == 1)) { $article->set_var('email_icon', ''); } else { $emailUrl = $_CONF['site_url'] . '/profiles.php?sid=' . $story->getSid() . '&what=emailstory'; $emailicon = '<img src="' . $_CONF['layout_url'] . '/images/mail.' . $_IMAGE_TYPE . '" alt="' . $LANG01[64] . '" title="' . $LANG11[2] . '" />'; $article->set_var('email_icon', COM_createLink($emailicon, $emailUrl)); $article->set_var('email_story_url', $emailUrl); $article->set_var('lang_email_story', $LANG11[2]); $article->set_var('lang_email_story_alt', $LANG01[64]); } $printUrl = COM_buildUrl($_CONF['site_url'] . '/article.php?story=' . $story->getSid() . '&mode=print'); if ($_CONF['hideprintericon'] == 1) { $article->set_var('print_icon', ''); } else { $printicon = '<img src="' . $_CONF['layout_url'] . '/images/print.' . $_IMAGE_TYPE . '" alt="' . $LANG01[65] . '" title="' . $LANG11[3] . '" />'; $article->set_var('print_icon', COM_createLink($printicon, $printUrl, array('rel' => 'nofollow'))); $article->set_var('print_story_url', $printUrl); $article->set_var('lang_print_story', $LANG11[3]); $article->set_var('lang_print_story_alt', $LANG01[65]); } $article->set_var('pdf_icon', ''); if ($_CONF['backend'] == 1) { $tid = $story->displayElements('tid'); $alt_tid = $story->displayElements('alternate_tid'); $result = DB_query("SELECT filename, title FROM {$_TABLES['syndication']} WHERE type = 'article' AND topic = '" . DB_escapeString($tid) . "' AND is_enabled = 1"); $feeds = DB_numRows($result); for ($i = 0; $i < $feeds; $i++) { list($filename, $title) = DB_fetchArray($result); $feedUrl = SYND_getFeedUrl($filename); $feedTitle = sprintf($LANG11[6], $title); } if ($feeds > 0) { $feedicon = '<img src="' . $_CONF['layout_url'] . '/images/rss_small.' . $_IMAGE_TYPE . '" alt="' . $feedTitle . '" title="' . $feedTitle . '" />'; $article->set_var('feed_icon', COM_createLink($feedicon, $feedUrl, array("type" => "application/rss+xml"))); $article->set_var('feed_url', $feedUrl); } else { $article->set_var('feed_icon', ''); } } else { $article->set_var('feed_icon', ''); } $article->set_var('story_display', 'index'); $storycounter++; $article->set_var('story_counter', $storycounter); } $article->set_var('article_url', $articleUrl); $article->set_var('recent_post_anchortag', $recent_post_anchortag); $access = $story->checkAccess(); $storyAccess = min($access, SEC_hasTopicAccess($story->DisplayElements('tid'))); if ($index != 'p' and SEC_hasRights('story.edit') and $story->checkAccess() == 3 and SEC_hasTopicAccess($story->DisplayElements('tid')) == 3) { $article->set_var('edit_link', COM_createLink($LANG01[4], $_CONF['site_admin_url'] . '/story.php?edit=x&sid=' . $story->getSid())); $article->set_var('edit_url', $_CONF['site_admin_url'] . '/story.php?edit=x&sid=' . $story->getSid()); $article->set_var('lang_edit_text', $LANG01[4]); $editicon = $_CONF['layout_url'] . '/images/edit.' . $_IMAGE_TYPE; $editiconhtml = '<img src="' . $editicon . '" alt="' . $LANG01[4] . '" title="' . $LANG01[4] . '" />'; $article->set_var('edit_icon', COM_createLink($editiconhtml, $_CONF['site_admin_url'] . '/story.php?edit=x&sid=' . $story->getSid())); $article->set_var('edit_image', $editiconhtml); } $article->set_var('lang_continue_reading', $LANG01['continue_reading']); PLG_templateSetVars($article_filevar, $article); if ($_CONF['rating_enabled'] != 0 && $index != 'p') { if (@in_array($story->getSid(), $ratedIds)) { $static = true; $voted = 1; } else { $static = 0; $voted = 0; } $uid = isset($_USER['uid']) ? $_USER['uid'] : 1; if ($_CONF['rating_enabled'] == 2 && $uid != $story->DisplayElements('owner_id')) { $article->set_var('rating_bar', RATING_ratingBar('article', $story->getSid(), $story->DisplayElements('votes'), $story->DisplayElements('rating'), $voted, 5, $static, 'sm'), false, true); } else { if (!COM_isAnonUser() && $uid != $story->DisplayElements('owner_id')) { $article->set_var('rating_bar', RATING_ratingBar('article', $story->getSid(), $story->DisplayElements('votes'), $story->DisplayElements('rating'), $voted, 5, $static, 'sm'), false, true); } else { $article->set_var('rating_bar', RATING_ratingBar('article', $story->getSid(), $story->DisplayElements('votes'), $story->DisplayElements('rating'), 1, 5, TRUE, 'sm'), false, true); } } } else { $article->set_var('rating_bar', '', false, true); } if ($index != 'p') { $article->create_instance($instance_id, $article_filevar); } } else { PLG_templateSetVars($article_filevar, $article); if ($_CONF['rating_enabled'] != 0) { if (@in_array($story->getSid(), $ratedIds)) { $static = true; $voted = 1; } else { $static = 0; $voted = 0; } $uid = isset($_USER['uid']) ? $_USER['uid'] : 1; if ($_CONF['rating_enabled'] == 2 && $uid != $story->DisplayElements('owner_id')) { $article->set_var('rating_bar', RATING_ratingBar('article', $story->getSid(), $story->DisplayElements('votes'), $story->DisplayElements('rating'), $voted, 5, $static, 'sm'), false, true); } else { if (!COM_isAnonUser() && $uid != $story->DisplayElements('owner_id')) { $article->set_var('rating_bar', RATING_ratingBar('article', $story->getSid(), $story->DisplayElements('votes'), $story->DisplayElements('rating'), $voted, 5, $static, 'sm'), false, true); } else { $article->set_var('rating_bar', RATING_ratingBar('article', $story->getSid(), $story->DisplayElements('votes'), $story->DisplayElements('rating'), $voted, 5, TRUE, 'sm'), false, true); } } } else { $article->set_var('rating_bar', '', false, true); } } $article->parse('finalstory', $article_filevar); return $article->finish($article->get_var('finalstory')); }
function FF_showtopic($showtopic, $mode = '', $onetwo = 1, $page = 1, $topictemplate) { global $_FF_CONF, $_CONF, $_TABLES, $_USER, $LANG_GF01, $LANG_GF02, $_SYSTEM; global $highlight; global $forumfiles; global $canPost; $retval = ''; if (isset($showtopic['date'])) { $dt = new Date($showtopic['date'], $_USER['tzid']); } else { $dt = new Date('now', $_USER['tzid']); } static $cacheUserArray = array(); static $_user_already_voted = array(); $oldPost = 0; if (!class_exists('StringParser')) { require_once $_CONF['path'] . 'lib/bbcode/stringparser_bbcode.class.php'; } if ($mode == 'preview') { $topictemplate->set_var(array('lang_postpreview' => $LANG_GF01['PREVIEW_HEADER'], 'preview' => true)); } $min_height = 50; // Base minimum height of topic - will increase if avatar or sig is used $foundUser = 0; if ($showtopic['uid'] > 1) { if (isset($cacheUserArray[$showtopic['uid']])) { $userarray = $cacheUserArray[$showtopic['uid']]; $username = $userarray['display_name']; $location = $userarray['location']; $posts = $userarray['posts']; $user_level = $userarray['user_level']; $user_levelname = $userarray['user_levelname']; $avatar = $userarray['avatar']; $onlinestatus = $userarray['onlinestatus']; $min_height = $userarray['min_height']; $regdate = $userarray['regdate']; $numposts = $userarray['numposts']; $foundUser = 1; } else { $sql = "SELECT users.*,userprefs.*,userinfo.*,gf_userinfo.rating,gf_userinfo.signature FROM {$_TABLES['users']} users LEFT JOIN {$_TABLES['userprefs']} userprefs ON users.uid=userprefs.uid LEFT JOIN {$_TABLES['userinfo']} userinfo ON users.uid=userinfo.uid LEFT JOIN {$_TABLES['ff_userinfo']} gf_userinfo ON users.uid=gf_userinfo.uid WHERE users.uid=" . (int) $showtopic['uid']; $userQuery = DB_query($sql); if (DB_numRows($userQuery) == 1) { $userarray = DB_fetchArray($userQuery); $username = COM_getDisplayName($showtopic['uid']); $userarray['display_name'] = $username; $postcount = DB_query("SELECT * FROM {$_TABLES['ff_topic']} WHERE uid='" . (int) $showtopic['uid'] . "'"); $posts = DB_numRows($postcount); $userarray['posts'] = $posts; $starimage = '<img src="%s" alt="' . $LANG_GF01['FORUM'] . ' %s" title="' . $LANG_GF01['FORUM'] . ' %s"/>'; if ($posts < $_FF_CONF['level2']) { $user_level = sprintf($starimage, _ff_getImage('rank1', 'ranks'), $_FF_CONF['level1name'], $_FF_CONF['level1name']); $user_levelname = $_FF_CONF['level1name']; } elseif ($posts >= $_FF_CONF['level2'] && $posts < $_FF_CONF['level3']) { $user_level = sprintf($starimage, _ff_getImage('rank2', 'ranks'), $_FF_CONF['level2name'], $_FF_CONF['level2name']); $user_levelname = $_FF_CONF['level2name']; } elseif ($posts >= $_FF_CONF['level3'] && $posts < $_FF_CONF['level4']) { $user_level = sprintf($starimage, _ff_getImage('rank3', 'ranks'), $_FF_CONF['level3name'], $_FF_CONF['level3name']); $user_levelname = $_FF_CONF['level3name']; } elseif ($posts >= $_FF_CONF['level4'] && $posts < $_FF_CONF['level5']) { $user_level = sprintf($starimage, _ff_getImage('rank4', 'ranks'), $_FF_CONF['level4name'], $_FF_CONF['level4name']); $user_levelname = $_FF_CONF['level4name']; } elseif ($posts > $_FF_CONF['level5']) { $user_level = sprintf($starimage, _ff_getImage('rank5', 'ranks'), $_FF_CONF['level5name'], $_FF_CONF['level5name']); $user_levelname = $_FF_CONF['level5name']; } if (forum_modPermission($showtopic['forum'], $showtopic['uid'])) { $user_level = sprintf($starimage, _ff_getImage('rank_mod', 'ranks'), $LANG_GF01['moderator'], $LANG_GF01['moderator']); $user_levelname = $LANG_GF01['moderator']; } if (SEC_inGroup(1, $showtopic['uid'])) { $user_level = sprintf($starimage, _ff_getImage('rank_admin', 'ranks'), $LANG_GF01['admin'], $LANG_GF01['admin']); $user_levelname = $LANG_GF01['admin']; } $userarray['user_level'] = $user_level; $userarray['user_levelname'] = $user_levelname; if ($userarray['photo'] != "") { $avatar = '<img src="' . USER_getPhoto($showtopic['uid'], '', '', '', '0') . '" alt="" title="" class="forum-userphoto" style="width:' . $_FF_CONF['avatar_width'] . 'px;"/>'; $min_height = $min_height + 150; } else { if (!isset($_CONF['default_photo']) || $_CONF['default_photo'] == '') { $img = $_CONF['site_url'] . '/images/userphotos/default.jpg'; } else { $img = $_CONF['default_photo']; } $avatar = '<img src="' . $img . '" alt="" title="" class="forum-userphoto" style="width:' . $_FF_CONF['avatar_width'] . 'px;"/>'; $min_height = $min_height + 150; } if ($_FF_CONF['enable_user_rating_system']) { if ($showtopic['uid'] > 1) { $min_height = $min_height + 10; } } if (SEC_inGroup('Root') && function_exists('plugin_cclabel_nettools') && isset($showtopic['ip'])) { $min_height = $min_height + 5; } $udt = new Date(strtotime($userarray['regdate']), $_USER['tzid']); $regdate = $udt->format($_CONF['shortdate'], true) . '<br/>'; $numposts = $posts; if (DB_count($_TABLES['sessions'], 'uid', (int) $showtopic['uid']) > 0 and DB_getItem($_TABLES['userprefs'], 'showonline', "uid=" . (int) $showtopic['uid'] . "") == 1) { $onlinestatus = $LANG_GF01['ONLINE']; } else { $onlinestatus = $LANG_GF01['OFFLINE']; } $userarray['avatar'] = $avatar; $userarray['onlinestatus'] = $onlinestatus; $userarray['min_height'] = $min_height; $userarray['regdate'] = $regdate; $userarray['numposts'] = $numposts; $location = $userarray['location']; $cacheUserArray[$showtopic['uid']] = $userarray; $foundUser = 1; } } } else { if (!isset($_CONF['default_photo']) || $_CONF['default_photo'] == '') { $img = $_CONF['site_url'] . '/images/userphotos/default.jpg'; } else { $img = $_CONF['default_photo']; } $avatar = '<img src="' . $img . '" alt="" title="" class="forum-userphoto" style="width:' . $_FF_CONF['avatar_width'] . 'px;"/>'; $min_height = $min_height + 150; } if ($foundUser) { $userlink = '<a href="' . $_CONF['site_url'] . '/users.php?mode=profile&uid=' . $showtopic['uid'] . '" '; $userlink .= 'class="authorname ' . $onetwo . '" rel="nofollow"><strong>' . $username . '</strong></a>'; $uservalid = true; if ($userarray['sig'] != '' || $userarray['signature'] != '') { $sig = ''; $sig .= FF_getSignature($userarray['sig'], $userarray['signature'], 'html'); $min_height = $min_height + 30; } } else { $uservalid = false; $userlink = $LANG_GF01['ANON'] . $showtopic['name']; } if ($_FF_CONF['show_moods'] && $showtopic['mood'] != "") { $moodimage = '<img style="vertical-align:middle;" src="' . _ff_getImage($showtopic['mood'], 'moods') . '" title="' . $showtopic['mood'] . '" alt=""/><br/>'; $min_height = $min_height + 30; } $showtopic['comment'] = FF_formatTextBlock($showtopic['comment'], $showtopic['postmode'], $mode, $showtopic['status']); $showtopic['subject'] = @htmlspecialchars(strip_tags($showtopic['subject']), ENT_QUOTES, COM_getEncodingt()); $showtopic['subject'] = COM_truncate($showtopic['subject'], $_FF_CONF['show_subject_length'], '...'); if ($mode != 'preview' && $uservalid && !COM_isAnonUser() && (isset($_USER['uid']) && $_USER['uid'] == $showtopic['uid'])) { /* Check if user can still edit this post - within allowed edit timeframe */ $editAllowed = false; if ($_FF_CONF['allowed_editwindow'] > 0) { $t1 = $showtopic['date']; $t2 = $_FF_CONF['allowed_editwindow']; if (time() - $t2 < $t1) { $editAllowed = true; } } else { $editAllowed = true; } if ($editAllowed) { $editlink = $_CONF['site_url'] . '/forum/createtopic.php?mode=edittopic&forum=' . $showtopic['forum'] . '&id=' . $showtopic['id'] . '&editid=' . $showtopic['id'] . '&page=' . $page; $editlinkimg = '<img src="' . _ff_getImage('edit_button') . '" style="vertical-align:middle;" alt="' . $LANG_GF01['EDITICON'] . '" title="' . $LANG_GF01['EDITICON'] . '"/>'; $topictemplate->set_var(array('editlink' => $editlink, 'editlinkimg' => $editlinkimg, 'LANG_edit' => $LANG_GF01['EDITICON'])); } } else { $topictemplate->set_var(array('editlink' => '', 'editlinkimg' => '', 'LANG_edit' => '')); } if ($highlight != '') { $showtopic['subject'] = str_replace("{$highlight}", "<span class=\"b\">{$highlight}</span>", $showtopic['subject']); $showtopic['comment'] = str_replace("{$highlight}", "<span class=\"b\">{$highlight}</span>", $showtopic['comment']); } if ($showtopic['pid'] == 0) { $replytopicid = $showtopic['id']; $is_lockedtopic = $showtopic['locked']; $views = $showtopic['views']; $topictemplate->set_var('read_msg', sprintf($LANG_GF02['msg49'], $views)); if ($is_lockedtopic) { $topictemplate->set_var('locked_icon', '<img src="' . _ff_getImage('padlock') . '" title="' . $LANG_GF02['msg114'] . '" alt=""/>'); } } else { $is_lockedtopic = $showtopic['locked']; $replytopicid = $showtopic['pid']; $topictemplate->set_var('read_msg', ''); } if ($_FF_CONF['allow_user_dateformat']) { $date = $dt->format($dt->getUserFormat(), true); } else { $date = $dt->format($_FF_CONF['default_Topic_Datetime_format'], true); } $topictemplate->set_var('posted_date', $date); if ($mode != 'preview') { if (!COM_isAnonUser()) { $bmArray = _ff_cacheBookMarks($_USER['uid']); if (isset($bmArray[$showtopic['id']])) { $topictemplate->set_var('bookmark_icon', '<img src="' . _ff_getImage('star_on_sm') . '" title="' . $LANG_GF02['msg204'] . '" alt=""/>'); $topictemplate->set_var('bookmarked', true); } else { $topictemplate->set_var('bookmark_icon', '<img src="' . _ff_getImage('star_off_sm') . '" title="' . $LANG_GF02['msg203'] . '" alt=""/>'); $topictemplate->unset_var('bookmarked'); } } $topictemplate->clear_var(array('quotelink', 'quotelinkimg', 'LANG_quote')); if ($is_lockedtopic == 0) { $is_readonly = $showtopic['is_readonly']; if ($is_readonly == 0 || forum_modPermission($showtopic['forum'], COM_isAnonUser() ? 1 : $_USER['uid'], 'mod_edit')) { if ($canPost != 0) { $quotelink = $_CONF['site_url'] . '/forum/createtopic.php?mode=newreply&forum=' . $showtopic['forum'] . '&id=' . $replytopicid . '&quoteid=' . $showtopic['id']; $quotelinkimg = '<img src="' . _ff_getImage('quote_button') . '" style="vertical-align:middle;" alt="' . $LANG_GF01['QUOTEICON'] . '" title="' . $LANG_GF01['QUOTEICON'] . '"/>'; $topictemplate->set_var(array('quotelink' => $quotelink, 'quotelinkimg' => $quotelinkimg, 'LANG_quote' => $LANG_GF01['QUOTEICON'])); } } } $topictemplate->set_var(array('topic_post_link_begin' => '<a name="' . $showtopic['id'] . '">', 'topic_post_link_end' => '</a>')); $mod_functions = _ff_getmodFunctions($showtopic); $topictemplate->clear_var(array('profilelink', 'profilelinkimg', 'LANG_profile')); $topictemplate->clear_var(array('pmlink', 'pmlinkimg', 'LANG_pm')); if ($showtopic['uid'] > 1 && $uservalid) { $profile_link = $_CONF['site_url'] . '/users.php?mode=profile&uid=' . $showtopic['uid']; $profile_linkimg = '<img src="' . _ff_getImage('profile_button') . '" style="border:none;vertical-align:middle;" alt="' . $LANG_GF01['ProfileLink'] . '" title="' . $LANG_GF01['ProfileLink'] . '"/>'; $topictemplate->set_var(array('profilelink' => $profile_link, 'profilelinkimg' => $profile_linkimg, 'LANG_profile' => $LANG_GF01['ProfileLink'])); if ($_FF_CONF['use_pm_plugin'] && (!COM_isAnonUser() && $_USER['uid'] != $showtopic['uid'])) { $pmplugin_link = forumPLG_getPMlink($showtopic['uid']); if ($pmplugin_link != '') { $pm_link = $pmplugin_link; $pm_linkimg = '<img src="' . _ff_getImage('pm_button') . '" style="vertical-align:middle;" alt="' . $LANG_GF01['PMLink'] . '" title="' . $LANG_GF01['PMLink'] . '"/>'; $topictemplate->set_var(array('pmlink' => $pm_link, 'pmlinkimg' => $pm_linkimg, 'LANG_pm' => $LANG_GF01['PMLink'])); } } } $topictemplate->clear_var(array('emaillink', 'emaillinkimg', 'LANG_email')); if (isset($userarray['email']) && $userarray['email'] != '' && $showtopic["uid"] > 1 && $userarray['emailfromuser'] == 1) { $email_link = $_CONF['site_url'] . '/profiles.php?uid=' . $showtopic['uid']; $email_linkimg = '<img src="' . _ff_getImage('email_button') . '" style="vertical-align:middle;" alt="' . $LANG_GF01['EmailLink'] . '" title="' . $LANG_GF01['EmailLink'] . '"/>'; $topictemplate->set_var(array('emaillink' => $email_link, 'emaillinkimg' => $email_linkimg, 'LANG_email' => $LANG_GF01['EmailLink'])); } $topictemplate->clear_var(array('websitelink', 'websitelinkimg', 'LANG_website')); if (isset($userarray['homepage']) && $userarray['homepage'] != '') { $homepage = trim($userarray['homepage']); if (!preg_match("/http/i", $homepage)) { $homepage = 'http://' . $homepage; } $homepageimg = '<img src="' . _ff_getImage('website_button') . '" style="vertical-align:middle;" alt="' . $LANG_GF01['WebsiteLink'] . '" title="' . $LANG_GF01['WebsiteLink'] . '"/>'; $topictemplate->set_var(array('websitelink' => $homepage, 'websitelinkimg' => $homepageimg, 'LANG_website' => $LANG_GF01['WebsiteLink'])); } $back2 = $LANG_GF01['back2top']; $backlink = '<center><a href="' . $_CONF['site_url'] . '/forum/viewtopic.php?showtopic=' . $replytopicid . '">' . $back2 . '</a></center>'; } else { if (!isset($_GET['onlytopic']) || $_GET['onlytopic'] != 1) { $topictemplate->set_var('preview_topic_subject', $showtopic['subject']); } else { $topictemplate->set_var('preview_topic_subject', ''); } $topictemplate->set_var('read_msg', ''); $topictemplate->set_var('locked_icon', ''); // Check and see if there are no [file] bbcode tags in content and reset the show_inline value // This is needed in case user had used the file bbcode tag and then removed it $imagerecs = ''; if (is_array($forumfiles)) { $imagerecs = implode(',', $forumfiles); } if (!empty($_POST['uniqueid'])) { $uniqueid = COM_applyFilter($_POST['uniqueid'], true); $sql = "UPDATE {$_TABLES['ff_attachments']} SET show_inline = 0 WHERE topic_id=" . (int) $uniqueid . " "; if ($imagerecs != '') { $sql .= "AND id NOT IN ({$imagerecs})"; } DB_query($sql); } else { if (isset($_POST['id'])) { $tid = COM_applyFilter($_POST['id'], true); $sql = "UPDATE {$_TABLES['ff_attachments']} SET show_inline = 0 WHERE topic_id=" . (int) $tid . " "; if ($imagerecs != '') { $sql .= "AND id NOT IN ({$imagerecs})"; } DB_query($sql); } } } $uniqueid = isset($_POST['uniqueid']) ? COM_applyFilter($_POST['uniqueid'], true) : 0; if ($showtopic['id'] > 0 && (!isset($_POST['action']) || $_POST['action'] != 'newreply')) { $topictemplate->set_var('attachments', _ff_showattachments((int) $showtopic['id'])); } elseif ($uniqueid > 0) { $topictemplate->set_var('attachments', _ff_showattachments((int) $uniqueid)); } if (SEC_inGroup('Root') && function_exists('plugin_cclabel_nettools') && isset($showtopic['ip'])) { $iplink = '<a href="' . $_CONF['site_admin_url'] . '/plugins/nettools/whois.php?domain=' . $showtopic['ip'] . '" target="_new">' . $showtopic['ip'] . '</a>'; $topictemplate->set_var('ipaddress', $iplink); } else { $topictemplate->set_var('ipaddress', ''); } $voteHTML = ''; if ($_FF_CONF['enable_user_rating_system']) { if ($showtopic['uid'] > 1) { //not an anonymous poster // grab the poster's current rating... $rating = _ff_getUserRating($showtopic['uid']); if ($rating > 0) { $grade = '+' . $rating; } else { $grade = $rating; } //Find out if user has rights to increase / decrease score if (!COM_isAnonUser() && $_USER['uid'] != $showtopic['uid']) { //Can't vote for yourself & must be logged in if (!isset($_user_already_voted[$showtopic['uid']])) { $_user_already_voted[$showtopic['uid']] = DB_getItem($_TABLES['ff_rating_assoc'], 'grade', "user_id = " . (int) $showtopic['uid'] . ' AND voter_id = ' . (int) $_USER['uid']); } if ($_user_already_voted[$showtopic['uid']] == '') { // user has never voted for this poster $vote_language = $LANG_GF01['grade_user']; $plus_vote = '<a href="#" onclick="ajax_voteuser(' . $_USER['uid'] . ',' . $showtopic['uid'] . ',' . $showtopic['id'] . ',1,1);return false;"><img src="' . $_CONF['site_url'] . '/forum/images/plus.png" alt="plus" /></a>'; $minus_vote = '<a href="#" onclick="ajax_voteuser(' . $_USER['uid'] . ',' . $showtopic['uid'] . ',' . $showtopic['id'] . ',-1,1);return false;"><img src="' . $_CONF['site_url'] . '/forum/images/minus.png" alt="minus" /></a>'; $min_height = $min_height + 10; } else { // user has already voted for this poster $vote_language = $LANG_GF01['retract_grade']; if ($_user_already_voted[$showtopic['uid']] > 0) { // gave a +1 show the minus to retract $plus_vote = ''; $minus_vote = '<a href="#" onclick="ajax_voteuser(' . $_USER['uid'] . ',' . $showtopic['uid'] . ',' . $showtopic['id'] . ',-1,0);return false;"><img src="' . $_CONF['site_url'] . '/forum/images/minus.png" alt="minus" /></a>'; $min_height = $min_height + 10; } else { // gave a -1 show the plus to retract $minus_vote = ''; $plus_vote = '<a href="#" onclick="ajax_voteuser(' . $_USER['uid'] . ',' . $showtopic['uid'] . ',' . $showtopic['id'] . ',1,0);return false;"><img src="' . $_CONF['site_url'] . '/forum/images/plus.png" alt="plus" /></a>'; $min_height = $min_height + 10; } } $voteHTML = '<div class="c' . $showtopic['uid'] . '"><span id="vote' . $showtopic['id'] . '">' . $vote_language . '<br />' . $minus_vote . $plus_vote . '<br />' . $LANG_GF01['grade'] . ': ' . $grade . '</span></div>'; } else { // display 'rating' $voteHTML = $LANG_GF01['grade'] . ': ' . $grade; } } } $topictemplate->set_var(array('user_name' => isset($username) ? $username : '******', 'vote_html' => $voteHTML, 'csscode' => $onetwo, 'postmode' => $showtopic['postmode'], 'userlink' => $userlink, 'lang_forum' => $LANG_GF01['FORUM'], 'user_levelname' => isset($user_levelname) ? $user_levelname : '', 'user_level' => isset($user_level) ? $user_level : '', 'magical_image' => isset($moodimage) ? $moodimage : '', 'avatar' => isset($avatar) ? $avatar : '', 'onlinestatus' => isset($onlinestatus) ? $onlinestatus : '', 'regdate' => isset($regdate) ? $regdate : '', 'numposts' => isset($numposts) ? $numposts : '', 'location' => isset($location) ? wordwrap(COM_truncate($location, 100), 20, '<br />') : '', 'topic_subject' => $showtopic['subject'], 'LANG_ON2' => $LANG_GF01['ON2'], 'mod_functions' => isset($mod_functions) ? $mod_functions : '', 'topic_comment' => $showtopic['comment'], 'subject' => $showtopic['subject'], 'comment_minheight' => "min-height:{$min_height}px", 'forumid' => $showtopic['forum'], 'topic_id' => $showtopic['id'], 'parent_id' => $replytopicid, 'back_link' => isset($backlink) ? $backlink : '', 'member_badge' => forumPLG_getMemberBadge($showtopic['uid']))); if ($replytopicid != 0) { $topictemplate->set_var('prefix', $LANG_GF01['RE']); } else { $topictemplate->set_var('prefix', ''); } if (isset($sig) && trim($sig) != '') { $topictemplate->set_var('sig', PLG_replaceTags($sig, 'forum', 'signature')); } else { $topictemplate->set_var('sig', ''); } }