[ Index ]

PHP Cross Reference of MyBB 1.8.38

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(isset($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(empty($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['action']))
 404              {
 405                  $parameters['action'] = '';
 406              }
 407              if(!isset($parameters['uid']))
 408              {
 409                  $parameters['uid'] = 0;
 410              }
 411              $parameters['uid'] = (int)$parameters['uid'];
 412              if($parameters['uid'] > 0)
 413              {
 414                  $uid_list[$parameters['uid']] = $parameters['uid'];
 415              }
 416              $user_activity['uid'] = $parameters['uid'];
 417  
 418              if($parameters['action'] == "add")
 419              {
 420                  $user_activity['activity'] = "reputation";
 421              }
 422              else
 423              {
 424                  $user_activity['activity'] = "reputation_report";
 425              }
 426              break;
 427          case "search":
 428              $user_activity['activity'] = "search";
 429              break;
 430          case "sendthread":
 431              if(!isset($parameters['tid']))
 432              {
 433                  $parameters['tid'] = 0;
 434              }
 435              $parameters['tid'] = (int)$parameters['tid'];
 436              if($parameters['tid'] > 0)
 437              {
 438                  $tid_list[$parameters['tid']] = $parameters['tid'];
 439              }
 440              $user_activity['activity'] = "sendthread";
 441              $user_activity['tid'] = $parameters['tid'];
 442          break;
 443          case "showteam":
 444              $user_activity['activity'] = "showteam";
 445              break;
 446          case "showthread":
 447              if(!isset($parameters['action']))
 448              {
 449                  $parameters['action'] = '';
 450              }
 451              if(!isset($parameters['pid']))
 452              {
 453                  $parameters['pid'] = 0;
 454              }
 455              $parameters['pid'] = (int)$parameters['pid'];
 456              if($parameters['pid'] > 0 && $parameters['action'] == "showpost")
 457              {
 458                  $pid_list[$parameters['pid']] = $parameters['pid'];
 459                  $user_activity['activity'] = "showpost";
 460                  $user_activity['pid'] = $parameters['pid'];
 461              }
 462              else
 463              {
 464                  if(!isset($parameters['page']))
 465                  {
 466                      $parameters['page'] = 0;
 467                  }
 468                  $parameters['page'] = (int)$parameters['page'];
 469                  $user_activity['page'] = $parameters['page'];
 470                  if(!isset($parameters['tid']))
 471                  {
 472                      $parameters['tid'] = 0;
 473                  }
 474                  $parameters['tid'] = (int)$parameters['tid'];
 475                  if($parameters['tid'] > 0)
 476                  {
 477                      $tid_list[$parameters['tid']] = $parameters['tid'];
 478                  }
 479                  $user_activity['activity'] = "showthread";
 480                  $user_activity['tid'] = $parameters['tid'];
 481              }
 482              break;
 483          case "stats":
 484              $user_activity['activity'] = "stats";
 485              break;
 486          case "usercp":
 487              if(!isset($parameters['action']))
 488              {
 489                  $parameters['action'] = '';
 490              }
 491              if($parameters['action'] == "profile" || $parameters['action'] == "do_profile")
 492              {
 493                  $user_activity['activity'] = "usercp_profile";
 494              }
 495              elseif($parameters['action'] == "options" || $parameters['action'] == "do_options")
 496              {
 497                  $user_activity['activity'] = "usercp_options";
 498              }
 499              elseif($parameters['action'] == "password" || $parameters['action'] == "do_password")
 500              {
 501                  $user_activity['activity'] = "usercp_password";
 502              }
 503              elseif($parameters['action'] == "editsig" || $parameters['action'] == "do_editsig")
 504              {
 505                  $user_activity['activity'] = "usercp_editsig";
 506              }
 507              elseif($parameters['action'] == "avatar" || $parameters['action'] == "do_avatar")
 508              {
 509                  $user_activity['activity'] = "usercp_avatar";
 510              }
 511              elseif($parameters['action'] == "editlists" || $parameters['action'] == "do_editlists")
 512              {
 513                  $user_activity['activity'] = "usercp_editlists";
 514              }
 515              elseif($parameters['action'] == "favorites")
 516              {
 517                  $user_activity['activity'] = "usercp_favorites";
 518              }
 519              elseif($parameters['action'] == "subscriptions")
 520              {
 521                  $user_activity['activity'] = "usercp_subscriptions";
 522              }
 523              elseif($parameters['action'] == "addfavorite" || $parameters['action'] == "removefavorite" || $parameters['action'] == "removefavorites")
 524              {
 525                  $user_activity['activity'] = "usercp_managefavorites";
 526              }
 527              else if($parameters['action'] == "addsubscription" || $parameters['action'] == "do_addsubscription" || $parameters['action'] == "removesubscription" || $parameters['action'] == "removesubscriptions")
 528              {
 529                  $user_activity['activity'] = "usercp_managesubscriptions";
 530              }
 531              elseif($parameters['action'] == "notepad" || $parameters['action'] == "do_notepad")
 532              {
 533                  $user_activity['activity'] = "usercp_notepad";
 534              }
 535              else
 536              {
 537                  $user_activity['activity'] = "usercp";
 538              }
 539              break;
 540          case "portal":
 541              $user_activity['activity'] = "portal";
 542              break;
 543          case "warnings":
 544              if(!isset($parameters['action']))
 545              {
 546                  $parameters['action'] = '';
 547              }
 548              if($parameters['action'] == "warn" || $parameters['action'] == "do_warn")
 549              {
 550                  $user_activity['activity'] = "warnings_warn";
 551              }
 552              elseif($parameters['action'] == "do_revoke")
 553              {
 554                  $user_activity['activity'] = "warnings_revoke";
 555              }
 556              elseif($parameters['action'] == "view")
 557              {
 558                  $user_activity['activity'] = "warnings_view";
 559              }
 560              else
 561              {
 562                  $user_activity['activity'] = "warnings";
 563              }
 564              break;
 565          case "nopermission":
 566              $user_activity['activity'] = "nopermission";
 567              $user_activity['nopermission'] = 1;
 568              break;
 569          default:
 570              $user_activity['activity'] = "unknown";
 571              break;
 572      }
 573  
 574      // Expects $location to be passed through already sanitized
 575      $user_activity['location'] = $location;
 576  
 577      $user_activity = $plugins->run_hooks("fetch_wol_activity_end", $user_activity);
 578  
 579      return $user_activity;
 580  }
 581  
 582  /**
 583   * Builds a friendly named Who's Online location from an "activity" and array of user data. Assumes fetch_wol_activity has already been called.
 584   *
 585   * @param array $user_activity Array containing activity and essential IDs.
 586   * @return string Location name for the activity being performed.
 587   */
 588  function build_friendly_wol_location($user_activity)
 589  {
 590      global $db, $lang, $uid_list, $aid_list, $pid_list, $tid_list, $fid_list, $ann_list, $eid_list, $plugins, $parser, $mybb;
 591      global $threads, $forums, $forums_linkto, $forum_cache, $posts, $announcements, $events, $usernames, $attachments;
 592  
 593      // Fetch forum permissions for this user
 594      $unviewableforums = get_unviewable_forums();
 595      $inactiveforums = get_inactive_forums();
 596      $fidnot = '';
 597      $unviewablefids = $inactivefids = array();
 598      if($unviewableforums)
 599      {
 600          $fidnot = " AND fid NOT IN ($unviewableforums)";
 601          $unviewablefids = explode(',', $unviewableforums);
 602      }
 603      if($inactiveforums)
 604      {
 605          $fidnot .= " AND fid NOT IN ($inactiveforums)";
 606          $inactivefids = explode(',', $inactiveforums);
 607      }
 608  
 609      // Fetch any users
 610      if(!is_array($usernames) && count($uid_list) > 0)
 611      {
 612          $uid_sql = implode(",", $uid_list);
 613          if($uid_sql != $mybb->user['uid'])
 614          {
 615              $query = $db->simple_select("users", "uid,username", "uid IN ($uid_sql)");
 616              while($user = $db->fetch_array($query))
 617              {
 618                  $usernames[$user['uid']] = htmlspecialchars_uni($user['username']);
 619              }
 620          }
 621          else
 622          {
 623              $usernames[$mybb->user['uid']] = htmlspecialchars_uni($mybb->user['username']);
 624          }
 625      }
 626  
 627      // Fetch any attachments
 628      if(!is_array($attachments) && count($aid_list) > 0)
 629      {
 630          $aid_sql = implode(",", $aid_list);
 631          $query = $db->simple_select("attachments", "aid,pid", "aid IN ($aid_sql)");
 632          while($attachment = $db->fetch_array($query))
 633          {
 634              $attachments[$attachment['aid']] = $attachment['pid'];
 635              $pid_list[] = $attachment['pid'];
 636          }
 637      }
 638  
 639      // Fetch any announcements
 640      if(!is_array($announcements) && count($ann_list) > 0)
 641      {
 642          $aid_sql = implode(",", $ann_list);
 643          $query = $db->simple_select("announcements", "aid,subject", "aid IN ({$aid_sql}) {$fidnot}");
 644          while($announcement = $db->fetch_array($query))
 645          {
 646              $announcement_title = htmlspecialchars_uni($parser->parse_badwords($announcement['subject']));
 647              $announcements[$announcement['aid']] = $announcement_title;
 648          }
 649      }
 650  
 651      // Fetch any posts
 652      if(!is_array($posts) && count($pid_list) > 0)
 653      {
 654          $pid_sql = implode(",", $pid_list);
 655          $query = $db->simple_select("posts", "pid,tid", "pid IN ({$pid_sql}) {$fidnot}");
 656          while($post = $db->fetch_array($query))
 657          {
 658              $posts[$post['pid']] = $post['tid'];
 659              $tid_list[] = $post['tid'];
 660          }
 661      }
 662  
 663      // Fetch any threads
 664      if(!is_array($threads) && count($tid_list) > 0)
 665      {
 666          $perms = array();
 667          $tid_sql = implode(",", $tid_list);
 668          $query = $db->simple_select('threads', 'uid, fid, tid, subject, visible, prefix', "tid IN({$tid_sql}) {$fidnot}");
 669  
 670          $threadprefixes = build_prefixes();
 671  
 672          while($thread = $db->fetch_array($query))
 673          {
 674              $thread['threadprefix'] = '';
 675              if($thread['prefix'] && !empty($threadprefixes[$thread['prefix']]))
 676              {
 677                  $thread['threadprefix'] = $threadprefixes[$thread['prefix']]['displaystyle'];
 678              }
 679              if(empty($perms[$thread['fid']]))
 680              {
 681                  $perms[$thread['fid']] = forum_permissions($thread['fid']);
 682              }
 683  
 684              if(isset($perms[$thread['fid']]['canonlyviewownthreads']) && $perms[$thread['fid']]['canonlyviewownthreads'] == 1 && $thread['uid'] != $mybb->user['uid'] && !is_moderator($thread['fid']))
 685              {
 686                  continue;
 687              }
 688  
 689              if(is_moderator($thread['fid']) || $thread['visible'] == 1)
 690              {
 691                  $thread_title = '';
 692                  if($thread['threadprefix'])
 693                  {
 694                      $thread_title = $thread['threadprefix'].'&nbsp;';
 695                  }
 696  
 697                  $thread_title .= htmlspecialchars_uni($parser->parse_badwords($thread['subject']));
 698  
 699                  $threads[$thread['tid']] = $thread_title;
 700                  $fid_list[] = $thread['fid'];
 701              }
 702          }
 703      }
 704  
 705      // Fetch any forums
 706      if(!is_array($forums) && count($fid_list) > 0)
 707      {
 708          $fidnot = array_merge($unviewablefids, $inactivefids);
 709  
 710          foreach($forum_cache as $fid => $forum)
 711          {
 712              if(in_array($fid, $fid_list) && !in_array($fid, $fidnot))
 713              {
 714                  $forums[$fid] = $forum['name'];
 715                  $forums_linkto[$fid] = $forum['linkto'];
 716              }
 717          }
 718      }
 719  
 720      // And finaly any events
 721      if(!is_array($events) && count($eid_list) > 0)
 722      {
 723          $eid_sql = implode(",", $eid_list);
 724          $query = $db->simple_select("events", "eid,name", "eid IN ($eid_sql)");
 725          while($event = $db->fetch_array($query))
 726          {
 727              $events[$event['eid']] = htmlspecialchars_uni($parser->parse_badwords($event['name']));
 728          }
 729      }
 730  
 731      // Now we've got everything we need we can put a name to the location
 732      switch($user_activity['activity'])
 733      {
 734          // announcement.php functions
 735          case "announcements":
 736              if(!empty($announcements[$user_activity['ann']]))
 737              {
 738                  $location_name =  $lang->sprintf($lang->viewing_announcements, get_announcement_link($user_activity['ann']), $announcements[$user_activity['ann']]);
 739              }
 740              else
 741              {
 742                  $location_name = $lang->viewing_announcements2;
 743              }
 744              break;
 745          // attachment.php actions
 746          case "attachment":
 747              $pid = $attachments[$user_activity['aid']];
 748              $tid = $posts[$pid];
 749              if(!empty($threads[$tid]))
 750              {
 751                  $location_name = $lang->sprintf($lang->viewing_attachment2, $user_activity['aid'], $threads[$tid], get_thread_link($tid));
 752              }
 753              else
 754              {
 755                  $location_name = $lang->viewing_attachment;
 756              }
 757              break;
 758          // calendar.php functions
 759          case "calendar":
 760              $location_name = $lang->viewing_calendar;
 761              break;
 762          case "calendar_event":
 763              if(!empty($events[$user_activity['eid']]))
 764              {
 765                  $location_name = $lang->sprintf($lang->viewing_event2, get_event_link($user_activity['eid']), $events[$user_activity['eid']]);
 766              }
 767              else
 768              {
 769                  $location_name = $lang->viewing_event;
 770              }
 771              break;
 772          case "calendar_addevent":
 773              $location_name = $lang->adding_event;
 774              break;
 775          case "calendar_editevent":
 776              $location_name = $lang->editing_event;
 777              break;
 778          case "contact":
 779              $location_name = $lang->viewing_contact_us;
 780              break;
 781          // editpost.php functions
 782          case "editpost":
 783              $location_name = $lang->editing_post;
 784              break;
 785          // forumdisplay.php functions
 786          case "forumdisplay":
 787              if(!empty($forums[$user_activity['fid']]))
 788              {
 789                  if($forums_linkto[$user_activity['fid']])
 790                  {
 791                      $location_name = $lang->sprintf($lang->forum_redirect_to, get_forum_link($user_activity['fid']), $forums[$user_activity['fid']]);
 792                  }
 793                  else
 794                  {
 795                      $location_name = $lang->sprintf($lang->viewing_forum2, get_forum_link($user_activity['fid']), $forums[$user_activity['fid']]);
 796                  }
 797              }
 798              else
 799              {
 800                  $location_name = $lang->viewing_forum;
 801              }
 802              break;
 803          // index.php functions
 804          case "index":
 805              $location_name = $lang->sprintf($lang->viewing_index, $mybb->settings['bbname']);
 806              break;
 807          // managegroup.php functions
 808          case "managegroup":
 809              $location_name = $lang->managing_group;
 810              break;
 811          // member.php functions
 812          case "member_activate":
 813              $location_name = $lang->activating_account;
 814              break;
 815          case "member_profile":
 816              if(!empty($usernames[$user_activity['uid']]))
 817              {
 818                  $location_name = $lang->sprintf($lang->viewing_profile2, get_profile_link($user_activity['uid']), $usernames[$user_activity['uid']]);
 819              }
 820              else
 821              {
 822                  $location_name = $lang->viewing_profile;
 823              }
 824              break;
 825          case "member_register":
 826              $location_name = $lang->registering;
 827              break;
 828          case "member":
 829          case "member_login":
 830              // Guest or member?
 831              if($mybb->user['uid'] == 0)
 832              {
 833                  $location_name = $lang->logging_in;
 834              }
 835              else
 836              {
 837                  $location_name = $lang->logging_in_plain;
 838              }
 839              break;
 840          case "member_logout":
 841              $location_name = $lang->logging_out;
 842              break;
 843          case "member_emailuser":
 844              $location_name = $lang->emailing_user;
 845              break;
 846          case "member_rate":
 847              $location_name = $lang->rating_user;
 848              break;
 849          case "member_resendactivation":
 850              $location_name = $lang->member_resendactivation;
 851              break;
 852          case "member_lostpw":
 853              $location_name = $lang->member_lostpw;
 854              break;
 855          // memberlist.php functions
 856          case "memberlist":
 857              $location_name = $lang->viewing_memberlist;
 858              break;
 859          // misc.php functions
 860          case "misc_dstswitch":
 861              $location_name = $lang->changing_dst;
 862              break;
 863          case "misc_whoposted":
 864              if(!empty($threads[$user_activity['tid']]))
 865              {
 866                  $location_name = $lang->sprintf($lang->viewing_whoposted2, get_thread_link($user_activity['tid']), $threads[$user_activity['tid']]);
 867              }
 868              else
 869              {
 870                  $location_name = $lang->viewing_whoposted;
 871              }
 872              break;
 873          case "misc_markread":
 874              $location_name = $lang->sprintf($lang->marking_read, $mybb->post_code);
 875              break;
 876          case "misc_help":
 877              $location_name = $lang->viewing_helpdocs;
 878              break;
 879          case "misc_buddypopup":
 880              $location_name = $lang->viewing_buddylist;
 881              break;
 882          case "misc_smilies":
 883              $location_name = $lang->viewing_smilies;
 884              break;
 885          case "misc_syndication":
 886              $location_name = $lang->viewing_syndication;
 887              break;
 888          // modcp.php functions
 889          case "modcp_modlogs":
 890              $location_name = $lang->viewing_modlogs;
 891              break;
 892          case "modcp_announcements":
 893              $location_name = $lang->managing_announcements;
 894              break;
 895          case "modcp_finduser":
 896              $location_name = $lang->search_for_user;
 897              break;
 898          case "modcp_warninglogs":
 899              $location_name = $lang->managing_warninglogs;
 900              break;
 901          case "modcp_ipsearch":
 902              $location_name = $lang->searching_ips;
 903              break;
 904          case "modcp_report":
 905              $location_name = $lang->viewing_reports;
 906              break;
 907          case "modcp_new_announcement":
 908              $location_name = $lang->adding_announcement;
 909              break;
 910          case "modcp_delete_announcement":
 911              $location_name = $lang->deleting_announcement;
 912              break;
 913          case "modcp_edit_announcement":
 914              $location_name = $lang->editing_announcement;
 915              break;
 916          case "modcp_mod_queue":
 917              $location_name = $lang->managing_modqueue;
 918              break;
 919          case "modcp_editprofile":
 920              $location_name = $lang->editing_user_profiles;
 921              break;
 922          case "modcp_banning":
 923              $location_name = $lang->managing_bans;
 924              break;
 925          case "modcp":
 926              $location_name = $lang->viewing_modcp;
 927              break;
 928          // moderation.php functions
 929          case "moderation":
 930              $location_name = $lang->using_modtools;
 931              break;
 932          // newreply.php functions
 933          case "newreply":
 934              if(!empty($threads[$user_activity['tid']]))
 935              {
 936                  $location_name = $lang->sprintf($lang->replying_thread2, get_thread_link($user_activity['tid']), $threads[$user_activity['tid']]);
 937              }
 938              else
 939              {
 940                  $location_name = $lang->replying_thread;
 941              }
 942              break;
 943          // newthread.php functions
 944          case "newthread":
 945              if(!empty($forums[$user_activity['fid']]))
 946              {
 947                  $location_name = $lang->sprintf($lang->posting_thread2, get_forum_link($user_activity['fid']), $forums[$user_activity['fid']]);
 948              }
 949              else
 950              {
 951                  $location_name = $lang->posting_thread;
 952              }
 953              break;
 954          // online.php functions
 955          case "wol":
 956              $location_name = $lang->viewing_wol;
 957              break;
 958          case "woltoday":
 959              $location_name = $lang->viewing_woltoday;
 960              break;
 961          // polls.php functions
 962          case "newpoll":
 963              $location_name = $lang->creating_poll;
 964              break;
 965          case "editpoll":
 966              $location_name = $lang->editing_poll;
 967              break;
 968          case "showresults":
 969              $location_name = $lang->viewing_pollresults;
 970              break;
 971          case "vote":
 972              $location_name = $lang->voting_poll;
 973              break;
 974          // printthread.php functions
 975          case "printthread":
 976              if(!empty($threads[$user_activity['tid']]))
 977              {
 978                  $location_name = $lang->sprintf($lang->printing_thread2, get_thread_link($user_activity['tid']), $threads[$user_activity['tid']]);
 979              }
 980              else
 981              {
 982                  $location_name = $lang->printing_thread;
 983              }
 984              break;
 985          // private.php functions
 986          case "private_send":
 987              $location_name = $lang->sending_pm;
 988              break;
 989          case "private_read":
 990              $location_name = $lang->reading_pm;
 991              break;
 992          case "private_folders":
 993              $location_name = $lang->editing_pmfolders;
 994              break;
 995          case "private":
 996              $location_name = $lang->using_pmsystem;
 997              break;
 998          /* Ratethread functions */
 999          case "ratethread":
1000              $location_name = $lang->rating_thread;
1001              break;
1002          // report.php functions
1003          case "report":
1004              $location_name = $lang->reporting_post;
1005              break;
1006          // reputation.php functions
1007          case "reputation":
1008              $location_name = $lang->sprintf($lang->giving_reputation, get_profile_link($user_activity['uid']), $usernames[$user_activity['uid']]);
1009              break;
1010          case "reputation_report":
1011              if(!empty($usernames[$user_activity['uid']]))
1012              {
1013                  $location_name = $lang->sprintf($lang->viewing_reputation_report, "reputation.php?uid={$user_activity['uid']}", $usernames[$user_activity['uid']]);
1014              }
1015              else
1016              {
1017                  $location_name = $lang->sprintf($lang->viewing_reputation_report2);
1018              }
1019              break;
1020          // search.php functions
1021          case "search":
1022              $location_name = $lang->sprintf($lang->searching_forum, $mybb->settings['bbname']);
1023              break;
1024          // showthread.php functions
1025          case "showthread":
1026              if(!empty($threads[$user_activity['tid']]))
1027              {
1028                  $pagenote = '';
1029                  $location_name = $lang->sprintf($lang->reading_thread2, get_thread_link($user_activity['tid']), $threads[$user_activity['tid']], $pagenote);
1030              }
1031              else
1032              {
1033                  $location_name = $lang->reading_thread;
1034              }
1035              break;
1036          case "showpost":
1037              if(!empty($posts[$user_activity['pid']]) && !empty($threads[$posts[$user_activity['pid']]]))
1038              {
1039                  $pagenote = '';
1040                  $location_name = $lang->sprintf($lang->reading_thread2, get_thread_link($posts[$user_activity['pid']]), $threads[$posts[$user_activity['pid']]], $pagenote);
1041              }
1042              else
1043              {
1044                  $location_name = $lang->reading_thread;
1045              }
1046              break;
1047          // showteam.php functions
1048          case "showteam":
1049              $location_name = $lang->viewing_team;
1050              break;
1051          // stats.php functions
1052          case "stats":
1053              $location_name = $lang->viewing_stats;
1054              break;
1055          // usercp.php functions
1056          case "usercp_profile":
1057              $location_name = $lang->updating_profile;
1058              break;
1059          case "usercp_editlists":
1060              $location_name = $lang->managing_buddyignorelist;
1061              break;
1062          case "usercp_options":
1063              $location_name = $lang->updating_options;
1064              break;
1065          case "usercp_editsig":
1066              $location_name = $lang->editing_signature;
1067              break;
1068          case "usercp_avatar":
1069              $location_name = $lang->changing_avatar;
1070              break;
1071          case "usercp_subscriptions":
1072              $location_name = $lang->viewing_subscriptions;
1073              break;
1074          case "usercp_favorites":
1075              $location_name = $lang->viewing_favorites;
1076              break;
1077          case "usercp_notepad":
1078              $location_name = $lang->editing_pad;
1079              break;
1080          case "usercp_password":
1081              $location_name = $lang->editing_password;
1082              break;
1083          case "usercp":
1084              $location_name = $lang->user_cp;
1085              break;
1086          case "usercp_managefavorites":
1087              $location_name = $lang->managing_favorites;
1088              break;
1089          case "usercp_managesubscriptions":
1090              $location_name = $lang->managing_subscriptions;
1091              break;
1092          case "portal":
1093              $location_name = $lang->viewing_portal;
1094              break;
1095          // sendthread.php functions
1096          case "sendthread":
1097              $location_name = $lang->sending_thread;
1098              break;
1099          // warnings.php functions
1100          case "warnings_revoke":
1101              $location_name = $lang->revoking_warning;
1102              break;
1103          case "warnings_warn":
1104              $location_name = $lang->warning_user;
1105              break;
1106          case "warnings_view":
1107              $location_name = $lang->viewing_warning;
1108              break;
1109          case "warnings":
1110              $location_name = $lang->managing_warnings;
1111              break;
1112      }
1113  
1114      $plugin_array = array('user_activity' => &$user_activity, 'location_name' => &$location_name);
1115      $plugins->run_hooks("build_friendly_wol_location_end", $plugin_array);
1116  
1117      if(isset($user_activity['nopermission']) && $user_activity['nopermission'] == 1)
1118      {
1119          $location_name = $lang->viewing_noperms;
1120      }
1121  
1122      if(!$location_name)
1123      {
1124          $location_name = $lang->sprintf($lang->unknown_location, $user_activity['location']);
1125      }
1126  
1127      return $location_name;
1128  }
1129  
1130  /**
1131   * Build a Who's Online row for a specific user
1132   *
1133   * @param array $user Array of user information including activity information
1134   * @return string Formatted online row
1135   */
1136  function build_wol_row($user)
1137  {
1138      global $mybb, $lang, $templates, $theme, $session, $db;
1139  
1140      // We have a registered user
1141      if($user['uid'] > 0)
1142      {
1143          // Only those with "canviewwolinvis" permissions can view invisible users
1144          if($user['invisible'] != 1 || $mybb->usergroup['canviewwolinvis'] == 1 || $user['uid'] == $mybb->user['uid'])
1145          {
1146              // Append an invisible mark if the user is invisible
1147              if($user['invisible'] == 1)
1148              {
1149                  $invisible_mark = "*";
1150              }
1151              else
1152              {
1153                  $invisible_mark = '';
1154              }
1155  
1156              $user['username'] = format_name(htmlspecialchars_uni($user['username']), $user['usergroup'], $user['displaygroup']);
1157              $online_name = build_profile_link($user['username'], $user['uid']).$invisible_mark;
1158          }
1159      }
1160      // We have a bot
1161      elseif(!empty($user['bot']))
1162      {
1163          $online_name = format_name($user['bot'], $user['usergroup']);
1164      }
1165      // Otherwise we've got a plain old guest
1166      else
1167      {
1168          $online_name = format_name($lang->guest, 1);
1169      }
1170  
1171      $online_time = my_date('relative', $user['time']);
1172  
1173      // Fetch the location name for this users activity
1174      $location = build_friendly_wol_location($user['activity']);
1175  
1176      // Can view IPs, then fetch the IP template
1177      if($mybb->usergroup['canviewonlineips'] == 1)
1178      {
1179          $user['ip'] = my_inet_ntop($db->unescape_binary($user['ip']));
1180  
1181          if($mybb->usergroup['canmodcp'] == 1 && $mybb->usergroup['canuseipsearch'] == 1)
1182          {
1183              eval("\$lookup = \"".$templates->get("online_row_ip_lookup")."\";");
1184          }
1185  
1186          eval("\$user_ip = \"".$templates->get("online_row_ip")."\";");
1187      }
1188      else
1189      {
1190          $user_ip = $lookup = $user['ip'] = '';
1191      }
1192  
1193      $online_row = '';
1194      // And finally if we have permission to view this user, return the completed online row
1195      if($user['invisible'] != 1 || $mybb->usergroup['canviewwolinvis'] == 1 || $user['uid'] == $mybb->user['uid'])
1196      {
1197          eval("\$online_row = \"".$templates->get("online_row")."\";");
1198      }
1199      return $online_row;
1200  }


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