[ Index ]

PHP Cross Reference of MyBB

title

Body

[close]

/inc/ -> functions_online.php (source)

   1  <?php
   2  /**
   3   * MyBB 1.6
   4   * Copyright 2010 MyBB Group, All Rights Reserved
   5   *
   6   * Website: http://mybb.com
   7   * License: http://mybb.com/about/license
   8   *
   9   * $Id$
  10   */
  11  
  12  $uid_list = $aid_list = $pid_list = $tid_list = $fid_list = $ann_list = $eid_list = array();
  13  
  14  /**
  15   * Fetch a users activity and any corresponding details from their location.
  16   *
  17   * @param string The location (URL) of the user.
  18   * @return array Array of location and activity information
  19   */
  20  function fetch_wol_activity($location, $nopermission=false)
  21  {
  22      global $uid_list, $aid_list, $pid_list, $tid_list, $fid_list, $ann_list, $eid_list, $plugins, $user, $parameters;
  23  
  24      $user_activity = array();
  25  
  26      $split_loc = explode(".php", $location);
  27      if($split_loc[0] == $user['location'])
  28      {
  29          $filename = '';
  30      }
  31      else
  32      {
  33          $filename = my_substr($split_loc[0], -my_strpos(strrev($split_loc[0]), "/"));
  34      }
  35      if($split_loc[1])
  36      {
  37          $temp = explode("&amp;", my_substr($split_loc[1], 1));
  38          foreach($temp as $param)
  39          {
  40              $temp2 = explode("=", $param, 2);
  41              $parameters[$temp2[0]] = $temp2[1];
  42          }
  43      }
  44      
  45      if($nopermission)
  46      {
  47          $filename = "nopermission";
  48      }
  49  
  50  
  51      switch($filename)
  52      {
  53          case "announcements":
  54              if(is_numeric($parameters['aid']))
  55              {
  56                  $ann_list[] = $parameters['aid'];
  57              }
  58              $user_activity['activity'] = "announcements";
  59              $user_activity['ann'] = $parameters['aid'];
  60              break;
  61          case "attachment":
  62              if(is_numeric($parameters['aid']))
  63              {
  64                  $aid_list[] = $parameters['aid'];
  65              }
  66              $user_activity['activity'] = "attachment";
  67              $user_activity['aid'] = $parameters['aid'];
  68              break;
  69          case "calendar":
  70              if($parameters['action'] == "event")
  71              {
  72                  if(is_numeric($parameters['eid']))
  73                  {
  74                      $eid_list[] = $parameters['eid'];
  75                  }
  76                  $user_activity['activity'] = "calendar_event";
  77                  $user_activity['eid'] = $parameters['eid'];
  78              }
  79              elseif($parameters['action'] == "addevent" || $parameters['action'] == "do_addevent")
  80              {
  81                  $user_activity['activity'] = "calendar_addevent";
  82              }
  83              elseif($parameters['action'] == "editevent" || $parameters['action'] == "do_editevent")
  84              {
  85                  $user_activity['activity'] = "calendar_editevent";
  86              }
  87              else
  88              {
  89                  $user_activity['activity'] = "calendar";
  90              }
  91              break;
  92          case "editpost":
  93              $user_activity['activity'] = "editpost";
  94              break;
  95          case "forumdisplay":
  96              if(is_numeric($parameters['fid']))
  97              {
  98                  $fid_list[] = $parameters['fid'];
  99              }
 100              $user_activity['activity'] = "forumdisplay";
 101              $user_activity['fid'] = $parameters['fid'];
 102              break;
 103          case "index":
 104          case '':
 105              $user_activity['activity'] = "index";
 106              break;
 107          case "managegroup":
 108              $user_activity['activity'] = "managegroup";
 109              break;
 110          case "member":
 111              if($parameters['action'] == "activate")
 112              {
 113                  $user_activity['activity'] = "member_activate";
 114              }
 115              elseif($parameters['action'] == "register" || $parameters['action'] == "do_register")
 116              {
 117                  $user_activity['activity'] = "member_register";
 118              }
 119              elseif($parameters['action'] == "login" || $parameters['action'] == "do_login")
 120              {
 121                  $user_activity['activity'] = "member_login";
 122              }
 123              elseif($parameters['action'] == "logout")
 124              {
 125                  $user_activity['activity'] = "member_logout";
 126              }
 127              elseif($parameters['action'] == "profile")
 128              {
 129                  $user_activity['activity'] = "member_profile";
 130                  if(is_numeric($parameters['uid']))
 131                  {
 132                      $uid_list[] = $parameters['uid'];
 133                  }
 134                  $user_activity['uid'] = $parameters['uid'];
 135              }
 136              elseif($parameters['action'] == "emailuser" || $parameters['action'] == "do_emailuser")
 137              {
 138                  $user_activity['activity'] = "member_emailuser";
 139              }
 140              elseif($parameters['action'] == "rate" || $parameters['action'] == "do_rate")
 141              {
 142                  $user_activity['activity'] = "member_rate";
 143              }
 144              elseif($parameters['action'] == "resendactivation" || $parameters['action'] == "do_resendactivation")
 145              {
 146                  $user_activity['activity'] = "member_resendactivation";
 147              }
 148              elseif($parameters['action'] == "lostpw" || $parameters['action'] == "do_lostpw" || $parameters['action'] == "resetpassword")
 149              {
 150                  $user_activity['activity'] = "member_lostpw";
 151              }
 152              else
 153              {
 154                  $user_activity['activity'] = "member";
 155              }
 156              break;
 157          case "memberlist":
 158              $user_activity['activity'] = "memberlist";
 159              break;
 160          case "misc":
 161              $accepted_parameters = array("markread", "help", "buddypopup", "smilies", "syndication", "imcenter", "dstswitch");
 162              if($parameters['action'] == "whoposted")
 163              {
 164                  if(is_numeric($parameters['tid']))
 165                  {
 166                      $tid_list[] = $parameters['tid'];
 167                  }
 168                  $user_activity['activity'] = "misc_whoposted";
 169                  $user_activity['tid'] = $parameters['tid'];
 170              }            
 171              elseif(in_array($parameters['action'], $accepted_parameters))
 172              {
 173                  $user_activity['activity'] = "misc_".$parameters['action'];
 174              }
 175              else
 176              {
 177                  $user_activity['activity'] = "misc";
 178              }
 179              break;
 180          case "modcp":
 181              $accepted_parameters = array("modlogs", "announcements", "finduser", "warninglogs", "ipsearch");
 182              
 183              foreach($accepted_parameters as $action)
 184              {
 185                  if($parameters['action'] == $action)
 186                  {
 187                      $user_activity['activity'] = "modcp_".$action;
 188                      break;
 189                  }
 190              }
 191              
 192              $accepted_parameters = array();
 193              $accepted_parameters['report'] = array("do_reports", "reports", "allreports");            
 194              $accepted_parameters['new_announcement'] = array("do_new_announcement", "new_announcement");
 195              $accepted_parameters['delete_announcement'] = array("do_delete_announcement", "delete_announcement");
 196              $accepted_parameters['edit_announcement'] = array("do_edit_announcement", "edit_announcement");
 197              $accepted_parameters['mod_queue'] = array("do_modqueue", "modqueue");
 198              $accepted_parameters['editprofile'] = array("do_editprofile", "editprofile");
 199              $accepted_parameters['banning'] = array("do_banuser", "banning", "liftban", "banuser");
 200              
 201              foreach($accepted_parameters as $name => $actions)
 202              {
 203                  if(in_array($parameters['action'], $actions))
 204                  {                    
 205                      $user_activity['activity'] = "modcp_".$name;
 206                      break;
 207                  }
 208              }
 209              
 210              if(!$user_activity['activity'])
 211              {
 212                  $user_activity['activity'] = "modcp";
 213              }
 214              break;
 215          case "moderation":
 216              $user_activity['activity'] = "moderation";
 217              break;
 218          case "newreply":
 219              if(is_numeric($parameters['pid']))
 220              {
 221                  $pid_list[] = $parameters['pid'];
 222                  $user_activity['activity'] = "newreply";
 223                  $user_activity['pid'] = $parameters['pid'];
 224              }
 225              else
 226              {
 227                  if(is_numeric($parameters['tid']))
 228                  {
 229                      $tid_list[] = $parameters['tid'];
 230                  }
 231                  $user_activity['activity'] = "newreply";
 232                  $user_activity['tid'] = $parameters['tid'];
 233              }
 234              break;
 235          case "newthread":
 236              if(is_numeric($parameters['fid']))
 237              {
 238                  $fid_list[] = $parameters['fid'];
 239              }
 240              $user_activity['activity'] = "newthread";
 241              $user_activity['fid'] = $parameters['fid'];
 242              break;
 243          case "online":
 244              if($parameters['action'] == "today")
 245              {
 246                  $user_activity['activity'] = "woltoday";
 247              }
 248              else
 249              {
 250                  $user_activity['activity'] = "wol";
 251              }
 252              break;
 253          case "polls":
 254              // Make the "do" parts the same as the other one.
 255              if($parameters['action'] == "do_newpoll")
 256              {
 257                  $user_activity['activity'] = "newpoll";
 258              }
 259              elseif($parameters['action'] == "do_editpoll")
 260              {
 261                  $user_activity['activity'] = "editpoll";
 262              }
 263              else
 264              {
 265                  $accepted_parameters = array("do_editpoll", "editpoll", "newpoll", "do_newpoll", "showresults", "vote");
 266              
 267                  foreach($accepted_parameters as $action)
 268                  {
 269                      if($parameters['action'] == $action)
 270                      {
 271                          $user_activity['activity'] = $action;
 272                          break;
 273                      }
 274                  }
 275                  
 276                  if(!$user_activity['activity'])
 277                  {
 278                      $user_activity['activity'] = "showresults";
 279                  }
 280              }
 281              break;
 282          case "printthread":
 283              if(is_numeric($parameters['tid']))
 284              {
 285                  $tid_list[] = $parameters['tid'];
 286              }
 287              $user_activity['activity'] = "printthread";
 288              $user_activity['tid'] = $parameters['tid'];
 289              break;
 290          case "private":
 291              if($parameters['action'] == "send" || $parameters['action'] == "do_send")
 292              {
 293                  $user_activity['activity'] = "private_send";
 294              }
 295              elseif($parameters['action'] == "read")
 296              {
 297                  $user_activity['activity'] = "private_read";
 298              }
 299              elseif($parameters['action'] == "folders" || $parameters['action'] == "do_folders")
 300              {
 301                  $user_activity['activity'] = "private_folders";
 302              }
 303              else
 304              {
 305                  $user_activity['activity'] = "private";
 306              }
 307              break;
 308          case "ratethread":
 309              $user_activity['activity'] = "ratethread";
 310              break;
 311          case "report":
 312              $user_activity['activity'] = "report";
 313              break;
 314          case "reputation":
 315              if(is_numeric($parameters['uid']))
 316              {
 317                  $uid_list[] = $parameters['uid'];
 318                  $user_activity['uid'] = $parameters['uid'];
 319              }
 320  
 321              if($parameters['action'] == "add")
 322              {
 323                  $user_activity['activity'] = "reputation";
 324              }
 325              else
 326              {
 327                  $user_activity['activity'] = "reputation_report";
 328              }
 329              break;
 330          case "search":
 331              $user_activity['activity'] = "search";
 332              break;
 333          case "sendthread":
 334              if(is_numeric($parameters['tid']))
 335              {
 336                  $tid_list[] = $parameters['tid'];
 337              }
 338              $user_activity['activity'] = "sendthread";
 339              $user_activity['tid'] = $parameters['tid'];
 340          break;
 341          case "showteam":
 342              $user_activity['activity'] = "showteam";
 343              break;
 344          case "showthread":
 345              if(is_numeric($parameters['pid']) && $parameters['action'] == "showpost")
 346              {
 347                  $pid_list[] = $parameters['pid'];
 348                  $user_activity['activity'] = "showpost";
 349                  $user_activity['pid'] = $parameters['pid'];
 350              }
 351              else
 352              {
 353                  if($parameters['page'])
 354                  {
 355                      $user_activity['page'] = $parameters['page'];
 356                  }
 357                  if(is_numeric($parameters['tid']))
 358                  {
 359                      $tid_list[] = $parameters['tid'];
 360                  }
 361                  $user_activity['activity'] = "showthread";
 362                  $user_activity['tid'] = $parameters['tid'];
 363              }
 364              break;
 365          case "stats":
 366              $user_activity['activity'] = "stats";
 367              break;
 368          case "usercp":
 369              if($parameters['action'] == "profile" || $parameters['action'] == "do_profile")
 370              {
 371                  $user_activity['activity'] = "usercp_profile";
 372              }
 373              elseif($parameters['action'] == "options" || $parameters['action'] == "do_options")
 374              {
 375                  $user_activity['activity'] = "usercp_options";
 376              }
 377              elseif($parameters['action'] == "password" || $parameters['action'] == "do_password")
 378              {
 379                  $user_activity['activity'] = "usercp_password";
 380              }
 381              elseif($parameters['action'] == "editsig" || $parameters['action'] == "do_editsig")
 382              {
 383                  $user_activity['activity'] = "usercp_editsig";
 384              }
 385              elseif($parameters['action'] == "avatar" || $parameters['action'] == "do_avatar")
 386              {
 387                  $user_activity['activity'] = "usercp_avatar";
 388              }
 389              elseif($parameters['action'] == "editlists" || $parameters['action'] == "do_editlists")
 390              {
 391                  $user_activity['activity'] = "usercp_editlists";
 392              }
 393              elseif($parameters['action'] == "favorites")
 394              {
 395                  $user_activity['activity'] = "usercp_favorites";
 396              }
 397              elseif($parameters['action'] == "subscriptions")
 398              {
 399                  $user_activity['activity'] = "usercp_subscriptions";
 400              }
 401              elseif($parameters['action'] == "notepad" || $parameters['action'] == "do_notepad")
 402              {
 403                  $user_activity['activity'] = "usercp_notepad";
 404              }
 405              else
 406              {
 407                  $user_activity['activity'] = "usercp";
 408              }
 409              break;
 410          case "usercp2":
 411              if($parameters['action'] == "addfavorite" || $parameters['action'] == "removefavorite" || $parameters['action'] == "removefavorites")
 412              {
 413                  $user_activity['activity'] = "usercp2_favorites";
 414              }
 415              else if($parameters['action'] == "addsubscription" || $parameters['action'] == "do_addsubscription" || $parameters['action'] == "removesubscription" || $parameters['action'] == "removesubscriptions")
 416              {
 417                  $user_activity['activity'] = "usercp2_subscriptions";
 418              }
 419              break;
 420          case "portal":
 421              $user_activity['activity'] = "portal";
 422              break;
 423          case "warnings":
 424              if($parameters['action'] == "warn" || $parameters['action'] == "do_warn")
 425              {
 426                  $user_activity['activity'] = "warnings_warn";
 427              }
 428              elseif($parameters['action'] == "do_revoke")
 429              {
 430                  $user_activity['activity'] = "warnings_revoke";
 431              }
 432              elseif($parameters['action'] == "view")
 433              {
 434                  $user_activity['activity'] = "warnings_view";
 435              }
 436              else
 437              {
 438                  $user_activity['activity'] = "warnings";
 439              }
 440              break;
 441          case "nopermission":
 442              $user_activity['activity'] = "nopermission";
 443              $user_activity['nopermission'] = 1;
 444              break;
 445          default:
 446              $user_activity['activity'] = "unknown";
 447              break;
 448      }
 449      
 450      // Expects $location to be passed through already sanitized
 451      $user_activity['location'] = $location;
 452      
 453      $user_activity = $plugins->run_hooks("fetch_wol_activity_end", $user_activity);
 454      
 455      return $user_activity;
 456  }
 457  
 458  /**
 459   * Builds a friendly named Who's Online location from an "activity" and array of user data. Assumes fetch_wol_activity has already been called.
 460   *
 461   * @param array Array containing activity and essential IDs.
 462   * @return string Location name for the activity being performed.
 463   */
 464  function build_friendly_wol_location($user_activity)
 465  {
 466      global $db, $lang, $uid_list, $aid_list, $pid_list, $tid_list, $fid_list, $ann_list, $eid_list, $plugins, $parser, $mybb;
 467      global $threads, $forums, $forums_linkto, $forum_cache, $posts, $announcements, $events, $usernames, $attachments;
 468  
 469      // Fetch forum permissions for this user
 470      $unviewableforums = get_unviewable_forums();
 471      if($unviewableforums)
 472      {
 473          $fidnot = " AND fid NOT IN ($unviewableforums)";
 474      }
 475  
 476      // Fetch any users
 477      if(!is_array($usernames) && count($uid_list) > 0)
 478      {
 479          $uid_sql = implode(",", $uid_list);
 480          $query = $db->simple_select("users", "uid,username", "uid IN ($uid_sql)");
 481          while($user = $db->fetch_array($query))
 482          {
 483              $usernames[$user['uid']] = $user['username'];
 484          }
 485      }
 486      
 487      // Fetch any attachments
 488      if(!is_array($attachments) && count($aid_list) > 0)
 489      {
 490          $aid_sql = implode(",", $aid_list);
 491          $query = $db->simple_select("attachments", "aid,pid", "aid IN ($aid_sql)");
 492          while($attachment = $db->fetch_array($query))
 493          {
 494              $attachments[$attachment['aid']] = $attachment['pid'];
 495              $pid_list[] = $attachment['pid'];
 496          }
 497      }
 498  
 499      // Fetch any announcements
 500      if(!is_array($announcements) && count($ann_list) > 0)
 501      {
 502          $aid_sql = implode(",", $ann_list);
 503          $query = $db->simple_select("announcements", "aid,subject", "aid IN ({$aid_sql}) {$fidnot}");
 504          while($announcement = $db->fetch_array($query))
 505          {
 506              $announcement_title = htmlspecialchars_uni($parser->parse_badwords($announcement['subject']));
 507              $announcements[$announcement['aid']] = $announcement_title;
 508          }
 509      }
 510  
 511      // Fetch any posts
 512      if(!is_array($posts) && count($pid_list) > 0)
 513      {
 514          $pid_sql = implode(",", $pid_list);
 515          $query = $db->simple_select("posts", "pid,tid", "pid IN ($pid_sql) $fidnot");
 516          while($post = $db->fetch_array($query))
 517          {
 518              $posts[$post['pid']] = $post['tid'];
 519              $tid_list[] = $post['tid'];
 520          }
 521      }
 522  
 523      // Fetch any threads
 524      if(!is_array($threads) && count($tid_list) > 0)
 525      {
 526          $perms = array();
 527          $tid_sql = implode(",", $tid_list);
 528          $query = $db->query("
 529              SELECT t.uid, t.fid, t.tid, t.subject, t.visible, p.displaystyle AS threadprefix
 530              FROM ".TABLE_PREFIX."threads t
 531              LEFT JOIN ".TABLE_PREFIX."threadprefixes p ON (p.pid=t.prefix)
 532              WHERE tid IN({$tid_sql}) {$fidnot} {$visible}
 533          ");
 534  
 535          while($thread = $db->fetch_array($query))
 536          {
 537              if(!$perms[$thread['fid']])
 538              {
 539                  $perms[$thread['fid']] = forum_permissions($thread['fid']);
 540              }
 541  
 542              if($perms[$thread['fid']]['canonlyviewownthreads'] == 1 && $thread['uid'] != $mybb->user['uid'] && !is_moderator($thread['fid']))
 543              {
 544                  continue;
 545              }
 546  
 547              if(is_moderator($thread['fid']) || $thread['visible'] != '0')
 548              {
 549                  $thread_title = '';
 550                  if($thread['threadprefix'])
 551                  {
 552                      $thread_title = $thread['threadprefix'].'&nbsp;';
 553                  }
 554                  
 555                  $thread_title .= htmlspecialchars_uni($parser->parse_badwords($thread['subject']));
 556                  
 557                  $threads[$thread['tid']] = $thread_title;
 558                  $fid_list[] = $thread['fid'];
 559              }
 560          }
 561      }
 562  
 563      // Fetch any forums
 564      if(!is_array($forums) && count($fid_list) > 0)
 565      {
 566          if($fidnot && $unviewableforums)
 567          {
 568              $fidnot = explode(',', $unviewableforums);
 569          }
 570  
 571          foreach($forum_cache as $fid => $forum)
 572          {
 573              if(in_array($fid, $fid_list) && (!$fidnot || is_array($fidnot) && !in_array("'{$fid}'", $fidnot)))
 574              {
 575                  $forums[$fid] = $forum['name'];
 576                  $forums_linkto[$fid] = $forum['linkto'];
 577              }
 578          }
 579      }
 580  
 581      // And finaly any events
 582      if(!is_array($events) && count($eid_list) > 0)
 583      {
 584          $eid_sql = implode(",", $eid_list);
 585          $query = $db->simple_select("events", "eid,name", "eid IN ($eid_sql)");
 586          while($event = $db->fetch_array($query))
 587          {
 588              $events[$event['eid']] = htmlspecialchars_uni($parser->parse_badwords($event['name']));
 589          }
 590      }
 591  
 592      // Now we've got everything we need we can put a name to the location
 593      switch($user_activity['activity'])
 594      {
 595          // announcement.php functions
 596          case "announcements":
 597              if($announcements[$user_activity['ann']])
 598              {
 599                  $location_name =  $lang->sprintf($lang->viewing_announcements, get_announcement_link($user_activity['ann']), $announcements[$user_activity['ann']]);
 600              }
 601              else
 602              {
 603                  $location_name = $lang->viewing_announcements2;
 604              }
 605              break;
 606          // attachment.php actions
 607          case "attachment":
 608              $pid = $attachments[$user_activity['aid']];
 609              $tid = $posts[$pid];
 610              if($threads[$tid])
 611              {
 612                  $location_name = $lang->sprintf($lang->viewing_attachment2, $user_activity['aid'], $threads[$tid], get_thread_link($tid));
 613              }
 614              else
 615              {
 616                  $location_name = $lang->viewing_attachment;
 617              }
 618              break;
 619          // calendar.php functions
 620          case "calendar":
 621              $location_name = $lang->viewing_calendar;
 622              break;
 623          case "calendar_event":
 624              if($events[$user_activity['eid']])
 625              {
 626                  $location_name = $lang->sprintf($lang->viewing_event2, get_event_link($user_activity['eid']), $events[$user_activity['eid']]);
 627              }
 628              else
 629              {
 630                  $location_name = $lang->viewing_event;
 631              }
 632              break;
 633          case "calendar_addevent":
 634              $location_name = $lang->adding_event;
 635              break;
 636          case "calendar_editevent":
 637              $location_name = $lang->editing_event;
 638              break;
 639          // editpost.php functions
 640          case "editpost":
 641              $location_name = $lang->editing_post;
 642              break;
 643          // forumdisplay.php functions
 644          case "forumdisplay":
 645              if($forums[$user_activity['fid']])
 646              {
 647                  if($forums_linkto[$user_activity['fid']])
 648                  {
 649                      $location_name = $lang->sprintf($lang->forum_redirect_to, get_forum_link($user_activity['fid']), $forums[$user_activity['fid']]);
 650                  }
 651                  else
 652                  {
 653                      $location_name = $lang->sprintf($lang->viewing_forum2, get_forum_link($user_activity['fid']), $forums[$user_activity['fid']]);
 654                  }
 655              }
 656              else
 657              {
 658                  $location_name = $lang->viewing_forum;
 659              }
 660              break;
 661          // index.php functions
 662          case "index":
 663              $location_name = $lang->sprintf($lang->viewing_index, $mybb->settings['bbname']);
 664              break;
 665          // managegroup.php functions
 666          case "managegroup":
 667              $location_name = $lang->managing_group;
 668              break;
 669          // member.php functions
 670          case "member_activate":
 671              $location_name = $lang->activating_account;
 672              break;
 673          case "member_profile":
 674              if($usernames[$user_activity['uid']])
 675              {
 676                  $location_name = $lang->sprintf($lang->viewing_profile2, get_profile_link($user_activity['uid']), $usernames[$user_activity['uid']]);
 677              }
 678              else
 679              {
 680                  $location_name = $lang->viewing_profile;
 681              }
 682              break;
 683          case "member_register":
 684              $location_name = $lang->registering;
 685              break;
 686          case "member":
 687          case "member_login":
 688              // Guest or member?
 689              if($mybb->user['uid'] == 0)
 690              {
 691                  $location_name = $lang->logging_in;
 692              }
 693              else
 694              {
 695                  $location_name = $lang->logging_in_plain;
 696              }
 697              break;
 698          case "member_logout":
 699              $location_name = $lang->logging_out;
 700              break;
 701          case "member_emailuser":
 702              $location_name = $lang->emailing_user;
 703              break;
 704          case "member_rate":
 705              $location_name = $lang->rating_user;
 706              break;
 707          case "member_resendactivation":
 708              $location_name = $lang->member_resendactivation;
 709              break;
 710          case "member_lostpw":
 711              $location_name = $lang->member_lostpw;
 712              break;
 713          // memberlist.php functions
 714          case "memberlist":
 715              $location_name = $lang->viewing_memberlist;
 716              break;
 717          // misc.php functions
 718          case "misc_dstswitch":
 719              $location_name = $lang->changing_dst;
 720              break;
 721          case "misc_whoposted":
 722              if($threads[$user_activity['tid']])
 723              {
 724                  $location_name = $lang->sprintf($lang->viewing_whoposted2, get_thread_link($user_activity['tid']), $threads[$user_activity['tid']]);
 725              }
 726              else
 727              {
 728                  $location_name = $lang->viewing_whoposted;
 729              }
 730              break;
 731          case "misc_markread":
 732              $location_name = $lang->sprintf($lang->marking_read, $mybb->post_code);
 733              break;
 734          case "misc_help":
 735              $location_name = $lang->viewing_helpdocs;
 736              break;
 737          case "misc_buddypopup":
 738              $location_name = $lang->viewing_buddylist;
 739              break;
 740          case "misc_smilies":
 741              $location_name = $lang->viewing_smilies;
 742              break;
 743          case "misc_syndication":
 744              $location_name = $lang->viewing_syndication;
 745              break;
 746          case "misc_imcenter":
 747              $location_name = $lang->viewing_imcenter;
 748              break;                        
 749          // modcp.php functions
 750          case "modcp_modlogs":
 751              $location_name = $lang->viewing_modlogs;
 752              break;
 753          case "modcp_announcements":
 754              $location_name = $lang->managing_announcements;
 755              break;
 756          case "modcp_finduser":
 757              $location_name = $lang->search_for_user;
 758              break;
 759          case "modcp_warninglogs":
 760              $location_name = $lang->managing_warninglogs;
 761              break;
 762          case "modcp_ipsearch":
 763              $location_name = $lang->searching_ips;
 764              break;
 765          case "modcp_report":
 766              $location_name = $lang->viewing_reports;
 767              break;
 768          case "modcp_new_announcement":
 769              $location_name = $lang->adding_announcement;
 770              break;
 771          case "modcp_delete_announcement":
 772              $location_name = $lang->deleting_announcement;
 773              break;
 774          case "modcp_edit_announcement":
 775              $location_name = $lang->editing_announcement;
 776              break;
 777          case "modcp_mod_queue":
 778              $location_name = $lang->managing_modqueue;
 779              break;
 780          case "modcp_editprofile":
 781              $location_name = $lang->editing_user_profiles;
 782              break;
 783          case "modcp_banning":
 784              $location_name = $lang->managing_bans;
 785              break;
 786          case "modcp":
 787              $location_name = $lang->viewing_modcp;
 788              break;
 789          // moderation.php functions
 790          case "moderation":
 791              $location_name = $lang->using_modtools;
 792              break;
 793          // newreply.php functions
 794          case "newreply":
 795              if($user_activity['pid'])
 796              {
 797                  $user_activity['tid'] = $posts[$user_activity['pid']];
 798              }
 799              if($threads[$user_activity['tid']])
 800              {
 801                  $location_name = $lang->sprintf($lang->replying_thread2, get_thread_link($user_activity['tid']), $threads[$user_activity['tid']]);
 802              }
 803              else
 804              {
 805                  $location_name = $lang->replying_thread;
 806              }
 807              break;
 808          // newthread.php functions
 809          case "newthread":
 810              if($forums[$user_activity['fid']])
 811              {
 812                  $location_name = $lang->sprintf($lang->posting_thread2, get_forum_link($user_activity['fid']), $forums[$user_activity['fid']]);
 813              }
 814              else
 815              {
 816                  $location_name = $lang->posting_thread;
 817              }
 818              break;
 819          // online.php functions
 820          case "wol":
 821              $location_name = $lang->viewing_wol;
 822              break;
 823          case "woltoday":
 824              $location_name = $lang->viewing_woltoday;
 825              break;
 826          // polls.php functions
 827          case "newpoll":
 828              $location_name = $lang->creating_poll;
 829              break;
 830          case "editpoll":
 831              $location_name = $lang->editing_poll;
 832              break;
 833          case "showresults":
 834              $location_name = $lang->viewing_pollresults;
 835              break;
 836          case "vote":
 837              $location_name = $lang->voting_poll;
 838              break;
 839          // printthread.php functions
 840          case "printthread":
 841              if($threads[$user_activity['tid']])
 842              {
 843                  $location_name = $lang->sprintf($lang->printing_thread2, get_thread_link($user_activity['tid']), $threads[$user_activity['tid']]);
 844              }
 845              else
 846              {
 847                  $location_name = $lang->printing_thread;
 848              }
 849              break;
 850          // private.php functions
 851          case "private_send":
 852              $location_name = $lang->sending_pm;
 853              break;
 854          case "private_read":
 855              $location_name = $lang->reading_pm;
 856              break;
 857          case "private_folders":
 858              $location_name = $lang->editing_pmfolders;
 859              break;
 860          case "private":
 861              $location_name = $lang->using_pmsystem;
 862              break;
 863          /* Ratethread functions */
 864          case "ratethread":
 865              $location_name = $lang->rating_thread;
 866              break;
 867          // report.php functions
 868          case "report":
 869              $location_name = $lang->reporting_post;
 870              break;
 871          // reputation.php functions
 872          case "reputation":
 873              $location_name = $lang->sprintf($lang->giving_reputation, get_profile_link($user_activity['uid']), $usernames[$user_activity['uid']]);
 874              break;
 875          case "reputation_report":
 876              if($usernames[$user_activity['uid']])
 877              {
 878                  $location_name = $lang->sprintf($lang->viewing_reputation_report, "reputation.php?uid={$user_activity['uid']}", $usernames[$user_activity['uid']]);
 879              }
 880              else
 881              {
 882                  $location_name = $lang->sprintf($lang->viewing_reputation_report2);
 883              }
 884              break;
 885          // search.php functions
 886          case "search":
 887              $location_name = $lang->sprintf($lang->searching_forum, $mybb->settings['bbname']);
 888              break;
 889          // showthread.php functions
 890          case "showthread":
 891              if($threads[$user_activity['tid']])
 892              {
 893                  $pagenote = '';
 894                  $location_name = $lang->sprintf($lang->reading_thread2, get_thread_link($user_activity['tid']), $threads[$user_activity['tid']], $pagenote);
 895              }
 896              else
 897              {
 898                  $location_name = $lang->reading_thread;
 899              }
 900              break;
 901          // showteam.php functions
 902          case "showteam":
 903              $location_name = $lang->viewing_team;
 904              break;
 905          // stats.php functions
 906          case "stats":
 907              $location_name = $lang->viewing_stats;
 908              break;
 909          // usercp.php functions
 910          case "usercp_profile":
 911              $location_name = $lang->updating_profile;
 912              break;
 913          case "usercp_editlists":
 914              $location_name = $lang->managing_buddyignorelist;
 915              break;
 916          case "usercp_options":
 917              $location_name = $lang->updating_options;
 918              break;
 919          case "usercp_editsig":
 920              $location_name = $lang->editing_signature;
 921              break;
 922          case "usercp_avatar":
 923              $location_name = $lang->changing_avatar;
 924              break;
 925          case "usercp_subscriptions":
 926              $location_name = $lang->viewing_subscriptions;
 927              break;
 928          case "usercp_favorites":
 929              $location_name = $lang->viewing_favorites;
 930              break;
 931          case "usercp_notepad":
 932              $location_name = $lang->editing_pad;
 933              break;
 934          case "usercp_password":
 935              $location_name = $lang->editing_password;
 936              break;
 937          case "usercp":
 938              $location_name = $lang->user_cp;
 939              break;
 940          case "usercp2_favorites":
 941              $location_name = $lang->managing_favorites;
 942              break;
 943          case "usercp2_subscriptions":
 944              $location_name = $lang->managing_subscriptions;
 945              break;
 946          case "portal":
 947              $location_name = $lang->viewing_portal;
 948              break;
 949          // sendthread.php functions
 950          case "sendthread":
 951              $location_name = $lang->sending_thread;
 952              break;
 953          // warnings.php functions
 954          case "warnings_revoke":
 955              $location_name = $lang->revoking_warning;
 956              break;
 957          case "warnings_warn":
 958              $location_name = $lang->warning_user;
 959              break;
 960          case "warnings_view":
 961              $location_name = $lang->viewing_warning;
 962              break;
 963          case "warnings":
 964              $location_name = $lang->managing_warnings;
 965              break;
 966      }
 967      
 968      $plugin_array = array('user_activity' => &$user_activity, 'location_name' => &$location_name);
 969      $plugins->run_hooks("build_friendly_wol_location_end", $plugin_array);
 970  
 971      if(isset($user_activity['nopermission']) && $user_activity['nopermission'] == 1)
 972      {
 973          $location_name = $lang->viewing_noperms;
 974      }
 975  
 976      if(!$location_name)
 977      {
 978          $location_name = $lang->sprintf($lang->unknown_location, $user_activity['location']);
 979      }
 980  
 981      return $location_name;
 982  }
 983  
 984  /**
 985   * Build a Who's Online row for a specific user
 986   *
 987   * @param array Array of user information including activity information
 988   * @return string Formatted online row
 989   */
 990  function build_wol_row($user)
 991  {
 992      global $mybb, $lang, $templates, $theme, $session;
 993  
 994      // We have a registered user
 995      if($user['uid'] > 0)
 996      {
 997          // Only those with "canviewwolinvis" permissions can view invisible users
 998          if($user['invisible'] != 1 || $mybb->usergroup['canviewwolinvis'] == 1 || $user['uid'] == $mybb->user['uid'])
 999          {
1000              // Append an invisible mark if the user is invisible
1001              if($user['invisible'] == 1)
1002              {
1003                  $invisible_mark = "*";
1004              }
1005              else
1006              {
1007                  $invisible_mark = '';
1008              }
1009  
1010              $user['username'] = format_name($user['username'], $user['usergroup'], $user['displaygroup']);
1011              $online_name = build_profile_link($user['username'], $user['uid']).$invisible_mark;
1012          }
1013      }
1014      // We have a bot
1015      elseif($user['bot'])
1016      {
1017          $online_name = format_name($user['bot'], $user['usergroup']);
1018      }
1019      // Otherwise we've got a plain old guest
1020      else
1021      {
1022          $online_name = format_name($lang->guest, 1);
1023      }
1024  
1025      $online_time = my_date($mybb->settings['timeformat'], $user['time']);
1026      
1027      // Fetch the location name for this users activity
1028      $location = build_friendly_wol_location($user['activity']);
1029  
1030      // Can view IPs, then fetch the IP template
1031      if($mybb->usergroup['canviewonlineips'] == 1)
1032      {
1033          eval("\$user_ip = \"".$templates->get("online_row_ip")."\";");
1034      }
1035      else
1036      {
1037          $user['ip'] = '';
1038      }
1039  
1040      // And finally if we have permission to view this user, return the completed online row
1041      if($user['invisible'] != 1 || $mybb->usergroup['canviewwolinvis'] == 1 || $user['uid'] == $mybb->user['uid'])
1042      {
1043          eval("\$online_row = \"".$templates->get("online_row")."\";");
1044      }
1045      return $online_row;
1046  }
1047  ?>


Generated: Tue Oct 8 19:19:50 2013 Cross-referenced by PHPXref 0.7.1