[ Index ]

PHP Cross Reference of MyBB 1.8.28

title

Body

[close]

/inc/ -> functions_online.php (source)

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


2005 - 2021 © MyBB.de | Alle Rechte vorbehalten! | Sponsor: netcup Cross-referenced by PHPXref