Source for file userpage.php

Documentation is available at userpage.php

  1. <?php //-*-php-*-
  2. /* ******************************************************************** **
  3. ** Copyright notice **
  4. ** **
  5. ** (c) 1995-2003 PHPOpenChat Development Team **
  6. ** http://phpopenchat.sourceforge.net/ **
  7. ** **
  8. ** All rights reserved **
  9. ** **
  10. ** This script is part of the PHPOpenChat project. The PHPOpenChat **
  11. ** project is free software; you can redistribute it and/or modify **
  12. ** it under the terms of the GNU General Public License as published by **
  13. ** the Free Software Foundation; either version 2 of the License, or **
  14. ** (at your option) any later version. **
  15. ** **
  16. ** The GNU General Public License can be found at **
  17. ** http://www.gnu.org/copyleft/gpl.html. **
  18. ** A copy is found in the textfile GPL and important notices to the **
  19. ** license from the team is found in the textfile LICENSE distributed **
  20. ** with these scripts. **
  21. ** **
  22. ** This script is distributed in the hope that it will be useful, **
  23. ** but WITHOUT ANY WARRANTY; without even the implied warranty of **
  24. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the **
  25. ** GNU General Public License for more details. **
  26. ** **
  27. ** This copyright notice MUST APPEAR in all copies of the script! **
  28. ** ******************************************************************** */
  29.  
  30. /*
  31. $Author: letreo $
  32. $Date: 2003/09/11 15:37:38 $
  33. $Source: /cvsroot/phpopenchat/chat3/userpage.php,v $
  34. $Revision: 1.26 $
  35. */
  36.  
  37. //Get default values
  38. require_once('config.inc.php');
  39.  
  40. require_once(POC_INCLUDE_PATH.'/adodb/adodb.inc.php');
  41. require_once(POC_INCLUDE_PATH.'/class.Chat.inc');
  42. require_once(POC_INCLUDE_PATH.'/class.Chatter.inc');
  43. require_once(POC_INCLUDE_PATH.'/class.Guestbook.inc');
  44. require_once(POC_INCLUDE_PATH.'/class.Guestbook_Post.inc');
  45. require_once(POC_INCLUDE_PATH.'/class.Translator.inc');
  46. require_once(POC_INCLUDE_PATH.'/class.Template.inc');
  47.  
  48. session_start();
  49.  
  50. /*check if chatter is authorized to get this page
  51. if( !isset($_SESSION['chatter']) )
  52. die('Login first!');*/
  53. if( !isset($_SESSION['chat']) )
  54. {
  55. header('Status: 302');
  56. header('Location: index.php');
  57. exit;
  58. }
  59. if ( !isset($_SESSION['template']) )
  60. {
  61. $template = &new Template();
  62. $_SESSION['template'] = $template;
  63. }
  64.  
  65. if(!isset($_GET['rand'])) {
  66. header('Content-type: text/html; charset='.$_SESSION['translator']->out('CHARACTER_ENCODING'));
  67. $_SESSION['template']->get_cached_content( 60*10 );//get cached content with a max age of 10 minutes
  68. }
  69. $_SESSION['reload_count'] = 0;//reset chat session expiration time
  70.  
  71. if( isset($_GET['nick']) )
  72. $_POST['nick'] = $_GET['nick'];
  73.  
  74. if( !isset($_POST['nick']) )
  75. die('No nickname given!');
  76.  
  77. $nickname = $_POST['nick'];
  78. $_chatter = &new Chatter(STATUS_BOT_NAME);
  79. $_chatter->set_nick($nickname);
  80. $_chatter->init_additional_profile_data();
  81. //if( isset($_SESSION['chatter']) && $nickname != $_SESSION['chatter']->get_nick() )
  82. $_chatter->count_hit('userpage');
  83. $homePageURL = $_chatter->get_homePageURL();
  84. $TEMPLATE_OUT['age'] = $_chatter->get_age();
  85. $gender = $_chatter->get_gender();
  86. $TEMPLATE_OUT['user_interests'] = $_chatter->get_interests();
  87. $TEMPLATE_OUT['user_motto'] = $_chatter->get_motto();
  88. $TEMPLATE_OUT['hit_count'] = $_chatter->get_hit_count('userpage');
  89. $TEMPLATE_OUT['lastActive'] = $_chatter->get_lastActive();
  90. $line_count = $_chatter->get_hit_count('line');
  91. $login_count = $_chatter->get_hit_count('login');
  92.  
  93. if( $gender != '' )
  94. $gender = ($gender=='f')? $_SESSION['translator']->out('FEMALE'):$_SESSION['translator']->out('MALE');
  95.  
  96. $TEMPLATE_OUT['gender'] = $gender;
  97. $email = $_chatter->get_email();
  98. if( $email == '' ) $email = ADMIN_MAIL_ADDRESS;//in case of user page of system bot
  99. $TEMPLATE_OUT['registrationTime'] = $_chatter->get_regTime();
  100.  
  101. $TEMPLATE_OUT['lines_per_day'] = '';
  102. $TEMPLATE_OUT['logins_per_day'] = '';
  103. //days since registration
  104. if( preg_match('/[^0-9]*([0-9]+)-([0-9]+)-([0-9]+)[^0-9]*/', $TEMPLATE_OUT['registrationTime'], $parts) )
  105. {
  106. $nowdate = mktime(0,0,0,date('m'),date('d'),date('Y'));
  107. $regdate = mktime(0,0,0,$parts[2],$parts[3],$parts[1]);
  108. // calculate the age in days
  109. $days_registered = intval(($nowdate-$regdate)/(60*60*24));
  110. if($days_registered>0)
  111. {
  112. $TEMPLATE_OUT['lines_per_day'] = round(($line_count / $days_registered),4);
  113. $TEMPLATE_OUT['logins_per_day'] = round(($login_count / $days_registered),4);
  114. }
  115. }
  116. $icqNumber = $_chatter->get_icqNumber();
  117. $aimNickname = $_chatter->get_aimNickname();
  118. $yimNickname = $_chatter->get_yimNickname();
  119. $friends = array();
  120. $friends = $_chatter->get_friends();
  121. $TEMPLATE_OUT['friends_list'] = '';
  122. if( count($friends) > 0 )
  123. {
  124. reset($friends);
  125. do {
  126. $TEMPLATE_OUT['friends_list'] .= current($friends).', ';
  127. }while( next($friends) );
  128. $TEMPLATE_OUT['friends_list'] = preg_replace('/, $/', '', $TEMPLATE_OUT['friends_list']);
  129. }
  130.  
  131. if( ALLOW_PRIVATE_IMAGES ) {
  132. $user_pic = Template::get_image_tag('/chatter');
  133. } else {
  134. $pictureURL = $_chatter->get_pictureURL();
  135. $user_pic='';
  136. if( $pictureURL != '' )
  137. $user_pic='<img src="'.$pictureURL.'" width="" height="" alt="" />';
  138. unset($pictureURL);
  139. }
  140. $icon_path = $_SESSION['template']->get_theme_path() . '/images/icons/';
  141. if( $_chatter->is_online() || $nickname == STATUS_BOT_NAME)
  142. $TEMPLATE_OUT['onlineStatusImg'] = '<img title="Status" src="'.$icon_path.'chatter_online.gif" alt="online status" align="middle" />';
  143. else
  144. $TEMPLATE_OUT['onlineStatusImg'] = '<img title="Status" src="'.$icon_path.'chatter_offline.gif" alt="offline status" align="middle" />';
  145.  
  146. $TEMPLATE_OUT['icq'] = '';
  147. if( intval($icqNumber) >= 1000 )
  148. $TEMPLATE_OUT['icq'] = '<a title="'.$_SESSION['translator']->out('ICQ_NUMBER').': '.$icqNumber.'" href="http://wwp.mirabilis.com/'.$icqNumber.'" target="_blank" style="text-decoration: none">
  149. <img hspace="2" src="http://wwp.icq.com/scripts/online.dll?icq='.$icqNumber.'&amp;img=5" align="middle" alt="online status for '.$nickname.'" height="18" width="18" border="0" />
  150. </a>';
  151.  
  152. $TEMPLATE_OUT['aim'] = '';
  153. if( $aimNickname != '' )
  154. $TEMPLATE_OUT['aim'] = '<img title="'.$_SESSION['translator']->out('AIM_NICKNAME').': '.$aimNickname.'" src="'.$icon_path.'aim.gif" alt="'.$aimNickname.'" align="middle" />&nbsp;&nbsp;';
  155.  
  156. $TEMPLATE_OUT['yahoo'] = '';
  157. if( $yimNickname != '' )
  158. $TEMPLATE_OUT['yahoo'] = '<img title="'.$_SESSION['translator']->out('YIM_NICKNAME').': '.$yimNickname.'" src="'.$icon_path.'yahoo.gif" alt="'.$yimNickname.'" align="middle" />';
  159. $TEMPLATE_OUT['homePageLink'] = '';
  160. if( $homePageURL != '' )
  161. $TEMPLATE_OUT['homePageLink'] = '<a class="imageLink" title="'.$homePageURL.'" href="jump.php?url='.$homePageURL.'" style="background: none" target="_blank"><img src="'.$icon_path.'home.gif" alt="'.$homePageURL.'" align="middle" border="0" /></a>';
  162.  
  163. $TEMPLATE_OUT['emailLink'] = '';
  164. if(!$_chatter->get_hide('email'))
  165. $TEMPLATE_OUT['emailLink'] = '<a class="imageLink" title="'.$email.'" href="mailto:'.$email.'" style="background:none"><img src="'.$icon_path.'email.gif" alt="'.$email.'" align="middle" border="0" /></a>&nbsp;&nbsp;';
  166.  
  167. $TEMPLATE_OUT['grade'] = ($_chatter->get_grade()!='')? $_SESSION['translator']->out($_chatter->get_grade()):'';
  168. $TEMPLATE_OUT['user_pic'] = $user_pic;
  169.  
  170. $TEMPLATE_OUT['misc'] = '';
  171. $TEMPLATE_OUT['misc'] = array();
  172. $TEMPLATE_OUT['misc'] = $_chatter->get_profile_misc();
  173.  
  174. /*
  175. * Guestbook stuff
  176. *
  177. */
  178. function gender_icon ($gender)
  179. {
  180. return(file_exists($_SESSION['template']->get_tmpl_sys_path().'/images/icons/'.$gender.'.gif'))?
  181. '<img src="'.$_SESSION['template']->get_tmpl_web_path().'/images/icons/'.$gender.'.gif" width="8" height="8" alt="'.$_SESSION['translator']->out('GENDER').'" />':'';
  182. }
  183.  
  184. function grade_icon (&$sender)
  185. {
  186. if($sender->is_group_member('operator',$_SESSION['channel']->get_name()))
  187. return '<img src="'.$_SESSION['template']->get_tmpl_web_path().'/images/icons/grade_operator.gif" title="'.$_SESSION['translator']->out('OPERATOR').'" alt="'.$_SESSION['translator']->out('OPERATOR').'" align="middle" />';
  188. $grade=strtolower($sender->get_grade());
  189. return(file_exists($_SESSION['template']->get_tmpl_sys_path().'/images/icons/'.$grade.'.gif'))?
  190. '<img src="'.$_SESSION['template']->get_tmpl_web_path().'/images/icons/'.$grade.'.gif" alt="'.$_SESSION['translator']->out('GRADE').'" />':'';
  191. }
  192.  
  193. function bday_icon()
  194. {
  195. return '<img src="'.$_SESSION['template']->get_tmpl_web_path().'/images/icons/smileys/birthday.gif" align="middle" />';
  196. }
  197.  
  198. $TEMPLATE_OUT['guestbook_posts'] = array();
  199. $guestbook = &new Guestbook( $_chatter );
  200. if( isset($_GET['delete_post']) )
  201. $guestbook->del_post( $_GET['sender'],$_GET['time'] );
  202.  
  203. $posts = $guestbook->get_posts();
  204. $c=0;
  205. foreach ( $posts as $post )
  206. {
  207. $current = unserialize( $post['POST'] );
  208. if( !is_object($current) ) continue;
  209. $sender = $current->get_sender();
  210. $TEMPLATE_OUT['guestbook_posts'][$c]['gender_icon'] = gender_icon($sender->get_gender());
  211. $TEMPLATE_OUT['guestbook_posts'][$c]['sender'] = $sender->get_nick();
  212. $TEMPLATE_OUT['guestbook_posts'][$c]['time'] = $current->get_time();
  213. $TEMPLATE_OUT['guestbook_posts'][$c]['birthday_icon'] = ($sender->has_birthday())? bday_icon():'';
  214. $TEMPLATE_OUT['guestbook_posts'][$c]['grade'] = grade_icon($sender);
  215. $TEMPLATE_OUT['guestbook_posts'][$c]['db_time'] = $current->get_db_time();
  216. $TEMPLATE_OUT['guestbook_posts'][$c]['content'] = $current->get_said();
  217. if( isset($_SESSION['chatter']) && $_SESSION['chatter']->is_online()
  218. && $_chatter->get_nick() == $_SESSION['chatter']->get_nick())
  219. $TEMPLATE_OUT['guestbook_posts'][$c]['delete'] = '<a class="imageLink" title="'.$_SESSION['translator']->out('DELETE').'" href="userpage.php?nick='.urlencode($_POST['nick']).'&amp;delete_post=1&amp;time='.$current->get_db_time().'&amp;sender='.urlencode($sender->get_nick()).'&amp;rand='.rand(0,99).'&amp;'.$_SESSION['session_get'].'#gb"><img src="'.$icon_path.'/trash.gif" alt="" border="0" align="middle" /></a>';
  220. else
  221. $TEMPLATE_OUT['guestbook_posts'][$c]['delete'] = '';
  222. $c++;
  223. }
  224. unset($_chatter);
  225. $_SESSION['template']->get_template();
  226. ?>

Documentation generated on Tue, 29 Jun 2004 14:42:48 +0200 by phpDocumentor 1.3.0RC3