Original image width. $height -> Original image height. $target -> Target resizing as a percentage. Output: Returns the new sizes in html image tag format. *****************************************************************/ function imageResize($width, $height, $target) { if ($width > $height) { $percentage = ($target / $width); } else { $percentage = ($target / $height); } $width = round($width * $percentage); $height = round($height * $percentage); return "width=\"$width\" height=\"$height\""; } /**************************************************************** Function: Determine day number without leading zero based on number with leading zero. Input: $day --> 01 for 1, 07 for 7, etc. Output: Day number without leading zero. *****************************************************************/ function remLeadZero($day) { if (substr($day, 0, 1) == '0') { return substr($day, 1, 1);; } else { return $day; } } if (!isset($_SESSION["id"])) { $_SESSION["error"] = "The action requested is not allowed. Please log in or sign up."; header("Location: Login.html"); exit(); } $mysqli = mysqli_connect("localhost", "skillini_Ann", "bbalsk94544", "skillini_hatcreek"); if (mysqli_connect_errno()) { echo "Your request cannot be processed at this time. Please try again later."; exit(); } else { $user_id = $_SESSION["id"]; $sql = "SELECT COUNT(*) FROM messages WHERE to_id = '$user_id' and receive_status = 1"; $res = mysqli_query($mysqli, $sql); $row = mysqli_fetch_row($res); $num_messages_received = $row[0]; mysqli_free_result($res); // echo "Number of messages received: $num_messages
"; $sql = "SELECT COUNT(*) FROM messages WHERE from_id = '$user_id' and send_status = 1"; $res = mysqli_query($mysqli, $sql); $row = mysqli_fetch_row($res); $num_messages_sent = $row[0]; mysqli_free_result($res); // echo "Number of messages sent: $num_messages
"; } //mysqli_close($mysqli); ?> Skillinity - Messages
Account Information
 
Account Info
Public Profile
Skills Posted
Jobs Posted
Testimonials
Messages
Inbox () Sent ()
Messages Received
0) { while($row = mysqli_fetch_array($res)) { $date = $row['date']; $regex_pattern = "/(.+)-(.+)-(.+)\s(.+)/"; preg_match_all($regex_pattern, $date, $matches); $month_name = date('F', mktime(0, 0, 0, $matches[2][0])); $day_number = remLeadZero($matches[3][0]); $year = $matches[1][0]; $time = date("g:i a", strtotime($matches[4][0])); $message_id = $row['message_id']; $from_id = $row['from_id' ]; $message = $row['message' ]; $link = $row['link' ]; $regex_pattern = "/.+&(.+)=(.+)/"; preg_match_all($regex_pattern, $link, $matches); $link_type = $matches[1][0]; $link_id = $matches[2][0]; if ($link_type == "sid") { $subject = "Service: "; $sql = "SELECT title FROM skills WHERE skill_id = $link_id"; $res2 = mysqli_query($mysqli, $sql); if ($res2) { $row2 = mysqli_fetch_array($res2); $title = $row2['title']; mysqli_free_result($res2); } } elseif ($link_type == "pid") { $subject = "Job: "; $sql = "SELECT title FROM projects WHERE project_id = $link_id"; $res2 = mysqli_query($mysqli, $sql); if ($res2) { $row2 = mysqli_fetch_array($res2); $title = $row2['title']; mysqli_free_result($res2); } } else { $subject = ""; $title = ""; } $sql = "SELECT user_name,profile_photo FROM profiles WHERE user_id = '$from_id'"; $res2 = mysqli_query($mysqli, $sql); if ($res2) { $row2 = mysqli_fetch_array($res2); $from_name = $row2['user_name']; $from_photo = $row2['profile_photo']; $mysock = getimagesize("uploads/$from_photo"); $image_size = imageResize($mysock[0], $mysock[1], 75); mysqli_free_result($res2); } echo ""; echo "
"; echo ""; echo "
 "; echo ""; echo ""; echo "
"; echo "From: $from_name$month_name $day_number, $year - $time
"; echo ""; echo ""; echo "
"; echo "$subject$title
"; echo "Message: $message
 "; echo ""; echo ""; echo "
"; } } } mysqli_free_result($res); //mysqli_close($mysqli); ?>
Messages Sent
0) { while($row = mysqli_fetch_array($res)) { $date = $row['date']; $regex_pattern = "/(.+)-(.+)-(.+)\s(.+)/"; preg_match_all($regex_pattern, $date, $matches); $month_name = date('F', mktime(0, 0, 0, $matches[2][0])); $day_number = remLeadZero($matches[3][0]); $year = $matches[1][0]; $time = date("g:i a", strtotime($matches[4][0])); $message_id = $row['message_id']; $to_id = $row['to_id' ]; $message = $row['message' ]; $link = $row['link' ]; $regex_pattern = "/.+&(.+)=(.+)/"; preg_match_all($regex_pattern, $link, $matches); $link_type = $matches[1][0]; $link_id = $matches[2][0]; if ($link_type == "sid") { $subject = "Service: "; $sql = "SELECT title FROM skills WHERE skill_id = $link_id"; $res2 = mysqli_query($mysqli, $sql); if ($res2) { $row2 = mysqli_fetch_array($res2); $title = $row2['title']; mysqli_free_result($res2); } } elseif ($link_type == "pid") { $subject = "Job: "; $sql = "SELECT title FROM projects WHERE project_id = $link_id"; $res2 = mysqli_query($mysqli, $sql); if ($res2) { $row2 = mysqli_fetch_array($res2); $title = $row2['title']; mysqli_free_result($res2); } } else { $subject = ""; $title = ""; } $sql = "SELECT profile_photo FROM profiles WHERE user_id = $user_id"; $res2 = mysqli_query($mysqli, $sql); if ($res2) { $row2 = mysqli_fetch_array($res2); $to_photo = $row2['profile_photo']; $mysock = getimagesize("uploads/$to_photo"); $image_size = imageResize($mysock[0], $mysock[1], 75); mysqli_free_result($res2); } $sql = "SELECT user_name FROM profiles WHERE user_id = $to_id"; $res2 = mysqli_query($mysqli, $sql); if ($res2) { $row2 = mysqli_fetch_array($res2); $to_name = $row2['user_name']; mysqli_free_result($res2); } echo ""; echo "
"; echo ""; echo "
 "; echo ""; echo ""; echo "
"; echo "To: $to_name$month_name $day_number, $year - $time
"; echo ""; echo ""; echo "
"; echo "$subject$title
"; echo "Message: $message
 "; echo ""; echo "
"; } } } mysqli_free_result($res); mysqli_close($mysqli); ?>