send_Action_Response('Success', $res); exit; break; case 'fetchArchives': $date = get_POST_var('DATE'); $roomId = get_POST_var('ROOMID'); $MCR = new ManageChatRooms(); $ARMSGS = $MCR->get_Archives_fromRoom($date, $roomId, $_SESSION['empl_id']); send_Action_Response('Success', " NEW_MESSAGES = " . json_encode($ARMSGS['NEW_MESSAGES']) . "; LASTFETCHEDMSGID = {$ARMSGS['LASTFETCHEDMSGID']} ;"); exit; break; case 'getRoomIdsForUser': $MU = new ManageUsers(); $MU->userId = get_POST_var('uid'); $user_rooms = $MU->getUser_AllowedChatRooms_IncludeDepricatedOnes(); send_Action_Response('Success', " USER_ROOMS = " . json_encode($user_rooms) . "; "); exit; break; case 'searchFiles': $date = get_POST_var('DATE'); list($stDay, $stMonth, $stYear) = explode("-", $date); $newdate = $stYear . '-' . $stMonth . '-' . $stDay; $MF = new ManageFiles(); $FILES = $MF->get_ListOfFiles_Search_with_details($_SESSION['empl_id'], $newdate); send_Action_Response('Success', " FILES = " . json_encode($FILES['NEW_FILES']) . "; "); exit; break; default: send_Action_Response('Fail', "SC Error #500: No case defined for Action : {$ACTION} "); break; }
$file_act_name = $send_FILEINFO['fileName']; $subject = 'Simple Chat File'; $body = nl2br($your_comment) . "<br/><br/><br/>Please find the file attached."; $send_FileUploadInfo = $send_MF->getChatFileUploadInfo($send_FILEINFO['fileId']); $msg = sendMailUsingMailer($emails, $subject, $body, $file_name, $file_act_name); if ($msg == 'Letter is sent') { $newmsg = "has emailed " . $file_act_name . "</a> to " . $emails . " [ <a href=\"chatfiledownload.php?fc={$send_FILEINFO['fileId']}\">View File</a> ]"; $success = execute_sqlInsert('tbl_ChatRooms', array('saidBy_username' => $_SESSION["uname"], 'saidBy_empl_id' => $_SESSION["empl_id"], 'message_base64' => '', 'message_plain_mysqlescaped' => $newmsg, 'chatRoom' => $send_FileUploadInfo['roomId'], 'msgType' => 'E')); } else { } register_LastPingAt(); } } if (get_GET_var('fid')) { $fid = get_GET_var('fid'); $MF = new ManageFiles(); $FILEINFO = $MF->get_file_Info($fid, $_SESSION["empl_id"]); if (!count($FILEINFO)) { echo "Invalid file or privilege"; exit; } $FileUploadInfo = $MF->getChatFileUploadInfo($FILEINFO['fileId']); } ?> <html><head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Send this page to a friend</title> <link rel="stylesheet" href="send.css" type="text/css"> <!--[if IE]> <style type="text/css"> h1 {height:50px; width:745px;}
include_once "include_functions.php"; if (!$_SESSION["uname"]) { header('Location: logout.php'); exit; } $CURRENT_USER = $_SESSION["uname"]; // check whether this user has access to this room $GMU = new ManageUsers(); $GMU->userId = $_SESSION['empl_id']; $rid = get_POST_var('rid'); if (!$GMU->has_AccessToRoom($rid)) { echo "You are not authorised to access this page."; exit; } // get file size and generate a random code $MF = new ManageFiles(); $UFID = $MF->createUnique_FID(16); $size = $_FILES['myfile']['size']; $file_name = str_replace(' ', '_', $_FILES['myfile']['name']); $file_type = $_FILES['myfile']['type']; $errors = $_FILES['myfile']['error']; //move the uploaded file to UPLOAD_PATH and insert into database $result = 0; if ($errors == UPLOAD_ERR_OK) { $tmp_name = $tmp_names; //$allowedExtensions = array("txt","csv","htm","html","xml","css","doc","xls","rtf","ppt","pdf","swf","flv","avi","wmv","mov","jpg","jpeg","gif","png"); $type = end(explode(".", strtolower($file_name))); $name = $UFID . "." . $type; $file_name = str_replace(' ', '_', $file_name); //if (in_array($type,$allowedExtensions)) { // Edit upload location here
append_file(FILES[t]); } }; </script> <center> <div id="title" style='margin-left: auto; margin-right: auto; margin:2px; font-size: 110%; font-weight: bold; padding: 10px; width: 82%;'>List of Recent Files</div> <p id="files_result" style="display:none; color:red; font-size:14px;"></p> <div id="search"> <input type='text' class='date_input' size=12 id='files_date'><input type="button" id="Go" name="Go" value="Go" onclick="searchFiles()" /> </div> <div id='BOOKMARKSLIST'> <?php $MF = new ManageFiles(); $LASTX_FILES_SQL = $MF->get_Last_XFiles_RelatedToUser_fullDetails_sql($CURRENT_USERID, 200); $result = mysql_query($LASTX_FILES_SQL); while ($row = mysql_fetch_array($result)) { $FUPLOAD_INFO = $MF->getChatFileUploadInfo($row['fileId']); // fileId, fileName, fileRandomName, fileExt, fileSize, fileCode, fileType $tmp_preview_str = "<div style='margin-top: 10px; padding: 10px; background-color: #F1F4E3; border-bottom: 2px solid #E7E7E7; text-align:left; display: table; width: 96%;'>"; $tmp_preview_str .= "<div style='float:left; line-height:150%;'><a href=\"chatfiledownload.php?fc={$row['fileId']}\">{$row['fileName']}</a>"; if (in_array($row['fileExt'], array('jpg', 'png', 'gif', 'bmp', 'jpeg', 'pjpeg'))) { $tmp_preview_str .= "<br/><a href=\"chatfiledownload.php?fc={$row['fileId']}\"><img src=files/chat_files/thumbs/{$row['fileRandomName']}></a>"; } $tmp_preview_str .= "</div>"; $tmp_preview_str .= "<div style='float:right;color: #C7AD8B; margin-right: 10px;'>" . caldateTS_to_humanWithTS($GMU->convert_to_UsersTimeZone($FUPLOAD_INFO['uploadedDate'])) . "</div>"; $tmp_preview_str .= "<div style='float:right; color: #C7AD8B; margin-right: 10px;'>- {$FUPLOAD_INFO['uploadedBy']}</div>"; $tmp_preview_str .= "<div style='float:right; color: #C7AD8B; margin-right: 10px;'>" . formatBytesToHumanReadable($row['fileSize']) . "</div>"; $tmp_preview_str .= "</div>";
<?php include_once "include_db.php"; include_once "include_functions.php"; if (!$_SESSION["uname"]) { header('Location: logout.php'); exit; } if (!get_GET_var('fc')) { echo "Invalid usage."; exit; } $fileId = get_GET_var('fc'); $MF = new ManageFiles(); $FILEINFO = $MF->get_file_Info($fileId, $_SESSION["empl_id"]); if (!count($FILEINFO)) { echo "Invalid file or privilege"; exit; } header("Expires: 0"); header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); header("Cache-Control: no-store, no-cache, must-revalidate"); header("Cache-Control: post-check=0, pre-check=0", false); header("Pragma: no-cache"); header("Content-type: {$FILEINFO['fileType']}"); header("Content-length: {$FILEINFO['fileSize']}"); header("Content-disposition: attachment; filename=\"{$FILEINFO['fileName']}\""); readfile(UPLOAD_PATH . $FILEINFO['fileRandomName']); exit;
public function get_Archives_fromRoom($date, $roomId, $UserId) { $this_query = ''; $NEW_MESSAGES = array(); $MU = new ManageUsers(); $MU->userId = $UserId; $TMP_MF = new ManageFiles(); if (!$MU->has_AccessToRoom($roomId)) { return; } list($stDay, $stMonth, $stYear) = explode("-", $date); $start_time = $stYear . '-' . $stMonth . '-' . $stDay . ' 00:00:00'; $end_time = $stYear . '-' . $stMonth . '-' . $stDay . ' 23:59:59'; $GMT_start_time = $MU->convert_from_UsersTimeZone($start_time); $GMT_end_time = $MU->convert_from_UsersTimeZone($end_time); $this_query = "SELECT * FROM tbl_ChatRooms WHERE chatRoom='{$roomId}' AND msgtime between '{$GMT_start_time}' and '{$GMT_end_time}'"; $result = mysql_query($this_query); while ($row = mysql_fetch_array($result)) { $LASTFETCHEDMSGID = $row['msgid']; $converted_date = $MU->convert_to_UsersTimeZone($row['msgtime']); if ($row['msgType'] == 'F') { $fileInfo = $TMP_MF->get_file_Info($row['fileId'], $UserId); $tmp_preview_str = "{$row['saidBy_username']} has uploaded a file <a href='chatfiledownload.php?fc={$fileInfo['fileId']}'>{$fileInfo['fileName']}</a> <span style='color: #A9A9A9;'>" . formatBytesToHumanReadable($fileInfo['fileSize']) . "</span> <a rel='prettyPhoto[iframes]' href='filemail.php?fid={$fileInfo['fileId']}&iframe=true&width=800&height=400'>Email</a>"; if (in_array($fileInfo['fileExt'], array('jpg', 'jpeg', 'gif', 'png', 'bmp'))) { $tmp_preview_str .= "<br/><img src=files/chat_files/thumbs/{$fileInfo['fileRandomName']}>"; } $row['message_base64'] = base64_encode($tmp_preview_str); } if ($row['msgType'] == 'L') { $row['msgid'] = 0; } if ($row['msgType'] == 'E') { $row['msgid'] = 0; $tmp_preview_str = $row['message_plain_mysqlescaped']; $row['message_base64'] = base64_encode($tmp_preview_str); } $NEW_MESSAGES[] = array('msgid' => $row['msgid'], 'msgBy' => $row['saidBy_username'], 'msgTime' => $converted_date, 'msg_base64' => $row['message_base64'], 'bookmark' => $row['bkm_id'], 'msgType' => $row['msgType']); } return array('NEW_MESSAGES' => $NEW_MESSAGES, 'LASTFETCHEDMSGID' => $LASTFETCHEDMSGID); }
if ($AM_I_ADMIN || $GMU->has_Privilege('Can Create New Rooms')) { echo "<A href='#' onclick='show_newRoom_form()'>Create New Room</A>"; } ?> </TD> </TR> </tbody> </TABLE> </div> <div style='float : right; margin-right: 30px;'> <div style='margin-top: 20px;'><A href='directory.php'>User Directory</A></div> <div style='margin-top: 20px; border-bottom: 1px solid #999;'> List of Recent Files </div> <?php $MF = new ManageFiles(); $LIST_OF_RECENT_FILES = $MF->get_Last_XFiles_RelatedToUser($CURRENT_USERID, 5); foreach ($LIST_OF_RECENT_FILES as $this_fileId) { $THIS_FILE_INFO = $MF->get_file_Info($this_fileId, $CURRENT_USERID); echo "<div style='padding: 4px;'><a href=\"chatfiledownload.php?fc={$this_fileId}\">{$THIS_FILE_INFO['fileName']}</a></div>"; } ?> </div> <div style='clear:both;'></div> <div id="div_createNewRoom_container" style="display:none; width: 740" class="divAbovedivAboveBg"> <TABLE width="740" cellpadding=0 cellspacing=0 border=0 class="divHeadingTable"> <TR>
}; </script> <center> <div style='margin-left: auto; margin-right: auto; margin:2px; font-size: 110%; font-weight: bold; padding: 10px; width: 82%;'>List of Recent BookMarks</div> <div id='BOOKMARKSLIST'> <?php $MB = new ManageBookMarks(); $LASTX_BOOKMARKS_SQL = $MB->get_LastX_BookMarks_query($CURRENT_USERID, 200); $result = mysql_query($LASTX_BOOKMARKS_SQL); $MCR = new ManageChatRooms(); while ($row = mysql_fetch_array($result)) { $tmp_preview_str = "<div style='margin-top: 10px; padding: 10px; background-color: #F1F4E3; border-bottom: 2px solid #E7E7E7; text-align:left; display: table; width: 96%;' id='{$row['bkm_msgId']}'>"; if ($row['msgType'] == 'F') { $TMP_MF = new ManageFiles(); $d_fileId = $row['fileId']; $fileInfo = $TMP_MF->get_file_Info($d_fileId, $CURRENT_USERID); $tmp_preview_str .= "<div class='umsg' style='float:left; line-height:150%;'>" . USERID_TO_USERNAME($row['saidBy_empl_id']) . " has uploaded a file <a href='chatfiledownload.php?fc={$fileInfo['fileId']}'>{$fileInfo['fileName']}</a> <span style='color: #A9A9A9;'>" . formatBytesToHumanReadable($fileInfo['fileSize']) . "</span> <a rel='prettyPhoto[iframes]' href='filemail.php?fid={$fileInfo['fileId']}&iframe=true&width=800&height=400'>Email</a>"; if (in_array($fileInfo['fileExt'], array('jpg', 'jpeg', 'gif', 'png', 'bmp'))) { $tmp_preview_str .= "<br/><img src=files/chat_files/thumbs/{$fileInfo['fileRandomName']}>"; } $tmp_preview_str .= "</div>"; } else { // bkm_id, bkms.bkm_msgId, bkms.bkm_dmsgid, bkms.bkm_roomId, cRoom.message_base64 $tmp_preview_str .= "<div style='float:left; line-height:150%;'>" . USERID_TO_USERNAME($row['saidBy_empl_id']) . ": " . base64_decode($row['message_base64']) . "</div>"; } $tmp_preview_str .= "<div style='float:right;'><img src='images/bookmark.png' class='bmarkstar' msgid='{$row['bkm_msgId']}' rid='{$row['bkm_roomId']}' ></div>"; $tmp_preview_str .= "<div style='float:right; color: #C7AD8B; margin-right: 10px;'> " . $MCR->get_roomTitle($row['bkm_roomId']) . "</div>"; $tmp_preview_str .= "</div>"; echo $tmp_preview_str;
$msg_class = "leftbox_msg"; $user_float = "float:left;"; $mark_float = "float:right;"; $from_to_name = USERID_TO_USERNAME($row['from_uid']); $user_image = USERID_TO_USERPIC($row['from_uid']); } else { $msg_class = "rightbox_msg"; $user_float = "float:right;"; $mark_float = "float:left;"; $from_to_name = "To " . USERID_TO_USERNAME($row['to_uid']); $user_image = USERID_TO_USERPIC($row['to_uid']); } $tmp_preview_str .= "<div style='{$user_float}'>{$from_to_name}:<div><img width='60' height='60' src='files/users/thumbs/{$user_image}'><div>" . $row['msgtime'] . "</div></div></div>"; $file_str = ''; if ($row['msgType'] == 'F') { $MF = new ManageFiles(); $THIS_FILEINFO = $MF->get_file_Info($row['fileId'], $CURRENT_USERID); $file_str .= "<div>File Name: <a href='chatfiledownload.php?fc={$THIS_FILEINFO['fileId']}'>{$THIS_FILEINFO['fileName']}</a>"; if (in_array($THIS_FILEINFO['fileExt'], array('jpg', 'jpeg', 'gif', 'png', 'bmp'))) { $file_str .= "<br/><a href='chatfiledownload.php?fc={$THIS_FILEINFO['fileId']}'><img src=files/chat_files/thumbs/{$THIS_FILEINFO['fileRandomName']}></a>"; } $file_str .= "</div>"; } $tmp_preview_str .= "<div class='{$msg_class}'> " . stripslashes(base64_decode($row['msg_base64'])) . "{$file_str}</div>"; if ($row['msgStatus'] == 'N' && $row['to_uid'] == $_SESSION['empl_id']) { $tmp_preview_str .= "<div id='mark' dmsgid='{$row['dmsgid']}' class='markasread' msgstatus='{$row['msgStatus']}' style='cursor: pointer; {$mark_float}' >Mark as read</div>"; } $tmp_preview_str .= "</div>"; echo $tmp_preview_str; } ?>