/** * display * * @return void */ public function display() { $this->setAvatarTypes(); if (!$this->getAvatarData()) { $this->fcmsError->displayError(); return; } $avatarOptions = buildHtmlSelectOptions($this->avatarTypes, $this->data['currentAvatarType']); echo ' <form id="frm" name="frm" enctype="multipart/form-data" action="profile.php?view=picture" method="post"> <fieldset> <legend><span>' . T_('Profile Picture') . '</span></legend> <div class="field-row"> <div class="field-label"> <label for="avatar"><b>' . T_('Change Avatar') . '</b></label> </div> <div class="field-widget"> <select name="avatar_type" id="avatar_type"> ' . $avatarOptions . ' </select><br/> </div> </div> <div id="fcms" class="field-row">'; $this->displayUploadArea(); echo ' </div> <div id="gravatar" class="field-row"> <div class="field-label"> </div> <div class="field-widget"> <b>' . T_('Gravatar Email') . '</b><br/> <input type="text" name="gravatar_email" size="30" value="' . cleanOutput($this->data['gravatar']) . '"/><br/> </div> </div> <div id="default" class="field-row"> <div class="field-label"> </div> <div class="field-widget"> <b>' . T_('Default') . '</b><br/> <img id="current-avatar" src="' . getAvatarPath('no_avatar.jpg', '') . '" alt="' . T_('Default avatar.') . '"/> </div> </div> <div class="field-row"> <div class="field-label"> <label for="avatar"><b>' . T_('Current Avatar') . '</b></label> </div> <div class="field-widget"> <img id="current-avatar" src="' . getCurrentAvatar($this->fcmsUser->id) . '" alt="' . T_('This is your current avatar.') . '"/> </div> </div> <p><input class="sub1" type="submit" name="submit" id="submit-avatar" value="' . T_('Submit') . '"/></p> </fieldset> </form>'; }
/** * displayPollTemplate * * @param array $data * @param string $displayResults * * @return void */ function displayPollTemplate($data, $displayResults = false) { $pollId = key($data); // Get comments $comments = $this->fcmsPoll->getPollCommentsData($pollId); if ($comments === false) { $this->fcmsError->displayError(); $this->displayFooter(); return; } $commentsTotal = $comments['total']; unset($comments['total']); $pollOptions = array(); // Show results - user already voted if (isset($data['users_who_voted'][$this->fcmsUser->id]) || $displayResults) { $pollResults = $this->fcmsPoll->formatPollResults($data); if ($pollResults === false) { $this->fcmsError->displayError(); $this->displayFooter(); return; } $pollParams = array('pollFormClass' => 'poll', 'pollId' => $pollId, 'textPolls' => T_('Polls'), 'pollQuestion' => cleanOutput($data[$pollId]['question'], 'html'), 'textCommentsCount' => sprintf(T_('Comments (%s)'), $commentsTotal), 'textAlreadyVoted' => T_('Already Voted'), 'pollResults' => $pollResults); loadTemplate('poll', 'result', $pollParams); } else { foreach ($data[$pollId]['options'] as $optionId => $optionData) { $pollOptions[] = array('id' => (int) $optionId, 'text' => cleanOutput($optionData['option'], 'html')); } $pollParams = array('pollFormClass' => 'poll', 'pollId' => $pollId, 'textPolls' => T_('Polls'), 'pollQuestion' => cleanOutput($data[$pollId]['question'], 'html'), 'textPollVote' => T_('Vote'), 'textPollResults' => T_('Results'), 'textPastPolls' => T_('Past Polls'), 'pollOptions' => $pollOptions); loadTemplate('poll', 'view', $pollParams); } // Comments $commentsParams = array(); foreach ($comments as $row) { $params = array('id' => (int) $row['id'], 'formClass' => 'delcom', 'formUrl' => 'polls.php?id=' . $pollId, 'avatar' => getAvatarPath($row['avatar'], $row['gravatar']), 'displayname' => $row['fname'] . ' ' . $row['lname'], 'date' => fixDate(T_('F j, Y g:i a'), $this->fcmsUser->tzOffset, $row['created']), 'comment' => parse($row['comment'])); if ($this->fcmsUser->id == $row['created'] || $this->fcmsUser->access < 2) { $params['textDelete'] = T_('Delete'); $params['deleteClass'] = 'gal_delcombtn'; $params['deleteTitle'] = T_('Delete this Comment'); } $commentsParams[] = $params; } $templateParams = array('comments' => $commentsParams, 'addCommentUrl' => 'polls.php?id=' . $pollId, 'textAddCommentLabel' => T_('Add Comment'), 'addCommentSubmitClass' => 'sub1', 'addCommentSubmitValue' => T_('Comment'), 'addCommentSubmitTitle' => T_('Add Comment')); loadTemplate('global', 'comments', $templateParams); $this->displayFooter(); }
/** * getMembersInCategory * * @param int $cid * * @return string */ function getMembersInCategory($uid, $cid) { $retVal = ''; $sql = "SELECT u.`id`, u.`fname`, u.`lname`, u.`avatar`, u.`gravatar`\n FROM `fcms_gallery_photos_tags` AS t\n LEFT JOIN `fcms_gallery_photos` AS p ON t.`photo` = p.`id`\n LEFT JOIN `fcms_category` AS c ON p.`category` = c.`id`\n LEFT JOIN `fcms_users` AS u ON t.`user` = u.`id`\n WHERE p.`category` = ?\n AND p.`user` = ?\n GROUP BY u.`id`"; $rows = $this->fcmsDatabase->getRows($sql, array($cid, $uid)); if ($rows === false) { $this->fcmsError->displayError(); return $retVal; } if (count($rows) <= 0) { if ($uid == $this->fcmsUser->id || $this->fcmsUser->access < 2) { $retVal .= '<a href="?tag=' . $cid . '&user='******'">' . T_('Tag Members In Photos') . '</a>'; } return $retVal; } $retVal .= ' <ul class="avatar-member-list-small">'; foreach ($rows as $row) { $id = (int) $row['id']; $displayname = cleanOutput($row['fname']) . ' ' . cleanOutput($row['lname']); $avatarPath = getAvatarPath($row['avatar'], $row['gravatar'], '../'); $retVal .= ' <li> <a href="index.php?uid=0&cid=' . $id . '" class="tooltip" title="" onmouseover="showTooltip(this)" onmouseout="hideTooltip(this)"> <img class="avatar" alt="avatar" src="' . $avatarPath . '"/> </a> <div class="tooltip" style="display:none;"> <h5>' . $displayname . '</h5> <span>' . sprintf(T_('Click to view more photos of %s.'), $displayname) . '</span> </div> </li>'; } $retVal .= ' </ul>'; return $retVal; }
//file_get_contents("http://armymax.com/api/noti/noti.php?a=insert&f=".$f."&t=".$t."&msg=".$m."&type=".$type); break; case $TYPES_chatInviteGroup: $data = array("type" => $type, "title" => $title, "alert" => $m, "from_id" => $f, "from_name" => $n, "from_avatar" => getAvatarPath($f), "to_id" => $t, "type" => $type, "cid" => $_GET["cid"], "extra" => $_GET["extra"], "chat_msg" => $m, "action" => "co.aquario.vmmax.PUSH_NOTIFICATION", "customdata" => "GOD LIKE ! (506 invite chat group)"); //file_get_contents("http://armymax.com/api/noti/noti.php?a=insert&f=".$f."&t=".$t."&msg=".$m."&type=".$type); insertNoti($f, $n, $t, $m, $type, $_GET["cid"], $_GET["extra"]); break; case $TYPES_confInvite: $data = array("type" => $type, "title" => $title, "alert" => $m, "from_id" => $f, "from_name" => $n, "from_avatar" => getAvatarPath($f), "to_id" => $t, "type" => $type, "room_name" => $_GET["room_name"], "action" => "co.aquario.vmmax.PUSH_NOTIFICATION", "customdata" => "GOD LIKE ! (600,601,602 conference)"); break; case $TYPES_confCreate: case $TYPES_confJoin: if (isset($_GET["cid"])) { $data = array("type" => $type, "title" => $title, "alert" => $m, "from_id" => $f, "from_name" => $n, "from_avatar" => getAvatarPath($f), "to_id" => $t, "type" => $type, "cid" => $_GET["cid"], "room_name" => $_GET["room_name"]); } else { $data = array("type" => $type, "title" => $title, "alert" => $m, "from_id" => $f, "from_name" => $n, "from_avatar" => getAvatarPath($f), "to_id" => $t, "type" => $type, "room_name" => $_GET["room_name"]); } insertNoti($f, $n, $t, $m, $type, $_GET["cid"], $_GET["room_name"]); //file_get_contents("http://armymax.com/api/noti/noti.php?a=insert&f=".$f."&t=".$t."&msg=".$m."&type=".$type."&post_id=".$_GET["room_name"]); break; } //Default for all $data['badge'] = $badge; $data['badge_social'] = $badgeSocial; $data['badge_chat'] = $badgeChat; $data['badge_follow'] = $badgeFollow; $data['sound'] = "homerun.caf"; //echo $_GET['type']; $cURLHandler = curl_init(); $url = "https://api.parse.com/1/push"; // if(isset($_GET["all"])) {
/** * The avatar is incredibly complicated, what with the options... and what not. * @todo argh, the avatar here. Take this out of here! * * @param mixed[] $value * @return false|string */ function profileSaveAvatarData(&$value) { global $modSettings, $profile_vars, $cur_profile, $context; $db = database(); $memID = $context['id_member']; if (empty($memID) && !empty($context['password_auth_failed'])) { return false; } // We need to know where we're going to be putting it.. require_once SUBSDIR . '/Attachments.subs.php'; require_once SUBSDIR . '/ManageAttachments.subs.php'; $uploadDir = getAvatarPath(); $id_folder = getAvatarPathID(); $downloadedExternalAvatar = false; $valid_http = isset($_POST['userpicpersonal']) && substr($_POST['userpicpersonal'], 0, 7) === 'http://' && strlen($_POST['userpicpersonal']) > 7; $valid_https = isset($_POST['userpicpersonal']) && substr($_POST['userpicpersonal'], 0, 8) === 'https://' && strlen($_POST['userpicpersonal']) > 8; if ($value == 'external' && allowedTo('profile_remote_avatar') && ($valid_http || $valid_https) && !empty($modSettings['avatar_download_external'])) { loadLanguage('Post'); if (!is_writable($uploadDir)) { fatal_lang_error('attachments_no_write', 'critical'); } require_once SUBSDIR . '/Package.subs.php'; $url = parse_url($_POST['userpicpersonal']); $contents = fetch_web_data((empty($url['scheme']) ? 'http://' : $url['scheme'] . '://') . $url['host'] . (empty($url['port']) ? '' : ':' . $url['port']) . str_replace(' ', '%20', trim($url['path']))); if ($contents != false) { // Create a hashed name to save $new_avatar_name = $uploadDir . '/' . getAttachmentFilename('avatar_tmp_' . $memID, false, null, true); if (file_put_contents($new_avatar_name, $contents) !== false) { $downloadedExternalAvatar = true; $_FILES['attachment']['tmp_name'] = $new_avatar_name; } } } if ($value == 'none') { $profile_vars['avatar'] = ''; // Reset the attach ID. $cur_profile['id_attach'] = 0; $cur_profile['attachment_type'] = 0; $cur_profile['filename'] = ''; removeAttachments(array('id_member' => $memID)); } elseif ($value == 'server_stored' && allowedTo('profile_server_avatar')) { $profile_vars['avatar'] = strtr(empty($_POST['file']) ? empty($_POST['cat']) ? '' : $_POST['cat'] : $_POST['file'], array('&' => '&')); $profile_vars['avatar'] = preg_match('~^([\\w _!@%*=\\-#()\\[\\]&.,]+/)?[\\w _!@%*=\\-#()\\[\\]&.,]+$~', $profile_vars['avatar']) != 0 && preg_match('/\\.\\./', $profile_vars['avatar']) == 0 && file_exists($modSettings['avatar_directory'] . '/' . $profile_vars['avatar']) ? $profile_vars['avatar'] == 'blank.png' ? '' : $profile_vars['avatar'] : ''; // Clear current profile... $cur_profile['id_attach'] = 0; $cur_profile['attachment_type'] = 0; $cur_profile['filename'] = ''; // Get rid of their old avatar. (if uploaded.) removeAttachments(array('id_member' => $memID)); } elseif ($value == 'gravatar' && allowedTo('profile_gravatar')) { $profile_vars['avatar'] = 'gravatar'; // Reset the attach ID. $cur_profile['id_attach'] = 0; $cur_profile['attachment_type'] = 0; $cur_profile['filename'] = ''; removeAttachments(array('id_member' => $memID)); } elseif ($value == 'external' && allowedTo('profile_remote_avatar') && ($valid_http || $valid_https) && empty($modSettings['avatar_download_external'])) { // We need these clean... $cur_profile['id_attach'] = 0; $cur_profile['attachment_type'] = 0; $cur_profile['filename'] = ''; // Remove any attached avatar... removeAttachments(array('id_member' => $memID)); $profile_vars['avatar'] = str_replace(' ', '%20', preg_replace('~action(?:=|%3d)(?!dlattach)~i', 'action-', $_POST['userpicpersonal'])); if ($profile_vars['avatar'] == 'http://' || $profile_vars['avatar'] == 'http:///') { $profile_vars['avatar'] = ''; } elseif (!$valid_http && !$valid_https) { return 'bad_avatar'; } elseif (!empty($modSettings['avatar_max_height_external']) || !empty($modSettings['avatar_max_width_external'])) { // Now let's validate the avatar. $sizes = url_image_size($profile_vars['avatar']); if (is_array($sizes) && ($sizes[0] > $modSettings['avatar_max_width_external'] && !empty($modSettings['avatar_max_width_external']) || $sizes[1] > $modSettings['avatar_max_height_external'] && !empty($modSettings['avatar_max_height_external']))) { // Houston, we have a problem. The avatar is too large!! if ($modSettings['avatar_action_too_large'] == 'option_refuse') { return 'bad_avatar'; } elseif ($modSettings['avatar_action_too_large'] == 'option_download_and_resize') { // @todo remove this if appropriate require_once SUBSDIR . '/Attachments.subs.php'; if (saveAvatar($profile_vars['avatar'], $memID, $modSettings['avatar_max_width_external'], $modSettings['avatar_max_height_external'])) { $profile_vars['avatar'] = ''; $cur_profile['id_attach'] = $modSettings['new_avatar_data']['id']; $cur_profile['filename'] = $modSettings['new_avatar_data']['filename']; $cur_profile['attachment_type'] = $modSettings['new_avatar_data']['type']; } else { return 'bad_avatar'; } } } } } elseif ($value == 'upload' && allowedTo('profile_upload_avatar') || $downloadedExternalAvatar) { if (isset($_FILES['attachment']['name']) && $_FILES['attachment']['name'] != '' || $downloadedExternalAvatar) { // Get the dimensions of the image. if (!$downloadedExternalAvatar) { if (!is_writable($uploadDir)) { loadLanguage('Post'); fatal_lang_error('attachments_no_write', 'critical'); } $new_avatar_name = $uploadDir . '/' . getAttachmentFilename('avatar_tmp_' . $memID, false, null, true); if (!move_uploaded_file($_FILES['attachment']['tmp_name'], $new_avatar_name)) { fatal_lang_error('attach_timeout', 'critical'); } $_FILES['attachment']['tmp_name'] = $new_avatar_name; } // If there is no size, then it's probably not a valid pic, so lets remove it. $sizes = @getimagesize($_FILES['attachment']['tmp_name']); if ($sizes === false) { @unlink($_FILES['attachment']['tmp_name']); return 'bad_avatar'; } elseif (!empty($modSettings['avatar_max_width_upload']) && $sizes[0] > $modSettings['avatar_max_width_upload'] || !empty($modSettings['avatar_max_height_upload']) && $sizes[1] > $modSettings['avatar_max_height_upload']) { if (!empty($modSettings['avatar_resize_upload'])) { // Attempt to chmod it. @chmod($_FILES['attachment']['tmp_name'], 0644); // @todo remove this require when appropriate require_once SUBSDIR . '/Attachments.subs.php'; if (!saveAvatar($_FILES['attachment']['tmp_name'], $memID, $modSettings['avatar_max_width_upload'], $modSettings['avatar_max_height_upload'])) { // Something went wrong, so lets delete this offender @unlink($_FILES['attachment']['tmp_name']); return 'bad_avatar'; } // Reset attachment avatar data. $cur_profile['id_attach'] = $modSettings['new_avatar_data']['id']; $cur_profile['filename'] = $modSettings['new_avatar_data']['filename']; $cur_profile['attachment_type'] = $modSettings['new_avatar_data']['type']; } else { @unlink($_FILES['attachment']['tmp_name']); return 'bad_avatar'; } } elseif (is_array($sizes)) { // Now try to find an infection. require_once SUBSDIR . '/Graphics.subs.php'; if (!checkImageContents($_FILES['attachment']['tmp_name'], !empty($modSettings['avatar_paranoid']))) { // It's bad. Try to re-encode the contents? if (empty($modSettings['avatar_reencode']) || !reencodeImage($_FILES['attachment']['tmp_name'], $sizes[2])) { @unlink($_FILES['attachment']['tmp_name']); return 'bad_avatar'; } // We were successful. However, at what price? $sizes = @getimagesize($_FILES['attachment']['tmp_name']); // Hard to believe this would happen, but can you bet? if ($sizes === false) { @unlink($_FILES['attachment']['tmp_name']); return 'bad_avatar'; } } $extensions = array('1' => 'gif', '2' => 'jpg', '3' => 'png', '6' => 'bmp'); $extension = isset($extensions[$sizes[2]]) ? $extensions[$sizes[2]] : 'bmp'; $mime_type = 'image/' . ($extension === 'jpg' ? 'jpeg' : ($extension === 'bmp' ? 'x-ms-bmp' : $extension)); $destName = 'avatar_' . $memID . '_' . time() . '.' . $extension; list($width, $height) = getimagesize($_FILES['attachment']['tmp_name']); $file_hash = empty($modSettings['custom_avatar_enabled']) ? getAttachmentFilename($destName, false, null, true) : ''; // Remove previous attachments this member might have had. removeAttachments(array('id_member' => $memID)); $db->insert('', '{db_prefix}attachments', array('id_member' => 'int', 'attachment_type' => 'int', 'filename' => 'string', 'file_hash' => 'string', 'fileext' => 'string', 'size' => 'int', 'width' => 'int', 'height' => 'int', 'mime_type' => 'string', 'id_folder' => 'int'), array($memID, empty($modSettings['custom_avatar_enabled']) ? 0 : 1, $destName, $file_hash, $extension, filesize($_FILES['attachment']['tmp_name']), (int) $width, (int) $height, $mime_type, $id_folder), array('id_attach')); $cur_profile['id_attach'] = $db->insert_id('{db_prefix}attachments', 'id_attach'); $cur_profile['filename'] = $destName; $cur_profile['attachment_type'] = empty($modSettings['custom_avatar_enabled']) ? 0 : 1; $destinationPath = $uploadDir . '/' . (empty($file_hash) ? $destName : $cur_profile['id_attach'] . '_' . $file_hash . '.elk'); if (!rename($_FILES['attachment']['tmp_name'], $destinationPath)) { // I guess a man can try. removeAttachments(array('id_member' => $memID)); fatal_lang_error('attach_timeout', 'critical'); } // Attempt to chmod it. @chmod($uploadDir . '/' . $destinationPath, 0644); } $profile_vars['avatar'] = ''; // Delete any temporary file. if (file_exists($_FILES['attachment']['tmp_name'])) { @unlink($_FILES['attachment']['tmp_name']); } } else { $profile_vars['avatar'] = ''; } } else { $profile_vars['avatar'] = ''; } // Setup the profile variables so it shows things right on display! $cur_profile['avatar'] = $profile_vars['avatar']; return false; }
/** * displayInbox * * @return void */ function displayInbox() { $this->displayHeader(array('jsOnload' => ' $(\'.pm_footer input[type="submit"]\').click(function(e) { return confirmDeleteLink(this, "' . T_('Are you sure you want to DELETE this?') . '", e); });')); if (isset($_SESSION['success'])) { displayOkMessage(); unset($_SESSION['success']); } $header = T_('Inbox'); if (isset($_SESSION['private_messages']) && $_SESSION['private_messages'] > 0) { $header = sprintf(T_('Inbox (%d)'), $_SESSION['private_messages']); } echo ' <form method="post" action="privatemsg.php"> <table id="pm" cellpadding="0" cellspacing="0"> <tr> <th colspan="3" class="pm_header">' . $header . '</th> </tr>'; $sql = "SELECT p.`id`, `to`, `from`, `title`, `date`, `read`, u.`avatar`, u.`gravatar`\n FROM `fcms_privatemsg` AS p\n LEFT JOIN `fcms_users` AS u ON p.`from` = u.`id`\n WHERE `to` = ?\n ORDER BY `date` DESC"; $rows = $this->fcmsDatabase->getRows($sql, $this->fcmsUser->id); if ($rows === false) { $this->fcmsError->displayError(); $this->displayFooter(); return; } foreach ($rows as $r) { $date = fixDate(T_('M. j, Y, g:i a'), $this->fcmsUser->tzOffset, $r['date']); $avatarPath = getAvatarPath($r['avatar'], $r['gravatar']); $from = getUserDisplayName($r['from']); $rowClass = ''; $linkClass = 'read'; if ($r['read'] < 1) { $rowClass = 'new'; $linkClass = ''; } echo ' <tr class="' . $rowClass . '"> <td class="img"></td> <td> <div class="user"> <img src="' . $avatarPath . '" alt="' . $from . '" title="' . $from . '"/> </div> <a class="' . $linkClass . '" href="?pm=' . (int) $r['id'] . '">' . cleanOutput($r['title']) . '</a> <span>' . $date . '</span> </td> <td class="check"><input type="checkbox" name="del[]" value="' . (int) $r['id'] . '"/></td> </tr>'; } echo ' <tr> <th colspan="3" class="pm_footer"> <input class="sub1" type="submit" name="delete" value="' . T_('Delete Selected') . '"/> </th> </tr> </table> </form>'; $this->displayFooter(); }
/** * displayPerson * * Displays the anchor representing a single * person on the tree. * * @param array $data * * @return void */ function displayPerson($data) { $data['sex'] = strtolower($data['sex']); $bday = '<i>' . T_('Living') . '</i>'; $dday = ''; // Just birthday if (isset($data['dob_year']) && !empty($data['dob_year'])) { $bday = (int) $data['dob_year']; $bday .= ' - '; $dday = '<i>' . T_('Living') . '</i>'; // Birthday and Deceased date if (isset($data['dod_year']) && !empty($data['dod_year'])) { $dday = (int) $data['dod_year']; } } else { if (isset($data['dod_year']) && !empty($data['dod_year'])) { $bday = '? - '; $dday = (int) $data['dod_year']; } } $middleName = isset($data['mname']) && !empty($data['mname']) ? $data['mname'] . '<br/>' : ''; $maidenName = ''; if (isset($data['maiden']) && !empty($data['maiden']) && $data['maiden'] != $data['lname']) { $maidenName = '<br/>(' . cleanOutput($data['maiden']) . ')'; } $avatarPath = getAvatarPath($data['avatar'], $data['gravatar']); $edit = ''; $add = ''; $del = ''; if ($data['phpass'] == 'NONMEMBER' || $this->fcmsUser->access == 1 || $this->fcmsUser->id == $data['id']) { $edit = '<a class="edit" href="?view=' . $data['id'] . '&edit=' . $data['id'] . '">' . T_('Edit') . '</a>'; $add = '<a class="add" href="#' . $data['id'] . '">' . T_('Add Family Member') . '</a>'; $del = '<a class="delete" href="?delete=' . $data['id'] . '">' . T_('Delete All Relationships') . '</a>'; $del .= '<script type="text/javascript">'; $del .= '$(\'a.delete\').each(function() {'; $del .= ' var jqLink = $(this);'; $del .= ' jqLink.click(function() {'; $del .= ' if (confirm(\'' . T_('Are you sure you want to DELETE this?') . '\')) {'; $del .= ' var url = jqLink.attr("href");'; $del .= ' window.location = url + "&confirm=1";'; $del .= ' }'; $del .= ' return false;'; $del .= ' });'; $del .= '});'; $del .= '</script>'; } echo ' <div class="person ' . $data['sex'] . '"> <div class="tree-thumbnail"> <img src="' . $avatarPath . '"/> </div> <div class="tree-detail"> <a href="?details=' . $data['id'] . '"> ' . cleanOutput($data['fname']) . '<br/> ' . $middleName . ' ' . cleanOutput($data['lname']) . ' ' . $maidenName . ' </a> <p>' . $bday . $dday . '</p> <span class="tools"> <a class="view" href="?view=' . $data['id'] . '">' . T_('View') . '</a> ' . $del . ' ' . $edit . ' ' . $add . ' </span> </div> </div>'; }
/** * getVideoComments * * Valid params: * * currentUserId - The current user's id. * id - The id of the video. * * @param string $url * @param string $params * * @return void */ function getVideoComments($url, $params) { $fcmsError = FCMS_Error::getInstance(); $fcmsDatabase = Database::getInstance($fcmsError); $fcmsUser = new User($fcmsError, $fcmsDatabase); $comments = ''; if (!isset($params['id'])) { die("Missing Video ID or User ID for getVideoComments"); } $id = $params['id']; $sql = "SELECT c.`id`, c.`comment`, c.`created`, c.`updated`, u.`fname`, u.`lname`, c.`created_id`, u.`avatar`, u.`gravatar`, s.`timezone`\n FROM `fcms_video_comment` AS c\n LEFT JOIN `fcms_users` AS u ON c.`created_id` = u.`id`\n LEFT JOIN `fcms_user_settings` AS s ON u.`id` = s.`user`\n WHERE `video_id` = '{$id}' \n ORDER BY `updated`"; $rows = $fcmsDatabase->getRows($sql, $id); if ($rows === false) { $fcmsError->displayError(); return; } foreach ($rows as $row) { $del_comment = ''; $date = fixDate(T_('F j, Y g:i a'), $row['timezone'], $row['updated']); $displayname = $row['fname'] . ' ' . $row['lname']; $comment = $row['comment']; $avatarPath = getAvatarPath($row['avatar'], $row['gravatar']); if ($fcmsUser->id == $row['created'] || $fcmsUser->access < 2) { $del_comment .= '<input type="submit" name="delcom" id="delcom" ' . 'value="' . T_('Delete') . '" class="gal_delcombtn" title="' . T_('Delete this Comment') . '"/>'; } $comments .= ' <div class="comment"> <form class="delcom" action="' . $url . '" method="post"> ' . $del_comment . ' <img class="avatar" alt="avatar" src="' . $avatarPath . '"/> <b>' . $displayname . '</b> <span>' . $date . '</span> <p> ' . parse($comment) . ' </p> <input type="hidden" name="id" value="' . $row['id'] . '"> </form> </div>'; } return $comments; }
/** * displayDetails * * @return void */ function displayDetails() { $this->displayHeader(array('jsOnload' => 'initAddRelative();')); $id = (int) $_GET['details']; $sql = "SELECT *\n FROM `fcms_users`\n WHERE `id` = ?"; $user = $this->fcmsDatabase->getRow($sql, $id); if ($user === false) { $this->fcmsError->displayError(); $this->displayFooter(); return; } $canEdit = false; $editLink = ''; if ($user['phpass'] == 'NONMEMBER' || $this->fcmsUser->access == 1) { $canEdit = true; $editLink = '<li><a href="?edit=' . $id . '">' . T_('Edit This Person') . '</a></li>'; } $avatarPath = getAvatarPath($user['avatar'], $user['gravatar']); $status = $user['phpass'] == 'NONMEMBER' ? T_('Non-member') : T_('Member'); // Bio if (strlen($user['bio']) > 0) { $bio = cleanOutput($user['bio']); } elseif ($canEdit) { $bio = '<a href="?edit=' . $id . '">' . T_('Share some information about this person.') . '</a>'; } else { $bio = T_('This user does not have a bio.'); } // Get Parents $parents = $this->fcmsFamilyTree->getParentsOfUsers(array($user['id'])); if ($parents === false) { $this->fcmsError->displayError(); $this->displayFooter(); return; } $father = array(); $mother = array(); foreach ($parents as $parent) { if ($parent['sex'] == 'M') { $father[] = $parent; } else { $mother[] = $parent; } } // Get spouse $spouse = $this->fcmsFamilyTree->getSpousesOfUsers(array($user['id'])); if ($spouse === false) { $this->fcmsError->displayError(); $this->displayFooter(); return; } // Get children $children = $this->fcmsFamilyTree->getChildrenOfUsers($spouse); if ($children === false) { $this->fcmsError->displayError(); $this->displayFooter(); return; } list($bday, $death) = $this->fcmsFamilyTree->getFormattedBirthdayAndDeath($user); echo ' <div id="sections_menu"> <ul> <li><a href="?view=' . $id . '">' . T_('View Family Tree') . '</a></li> </ul> </div> <div id="actions_menu"> <ul class="tools"> ' . $editLink . ' <li><a class="add" href="#' . $id . '">' . T_('Add Family Member') . '</a></li> </ul> </div> <div class="person-details"> <img class="avatar" src="' . $avatarPath . '"/> <h1>' . $user['fname'] . ' ' . $user['lname'] . '</h1> <p class="member_status">' . $status . '</p> </div> <p> ' . $bday . '<br/> ' . $death . ' </p> <h3>' . T_('Bio') . '</h3> <p>' . $bio . '</p> <h3>' . T_('Immediate Family') . '</h3> <ul id="immediate-family">'; // Print parents, spouses, and children $types = array('father' => array('M' => T_('Father')), 'mother' => array('F' => T_('Mother')), 'spouse' => array('M' => T_('Spouse'), 'F' => T_('Spouse')), 'children' => array('M' => T_('Son'), 'F' => T_('Daughter'))); foreach ($types as $type => $i18n) { foreach (${$type} as $relative) { if (!empty($relative)) { $relAvatarPath = getAvatarPath($relative['avatar'], $relative['gravatar']); $maiden = strlen($relative['maiden']) > 0 ? '(' . $relative['maiden'] . ')' : ''; echo ' <li> <img class="small-avatar" src="' . $relAvatarPath . '"/> <p> <a href="?details=' . $relative['id'] . '"> ' . $relative['fname'] . ' ' . $relative['mname'] . ' ' . $relative['lname'] . ' ' . $maiden . ' </a> <i>' . $i18n[$relative['sex']] . '</i> </p> </li>'; } } } $this->displayFooter(); }
/** * displayUserVideosPage * * @return void */ function displayUserVideosPage() { $this->displayHeader(); $userId = (int) $_GET['u']; if (isset($_SESSION['message'])) { $this->displayMessage($_SESSION['message']); } // Get user info $sql = "SELECT 'id', `fname`, `lname`, `avatar`, `gravatar`\n FROM `fcms_users`\n WHERE `id` = ?"; $row = $this->fcmsDatabase->getRow($sql, $userId); if ($row === false) { $this->fcmsError->displayError(); $this->displayFooter(); return; } if (empty($row)) { echo '<div class="error-alert">' . T_('Member not found.') . '</div>'; $this->displayFooter(); return; } $name = cleanOutput($row['fname']) . ' ' . cleanOutput($row['lname']); $avatarPath = getAvatarPath($row['avatar'], $row['gravatar']); echo ' <div id="sections_menu"> <ul> <li><a href="video.php">Latest Videos</a></li> <li><a href="video.php?members=all">Members</a></li> </ul> </div> <div id="video_content"> <div id="member"> <img src="' . $avatarPath . '" titl="' . $name . '"/> <span>' . T_('Videos For:') . '</span> <h2>' . $name . '</h2> </div> <ul class="categories">'; // Get videos $sql = "SELECT `id`, `source_id`, `title`, `active`, `created`, `created_id`\n FROM `fcms_video`\n WHERE `created_id` = ?\n ORDER BY `updated` DESC"; $rows = $this->fcmsDatabase->getRows($sql, $userId); if ($rows === false) { $this->fcmsError->displayError(); $this->displayFooter(); return; } if (count($rows) <= 0) { echo '<div class="error-alert">' . T_('No videos found.') . '</div>'; $this->displayFooter(); return; } foreach ($rows as $row) { $class = ''; if ($row['active'] == '0') { if ($row['created_id'] != $this->fcmsUser->id) { continue; } $class = 'removed'; } $date = fixDate('Y-m-d', '', $row['created'], $this->fcmsUser->id); echo ' <li class="category ' . $class . '"> <a href="?u=' . $userId . '&id=' . $row['id'] . '"><img src="http://i.ytimg.com/vi/' . $row['source_id'] . '/default.jpg"/></a> <span> <strong>' . cleanOutput($row['title']) . '</strong> <i>' . sprintf(T_pgettext('%s is a date', 'on %s'), $date) . '</i> </span> </li>'; } $this->displayFooter(); }
/** * Saves a file and stores it locally for avatar use by id_member. * * What it does: * - supports GIF, JPG, PNG, BMP and WBMP formats. * - detects if GD2 is available. * - uses resizeImageFile() to resize to max_width by max_height, and saves the result to a file. * - updates the database info for the member's avatar. * - returns whether the download and resize was successful. * * @uses subs/Graphics.subs.php * @package Attachments * @param string $temporary_path the full path to the temporary file * @param int $memID member ID * @param int $max_width * @param int $max_height * @return boolean whether the download and resize was successful. * */ function saveAvatar($temporary_path, $memID, $max_width, $max_height) { global $modSettings; $db = database(); $ext = !empty($modSettings['avatar_download_png']) ? 'png' : 'jpeg'; $destName = 'avatar_' . $memID . '_' . time() . '.' . $ext; // Just making sure there is a non-zero member. if (empty($memID)) { return false; } require_once SUBSDIR . '/ManageAttachments.subs.php'; removeAttachments(array('id_member' => $memID)); $id_folder = getAttachmentPathID(); $avatar_hash = empty($modSettings['custom_avatar_enabled']) ? getAttachmentFilename($destName, 0, null, true) : ''; $db->insert('', '{db_prefix}attachments', array('id_member' => 'int', 'attachment_type' => 'int', 'filename' => 'string-255', 'file_hash' => 'string-255', 'fileext' => 'string-8', 'size' => 'int', 'id_folder' => 'int'), array($memID, empty($modSettings['custom_avatar_enabled']) ? 0 : 1, $destName, $avatar_hash, $ext, 1, $id_folder), array('id_attach')); $attachID = $db->insert_id('{db_prefix}attachments', 'id_attach'); // First, the temporary file will have the .tmp extension. $tempName = getAvatarPath() . '/' . $destName . '.tmp'; // The destination filename will depend on whether custom dir for avatars has been set $destName = getAvatarPath() . '/' . $destName; $path = getAttachmentPath(); $destName = empty($avatar_hash) ? $destName : $path . '/' . $attachID . '_' . $avatar_hash . '.elk'; // Resize it. require_once SUBSDIR . '/Graphics.subs.php'; if (!empty($modSettings['avatar_download_png'])) { $success = resizeImageFile($temporary_path, $tempName, $max_width, $max_height, 3); } else { $success = resizeImageFile($temporary_path, $tempName, $max_width, $max_height); } if ($success) { // Remove the .tmp extension from the attachment. if (rename($tempName, $destName)) { list($width, $height) = getimagesize($destName); $mime_type = 'image/' . $ext; // Write filesize in the database. $db->query('', ' UPDATE {db_prefix}attachments SET size = {int:filesize}, width = {int:width}, height = {int:height}, mime_type = {string:mime_type} WHERE id_attach = {int:current_attachment}', array('filesize' => filesize($destName), 'width' => (int) $width, 'height' => (int) $height, 'current_attachment' => $attachID, 'mime_type' => $mime_type)); // Retain this globally in case the script wants it. $modSettings['new_avatar_data'] = array('id' => $attachID, 'filename' => $destName, 'type' => empty($modSettings['custom_avatar_enabled']) ? 0 : 1); return true; } else { return false; } } else { $db->query('', ' DELETE FROM {db_prefix}attachments WHERE id_attach = {int:current_attachment}', array('current_attachment' => $attachID)); @unlink($tempName); return false; } }
if (empty($data['access_token'])) { continue; } $fsObj = new EpiFoursquare($config['fs_client_id'], $config['fs_client_secret'], $data['access_token']); try { $creds = $fsObj->get('/users/' . $data['user_id'] . '/checkins'); } catch (EpiFoursquareException $e) { echo 'We caught an EpiOAuthException'; echo $e->getMessage(); break; } catch (Exception $e) { echo 'We caught an unexpected Exception'; echo $e->getMessage(); break; } $photo = getAvatarPath($data['avatar'], $data['gravatar']); foreach ($creds->response->checkins->items as $checkin) { // Skip shouts, etc if ($checkin->type != 'checkin') { continue; } $address = isset($checkin->venue->location->address) ? $checkin->venue->location->address : ''; $shout = isset($checkin->shout) ? $checkin->shout : ''; $date = fixDate('F j, Y', $data['timezone'], date('Y-m-d H:i:s', $checkin->createdAt)); $sort = $checkin->createdAt; $historyData[$i] = array('photo' => $photo, 'name' => $data['name'], 'venue' => $checkin->venue->name, 'address' => $address, 'date' => $date, 'sort' => $sort, 'shout' => $shout); $i++; } } $historyData = subval_sort($historyData, 'sort'); $historyData = array_reverse($historyData);
/** * getUsersAvatarName * * Gets the avatar and name for the given members. * * @param array $users * * @return array */ function getUsersAvatarName($users) { $avatars = array(); $ids = implode(',', array_keys($users)); $sql = "SELECT `id`, `avatar`, `gravatar`, `fname`, `lname`\n FROM `fcms_users`\n WHERE `id` IN ({$ids})"; $rows = $this->fcmsDatabase->getRows($sql); if ($rows === false) { $this->fcmsError->setMessage(T_('Could not get member information.')); return false; } foreach ($rows as $r) { $avatars[$r['id']]['avatar'] = getAvatarPath($r['avatar'], $r['gravatar']); $avatars[$r['id']]['name'] = $r['fname'] . ' ' . $r['lname']; } return $avatars; }
/** * getCurrentAvatar * * @param int $id User id * * @return string */ function getCurrentAvatar($id) { $fcmsError = FCMS_Error::getInstance(); $fcmsDatabase = Database::getInstance($fcmsError); $id = (int) $id; $sql = "SELECT `avatar`, `gravatar`\n FROM `fcms_users`\n WHERE `id` = ?"; $r = $fcmsDatabase->getRow($sql, $id); if ($r === false) { return getAvatarPath('no_avatar.jpg', NULL); } // No Avatar set if (count($r) <= 0) { return getAvatarPath('no_avatar.jpg', NULL); } return getAvatarPath($r['avatar'], $r['gravatar']); }