Ejemplo n.º 1
0
 /**
  * Get feedback items assigned to this user
  * @since Version 3.9
  * @return array
  */
 public function getAssignedItems()
 {
     if (!$this->Staff instanceof User) {
         throw new Exception("You must assign a valid User object before fetching assigned feedback items");
     }
     $query = "SELECT f.*, fs.name AS status_text, fa.feedback_title AS area_text\r\n                FROM feedback AS f \r\n                INNER JOIN feedback_status AS fs ON f.status = fs.id\r\n                INNER JOIN feedback_area AS fa ON f.area = fa.feedback_id\r\n                WHERE f.assigned_to = ?\r\n                ORDER BY f.time DESC";
     $return = array();
     foreach ($this->db->fetchAll($query, $this->Staff->id) as $row) {
         $date = new DateTime(sprintf("@%s", $row['time']));
         $data = array("id" => $row['id'], "message" => $row['message'], "date" => array("absolute" => $date->format("Y-m-d H:i:s"), "relative" => time2str($row['time'])), "area" => array("id" => $row['area'], "text" => $row['area_text']), "status" => array("id" => $row['status'], "text" => $row['status_text']), "author" => array("id" => false, "username" => false, "realname" => false, "email" => $row['email']));
         if (filter_var($row['user_id'], FILTER_VALIDATE_INT) && $row['user_id'] > 0) {
             $Author = new User($row['user_id']);
             $data['author']['id'] = $Author->id;
             $data['author']['username'] = $Author->username;
             $data['author']['realname'] = $Author->real_name;
             $data['author']['url'] = $Author->url->url;
             $data['author']['avatar'] = array("large" => format_avatar($Author->avatar, 120), "small" => format_avatar($Author->avatar, 40));
         }
         $return[] = $data;
     }
     return $return;
 }
Ejemplo n.º 2
0
 /**
  * Validate user avatar
  * @since Version 3.9.1
  * @return \Railpage\Users\User
  *
  * @param boolean $force
  */
 public function validateAvatar($force = false)
 {
     if (!empty($this->avatar)) {
         if ($force || (empty($this->avatar_width) || empty($this->avatar_height) || $this->avatar_width == 0 || $this->avatar_height == 0)) {
             if ($size = @getimagesize($this->avatar)) {
                 $Config = AppCore::getConfig();
                 if ($size[0] >= $Config->AvatarMaxWidth || $size[1] >= $Config->AvatarMaxHeight) {
                     $this->avatar = sprintf("https://static.railpage.com.au/image_resize.php?w=%d&h=%d&image=%s", $Config->AvatarMaxWidth, $Config->AvatarMaxHeight, urlencode($this->avatar));
                     $this->avatar_filename = $this->avatar;
                     $this->avatar_width = $size[0];
                     $this->avatar_height = $size[1];
                 } else {
                     $this->avatar_width = $size[0];
                     $this->avatar_height = $size[1];
                     $this->avatar_filename = $this->avatar;
                 }
                 $this->commit(true);
                 return $this;
             }
         }
     }
     $this->avatar = function_exists("format_avatar") ? format_avatar("http://static.railpage.com.au/modules/Forums/images/avatars/gallery/blank.png", 120, 120) : "http://static.railpage.com.au/modules/Forums/images/avatars/gallery/blank.png";
     $this->avatar_filename = function_exists("format_avatar") ? format_avatar("http://static.railpage.com.au/modules/Forums/images/avatars/gallery/blank.png", 120, 120) : "http://static.railpage.com.au/modules/Forums/images/avatars/gallery/blank.png";
     $this->avatar_width = 120;
     $this->avatar_height = 120;
     return $this;
 }
Ejemplo n.º 3
0
 public function comment_process($comment, $memprofile)
 {
     global $templates, $cache, $settings, $mybb, $lang;
     MyProfileUtils::lang_load_myprofile();
     $usergroups = $cache->read("usergroups");
     $editable = $this->can_edit_comment($comment);
     $approvable = $this->can_approve_comment($comment);
     $deletable = $this->can_delete_comment($comment);
     /* replyable: well, it's replyable if I'm memprofile, and I'm trying to send a comment to the commentor (but I am not the commentor, otherwise it will be an infinite loop) */
     $replyable = $mybb->user["uid"] == $memprofile["uid"] && $comment["cuid"] != $comment["userid"] && $this->can_send_comments($memprofile, $comment);
     $reportable = $this->can_report_comment($comment);
     /* now we add html content to the comment */
     list($avatar_src, $avatar_width_height) = array_values(format_avatar($comment["avatar"], $comment["avatardimensions"]));
     $date = my_date($settings["dateformat"], $comment["time"]);
     $time = my_date($settings["timeformat"], $comment["time"]);
     $username = format_name(htmlspecialchars_uni($comment["username"]), $comment["usergroup"], $comment["displaygroup"]);
     $profile_link = build_profile_link($username, $comment["cuid"]);
     $message = $this->parse_comment($comment["message"]);
     if ($editable) {
         eval("\$comments_edit = \"" . $templates->get('myprofile_comments_comment_edit') . "\";");
     }
     if ($approvable) {
         $trow_class = "trow_shaded";
         eval("\$comments_approve = \"" . $templates->get('myprofile_comments_comment_approve') . "\";");
     }
     if ($deletable) {
         eval("\$comments_delete = \"" . $templates->get('myprofile_comments_comment_delete') . "\";");
     }
     if ($replyable) {
         $commentor_uid = $comment["cuid"];
         eval("\$comments_reply = \"" . $templates->get('myprofile_comments_comment_reply') . "\";");
     }
     if ($reportable) {
         eval("\$comments_report = \"" . $templates->get('myprofile_comments_comment_report') . "\";");
     }
     if ($comment["isprivate"] == "1") {
         $comment_private = $lang->mp_comments_comment_private;
     }
     if (isset($mybb->input["highlight"]) && $mybb->input["highlight"] == $comment["cid"]) {
         $trow_class = "trow_selected";
     }
     /* last eval() */
     eval("\$comment_content = \"" . $templates->get('myprofile_comments_comment') . "\";");
     //$comment["html"] = $comment_content;
     return $comment_content;
 }
Ejemplo n.º 4
0
/**
 * Build a post bit
 *
 * @param array $post The post data
 * @param int $post_type The type of post bit we're building (1 = preview, 2 = pm, 3 = announcement, else = post)
 * @return string The built post bit
 */
function build_postbit($post, $post_type = 0)
{
    global $db, $altbg, $theme, $mybb, $postcounter, $profile_fields;
    global $titlescache, $page, $templates, $forumpermissions, $attachcache;
    global $lang, $ismod, $inlinecookie, $inlinecount, $groupscache, $fid;
    global $plugins, $parser, $cache, $ignored_users, $hascustomtitle;
    $hascustomtitle = 0;
    // Set default values for any fields not provided here
    foreach (array('pid', 'aid', 'pmid', 'posturl', 'button_multiquote', 'subject_extra', 'attachments', 'button_rep', 'button_warn', 'button_purgespammer', 'button_pm', 'button_pubkey', 'button_reply_pm', 'button_replyall_pm', 'button_forward_pm', 'button_delete_pm', 'replink', 'warninglevel') as $post_field) {
        if (empty($post[$post_field])) {
            $post[$post_field] = '';
        }
    }
    // Set up the message parser if it doesn't already exist.
    if (!$parser) {
        require_once MYBB_ROOT . "inc/class_parser.php";
        $parser = new postParser();
    }
    if (!function_exists("purgespammer_show")) {
        require_once MYBB_ROOT . "inc/functions_user.php";
    }
    $unapproved_shade = '';
    if (isset($post['visible']) && $post['visible'] == 0 && $post_type == 0) {
        $altbg = $unapproved_shade = 'unapproved_post';
    } elseif (isset($post['visible']) && $post['visible'] == -1 && $post_type == 0) {
        $altbg = $unapproved_shade = 'unapproved_post deleted_post';
    } elseif ($altbg == 'trow1') {
        $altbg = 'trow2';
    } else {
        $altbg = 'trow1';
    }
    $post['fid'] = $fid;
    switch ($post_type) {
        case 1:
            // Message preview
            global $forum;
            $parser_options['allow_html'] = $forum['allowhtml'];
            $parser_options['allow_mycode'] = $forum['allowmycode'];
            $parser_options['allow_smilies'] = $forum['allowsmilies'];
            $parser_options['allow_imgcode'] = $forum['allowimgcode'];
            $parser_options['allow_videocode'] = $forum['allowvideocode'];
            $parser_options['me_username'] = $post['username'];
            $parser_options['filter_badwords'] = 1;
            $id = 0;
            break;
        case 2:
            // Private message
            global $message, $pmid;
            $idtype = 'pmid';
            $parser_options['allow_html'] = $mybb->settings['pmsallowhtml'];
            $parser_options['allow_mycode'] = $mybb->settings['pmsallowmycode'];
            $parser_options['allow_smilies'] = $mybb->settings['pmsallowsmilies'];
            $parser_options['allow_imgcode'] = $mybb->settings['pmsallowimgcode'];
            $parser_options['allow_videocode'] = $mybb->settings['pmsallowvideocode'];
            $parser_options['me_username'] = $post['username'];
            $parser_options['filter_badwords'] = 1;
            $id = $pmid;
            break;
        case 3:
            // Announcement
            global $announcementarray, $message;
            $parser_options['allow_html'] = $announcementarray['allowhtml'];
            $parser_options['allow_mycode'] = $announcementarray['allowmycode'];
            $parser_options['allow_smilies'] = $announcementarray['allowsmilies'];
            $parser_options['allow_imgcode'] = 1;
            $parser_options['allow_videocode'] = 1;
            $parser_options['me_username'] = $post['username'];
            $parser_options['filter_badwords'] = 1;
            $id = $announcementarray['aid'];
            break;
        default:
            // Regular post
            global $forum, $thread, $tid;
            $oldforum = $forum;
            $id = (int) $post['pid'];
            $idtype = 'pid';
            $parser_options['allow_html'] = $forum['allowhtml'];
            $parser_options['allow_mycode'] = $forum['allowmycode'];
            $parser_options['allow_smilies'] = $forum['allowsmilies'];
            $parser_options['allow_imgcode'] = $forum['allowimgcode'];
            $parser_options['allow_videocode'] = $forum['allowvideocode'];
            $parser_options['filter_badwords'] = 1;
            if (!$post['username']) {
                $post['username'] = $lang->guest;
            }
            if ($post['userusername']) {
                $parser_options['me_username'] = $post['userusername'];
            } else {
                $parser_options['me_username'] = $post['username'];
            }
            break;
    }
    if (!$postcounter) {
        // Used to show the # of the post
        if ($page > 1) {
            if (!$mybb->settings['postsperpage'] || (int) $mybb->settings['postsperpage'] < 1) {
                $mybb->settings['postsperpage'] = 20;
            }
            $postcounter = $mybb->settings['postsperpage'] * ($page - 1);
        } else {
            $postcounter = 0;
        }
        $post_extra_style = "border-top-width: 0;";
    } elseif ($mybb->input['mode'] == "threaded") {
        $post_extra_style = "border-top-width: 0;";
    } else {
        $post_extra_style = "margin-top: 5px;";
    }
    if (!$altbg) {
        // Define the alternate background colour if this is the first post
        $altbg = "trow1";
    }
    $postcounter++;
    // Format the post date and time using my_date
    //$post['postdate'] = my_date('relative', $post['dateline']);
    $post['postdate'] = date('Y-m-d', $post['dateline']);
    // Dont want any little 'nasties' in the subject
    $post['subject'] = $parser->parse_badwords($post['subject']);
    // Pm's have been htmlspecialchars_uni()'ed already.
    if ($post_type != 2) {
        $post['subject'] = htmlspecialchars_uni($post['subject']);
    }
    if (empty($post['subject'])) {
        $post['subject'] = '&nbsp;';
    }
    $post['author'] = $post['uid'];
    $post['subject_title'] = $post['subject'];
    // Get the usergroup
    if ($post['userusername']) {
        if (!$post['displaygroup']) {
            $post['displaygroup'] = $post['usergroup'];
        }
        $usergroup = $groupscache[$post['displaygroup']];
    } else {
        $usergroup = $groupscache[1];
    }
    if (!is_array($titlescache)) {
        $cached_titles = $cache->read("usertitles");
        if (!empty($cached_titles)) {
            foreach ($cached_titles as $usertitle) {
                $titlescache[$usertitle['posts']] = $usertitle;
            }
        }
        if (is_array($titlescache)) {
            krsort($titlescache);
        }
        unset($usertitle, $cached_titles);
    }
    // Work out the usergroup/title stuff
    $post['groupimage'] = '';
    if (!empty($usergroup['image'])) {
        $language = $mybb->settings['bblanguage'];
        if (!empty($mybb->user['language'])) {
            $language = $mybb->user['language'];
        }
        $usergroup['image'] = str_replace("{lang}", $language, $usergroup['image']);
        $usergroup['image'] = str_replace("{theme}", $theme['imgdir'], $usergroup['image']);
        eval("\$post['groupimage'] = \"" . $templates->get("postbit_groupimage") . "\";");
        if ($mybb->settings['postlayout'] == "classic") {
            $post['groupimage'] .= "<br />";
        }
    }
    if ($post['userusername']) {
        // This post was made by a registered user
        $post['username'] = $post['userusername'];
        $post['profilelink_plain'] = get_profile_link($post['uid']);
        $post['username_formatted'] = format_name($post['username'], $post['usergroup'], $post['displaygroup']);
        $post['profilelink'] = build_profile_link($post['username_formatted'], $post['uid']);
        if (trim($post['usertitle']) != "") {
            $hascustomtitle = 1;
        }
        if ($usergroup['usertitle'] != "" && !$hascustomtitle) {
            $post['usertitle'] = $usergroup['usertitle'];
        } elseif (is_array($titlescache) && !$usergroup['usertitle']) {
            reset($titlescache);
            foreach ($titlescache as $key => $titleinfo) {
                if ($post['postnum'] >= $key) {
                    if (!$hascustomtitle) {
                        $post['usertitle'] = $titleinfo['title'];
                    }
                    $post['stars'] = $titleinfo['stars'];
                    $post['starimage'] = $titleinfo['starimage'];
                    break;
                }
            }
        }
        $post['usertitle'] = htmlspecialchars_uni($post['usertitle']);
        if ($usergroup['stars']) {
            $post['stars'] = $usergroup['stars'];
        }
        if (empty($post['starimage'])) {
            $post['starimage'] = $usergroup['starimage'];
        }
        if ($post['starimage'] && $post['stars']) {
            // Only display stars if we have an image to use...
            $post['starimage'] = str_replace("{theme}", $theme['imgdir'], $post['starimage']);
            $post['userstars'] = '';
            for ($i = 0; $i < $post['stars']; ++$i) {
                eval("\$post['userstars'] .= \"" . $templates->get("postbit_userstar", 1, 0) . "\";");
            }
            $post['userstars'] .= "<br />";
        }
        $postnum = $post['postnum'];
        $post['postnum'] = my_number_format($post['postnum']);
        $post['threadnum'] = my_number_format($post['threadnum']);
        // Determine the status to show for the user (Online/Offline/Away)
        /*
        $timecut = TIME_NOW - $mybb->settings['wolcutoff'];
        if($post['lastactive'] > $timecut && ($post['invisible'] != 1 || $mybb->usergroup['canviewwolinvis'] == 1) && $post['lastvisit'] != $post['lastactive'])
        {
        	eval("\$post['onlinestatus'] = \"".$templates->get("postbit_online")."\";");
        }
        else
        {
        	if($post['away'] == 1 && $mybb->settings['allowaway'] != 0)
        	{
        		eval("\$post['onlinestatus'] = \"".$templates->get("postbit_away")."\";");
        	}
        	else
        	{
        		eval("\$post['onlinestatus'] = \"".$templates->get("postbit_offline")."\";");
        	}
        }
        */
        // Show as always offline
        eval("\$post['onlinestatus'] = \"" . $templates->get("postbit_offline") . "\";");
        $post['useravatar'] = '';
        if (isset($mybb->user['showavatars']) && $mybb->user['showavatars'] != 0 || $mybb->user['uid'] == 0) {
            $useravatar = format_avatar($post['avatar'], $post['avatardimensions'], $mybb->settings['postmaxavatarsize']);
            eval("\$post['useravatar'] = \"" . $templates->get("postbit_avatar") . "\";");
        }
        $post['button_find'] = '';
        if ($mybb->usergroup['cansearch'] == 1) {
            eval("\$post['button_find'] = \"" . $templates->get("postbit_find") . "\";");
        }
        if ($mybb->settings['enablepms'] == 1 && $post['receivepms'] != 0 && $mybb->usergroup['cansendpms'] == 1 && my_strpos("," . $post['ignorelist'] . ",", "," . $mybb->user['uid'] . ",") === false) {
            //eval("\$post['button_pm'] = \"".$templates->get("postbit_pm")."\";");
        }
        $post['button_rep'] = '';
        if ($post_type != 3 && $mybb->settings['enablereputation'] == 1 && $mybb->settings['postrep'] == 1 && $mybb->usergroup['cangivereputations'] == 1 && $usergroup['usereputationsystem'] == 1 && ($mybb->settings['posrep'] || $mybb->settings['neurep'] || $mybb->settings['negrep']) && $post['uid'] != $mybb->user['uid'] && $post['visible'] == 1) {
            if (!$post['pid']) {
                $post['pid'] = 0;
            }
            eval("\$post['button_rep'] = \"" . $templates->get("postbit_rep_button") . "\";");
        }
        if ($post['website'] != "" && !is_member($mybb->settings['hidewebsite']) && $usergroup['canchangewebsite'] == 1) {
            $post['website'] = htmlspecialchars_uni($post['website']);
            eval("\$post['button_www'] = \"" . $templates->get("postbit_www") . "\";");
        } else {
            $post['button_www'] = "";
        }
        if ($post['hideemail'] != 1 && $mybb->usergroup['cansendemail'] == 1) {
            eval("\$post['button_email'] = \"" . $templates->get("postbit_email") . "\";");
        } else {
            $post['button_email'] = "";
        }
        $post['userregdate'] = $lang->na;
        //my_date($mybb->settings['regdateformat'], $post['regdate']);
        // Work out the reputation this user has (only show if not announcement)
        if ($post_type != 3 && $usergroup['usereputationsystem'] != 0 && $mybb->settings['enablereputation'] == 1) {
            $post['userreputation'] = get_reputation($post['reputation'], $post['uid']);
            eval("\$post['replink'] = \"" . $templates->get("postbit_reputation") . "\";");
        }
        // Showing the warning level? (only show if not announcement)
        if ($post_type != 3 && $mybb->settings['enablewarningsystem'] != 0 && $usergroup['canreceivewarnings'] != 0 && ($mybb->usergroup['canwarnusers'] != 0 || $mybb->user['uid'] == $post['uid'] && $mybb->settings['canviewownwarning'] != 0)) {
            if ($mybb->settings['maxwarningpoints'] < 1) {
                $mybb->settings['maxwarningpoints'] = 10;
            }
            $warning_level = round($post['warningpoints'] / $mybb->settings['maxwarningpoints'] * 100);
            if ($warning_level > 100) {
                $warning_level = 100;
            }
            $warning_level = get_colored_warning_level($warning_level);
            // If we can warn them, it's not the same person, and we're in a PM or a post.
            if ($mybb->usergroup['canwarnusers'] != 0 && $post['uid'] != $mybb->user['uid'] && ($post_type == 0 || $post_type == 2)) {
                eval("\$post['button_warn'] = \"" . $templates->get("postbit_warn") . "\";");
                $warning_link = "warnings.php?uid={$post['uid']}";
            } else {
                $post['button_warn'] = '';
                $warning_link = "usercp.php";
            }
            eval("\$post['warninglevel'] = \"" . $templates->get("postbit_warninglevel") . "\";");
        }
        if ($post_type != 3 && $post_type != 1 && purgespammer_show($post['postnum'], $post['usergroup'], $post['uid'])) {
            eval("\$post['button_purgespammer'] = \"" . $templates->get('postbit_purgespammer') . "\";");
        }
        // Display profile fields on posts - only if field is filled in
        if (is_array($profile_fields)) {
            foreach ($profile_fields as $field) {
                $fieldfid = "fid{$field['fid']}";
                if (!empty($post[$fieldfid])) {
                    $post['fieldvalue'] = '';
                    $post['fieldname'] = htmlspecialchars_uni($field['name']);
                    $thing = explode("\n", $field['type'], "2");
                    $type = trim($thing[0]);
                    $useropts = explode("\n", $post[$fieldfid]);
                    if (is_array($useropts) && ($type == "multiselect" || $type == "checkbox")) {
                        foreach ($useropts as $val) {
                            if ($val != '') {
                                eval("\$post['fieldvalue_option'] .= \"" . $templates->get("postbit_profilefield_multiselect_value") . "\";");
                            }
                        }
                        if ($post['fieldvalue_option'] != '') {
                            eval("\$post['fieldvalue'] .= \"" . $templates->get("postbit_profilefield_multiselect") . "\";");
                        }
                    } else {
                        $field_parser_options = array("allow_html" => $field['allowhtml'], "allow_mycode" => $field['allowmycode'], "allow_smilies" => $field['allowsmilies'], "allow_imgcode" => $field['allowimgcode'], "allow_videocode" => $field['allowvideocode'], "filter_badwords" => 1);
                        if ($customfield['type'] == "textarea") {
                            $field_parser_options['me_username'] = $post['username'];
                        } else {
                            $field_parser_options['nl2br'] = 0;
                        }
                        if ($mybb->user['showimages'] != 1 && $mybb->user['uid'] != 0 || $mybb->settings['guestimages'] != 1 && $mybb->user['uid'] == 0) {
                            $field_parser_options['allow_imgcode'] = 0;
                        }
                        $post['fieldvalue'] = $parser->parse_message($post[$fieldfid], $field_parser_options);
                    }
                    eval("\$post['profilefield'] .= \"" . $templates->get("postbit_profilefield") . "\";");
                }
            }
        }
        eval("\$post['user_details'] = \"" . $templates->get("postbit_author_user") . "\";");
    } else {
        // Message was posted by a guest or an unknown user
        $post['profilelink'] = format_name($post['username'], 1);
        if ($usergroup['usertitle']) {
            $post['usertitle'] = $usergroup['usertitle'];
        } else {
            $post['usertitle'] = $lang->guest;
        }
        $post['usertitle'] = htmlspecialchars_uni($post['usertitle']);
        $usergroup['title'] = $lang->na;
        $post['userregdate'] = $lang->na;
        $post['postnum'] = $lang->na;
        $post['button_profile'] = '';
        $post['button_email'] = '';
        $post['button_www'] = '';
        $post['signature'] = '';
        $post['button_pm'] = $lang->na;
        $post['button_find'] = '';
        $post['onlinestatus'] = '';
        $post['replink'] = '';
        eval("\$post['user_details'] = \"" . $templates->get("postbit_author_guest") . "\";");
    }
    $post['button_edit'] = '';
    $post['button_quickdelete'] = '';
    $post['button_quickrestore'] = '';
    $post['button_quote'] = '';
    $post['button_quickquote'] = '';
    $post['button_report'] = '';
    $post['button_reply_pm'] = '';
    $post['button_replyall_pm'] = '';
    $post['button_forward_pm'] = '';
    $post['button_delete_pm'] = '';
    // For private messages, fetch the reply/forward/delete icons
    if ($post_type == 2 && $post['pmid']) {
        global $replyall;
        eval("\$post['button_reply_pm'] = \"" . $templates->get("postbit_reply_pm") . "\";");
        eval("\$post['button_forward_pm'] = \"" . $templates->get("postbit_forward_pm") . "\";");
        eval("\$post['button_delete_pm'] = \"" . $templates->get("postbit_delete_pm") . "\";");
        if ($replyall == true) {
            eval("\$post['button_replyall_pm'] = \"" . $templates->get("postbit_replyall_pm") . "\";");
        }
    }
    $post['editedmsg'] = '';
    if (!$post_type) {
        // Figure out if we need to show an "edited by" message
        if ($post['edituid'] != 0 && $post['edittime'] != 0 && $post['editusername'] != "" && ($mybb->settings['showeditedby'] != 0 && $usergroup['cancp'] == 0 || $mybb->settings['showeditedbyadmin'] != 0 && $usergroup['cancp'] == 1)) {
            //$post['editdate'] = my_date('relative', $post['edittime']);
            $post['editdate'] = $lang->na;
            $post['editnote'] = $lang->sprintf($lang->postbit_edited, $post['editdate']);
            $post['editedprofilelink'] = build_profile_link($post['editusername'], $post['edituid']);
            $editreason = "";
            if ($post['editreason'] != "") {
                $post['editreason'] = $parser->parse_badwords($post['editreason']);
                $post['editreason'] = htmlspecialchars_uni($post['editreason']);
                eval("\$editreason = \"" . $templates->get("postbit_editedby_editreason") . "\";");
            }
            eval("\$post['editedmsg'] = \"" . $templates->get("postbit_editedby") . "\";");
        }
        $time = TIME_NOW;
        if (is_moderator($fid, "caneditposts") || $forumpermissions['caneditposts'] == 1 && $mybb->user['uid'] == $post['uid'] && $thread['closed'] != 1 && $mybb->usergroup['edittimelimit'] == 0 && $mybb->user['uid'] != 0) {
            eval("\$post['button_edit'] = \"" . $templates->get("postbit_edit") . "\";");
        }
        // Quick Delete button
        $can_delete_thread = $can_delete_post = 0;
        if ($mybb->user['uid'] == $post['uid'] && $thread['closed'] == 0) {
            if ($forumpermissions['candeletethreads'] == 1 && $postcounter == 1) {
                $can_delete_thread = 1;
            } else {
                if ($forumpermissions['candeleteposts'] == 1 && $postcounter != 1) {
                    $can_delete_post = 1;
                }
            }
        }
        $postbit_qdelete = $postbit_qrestore = '';
        if ($mybb->user['uid'] != 0) {
            if ((is_moderator($fid, "candeleteposts") || is_moderator($fid, "cansoftdeleteposts") || $can_delete_post == 1) && $postcounter != 1) {
                $postbit_qdelete = $lang->postbit_qdelete_post;
                $display = '';
                if ($post['visible'] == -1) {
                    $display = "none";
                }
                eval("\$post['button_quickdelete'] = \"" . $templates->get("postbit_quickdelete") . "\";");
            } else {
                if ((is_moderator($fid, "candeletethreads") || is_moderator($fid, "cansoftdeletethreads") || $can_delete_thread == 1) && $postcounter == 1) {
                    $postbit_qdelete = $lang->postbit_qdelete_thread;
                    $display = '';
                    if ($post['visible'] == -1) {
                        $display = "none";
                    }
                    eval("\$post['button_quickdelete'] = \"" . $templates->get("postbit_quickdelete") . "\";");
                }
            }
            // Restore Post
            if (is_moderator($fid, "canrestoreposts") && $postcounter != 1) {
                $display = "none";
                if ($post['visible'] == -1) {
                    $display = '';
                }
                $postbit_qrestore = $lang->postbit_qrestore_post;
                eval("\$post['button_quickrestore'] = \"" . $templates->get("postbit_quickrestore") . "\";");
            } else {
                if (is_moderator($fid, "canrestorethreads") && $postcounter == 1) {
                    $display = "none";
                    if ($post['visible'] == -1) {
                        $display = "";
                    }
                    $postbit_qrestore = $lang->postbit_qrestore_thread;
                    eval("\$post['button_quickrestore'] = \"" . $templates->get("postbit_quickrestore") . "\";");
                }
            }
        }
        // Inline moderation stuff
        if ($ismod) {
            if (isset($mybb->cookies[$inlinecookie]) && my_strpos($mybb->cookies[$inlinecookie], "|" . $post['pid'] . "|")) {
                $inlinecheck = "checked=\"checked\"";
                $inlinecount++;
            } else {
                $inlinecheck = "";
            }
            eval("\$post['inlinecheck'] = \"" . $templates->get("postbit_inlinecheck") . "\";");
            if ($post['visible'] == 0) {
                $invisiblepost = 1;
            }
        } else {
            $post['inlinecheck'] = "";
        }
        $post['postlink'] = get_post_link($post['pid'], $post['tid']);
        $post_number = my_number_format($postcounter);
        eval("\$post['posturl'] = \"" . $templates->get("postbit_posturl") . "\";");
        global $forum, $thread;
        if ($forum['open'] != 0 && ($thread['closed'] != 1 || is_moderator($forum['fid'], "canpostclosedthreads")) && ($thread['uid'] == $mybb->user['uid'] || $forumpermissions['canonlyreplyownthreads'] != 1)) {
            eval("\$post['button_quote'] = \"" . $templates->get("postbit_quote") . "\";");
        }
        if ($forumpermissions['canpostreplys'] != 0 && ($thread['uid'] == $mybb->user['uid'] || $forumpermissions['canonlyreplyownthreads'] != 1) && ($thread['closed'] != 1 || is_moderator($fid, "canpostclosedthreads")) && $mybb->settings['multiquote'] != 0 && $forum['open'] != 0 && !$post_type) {
            eval("\$post['button_multiquote'] = \"" . $templates->get("postbit_multiquote") . "\";");
        }
        if ($mybb->user['uid'] != "0") {
            eval("\$post['button_report'] = \"" . $templates->get("postbit_report") . "\";");
        }
    } elseif ($post_type == 3) {
        if ($mybb->usergroup['canmodcp'] == 1 && $mybb->usergroup['canmanageannounce'] == 1 && is_moderator($fid, "canmanageannouncements")) {
            eval("\$post['button_edit'] = \"" . $templates->get("announcement_edit") . "\";");
            eval("\$post['button_quickdelete'] = \"" . $templates->get("announcement_quickdelete") . "\";");
        }
    }
    $post['iplogged'] = '';
    $show_ips = $mybb->settings['logip'];
    //$ipaddress = my_inet_ntop($db->unescape_binary($post['ipaddress']));
    $ipaddress = '127.0.0.1';
    // Show post IP addresses... PMs now can have IP addresses too as of 1.8!
    if ($post_type == 2) {
        $show_ips = $mybb->settings['showpmip'];
    }
    if (!$post_type || $post_type == 2) {
        if ($show_ips != "no" && !empty($post['ipaddress'])) {
            if ($show_ips == "show") {
                eval("\$post['iplogged'] = \"" . $templates->get("postbit_iplogged_show") . "\";");
            } else {
                if ($show_ips == "hide" && (is_moderator($fid, "canviewips") || $mybb->usergroup['issupermod'])) {
                    $action = 'getip';
                    if ($post_type == 2) {
                        $action = 'getpmip';
                    }
                    eval("\$post['iplogged'] = \"" . $templates->get("postbit_iplogged_hiden") . "\";");
                }
            }
        }
    }
    if (isset($post['smilieoff']) && $post['smilieoff'] == 1) {
        $parser_options['allow_smilies'] = 0;
    }
    if ($mybb->user['showimages'] != 1 && $mybb->user['uid'] != 0 || $mybb->settings['guestimages'] != 1 && $mybb->user['uid'] == 0) {
        $parser_options['allow_imgcode'] = 0;
    }
    if ($mybb->user['showvideos'] != 1 && $mybb->user['uid'] != 0 || $mybb->settings['guestvideos'] != 1 && $mybb->user['uid'] == 0) {
        $parser_options['allow_videocode'] = 0;
    }
    // If we have incoming search terms to highlight - get it done.
    if (!empty($mybb->input['highlight'])) {
        $parser_options['highlight'] = $mybb->input['highlight'];
        $post['subject'] = $parser->highlight_message($post['subject'], $parser_options['highlight']);
    }
    $post['message'] = $parser->parse_message($post['message'], $parser_options);
    // Validate key
    $keyinfo = user_key_info($post['uid']);
    $post['signstatus'];
    if ($keyinfo['status'] == "OK") {
        $post['signstatus'] = "<span style=\"color: #07a407;\" title=\"Fingerprint: {$keyinfo['fingerprint']}\">✓ podpisano przez {$post['profilelink']}</span>";
    }
    // Jid link
    $ujid = user_jid($post['uid']);
    $post['jidlink'] = $ujid;
    // User key
    $post['userpubkey'] = $keyinfo['key'];
    if ($keyinfo['key'] != "") {
        eval("\$post['button_pubkey'] = \"" . $templates->get("postbit_pubkey") . "\";");
    } else {
        $post['button_pubkey'];
    }
    $post['attachments'] = '';
    if ($mybb->settings['enableattachments'] != 0) {
        get_post_attachments($id, $post);
    }
    if (isset($post['includesig']) && $post['includesig'] != 0 && $post['username'] && $post['signature'] != "" && ($mybb->user['uid'] == 0 || $mybb->user['showsigs'] != 0) && ($post['suspendsignature'] == 0 || $post['suspendsignature'] == 1 && $post['suspendsigtime'] != 0 && $post['suspendsigtime'] < TIME_NOW) && $usergroup['canusesig'] == 1 && ($usergroup['canusesigxposts'] == 0 || $usergroup['canusesigxposts'] > 0 && $postnum > $usergroup['canusesigxposts']) && !is_member($mybb->settings['hidesignatures'])) {
        $sig_parser = array("allow_html" => $mybb->settings['sightml'], "allow_mycode" => $mybb->settings['sigmycode'], "allow_smilies" => $mybb->settings['sigsmilies'], "allow_imgcode" => $mybb->settings['sigimgcode'], "me_username" => $post['username'], "filter_badwords" => 1);
        if ($usergroup['signofollow']) {
            $sig_parser['nofollow_on'] = 1;
        }
        if ($mybb->user['showimages'] != 1 && $mybb->user['uid'] != 0 || $mybb->settings['guestimages'] != 1 && $mybb->user['uid'] == 0) {
            $sig_parser['allow_imgcode'] = 0;
        }
        $post['signature'] = $parser->parse_message($post['signature'], $sig_parser);
        eval("\$post['signature'] = \"" . $templates->get("postbit_signature") . "\";");
    } else {
        $post['signature'] = "";
    }
    $icon_cache = $cache->read("posticons");
    if (isset($post['icon']) && $post['icon'] > 0 && $icon_cache[$post['icon']]) {
        $icon = $icon_cache[$post['icon']];
        $icon['path'] = htmlspecialchars_uni($icon['path']);
        $icon['path'] = str_replace("{theme}", $theme['imgdir'], $icon['path']);
        $icon['name'] = htmlspecialchars_uni($icon['name']);
        eval("\$post['icon'] = \"" . $templates->get("postbit_icon") . "\";");
    } else {
        $post['icon'] = "";
    }
    $post_visibility = $ignore_bit = '';
    switch ($post_type) {
        case 1:
            // Message preview
            $post = $plugins->run_hooks("postbit_prev", $post);
            break;
        case 2:
            // Private message
            $post = $plugins->run_hooks("postbit_pm", $post);
            break;
        case 3:
            // Announcement
            $post = $plugins->run_hooks("postbit_announcement", $post);
            break;
        default:
            // Regular post
            $post = $plugins->run_hooks("postbit", $post);
            // Is this author on the ignore list of the current user? Hide this post
            if (is_array($ignored_users) && $post['uid'] != 0 && isset($ignored_users[$post['uid']]) && $ignored_users[$post['uid']] == 1) {
                $ignored_message = $lang->sprintf($lang->postbit_currently_ignoring_user, $post['username']);
                eval("\$ignore_bit = \"" . $templates->get("postbit_ignored") . "\";");
                $post_visibility = "display: none;";
            }
            break;
    }
    if ($mybb->settings['postlayout'] == "classic") {
        eval("\$postbit = \"" . $templates->get("postbit_classic") . "\";");
    } else {
        eval("\$postbit = \"" . $templates->get("postbit") . "\";");
    }
    $GLOBALS['post'] = "";
    return $postbit;
}
Ejemplo n.º 5
0
     $profilelink = build_profile_link($announcement['username'], $announcement['uid']);
 }
 if (!$announcement['username']) {
     $announcement['username'] = $announcement['threadusername'];
 }
 $announcement['subject'] = htmlspecialchars_uni($parser->parse_badwords($announcement['subject']));
 if ($announcement['icon'] > 0 && $icon_cache[$announcement['icon']]) {
     $icon = $icon_cache[$announcement['icon']];
     $icon['path'] = str_replace("{theme}", $theme['imgdir'], $icon['path']);
     $icon['path'] = htmlspecialchars_uni($icon['path']);
     $icon['name'] = htmlspecialchars_uni($icon['name']);
     eval("\$icon = \"" . $templates->get("portal_announcement_icon") . "\";");
 } else {
     $icon = "&nbsp;";
 }
 $useravatar = format_avatar($announcement['avatar'], $announcement['avatardimensions']);
 eval("\$avatar = \"" . $templates->get("portal_announcement_avatar") . "\";");
 $anndate = my_date('relative', $announcement['dateline']);
 if ($announcement['replies']) {
     eval("\$numcomments = \"" . $templates->get("portal_announcement_numcomments") . "\";");
 } else {
     eval("\$numcomments = \"" . $templates->get("portal_announcement_numcomments_no") . "\";");
     $lastcomment = '';
 }
 $senditem = '';
 if ($mybb->user['uid'] > 0 && $mybb->usergroup['cansendemail'] == 1) {
     eval("\$senditem = \"" . $templates->get("portal_announcement_send_item") . "\";");
 }
 $plugins->run_hooks("portal_announcement");
 $parser_options = array("allow_html" => $forum[$announcement['fid']]['allowhtml'], "allow_mycode" => $forum[$announcement['fid']]['allowmycode'], "allow_smilies" => $forum[$announcement['fid']]['allowsmilies'], "allow_imgcode" => $forum[$announcement['fid']]['allowimgcode'], "allow_videocode" => $forum[$announcement['fid']]['allowvideocode'], "filter_badwords" => 1);
 if ($announcement['smilieoff'] == 1) {
Ejemplo n.º 6
0
function teamonline_show()
{
    global $cache, $groupscache, $db, $mybb, $teamonline, $lang, $theme, $templates, $online;
    $lang->load('teamonline');
    if ($mybb->settings['teamonline_gid']) {
        $gid = " IN (" . $mybb->settings['teamonline_gid'] . ")";
        $timesearch = TIME_NOW - $mybb->settings['wolcutoffmins'] * 60;
        $teamonline_row = '';
        $trowbg = alt_trow();
        $query = $db->query("\n\t\t\tSELECT s.sid, s.ip, s.uid, u.username, s.time, u.avatar, u.usergroup, u.displaygroup, u.invisible\n\t\t\tFROM " . TABLE_PREFIX . "sessions s\n\t\t\tLEFT JOIN " . TABLE_PREFIX . "users u ON (s.uid=u.uid)\n\t\t\tWHERE u.usergroup {$gid} AND time>'{$timesearch}'\n\t\t\tORDER BY u.username ASC, s.time DESC\n\t\t\t");
        if (!$db->num_rows($query)) {
            eval("\$teamonline_no = \"" . $templates->get("teamonline_no") . "\";");
            $invisible = 0;
            $membercount = 0;
        } else {
            if (!is_array($groupscache)) {
                $groupscache = $cache->read("usergroups");
            }
            while ($online = $db->fetch_array($query)) {
                $invisible_mark = '';
                if ($online['invisible'] == 1) {
                    $invisible_mark = '*';
                }
                if ($online['invisible'] != 1 || $mybb->usergroup['canviewwolinvis'] == 1 || $online['uid'] == $mybb->user['uid']) {
                    $avatar_teamonline = format_avatar($online['avatar']);
                    $online['username'] = format_name($online['username'], $online['usergroup'], $online['displaygroup']);
                    $online['profilelink'] = build_profile_link($online['username'], $online['uid']) . $invisible_mark;
                    $online['groupname'] = $groupscache[$online['usergroup']]['title'];
                    eval("\$teamonline_row .= \"" . $templates->get("teamonline_row") . "\";");
                }
                $invisible += $online['invisible'];
                $membercount++;
            }
        }
        eval("\$teamonline = \"" . $templates->get("teamonline") . "\";");
    }
}
Ejemplo n.º 7
0
function chatcat_insert_footer()
{
    global $mybb, $templates, $myval;
    $myval = "";
    if ($mybb->settings['chatcat_enable'] == 1) {
        $apikey = $mybb->settings['chatcat_enable_api'];
        $api_url = '';
        if (strlen($mybb->settings['chatcat_enable_api']) != 0) {
            $user = $mybb->user;
            $api_key = $mybb->settings['chatcat_enable_api'];
            $secret = $mybb->settings['chatcat_secret'];
            $uid = $user['uid'];
            if (function_exists('format_avatar')) {
                $useravatar = format_avatar(htmlspecialchars_uni($user['avatar']), $user['avatardimensions'], my_strtolower($mybb->settings['memberlistmaxavatarsize']));
                if (!empty($useravatar['image'])) {
                    $src = $useravatar['image'];
                }
            }
            $username = $user['username'];
            $dateOfBirth = strtotime($user['birthday']) * 1000;
            //var_dump($user);
            // Get the user's description
            $description = $user['fid2'];
            $location = $user['fid1'];
            $sex = $user['fid3'];
            $params = array('api_key' => $api_key, 'secret' => $secret, 'src' => urlencode($src), 'username' => $username, 'description' => $description, 'uid' => $uid, 'dateOfBirth' => $dateOfBirth, 'location' => $location, 'sex' => $sex, 'homepage' => urlencode($mybb->settings['bburl'] . "/" . get_profile_link($uid)));
            $extension = '?';
            foreach ($params as $key => $value) {
                if ($value) {
                    $extension .= $key . '=' . $value . '&';
                }
            }
            $extension = substr($extension, 0, -1);
            $api_url = $mybb->settings['bburl'] . '/ajaxchat.php' . $extension;
        }
        if ($mybb->settings['chatcat_enable_login'] == '') {
            $login_url = $mybb->settings['bburl'] . '/member.php?action=login';
        } else {
            $login_url = $mybb->settings['chatcat_enable_login'];
            if (!preg_match("@^[hf]tt?ps?://@", $login_url)) {
                $login_url = "http://" . $login_url;
            }
        }
        if ($mybb->settings['chatcat_enable_register'] == '') {
            $register_url = $mybb->settings['bburl'] . '/member.php?action=register';
        } else {
            $register_url = $mybb->settings['chatcat_enable_register'];
            if (!preg_match("@^[hf]tt?ps?://@", $register_url)) {
                $register_url = "http://" . $register_url;
            }
        }
        if ($mybb->settings['chatcat_enable_primary'] != '') {
            $primary_url = $mybb->settings['chatcat_enable_primary'];
        } else {
            $primary_url = $mybb->settings['bburl'];
        }
        ?>

    <div ng-app="myApp" ><ng-include src=" baseURL + 'chatcat.html'" ng-controller="AppController"></ng-include></div>
    <script type="text/javascript">

        // Set options here
        var CC_OPTIONS = {

            
            primaryDomain: '<?php 
        echo $primary_url;
        ?>
',
			        

            // Users can create public chat rooms?
            // If this is true users will be able to setup new
            // public rooms
            usersCanCreatePublicRooms: true,

            // Allow anonymous login?
            anonymousLoginEnabled: false,

            // Enable social login - please email us to get your domain whitelisted
            socialLoginEnabled: true,

            // The URL to contact for single sign on
            singleSignOnURL: '<?php 
        echo $api_url;
        ?>
',
            singleSignOnAPILevel: 1,

            // Optional - if this is set the login box will direct users
            // to log in
            loginURL: '<?php 
        echo $login_url;
        ?>
',

            // Optional - if this is set the login box will direct users
            // to register
            registerURL: '<?php 
        echo $register_url;
        ?>
'

        }

        var ccProtocol = (("https:" == document.location.protocol) ? "https://" : "http://");

    <?php 
        if ($_SERVER['SERVER_NAME'] == 'ccwp') {
            ?>

        // TEST
        document.write(decodeURI("%3Clink rel='stylesheet' href='" + ccProtocol + "chatcat/dist/css/_/cc_styles.min.css' %3E%3C/link%3E"));
        document.write(decodeURI("%3Cscript src='" + ccProtocol + "chatcat/dist/js/all.js' type='text/javascript'%3E%3C/script%3E"));

    <?php 
        } else {
            ?>

        // PRODUCTION
        document.write(decodeURI("%3Clink rel='stylesheet' href='" + ccProtocol + "chatcat.firebaseapp.com/css/_/cc_styles.min.css' %3E%3C/link%3E"));
        document.write(decodeURI("%3Cscript src='" + ccProtocol + "chatcat.firebaseapp.com/js/all.min.js' type='text/javascript'%3E%3C/script%3E"));

    <?php 
        }
        ?>

    </script>

<?php 
    }
}
Ejemplo n.º 8
0
 /**
  * Populate the user object
  * @since Version 3.0.1
  * @version 3.0.1
  * @return boolean
  * @param int $user_id
  */
 public function load($user_id = false)
 {
     if ($user_id) {
         $this->id = $user_id;
     }
     // Get out early
     if (!$this->id) {
         return false;
     }
     $this->createUrls();
     $this->mckey = "railpage:user_id=" . $this->id;
     $cached = false;
     if ($data = $this->getCache($this->mckey)) {
         $cached = true;
     } elseif ($this->db instanceof \sql_db) {
         $query = "SELECT u.*, COALESCE(SUM((SELECT COUNT(*) FROM nuke_bbprivmsgs WHERE privmsgs_to_userid='" . $this->db->real_escape_string($this->id) . "' AND (privmsgs_type='5' OR privmsgs_type='1'))), 0) AS unread_pms FROM nuke_users u WHERE u.user_id = '" . $this->db->real_escape_string($this->id) . "';";
         if (!defined("RP_PLATFORM") || RP_PLATFORM != "API") {
             $query .= "SELECT o.* FROM organisation o, organisation_member om WHERE o.organisation_id = om.organisation_id AND om.user_id = " . $this->db->real_escape_string($this->id) . ";";
             $query .= "SELECT oc.* FROM oauth_consumer AS oc LEFT JOIN nuke_users AS u ON u.oauth_consumer_id = oc.id WHERE u.user_id = " . $this->db->real_escape_string($this->id) . ";";
         }
         if ($this->db->multi_query($query)) {
             // Get the user data
             if ($rs = $this->db->store_result()) {
                 if ($rs->num_rows == 1 && ($data = $rs->fetch_assoc())) {
                     //unset($data['user_password']);
                     $data['session_logged_in'] = true;
                     $data['session_start'] = $data['user_session_time'];
                     $rs->free();
                 } else {
                     trigger_error("User: Could not retrieve user from database");
                     trigger_error($this->db->error);
                     trigger_error($query);
                     return false;
                 }
             } else {
                 trigger_error("User: Could not retrieve user from database");
                 trigger_error($this->db->error);
                 trigger_error($query);
                 return false;
             }
             // Get the organisation membership
             if ($this->db->more_results()) {
                 $this->db->next_result();
                 if ($rs = $this->db->store_result()) {
                     $data['organisations'] = array();
                     while ($row = $rs->fetch_assoc()) {
                         $data['organisations'][$row['organisation_id']] = $row;
                     }
                 }
             }
             // OAuth consumer key
             if ($this->db->more_results()) {
                 $this->db->next_result();
                 if ($rs = $this->db->store_result()) {
                     $row = $rs->fetch_assoc();
                     $data['oauth_key'] = $row['consumer_key'];
                     $data['oauth_secret'] = $row['consumer_secret'];
                 }
             }
         } else {
             throw new \Exception($this->db->error);
             return false;
         }
     } else {
         // Zend_Db
         $query = "SELECT u.*, COALESCE(SUM((SELECT COUNT(*) FROM nuke_bbprivmsgs WHERE privmsgs_to_userid= ? AND (privmsgs_type='5' OR privmsgs_type='1'))), 0) AS unread_pms FROM nuke_users u WHERE u.user_id = ?";
         if ($data = $this->db->fetchRow($query, array($this->id, $this->id))) {
             #unset($data['user_password']);
             #unset($data['user_password_bcrypt']);
             $data['session_logged_in'] = true;
             $data['session_start'] = $data['user_session_time'];
             if (!defined("RP_PLATFORM") || RP_PLATFORM != "API") {
                 $data['organisations'] = array();
                 $query = "SELECT o.* FROM organisation o, organisation_member om WHERE o.organisation_id = om.organisation_id AND om.user_id = ?";
                 if ($orgs = $this->db->fetchAll($query, $this->id)) {
                     foreach ($orgs as $row) {
                         $data['organisations'][$row['organisation_id']] = $row;
                     }
                 }
                 $query = "SELECT oc.* FROM oauth_consumer AS oc LEFT JOIN nuke_users AS u ON u.oauth_consumer_id = oc.id WHERE u.user_id = ?";
                 if ($row = $this->db->fetchRow($query, $this->id)) {
                     $data['oauth_key'] = $row['consumer_key'];
                     $data['oauth_secret'] = $row['consumer_secret'];
                 }
             }
         }
     }
     /**
      * Process some of the returned values
      */
     // Set the full avatar path
     if (!empty($data['user_avatar'])) {
         $data['user_avatar_filename'] = $data['user_avatar'];
         if (!stristr($data['user_avatar'], "http://") && !stristr($data['user_avatar'], "https://")) {
             // Assume local avatar
             $data['user_avatar'] = "http://" . $_SERVER['SERVER_NAME'] . "/modules/Forums/images/avatars/" . $data['user_avatar'];
         }
         if (is_null($data['user_avatar_width']) || is_null($data['user_avatar_height'])) {
             if ($size = @getimagesize($data['user_avatar'])) {
                 $data['user_avatar_width'] = $size[0];
                 $data['user_avatar_height'] = $size[1];
             }
         }
     }
     if (empty($data['user_avatar']) || substr($data['user_avatar'], -9, 5) == "blank") {
         $data['user_avatar'] = format_avatar("http://static.railpage.com.au/modules/Forums/images/avatars/gallery/blank.png", 120, 120);
         $data['user_avatar_filename'] = format_avatar("http://static.railpage.com.au/modules/Forums/images/avatars/gallery/blank.png", 120, 120);
     }
     // Backwards compatibility
     if ($data['timezone']) {
         $timezone = new DateTime(null, new DateTimeZone($data['timezone']));
         $data['user_timezone'] = str_pad($timezone->getOffset() / 60 / 60, 5, ".00");
     }
     // Check for theme existance
     if (class_exists("\\smarty_railpage")) {
         $smarty = new \smarty_railpage();
         if (!$smarty->theme_exists($data['theme']) || $data['theme'] == "MGHTheme" || $data['theme'] == "") {
             $data['theme'] = $this->default_theme;
         }
     }
     // Nice time
     $data['user_lastvisit_nice'] = date($data['user_dateformat'], $data['user_lastvisit']);
     /**
      * Start setting the class vars
      */
     $this->getGroups();
     if (!$cached) {
         $this->setCache($this->mckey, $data, strtotime("+6 hours"));
     }
     $this->provider = isset($data['provider']) ? $data['provider'] : "railpage";
     $this->preferences = json_decode($data['user_opts']);
     $this->guest = false;
     $this->ssl = $data['user_enablessl'];
     $this->username = $data['username'];
     $this->active = $data['user_active'];
     $this->regdate = $data['user_regdate'];
     $this->level = $data['user_level'];
     $this->posts = $data['user_posts'];
     $this->style = $data['user_style'];
     $this->theme = !is_null($data['theme']) ? $data['theme'] : $this->default_theme;
     $this->lang = $data['user_lang'];
     $this->date_format = $data['user_dateformat'];
     $this->rank_id = $data['user_rank'];
     $this->rank_text = isset($data['rank_title']) && !empty($data['rank_title']) ? $data['rank_title'] : NULL;
     $this->location = $data['user_from'];
     $this->occupation = $data['user_occ'];
     $this->interests = $data['user_interests'];
     $this->real_name = $data['name'];
     $this->timezone = isset($data['timezone']) && !empty($data['timezone']) ? $data['timezone'] : "Australia/Melbourne";
     $this->website = $data['user_website'];
     $this->hide = $data['user_allow_viewonline'];
     $this->wheat = $data['uWheat'];
     $this->chaff = $data['uChaff'];
     $this->facebook_user_id = $data['facebook_user_id'];
     if ($this->wheat == 0) {
         $this->reputation = '100% (+' . $this->wheat . '/' . $this->chaff . '-)';
     } else {
         $this->reputation = number_format($this->chaff / $this->wheat / 2 * 100, 1) . '% (+' . $this->wheat . '/' . $this->chaff . '-)';
     }
     $this->api_key = $data['api_key'];
     $this->api_secret = $data['api_secret'];
     $this->report_optout = $data['user_report_optout'];
     $this->warning_level = $data['user_warnlevel'];
     $this->warning_exempt = $data['disallow_mod_warn'];
     $this->group_cp = $data['user_group_cp'];
     $this->group_list_cp = $data['user_group_list_cp'];
     $this->active_cp = $data['user_active_cp'];
     $this->items_per_page = $data['user_forum_postsperpage'];
     $this->avatar = $data['user_avatar'];
     $this->avatar_filename = $data['user_avatar_filename'];
     $this->avatar_type = $data['user_avatar_type'];
     $this->avatar_width = $data['user_avatar_width'];
     $this->avatar_height = $data['user_avatar_height'];
     $this->avatar_gravatar = $data['user_avatar_gravatar'];
     $this->privmsg_new = $data['user_new_privmsg'];
     $this->privmsg_unread = $data['user_unread_privmsg'];
     $this->privmsg_last_id = $data['user_last_privmsg'];
     $this->email_show = $data['user_viewemail'];
     $this->news_submissions = $data['storynum'];
     $this->notify = $data['user_notify'];
     $this->notify_privmsg = $data['user_notify_pm'];
     $this->contact_email = $data['user_email'];
     $this->contact_icq = $data['user_icq'];
     $this->contact_aim = $data['user_aim'];
     $this->contact_yim = $data['user_yim'];
     $this->contact_msn = $data['user_msnm'];
     if ($this->email_show) {
         $this->contact_email_public = $this->contact_email;
     } else {
         $this->contact_email_public = $data['femail'];
     }
     $this->signature = $data['user_sig'];
     $this->signature_attach = $data['user_attachsig'];
     $this->signature_showall = $data['user_showsigs'];
     $this->signature_bbcode_uid = $data['user_sig_bbcode_uid'];
     $this->act_key = $data['user_actkey'];
     if (isset($data['password_new'])) {
         $this->password_new = $data['password_new'];
     }
     $this->password = $data['user_password'];
     $this->password_bcrypt = $data['user_password_bcrypt'];
     $this->lastvisit = $data['user_lastvisit'];
     $this->session_time = $data['user_session_time'];
     $this->session_page = $data['user_session_page'];
     $this->session_current = $data['user_current_visit'];
     $this->session_last = $data['user_last_visit'];
     $this->session_last_nice = date($data['user_dateformat'], $data['user_lastvisit']);
     $this->session_ip = $data['last_session_ip'];
     $this->session_cslh = $data['last_session_cslh'];
     $this->session_mu_ignore = $data['last_session_ignore'];
     $this->enable_rte = $data['user_enablerte'];
     $this->enable_glossary = $data['user_enableglossary'];
     $this->enable_html = $data['user_allowhtml'];
     $this->enable_bbcode = $data['user_allowbbcode'];
     $this->enable_emoticons = $data['user_allowsmile'];
     $this->enable_avatar = $data['user_allowavatar'];
     $this->enable_privmsg = $data['user_allow_pm'];
     $this->enable_privmsg_popup = $data['user_popup_pm'];
     $this->enable_autologin = $data['user_enableautologin'];
     $this->flickr_oauth_token = $data['flickr_oauth_token'];
     $this->flickr_oauth_secret = $data['flickr_oauth_token_secret'];
     $this->flickr_nsid = $data['flickr_nsid'];
     $this->flickr_username = $data['flickr_username'];
     $this->sidebar_type = $data['sidebar_type'];
     $this->reported_to_sfs = $data['reported_to_sfs'];
     $this->meta = isset($data['meta']) ? json_decode($data['meta'], true) : array();
     /**
      * Update the user registration date if required
      */
     if (empty($data['user_regdate_nice'])) {
         $datetime = new DateTime($data['user_regdate']);
         $data['user_regdate_nice'] = $datetime->format("Y-m-d");
         $update['user_regdate_nice'] = $data['user_regdate_nice'];
         $this->db->update("nuke_users", $update, array("user_id = ?" => $this->id));
     }
     /**
      * Fetch the last IP address from the login logs
      */
     $lastlogin = $this->getLogins(1);
     if (count($lastlogin)) {
         $this->session_ip = $lastlogin[key($lastlogin)]['login_ip'];
         if ($this->lastvisit == 0) {
             $this->lastvisit = $lastlogin[key($lastlogin)]['login_time'];
         }
     }
     if ($this->warning_level == 0) {
         $this->warning_level_colour = "green";
     } elseif ($this->warning_level < 66) {
         $this->warning_level_colour = "orange";
     } else {
         $this->warning_level_colour = "red";
     }
     if (isset($data['oauth_key']) && isset($data['oauth_secret'])) {
         $this->oauth_key = $data['oauth_key'];
         $this->oauth_secret = $data['oauth_secret'];
     }
     $this->oauth_id = $data['oauth_consumer_id'];
     // Bugfix for REALLY old accounts with a NULL user_level
     if ($this->level == NULL && ($this->active = 1)) {
         $this->level = 1;
     }
     // Generate a new API key and secret
     if (empty($this->api_key) || empty($this->api_secret)) {
         require_once "includes/bcrypt.class.php";
         $bcrypted = new \Bcrypt(4);
         $this->api_secret = $bcrypted->hash($this->username . $this->regdate . $this->id);
         $this->api_key = crypt($this->username . $this->id, "rl");
         try {
             $this->commit(true);
         } catch (Exception $e) {
             global $Error;
             $Error->save($e);
         }
     }
     /**
      * Set some default values for $this->preferences
      */
     if (empty($this->preferences)) {
         $this->preferences = new stdClass();
         $this->preferences->home = "Home";
         $this->preferences->showads = true;
         $this->preferences->forums = new stdClass();
         $this->preferences->forums->hideinternational = false;
         $this->commit(true);
     }
     return true;
 }
Ejemplo n.º 9
0
function recentthread_list_threads($return = false)
{
    global $mybb, $db, $templates, $recentthreadtable, $recentthreads, $settings, $canviewrecentthreads, $cache, $theme;
    // First check permissions
    if (!recentthread_can_view()) {
        return;
    }
    require_once MYBB_ROOT . "inc/functions_search.php";
    $threadlimit = (int) $mybb->settings['recentthread_threadcount'];
    if (!$threadlimit) {
        $threadlimit = 15;
    }
    $onlyusfids = array();
    // Check group permissions if we can't view threads not started by us
    $group_permissions = forum_permissions();
    foreach ($group_permissions as $fid => $forum_permissions) {
        if ($forum_permissions['canonlyviewownthreads'] == 1) {
            $onlyusfids[] = $fid;
        }
    }
    if (!empty($onlyusfids)) {
        $where .= "AND ((t.fid IN(" . implode(',', $onlyusfids) . ") AND t.uid='{$mybb->user['uid']}') OR t.fid NOT IN(" . implode(',', $onlyusfids) . "))";
    }
    $approved = 0;
    // Moderators can view unapproved threads
    if ($mybb->usergroup['canmodcp'] == 1) {
        $approved = -1;
    }
    $unsearchableforums = get_unsearchable_forums();
    $unviewableforums = get_unviewable_forums();
    if ($unsearchableforums && $unviewableforums) {
        $forumarray = explode(",", $unsearchableforums . "," . $unviewableforums);
        $newarray = array_unique($forumarray);
        $unsearchableforumssql = " AND t.fid NOT IN(" . implode(",", $newarray) . ") ";
    }
    // Take into account any ignored forums
    if ($mybb->settings['recentthread_forumskip']) {
        $ignoreforums = " AND t.fid NOT IN(" . $mybb->settings['recentthread_forumskip'] . ") ";
    }
    $forums = $cache->read("forums");
    $query = $db->query("\n\t\t\tSELECT t.*, u.username AS userusername, u.usergroup, u.displaygroup, u.avatar as threadavatar, u.avatardimensions as threaddimensions, lp.usergroup AS lastusergroup, lp.avatar as lastavatar, lp.avatardimensions as lastdimensions, lp.displaygroup as lastdisplaygroup\n\t\t\tFROM " . TABLE_PREFIX . "threads t\n\t\t\tLEFT JOIN " . TABLE_PREFIX . "users u ON (u.uid=t.uid)\n\t\t\tLEFT JOIN " . TABLE_PREFIX . "users lp ON (t.lastposteruid=lp.uid)\n\t\t\tWHERE 1=1 {$where} AND t.visible > {$approved} {$unsearchableforumssql} {$ignoreforums}\n\t\t\tORDER BY t.lastpost DESC\n\t\t\tLIMIT {$threadlimit}\n\t\t");
    while ($thread = $db->fetch_array($query)) {
        $trow = alt_trow();
        $thread['forum'] = $forums[$thread['fid']]['name'];
        $threadlink = get_thread_link($thread['tid'], "", "newpost");
        $lastpostlink = get_thread_link($thread['tid'], "", "lastpost");
        $lastpostdate = my_date($mybb->settings['dateformat'], $thread['lastpost']);
        $lastposttime = my_date($mybb->settings['timeformat'], $thread['lastpost']);
        $lastposttimeago = my_date("relative", $thread['lastpost']);
        $lastposter = $thread['lastposter'];
        $lastposteruid = $thread['lastposteruid'];
        $thread['author'] = build_profile_link(format_name($thread['userusername'], $thread['usergroup'], $thread['displaygroup']), $thread['uid']);
        // Don't link to guest's profiles (they have no profile).
        if ($lastposteruid == 0) {
            $lastposterlink = $lastposter;
        } else {
            $lastposterlink = build_profile_link(format_name($lastposter, $thread['lastusergroup'], $thread['lastdisplaygroup']), $lastposteruid);
        }
        if ($mybb->settings['recentthread_threadavatar']) {
            $threadavatar = format_avatar($thread['threadavatar'], $thread['threaddimensions']);
            $avatarurl = $threadavatar['image'];
            $dimensions = $threadavatar['width_height'];
            eval("\$posteravatar = \"" . $templates->get("recentthread_avatar") . "\";");
        }
        if ($mybb->settings['recentthread_lastavatar']) {
            $lastposteravatar = format_avatar($thread['lastavatar'], $thread['lastdimensions']);
            $avatarurl = $lastposteravatar['image'];
            $dimensions = $lastposteravatar['width_height'];
            eval("\$lastavatar = \"" . $templates->get("recentthread_avatar") . "\";");
        }
        // Now check the length of subjects
        $length = (int) $mybb->settings['recentthread_subject_length'];
        if (strlen($thread['subject']) > $length && $length != 0) {
            // Figure out if we need to split it up.
            $title = my_substr($thread['subject'], 0, $length);
            if ($mybb->settings['recentthread_subject_breaker']) {
                $words = explode(" ", $title);
                $count = count($words) - 1;
                $currenttitle = "";
                for ($x = 0; $x < $count; $x++) {
                    $currenttitle .= $words[$x] . " ";
                }
                $thread['subject'] = $currenttitle . " ...";
            }
            if (!$mybb->settings['recentthread_subject_breaker']) {
                $thread['subject'] = $title . "...";
            }
        }
        // Moderator stuff baby!
        if (is_moderator($thread['fid'])) {
            $ismod = TRUE;
            // fetch the inline mod column
        } else {
            $ismod = FALSE;
        }
        if (is_moderator($thread['fid'], "caneditposts") || $fpermissions['caneditposts'] == 1) {
            $can_edit_titles = 1;
        } else {
            $can_edit_titles = 0;
        }
        $inline_edit_class = '';
        if ($thread['uid'] == $mybb->user['uid'] && $thread['closed'] != 1 && $mybb->user['uid'] != 0 && $can_edit_titles == 1 || $ismod == true) {
            $inline_edit_class = "subject_editable";
        }
        eval("\$recentthreads .= \"" . $templates->get("recentthread_thread") . "\";");
        unset($posteravatar);
        unset($lastavatar);
    }
    eval("\$recentthreadtable = \"" . $templates->get("recentthread") . "\";");
    if ($return) {
        return $recentthreadtable;
    }
}
Ejemplo n.º 10
0
 /**
  * List the contents of this folder
  * @since Version 3.3
  * @version 3.3
  * @return array
  * @param object $User
  * @param int $page
  * @param int $items_per_page
  */
 public function getContents($User = false, $page = 1, $items_per_page = 25)
 {
     if (empty($this->folder)) {
         throw new \Exception("Cannot get folder contents - no folder specified");
     }
     if (!$User || !is_object($User)) {
         throw new \Exception("Cannot get folder contents - User object not provided");
     }
     if (!$User->id) {
         throw new \Exception("No user ID available");
     }
     if (!$User->enable_privmsg) {
         throw new \Exception("Private messages not available to this user");
     }
     // Store the user object
     $this->user = $User;
     // Fetch message IDs that have been "deleted" by this user
     $deleted = $this->getDeleted($User->id);
     if (count($deleted)) {
         $exclude_sql = " AND privmsgs_id NOT IN ('" . implode("', '", $deleted) . "') ";
     } else {
         $exclude_sql = "";
     }
     if ($this->folder == PM_INBOX) {
         $pm_folder_sql = "pm.privmsgs_to_userid = " . $this->user->id . " AND (pm.privmsgs_type = " . PRIVMSGS_READ_MAIL . " OR pm.privmsgs_type = " . PRIVMSGS_NEW_MAIL . " OR pm.privmsgs_type = " . PRIVMSGS_UNREAD_MAIL . " )";
     } elseif ($this->folder == PM_OUTBOX) {
         $pm_folder_sql = "pm.privmsgs_from_userid = " . $this->user->id . " AND (pm.privmsgs_type = " . PRIVMSGS_NEW_MAIL . " OR pm.privmsgs_type = " . PRIVMSGS_UNREAD_MAIL . ")";
     } elseif ($this->folder == PM_SENTBOX) {
         $pm_folder_sql = "pm.privmsgs_from_userid = " . $this->user->id . " AND (pm.privmsgs_type = " . PRIVMSGS_READ_MAIL . " OR pm.privmsgs_type = " . PRIVMSGS_SENT_MAIL . ")";
     } elseif ($this->folder == PM_SAVEBOX) {
         $pm_folder_sql = "((pm.privmsgs_to_userid = " . $this->user->id . " AND pm.privmsgs_type = " . PRIVMSGS_SAVED_IN_MAIL . ") OR (pm.privmsgs_from_userid = " . $this->user->id . " AND pm.privmsgs_type = " . PRIVMSGS_SAVED_OUT_MAIL . "))";
     }
     // Which "page" is this?
     if ($page == 1) {
         $start = 0;
     } else {
         $start = $page * $items_per_page;
     }
     // Done checking - get the PMs - sort by date ASC because the uasort() function will fix them up properly
     $query = "SELECT pm.*, pmt.*, ufrom.username AS username_from, ufrom.user_id AS user_id_from, ufrom.user_avatar AS user_avatar_from, uto.username AS username_to, uto.user_id AS user_id_from, uto.user_avatar AS user_avatar_to\r\n\t\t\t\t\t\tFROM nuke_bbprivmsgs AS pm\r\n\t\t\t\t\t\tLEFT JOIN nuke_bbprivmsgs_text AS pmt ON pm.privmsgs_id = pmt.privmsgs_text_id\r\n\t\t\t\t\t\tLEFT JOIN nuke_users AS ufrom ON ufrom.user_id = privmsgs_from_userid\r\n\t\t\t\t\t\tLEFT JOIN nuke_users AS uto ON uto.user_id = privmsgs_to_userid\r\n\t\t\t\t\t\tWHERE " . $pm_folder_sql . "\r\n\t\t\t\t\t\t" . $exclude_sql . "\r\n\t\t\t\t\t\tORDER BY pm.privmsgs_date ASC";
     #LIMIT ".$start.", ".$this->db->real_escape_string($items_per_page);
     #echo $query;
     if ($this->db instanceof \sql_db) {
         if ($rs = $this->db->query($query)) {
             #$total = $this->db->query("SELECT FOUND_ROWS() AS total");
             #$total = $total->fetch_assoc();
             $return = array();
             $return['stat'] = "ok";
             #$return['total'] = $total['total'];
             $return['page'] = $page;
             $return['perpage'] = $items_per_page;
             $return['messages'] = array();
             while ($row = $rs->fetch_assoc()) {
                 // Fix up the sodding non-UTF8 characters
                 $row['privmsgs_text'] = convert_to_utf8($row['privmsgs_text']);
                 $row['privmsgs_subject'] = str_replace("Re: ", "", $row['privmsgs_subject']);
                 if ($row['privmsgs_from_userid'] == $this->user->id) {
                     $pm_from = $row['privmsgs_to_userid'];
                 } else {
                     $pm_from = $row['privmsgs_from_userid'];
                 }
                 $id = md5($row['privmsgs_subject'] . $pm_from);
                 if (function_exists("format_avatar")) {
                     $row['user_avatar_from'] = format_avatar($row['user_avatar_from'], 40, 40);
                     $row['user_avatar_to'] = format_avatar($row['user_avatar_to'], 40, 40);
                 }
                 $return['messages'][$id] = $row;
             }
             // Sort by loco number
             uasort($return['messages'], function ($a, $b) {
                 return strnatcmp($b['privmsgs_date'], $a['privmsgs_date']);
             });
         } else {
             throw new \Exception($this->db->error);
             $return['stat'] = "error";
             $return['error'] = $this->db->error;
         }
         $return['total'] = count($return['messages']);
         $return['messages'] = array_slice($return['messages'], $start, $items_per_page);
         return $return;
     } else {
         $return = array();
         $return['stat'] = "ok";
         $return['page'] = $page;
         $return['perpage'] = $items_per_page;
         $return['messages'] = array();
         foreach ($this->db->fetchAll($query) as $row) {
             $row['privmsgs_text'] = convert_to_utf8($row['privmsgs_text']);
             $row['privmsgs_subject'] = str_replace("Re: ", "", $row['privmsgs_subject']);
             if ($row['privmsgs_from_userid'] == $this->user->id) {
                 $pm_from = $row['privmsgs_to_userid'];
             } else {
                 $pm_from = $row['privmsgs_from_userid'];
             }
             $id = md5($row['privmsgs_subject'] . $pm_from);
             if (function_exists("format_avatar")) {
                 $row['user_avatar_from'] = @format_avatar($row['user_avatar_from'], 40, 40);
                 $row['user_avatar_to'] = @format_avatar($row['user_avatar_to'], 40, 40);
             }
             $return['messages'][$id] = $row;
         }
         // Sort by loco number
         uasort($return['messages'], function ($a, $b) {
             return strnatcmp($b['privmsgs_date'], $a['privmsgs_date']);
         });
         $return['total'] = count($return['messages']);
         $return['messages'] = array_slice($return['messages'], $start, $items_per_page);
         return $return;
     }
 }
Ejemplo n.º 11
0
     require_once MYBB_ROOT . "inc/class_parser.php";
     $parser = new postParser();
     $pm = '';
     $query = $db->query("\n\t\tSELECT pm.*,u.*, u.username AS fromusername, u.avatar, u.avatardimensions\n\t\tFROM " . TABLE_PREFIX . "privatemessages pm\n\t\tLEFT JOIN " . TABLE_PREFIX . "users u ON (u.uid=pm.fromid)\n\t\tWHERE pm.folder='1' AND pm.uid='" . $mybb->user['uid'] . "'\n\t\tORDER BY pm.dateline DESC\n\t\tLIMIT 5\n\t");
     if ($db->num_rows($query) > 0) {
         while ($pm = $db->fetch_array($query)) {
             $pmsubject = htmlspecialchars_uni($parser->parse_badwords($pm['subject']));
             $pmsubjectshort = substr($pmsubject, 0, 20) . "...";
             $fromusername = $pm['fromusername'];
             $fromuid = $pm['fromid'];
             $fromuser = build_profile_link($fromusername, $fromuid);
             $pmid = $pm['pmid'];
             $sendpmdate = my_date($mybb->settings['dateformat'], $pm['dateline']);
             $sendpmtime = my_date($mybb->settings['timeformat'], $pm['dateline']);
             $senddate = $sendpmdate . ", " . $sendpmtime;
             $formated_avatar = format_avatar($pm['avatar'], $pm['avatardimensions']);
             $useravatar = "<img src=\"{$formated_avatar['image']}\" valign=\"middle\" />";
             if (!empty($pm['avatar'])) {
                 $avatar = $pm['avatar'];
             } else {
                 $avatar = $mybb->settings['useravatar'];
             }
             //$useravatar = format_avatar($avatar, $pm['avatardimensions']);
             eval("\$listbit .= \"" . $templates->get("inbox_listbit") . "\";");
         }
     } else {
         eval("\$listbit .= \"" . $templates->get("inbox_nomessages") . "\";");
     }
 } else {
     //PM system disabled message
     eval("\$listbit .= \"" . $templates->get("inbox_error_pm_disabled") . "\";");
Ejemplo n.º 12
0
function mylikes_popup()
{
    global $db, $mybb, $lang, $groupscache, $templates;
    if ($mybb->input['action'] == "likes_recount") {
        // Rebuild the cache for this post - the reputation/like counter may have changed
        if (!empty($mybb->input['pid'])) {
            JB_MyLikes_Like::cache($mybb->input['pid']);
        }
        exit;
    }
    if ($mybb->input['action'] != "likes") {
        return;
    }
    if (empty($mybb->input['pid']) || empty($mybb->input['uid'])) {
        error_no_permission();
    }
    $lang->load("mylikes");
    $pid = $mybb->get_input("pid");
    $uid = $mybb->get_input("uid");
    $query = $db->simple_select("reputation", "*", "uid={$uid} AND pid={$pid}");
    $users = "";
    while ($like = $db->fetch_array($query)) {
        $user = get_user($like['adduid']);
        $name = format_name($user['username'], $user['usergroup'], $user['displaygroup']);
        $profile_link = build_profile_link($name, $user['uid'], '_blank', 'if(window.opener) { window.opener.location = this.href; return false; }');
        $send_pm = '';
        if ($mybb->user['receivepms'] != 0 && $user['receivepms'] != 0 && $groupscache[$user['usergroup']]['canusepms'] != 0) {
            eval("\$send_pm = \"" . $templates->get("misc_buddypopup_user_sendpm") . "\";");
        }
        if ($user['lastactive']) {
            $last_active = $lang->sprintf($lang->last_active, my_date('relative', $user['lastactive']));
        } else {
            $last_active = $lang->sprintf($lang->last_active, $lang->never);
        }
        $user['avatar'] = format_avatar(htmlspecialchars_uni($user['avatar']), $user['avatardimensions'], '44x44');
        $online_alt = alt_trow();
        $users .= eval($templates->render("misc_mylikes_like"));
    }
    if (empty($users)) {
        $users = eval($templates->render("misc_mylikes_nolikes"));
    }
    echo eval($templates->render("misc_mylikes", 1, 0));
    exit;
}
Ejemplo n.º 13
0
function avatarep_format_avatar($user)
{
    global $mybb, $avatar;
    $size = 2048;
    $dimensions = "30px";
    $avatar = format_avatar($user['avatar'], $dimensions, $size);
    $avatar = htmlspecialchars_uni($avatar['image']);
    if (THIS_SCRIPT == "showthread.php") {
        if ($user['avatartype'] == "upload") {
            $avatar = $mybb->settings['bburl'] . "/" . $user['avatar'];
        } else {
            if ($user['avatartype'] == "gallery") {
                //UPDATE `miforo_users` set avatar = REPLACE(avatar, './uploads/', 'uploads/');
                $avatar = $mybb->settings['bburl'] . "/" . $user['avatar'];
            } else {
                if ($user['avatartype'] == "remote") {
                    $avatar = $user['avatar'];
                } else {
                    if ($user['avatartype'] == "" && $user['avatar']) {
                        $avatar = $mybb->settings['bburl'] . "/images/default_avatar.png";
                    }
                }
            }
        }
    }
    $avatar = $user['avatar'] ? htmlspecialchars_uni($user['avatar']) : $mybb->settings['bburl'] . '/images/default_avatar.png';
    return array('avatar' => $avatar, 'avatarep' => "<img src='" . $avatar . "' class='avatarep_img' alt='{$user['userusername']}' />", 'username' => htmlspecialchars_uni($user['userusername']), 'profilelink' => get_profile_link($user['uid']), 'uid' => (int) $user['uid'], 'usergroup' => (int) $user['usergroup'], 'displaygroup' => (int) $user['displaygroup']);
    return format_avatar($user);
}
Ejemplo n.º 14
0
 /**
  * Get a standardised array of this data
  * @since Version 3.9.1
  * @return array
  */
 public function getArray()
 {
     $idea = array("id" => $this->id, "title" => $this->title, "description" => function_exists("format_post") ? format_post($this->description) : $this->description, "status" => Ideas::getStatusDescription($this->status), "url" => $this->url->getURLs(), "votes" => array("num" => $this->getVotes(), "text" => $this->getVotes() == 1 ? "1 vote" : sprintf("%d votes", $this->getVotes())), "date" => array("absolute" => $this->User instanceof User ? $this->Date->format($this->User->date_format) : $this->Date->format("F j, Y, g:i a"), "relative" => time2str($this->Date->getTimestamp())), "author" => array("id" => $this->Author->id, "username" => $this->Author->username, "url" => $this->Author->url, "avatar" => array("small" => function_exists("format_avatar") ? format_avatar($this->Author->avatar, 40) : $this->Author->avatar, "large" => function_exists("format_avatar") ? format_avatar($this->Author->avatar, 120) : $this->Author->avatar)), "category" => array("id" => $this->Category->id, "name" => $this->Category->name, "url" => $this->Category->url), "voters" => array());
     return $idea;
 }
Ejemplo n.º 15
0
 /**
  * Load notes
  * @since Version 3.2
  * @version 3.2
  * @return array
  */
 public function loadNotes()
 {
     if ($this->db instanceof \sql_db) {
         $query = "SELECT n.*, u.username, user_avatar FROM loco_notes AS n LEFT JOIN nuke_users AS u ON n.user_id = u.user_id WHERE n.loco_id = " . $this->id;
         if ($rs = $this->db->query($query)) {
             $notes = array();
             while ($row = $rs->fetch_assoc()) {
                 if (!empty($row['user_avatar'])) {
                     try {
                         $row['user_avatar'] = format_avatar($row['user_avatar'], 50);
                     } catch (Exception $e) {
                         global $Error;
                         $Error->save($e);
                     }
                 }
                 $notes[$row['note_id']] = $row;
             }
             return $notes;
         } else {
             throw new Exception($this->db->error . "\n" . $query);
             return false;
         }
     } else {
         $query = "SELECT n.*, u.username, user_avatar FROM loco_notes AS n LEFT JOIN nuke_users AS u ON n.user_id = u.user_id WHERE n.loco_id = ?";
         $notes = array();
         foreach ($this->db->fetchAll($query, $this->id) as $row) {
             if (!empty($row['user_avatar'])) {
                 try {
                     $User = new User($row['user_id']);
                     $row['user_avatar'] = format_avatar($row['user_avatar'], 50);
                     $row['user_url'] = $User->url;
                 } catch (Exception $e) {
                     global $Error;
                     $Error->save($e);
                 }
             }
             $notes[$row['note_id']] = $row;
         }
         return $notes;
     }
 }
Ejemplo n.º 16
0
 /**
  * Process and format each conversation in this folder, in this page
  * @since Version 3.9.1
  * @param array $row
  * @return array
  */
 private function processConversations($conversations)
 {
     foreach ($conversations as $id => $row) {
         $row['privmsgs_text'] = function_exists("convert_to_utf8") ? convert_to_utf8($row['privmsgs_text']) : $row['privmsgs_text'];
         $row['user_avatar_from'] = function_exists("format_avatar") ? format_avatar($row['user_avatar_from'], 40, 40) : $row['user_avatar_from'];
         $row['user_avatar_to'] = function_exists("format_avatar") ? format_avatar($row['user_avatar_to'], 40, 40) : $row['user_avatar_to'];
         $conversations[$id] = $row;
     }
     return $conversations;
 }
Ejemplo n.º 17
0
 $buddys = array('online' => '', 'offline' => '');
 $timecut = TIME_NOW - $mybb->settings['wolcutoff'];
 $query = $db->simple_select("users", "*", "uid IN ({$mybb->user['buddylist']})", array('order_by' => 'lastactive'));
 while ($buddy = $db->fetch_array($query)) {
     $buddy_name = format_name($buddy['username'], $buddy['usergroup'], $buddy['displaygroup']);
     $profile_link = build_profile_link($buddy_name, $buddy['uid'], '_blank', 'if(window.opener) { window.opener.location = this.href; return false; }');
     $send_pm = '';
     if ($mybb->user['receivepms'] != 0 && $buddy['receivepms'] != 0 && $groupscache[$buddy['usergroup']]['canusepms'] != 0) {
         eval("\$send_pm = \"" . $templates->get("misc_buddypopup_user_sendpm") . "\";");
     }
     if ($buddy['lastactive']) {
         $last_active = $lang->sprintf($lang->last_active, my_date('relative', $buddy['lastactive']));
     } else {
         $last_active = $lang->sprintf($lang->last_active, $lang->never);
     }
     $buddy['avatar'] = format_avatar($buddy['avatar'], $buddy['avatardimensions'], '44x44');
     if ($buddy['lastactive'] > $timecut && ($buddy['invisible'] == 0 || $mybb->user['usergroup'] == 4) && $buddy['lastvisit'] != $buddy['lastactive']) {
         $bonline_alt = alt_trow();
         eval("\$buddys['online'] .= \"" . $templates->get("misc_buddypopup_user_online") . "\";");
     } else {
         $boffline_alt = alt_trow();
         eval("\$buddys['offline'] .= \"" . $templates->get("misc_buddypopup_user_offline") . "\";");
     }
 }
 $colspan = ' colspan="2"';
 if (empty($buddys['online'])) {
     $error = $lang->online_none;
     eval("\$buddys['online'] = \"" . $templates->get("misc_buddypopup_user_none") . "\";");
 }
 if (empty($buddys['offline'])) {
     $error = $lang->offline_none;
Ejemplo n.º 18
0
function parse_alert(MybbStuff_MyAlerts_Entity_Alert $alertToParse)
{
    global $mybb, $lang, $plugins;
    if (!isset($lang->myalerts)) {
        $lang->load('myalerts');
    }
    /** @var MybbStuff_MyAlerts_Formatter_AbstractFormatter $formatter */
    $formatter = MybbStuff_MyAlerts_AlertFormatterManager::getInstance()->getFormatterForAlertType($alertToParse->getType()->getCode());
    $outputAlert = array();
    if ($formatter != null) {
        $plugins->run_hooks('myalerts_alerts_output_start', $alert);
        $formatter->init();
        $fromUser = $alertToParse->getFromUser();
        $maxDimensions = str_replace('|', 'x', $mybb->settings['myalerts_avatar_size']);
        $outputAlert['avatar'] = format_avatar($fromUser['avatar'], $mybb->settings['myalerts_avatar_size'], $maxDimensions);
        $outputAlert['avatar']['image'] = htmlspecialchars_uni($outputAlert['avatar']['image']);
        $outputAlert['id'] = $alertToParse->getId();
        $outputAlert['username'] = htmlspecialchars_uni($fromUser['username']);
        $outputAlert['from_user'] = format_name(htmlspecialchars_uni($fromUser['username']), $fromUser['usergroup'], $fromUser['displaygroup']);
        $outputAlert['from_user_raw_profilelink'] = get_profile_link((int) $fromUser['uid']);
        // htmlspecialchars_uni done by get_profile_link
        $outputAlert['from_user_profilelink'] = build_profile_link($outputAlert['from_user'], $fromUser['uid']);
        $outputAlert['alert_status'] = ' alert--read';
        if ($alertToParse->getUnread()) {
            $outputAlert['alert_status'] = ' alert--unread';
        }
        $outputAlert['message'] = $formatter->formatAlert($alertToParse, $outputAlert);
        $outputAlert['alert_code'] = $alertToParse->getType()->getCode();
        $outputAlert['received_at'] = htmlspecialchars_uni(my_date($mybb->settings['dateformat'], $alertToParse->getCreatedAt()->getTimestamp()));
        $plugins->run_hooks('myalerts_alerts_output_end', $alert);
    }
    return $outputAlert;
}
Ejemplo n.º 19
0
 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));
 }
Ejemplo n.º 20
0
 /**
  * Get this album as an array
  * @since Version 3.10.0
  * @return array
  */
 public function getArray()
 {
     $album = array("id" => $this->id, "name" => $this->name, "url" => $this->url instanceof Url ? $this->url->getUrls() : array(), "num_photos" => $this->meta['fields']['cached_photo_count'], "num_albums" => 0, "mckey" => urlencode($this->mckey));
     $AlbumOwner = $this->getOwner();
     if ($AlbumOwner instanceof User) {
         $album['owner'] = array("id" => $AlbumOwner->id, "username" => $AlbumOwner->username, "url" => $AlbumOwner->url->getUrls(), "avatar" => array("small" => format_avatar($AlbumOwner->avatar, 40), "large" => format_avatar($AlbumOwner->avatar, 120)));
     }
     return $album;
 }
Ejemplo n.º 21
0
 $perday = round($perday, 2);
 if ($perday > $mybb->user['postnum']) {
     $perday = $mybb->user['postnum'];
 }
 $stats = $cache->read("stats");
 $posts = $stats['numposts'];
 if ($posts == 0) {
     $percent = "0";
 } else {
     $percent = $mybb->user['postnum'] * 100 / $posts;
     $percent = round($percent, 2);
 }
 $colspan = 2;
 $lang->posts_day = $lang->sprintf($lang->posts_day, my_number_format($perday), $percent);
 $regdate = my_date('relative', $mybb->user['regdate']);
 $useravatar = format_avatar($mybb->user['avatar'], $mybb->user['avatardimensions'], '100x100');
 eval("\$avatar = \"" . $templates->get("usercp_currentavatar") . "\";");
 $usergroup = htmlspecialchars_uni($groupscache[$mybb->user['usergroup']]['title']);
 if ($mybb->user['usergroup'] == 5 && $mybb->settings['regtype'] != "admin") {
     eval("\$usergroup .= \"" . $templates->get("usercp_resendactivation") . "\";");
 }
 // Make reputations row
 $reputations = '';
 if ($mybb->usergroup['usereputationsystem'] == 1 && $mybb->settings['enablereputation'] == 1) {
     $reputation_link = get_reputation($mybb->user['reputation']);
     eval("\$reputation = \"" . $templates->get("usercp_reputation") . "\";");
 }
 $latest_warnings = '';
 if ($mybb->settings['enablewarningsystem'] != 0 && $mybb->settings['canviewownwarning'] != 0) {
     if ($mybb->settings['maxwarningpoints'] < 1) {
         $mybb->settings['maxwarningpoints'] = 10;
Ejemplo n.º 22
0
     if (empty($user['starimage'])) {
         $user['starimage'] = $usergroup['starimage'];
     }
     $user['userstars'] = '';
     if (!empty($user['starimage'])) {
         // Only display stars if we have an image to use...
         $starimage = str_replace("{theme}", $theme['imgdir'], $user['starimage']);
         for ($i = 0; $i < $user['stars']; ++$i) {
             eval("\$user['userstars'] .= \"" . $templates->get("memberlist_user_userstar", 1, 0) . "\";");
         }
     }
     if ($user['userstars'] && $usergroup['groupimage']) {
         $user['userstars'] = "<br />" . $user['userstars'];
     }
     // Show avatar
     $useravatar = format_avatar($user['avatar'], $user['avatardimensions'], my_strtolower($mybb->settings['memberlistmaxavatarsize']));
     eval("\$user['avatar'] = \"" . $templates->get("memberlist_user_avatar") . "\";");
     if ($user['invisible'] == 1 && $mybb->usergroup['canviewwolinvis'] != 1 && $user['uid'] != $mybb->user['uid']) {
         $user['lastvisit'] = $lang->lastvisit_never;
         if ($user['lastvisit']) {
             // We have had at least some active time, hide it instead
             $user['lastvisit'] = $lang->lastvisit_hidden;
         }
     } else {
         $user['lastvisit'] = my_date('relative', $user['lastactive']);
     }
     $user['regdate'] = my_date('relative', $user['regdate']);
     $user['postnum'] = my_number_format($user['postnum']);
     $user['threadnum'] = my_number_format($user['threadnum']);
     eval("\$users .= \"" . $templates->get("memberlist_user") . "\";");
 }
Ejemplo n.º 23
0
 // Get member's permissions
 $memperms = user_permissions($memprofile['uid']);
 $lang->nav_profile = $lang->sprintf($lang->nav_profile, $memprofile['username']);
 add_breadcrumb($lang->nav_profile);
 $lang->users_forum_info = $lang->sprintf($lang->users_forum_info, $memprofile['username']);
 $lang->users_contact_details = $lang->sprintf($lang->users_contact_details, $memprofile['username']);
 if ($mybb->settings['enablepms'] != 0 && ($memprofile['receivepms'] != 0 && $memperms['canusepms'] != 0 && my_strpos("," . $memprofile['ignorelist'] . ",", "," . $mybb->user['uid'] . ",") === false || $mybb->usergroup['canoverridepm'] == 1)) {
     $lang->send_pm = $lang->sprintf($lang->send_pm, $memprofile['username']);
 } else {
     $lang->send_pm = '';
 }
 $lang->away_note = $lang->sprintf($lang->away_note, $memprofile['username']);
 $lang->users_additional_info = $lang->sprintf($lang->users_additional_info, $memprofile['username']);
 $lang->users_signature = $lang->sprintf($lang->users_signature, $memprofile['username']);
 $lang->send_user_email = $lang->sprintf($lang->send_user_email, $memprofile['username']);
 $useravatar = format_avatar($memprofile['avatar'], $memprofile['avatardimensions']);
 eval("\$avatar = \"" . $templates->get("member_profile_avatar") . "\";");
 $website = $sendemail = $sendpm = $contact_details = '';
 if ($memprofile['website'] && !is_member($mybb->settings['hidewebsite']) && $memperms['canchangewebsite'] == 1) {
     $memprofile['website'] = htmlspecialchars_uni($memprofile['website']);
     $bgcolor = alt_trow();
     eval("\$website = \"" . $templates->get("member_profile_website") . "\";");
 }
 if ($memprofile['hideemail'] != 1 && (my_strpos("," . $memprofile['ignorelist'] . ",", "," . $mybb->user['uid'] . ",") === false || $mybb->usergroup['cansendemailoverride'] != 0)) {
     $bgcolor = alt_trow();
     eval("\$sendemail = \"" . $templates->get("member_profile_email") . "\";");
 }
 if ($mybb->settings['enablepms'] == 1 && $memprofile['receivepms'] != 0 && $mybb->usergroup['cansendpms'] == 1 && my_strpos("," . $memprofile['ignorelist'] . ",", "," . $mybb->user['uid'] . ",") === false) {
     $bgcolor = alt_trow();
     eval('$sendpm = "' . $templates->get("member_profile_pm") . '";');
 }
Ejemplo n.º 24
0
 /**
  * Format avatars for account lists.
  *
  * @param string The avatar file name
  * @param string Dimensions of the avatar, width x height (e.g. 44|44)
  * @return string The formatted avatar
  */
 public function attached_avatar($avatar, $dimensions)
 {
     global $avadims, $attachedPostUser;
     // Set the max. dimensions
     $maxdims = $this->mybb->settings['maxavatardims'];
     if (THIS_SCRIPT == "showthread.php" || THIS_SCRIPT == "private.php" || THIS_SCRIPT == "portal.php" || THIS_SCRIPT == "newreply.php") {
         $maxdims = $this->mybb->settings['postmaxavatarsize'];
     }
     if (THIS_SCRIPT == "memberlist.php") {
         $maxdims = $this->mybb->settings['memberlistmaxavatarsize'];
     }
     // Format the avatar
     $ava = format_avatar($avatar, $dimensions, $maxdims);
     $userAvatar = htmlspecialchars_uni($ava['image']);
     // Load the avatar template
     $userAvatar = eval($this->templates->render('accountswitcher_avatar'));
     return $userAvatar;
 }