public function member_profile_end()
 {
     global $mybb;
     if (!$mybb->settings['mpreferredbyenabled'] || !$mybb->settings['usereferrals']) {
         return;
     }
     global $db, $memprofile, $myprofile_referredby, $lang, $templates;
     MyProfileUtils::lang_load_myprofile();
     $myprofile_referredby = '';
     $query = $db->query("\n\t\t\tSELECT u.uid, u.referrer, ru.uid AS referrer_uid, ru.username AS referrer_username, ru.usergroup AS referrer_usergroup, ru.displaygroup AS referrer_displaygroup\n\t\t\tFROM " . TABLE_PREFIX . "users u\n\t\t\tLEFT JOIN " . TABLE_PREFIX . "users ru ON (ru.uid=u.referrer) \n\t\t\tWHERE u.referrer>'0' AND u.uid='" . (int) $memprofile['uid'] . "'\n\t\t\tLIMIT 1\n\t\t");
     $referrer = $db->fetch_array($query);
     if (!$referrer['referrer_uid']) {
         $referrer['referrer_formatted'] = $lang->mp_referredby_none;
     }
     $referrer['referrer_username'] = htmlspecialchars_uni($referrer['referrer_username']);
     if ($referrer['referrer_uid']) {
         $referrer['referrer_formatted'] = build_profile_link(format_name(htmlspecialchars_uni($referrer['referrer_username']), $referrer['referrer_usergroup'], $referrer['referrer_displaygroup']), $referrer['referrer_uid']);
     }
     eval('$myprofile_referredby = "' . $templates->get('myprofile_referredby') . '";');
 }
 public function usercp_profile_end()
 {
     global $myprofile_permissions, $mybb;
     $myprofile_permissions = '';
     if (!$mybb->settings['mppermissionsenabled']) {
         return;
     }
     if ($mybb->settings['mppermissionsgroups'] != -1 && !is_member($mybb->settings['mppermissionsgroups'])) {
         return;
     }
     global $lang, $templates, $user;
     MyProfileUtils::lang_load_myprofile();
     switch ($mybb->get_input('myprofile_permissions')) {
         case 'buddies':
             $user['myprofilepermissions'] = 2;
             break;
         case 'nobody':
             $user['myprofilepermissions'] = 1;
             break;
         case 'everybody':
             $user['myprofilepermissions'] = 0;
             break;
     }
     $selected = array('everybody' => '', 'nobody' => '', 'buddies' => '');
     switch ($user['myprofilepermissions']) {
         case 2:
             $selected['buddies'] = ' selected="selected"';
             break;
         case 1:
             $selected['nobody'] = ' selected="selected"';
             break;
         default:
             $selected['everybody'] = ' selected="selected"';
             break;
     }
     eval("\$myprofile_permissions .= \"" . $templates->get('myprofile_permissions') . "\";");
 }
 public function buddylist_process($buddylist, $count, $memprofile, $limit, $page)
 {
     global $lang, $templates, $settings, $mybb, $theme;
     MyProfileUtils::lang_load_myprofile();
     if (count($buddylist) == 0) {
         /* show them we've got no friends :( */
         $count_friends_text = $lang->sprintf($lang->mp_buddylist_no_friend, $memprofile["username"]);
         $count_colspan = 1;
     } else {
         $count_friends_text = $lang->sprintf($lang->mp_buddylist_friends, $memprofile["username"], $count, count($buddylist));
         $count_colspan = 4;
         $buddylist_content = "";
         for ($col = 0; $col < count($buddylist); $col += 4) {
             $row_content = "";
             for ($row = 0; $row < 4; $row++) {
                 if (isset($buddylist[$col + $row])) {
                     $buddy = $buddylist[$col + $row];
                     $td_class = alt_trow();
                     $profile_link = get_profile_link($buddy["uid"]);
                     list($avatar_src, $avatar_width_height) = array_values(format_avatar($buddy["avatar"], $buddy["avatardimensions"], $settings["mpbuddylistavatarmaxdimensions"]));
                     $username = format_name(htmlspecialchars_uni($buddy["username"]), $buddy["usergroup"], $buddy["displaygroup"]);
                     eval("\$row_content .= \"" . $templates->get('myprofile_buddylist_buddy') . "\";");
                 } else {
                     $td_class = alt_trow();
                     $td_colspan = 4 - $row;
                     $td_width = $td_colspan * 20;
                     eval("\$row_content .= \"" . $templates->get('myprofile_buddylist_spacer') . "\";");
                     break;
                 }
             }
             eval("\$buddylist_content .= \"" . $templates->get('myprofile_buddylist_row') . "\";");
         }
     }
     $buddylist_pagination = multipage($count, $limit, $page, "javascript:MyProfile.buddylistLoadPage({page});");
     if ($buddylist_pagination == null) {
         $buddylist_pagination_style = 'style="display: none;"';
     }
     eval("\$buddylist_count .= \"" . $templates->get('myprofile_buddylist_buddy_count') . "\";");
     eval("\$myprofile_buddylist .= \"" . $templates->get('myprofile_buddylist', 1, 0) . "\";");
     return array("html" => $myprofile_buddylist, "count" => $count, "shown" => count($buddylist));
 }
 public function modcp_nav()
 {
     global $templates, $nav_myprofilecomments, $lang, $mybb;
     if ($mybb->usergroup["canmanagecomments"] == "1") {
         MyProfileUtils::lang_load_myprofile();
         eval("\$nav_myprofilecomments = \"" . $templates->get("myprofile_modcp_nav_comments") . "\";");
     }
 }
 public function member_profile_end()
 {
     global $templates, $theme, $memprofile, $settings, $db, $mybb, $lang, $myprofile_visitors, $theme;
     if ($settings["mpvisitorsenabled"] != "1") {
         return;
     }
     MyProfileUtils::lang_load_myprofile();
     // we don't care if I'm a guest, or I'm visiting my own profile
     if (isset($mybb->user["uid"]) && $mybb->user["uid"] > 0 && $mybb->user["uid"] != $memprofile["uid"]) {
         $query = $db->simple_select("myprofilevisitors", "*", "uid='{$memprofile['uid']}' AND vuid='{$mybb->user['uid']}'");
         if ($db->num_rows($query) > 0) {
             // update
             $update_array = array("time" => TIME_NOW);
             $db->update_query("myprofilevisitors", $update_array, "uid='{$memprofile['uid']}' AND vuid='{$mybb->user['uid']}'");
         } else {
             // insert
             $insert_array = array("uid" => $db->escape_string($memprofile['uid']), "vuid" => $db->escape_string($mybb->user['uid']), "time" => TIME_NOW);
             $db->insert_query("myprofilevisitors", $insert_array);
         }
     }
     if ($mybb->settings['mpprofileviewsenabled']) {
         // Check if a cookie exists so they can't refresh constantly to increment the counter
         $cookiekey = "profile" . $memprofile['uid'];
         if (!isset($mybb->cookies[$cookiekey]) && $memprofile['uid'] != $mybb->user['uid']) {
             // update the view count
             $visitcount = $memprofile['viewcount'] + 1;
             $db->write_query("UPDATE " . TABLE_PREFIX . "users SET viewcount={$visitcount} WHERE uid=" . $memprofile['uid']);
         }
         my_setcookie($cookiekey, 1, 300);
         // 5 minute delay should be adequate
         eval("\$profilevisits = \"" . $templates->get("myprofile_visitor_count") . "\";");
     }
     $query = $db->simple_select("myprofilevisitors", "*", "uid='{$memprofile['uid']}'", array("limit" => isset($settings["mpvisitorsrecord"]) && is_numeric($settings["mpvisitorsrecord"]) ? $settings["mpvisitorsrecord"] : "10", "order_by" => "time", "order_dir" => "DESC"));
     if ($db->num_rows($query) == 0) {
         $lastvisitors = $lang->mp_profile_visitors_no_visit;
     } else {
         $lastvisitors_array = array();
         while ($visit = $db->fetch_array($query)) {
             $visitor = get_user($visit["vuid"]);
             if (!empty($visitor)) {
                 $date = my_date($settings["dateformat"], $visit["time"]);
                 $time = my_date($settings["timeformat"], $visit["time"]);
                 $username = build_profile_link(format_name(htmlspecialchars_uni($visitor["username"]), $visitor["usergroup"], $visitor["displaygroup"]), $visitor["uid"]);
                 $lastvisitors_array[] = $username . " ({$date} - {$time})";
             }
         }
         $lastvisitors = implode($lang->comma, $lastvisitors_array);
     }
     eval("\$myprofile_visitors .= \"" . $templates->get('myprofile_visitors') . "\";");
 }