function getProfileImageUrl($user_id, $width = null, $height = null) { $image = "images/" . getProfileImageRelativePath($user_id, $width, $height); if (!file_exists(getProfileImagePath($user_id, $width, $height))) { $image = "library/getimagenew.php?id={$user_id}&width={$width}&height={$height}"; } return SITE_URL . $image; }
function getProfileImage($userid, $width = null, $height = null) { $image = getProfileImagePath($userid); if (file_exists($image)) { return getProfileImageUrl($userid, $width, $height); } else { $brw = $this->getBorrowerDetails($userid); $fb_data = unserialize(base64_decode($brw['fb_data'])); if (!empty($fb_data['user_profile']['id'])) { // return "https://graph.facebook.com/".$fb_data['user_profile']['id']."/picture?width=$width&height=$height"; return "https://graph.facebook.com/" . $fb_data['user_profile']['id'] . "/picture?width=9999&height=9999"; } } return getDefaultImageUrl(); }
<?php require_once 'database.php'; require_once 'utility.php'; global $database; $id = array_get($_GET, 'id'); $width = array_get($_GET, 'width', ''); $height = array_get($_GET, 'height', ''); $format = $width . "x" . $height; // Validate the parameters $formats = array("350x", "50x", "36x", "580x"); if (!is_scalar($id) || !is_scalar($width) || !is_scalar($height)) { die; } //if (!in_array($format, $formats)) { // die(); //} if (!$database->getUserNameById($id)) { die; } $picture = getProfileImagePath($id); $cached_picture = getProfileImagePath($id, $width, $height); if (file_exists($cached_picture)) { $image = $cached_picture; } elseif (!file_exists($picture)) { $image = getDefaultImagePath(); } else { $image = getImage($picture, $cached_picture, $width, $height); } serveImage($image);