|
From: Justin H. <jus...@us...> - 2005-10-14 20:37:43
|
Update of /cvsroot/mxbb/mx_who_am_i/includes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12498/mx_who_am_i/includes Added Files: mx_common.php Log Message: New module: mx_who_am_i Quick profile view for users logged in with REG access rights. --- NEW FILE: mx_common.php --- <?php /********************************************************************************\ | | subject : mx-portal, CMS & portal, module | name : Who Am I | begin : october, 2005 | copyright : (C) 2002-2005 MX-System | author : horace & retorq (see below) | email : ho...@em... | mxBB project site : www.mx-system.com | | credit : This module is based on the mx_loggedin function | created by RETORQ. | re...@di... | www.digitalhijinx.com | | description : The "Who Am I" block is a block is a block that | will be visable only to registered users who are | logged in. It can be used to quickly display | statistics and current user image. |********************************************************************************| | | $Id: mx_common.php,v 1.1 2005/10/14 20:37:32 justinheasman Exp $ | \********************************************************************************/ /********************************************************************************\ | | This program is free software; you can redistribute it and/or modify | it under the terms of the GNU General Public License as published by | the Free Software Foundation; either version 2 of the License, or | (at your option) any later version. | \********************************************************************************/ /********************************************************************************\ | Security Section (Self Explainatory) \********************************************************************************/ if (!defined('IN_PORTAL')) { die("Hacking attempt"); } /********************************************************************************\ | Class Declaration Section (Classes) \********************************************************************************/ class mx_who_am_i { var $regdate; var $memberdays; var $posts_per_day; var $percentage; var $total_posts; var $avatar_img; var $no_avatar_img; /********************************************************************************\ | The main Who Am I Constructor (Used to initialise variables) \********************************************************************************/ function mx_who_am_i() { global $phpEx; global $mx_root_path; global $userdata; $this->regdate = $userdata['user_regdate']; $this->memberdays = max(1, round((time() - $this->regdate) / 86400)); $this->posts_per_day = round($userdata['user_posts'] / $this->memberdays, 2); $this->percentage = 0; $this->total_posts = 0; $this->avatar_img = ''; $this->no_avatar_img = 'noavatar.png'; } /********************************************************************************\ | The Get_Details function oes exactly what it says - it gets and poulates | the class variables. \********************************************************************************/ function get_details() { global $userdata; global $board_config; global $module_root_path; global $theme; global $lang; if ($userdata['user_posts'] != 0) { $this->total_posts = get_db_stat('postcount'); $this->percentage = round(($this->total_posts) ? min(100, ($userdata['user_posts'] / $this->total_posts) * 100) : 0, 2); } else { $this->percentage = 0; } if ($userdata['user_avatar_type'] && $userdata['user_allowavatar']) { switch($userdata['user_avatar_type']) { case USER_AVATAR_UPLOAD: $this->avatar_img = '<img src=' . '"' . PHPBB_URL . $board_config['avatar_path'] . '/' . $userdata['user_avatar'] . '" alt="" border="0">'; break; case USER_AVATAR_REMOTE: $this->avatar_img = '<img src=' . '"' . $userdata['user_avatar'] . '" alt="" border="0">'; break; case USER_AVATAR_GALLERY: $this->avatar_img = '<img src=' . '"' . PHPBB_URL . $board_config['avatar_gallery_path'] . '/' . $userdata['user_avatar'] . '" alt="" border="0">'; break; } } if (empty($this->avatar_img)) { if (file_exists($module_root_path . 'templates/' . $theme['template_name'] . '/' . 'images/' . $this->no_avatar_img)) { $this->avatar_img = '<img src=' . '"' . $module_root_path . 'templates/' . $theme['template_name'] . '/' . 'images/' . $this->no_avatar_img . '" alt="" border="0">'; } else { $this->avatar_img = $lang['Missing_default_image']; } } } /********************************************************************************\ | Get language for the HTML Output (All Language Related) \********************************************************************************/ function get_language() { global $phpEx; global $module_root_path; global $lang; if (!file_exists($module_root_path . 'language/lang_' . $board_config['default_lang'] . '/lang_main.' . $phpEx)) { include($module_root_path . 'language/lang_english/lang_main.' . $phpEx); } else { include($module_root_path . 'language/lang_' . $board_config['default_lang'] . '/lang_main.' . $phpEx); } } /********************************************************************************\ | HTML Output Section - Using Templates (All Output Related) \********************************************************************************/ function html_output() { global $phpEx; global $userdata; global $board_config; global $template; global $lang; $template->set_filenames(array( 'body_who_am_i' => 'mx_who_am_i.tpl') ); $template->assign_vars(array( 'LANG_PROFILE_NAME' => $lang['Profile_Name'], 'LANG_DATE_JOINED' => $lang['Date_Joined'], 'LANG_POST_TOTAL' => $lang['Post_Total'], 'LANG_POST_STATS' => $lang['Post_Stats'], 'LANG_CHANGE_PROFILE' => $lang['Change_Profile'], 'LANG_OF_TOTAL_POSTS' => $lang['Of_Total_Posts'], 'LANG_POSTS_PER_DAY' => $lang['Posts_Per_Day'], 'USERNAME' => $userdata['username'], 'AVATAR_IMG' => '<a href="' . PHPBB_URL . 'profile.php?mode=viewprofile&u=' . $userdata['user_id'] . '">' . $this->avatar_img . '</a>', 'U_PROFILE' => append_sid(PHPBB_URL . 'profile.' . $phpEx . '?mode=editprofile'), 'JOINED' => create_date($lang['DATE_FORMAT'], $userdata['user_regdate'], $board_config['board_timezone']), 'POSTS' => $userdata['user_posts'], 'POST_PER_DAY' => $this->posts_per_day, 'POST_PERCENTAGE' => $this->percentage) ); $template->pparse('body_who_am_i'); } /********************************************************************************\ | HTML Output Section - Using Templates (All Output Related) \********************************************************************************/ function show_block() { $this->get_language(); $this->get_details(); $this->html_output(); } } /********************************************************************************\ | Main Body Section (Main Stuff) \********************************************************************************/ $who_am_i = new mx_who_am_i; /********************************************************************************\ | End Of Function (Self Explainatory) \********************************************************************************/ ?> |