// $Id$ $_user_location = 'public'; define('AT_INCLUDE_PATH', '../../../include/'); require AT_INCLUDE_PATH . 'vitals.inc.php'; include AT_PA_INCLUDE . 'classes/PhotoAlbum.class.php'; include AT_PA_INCLUDE . 'lib.inc.php'; //$_custom_css = $_base_path . AT_PA_BASENAME . 'module.css'; // use a custom stylesheet $_custom_head .= '<script type="text/javascript" src="' . AT_PA_BASENAME . 'include/imageReorderer.js"></script>'; $aid = intval($_GET['aid']); $pid = intval($_GET['pid']); //init $pa = new PhotoAlbum($aid); //get details $info = $pa->getAlbumInfo(); $photos = $pa->getAlbumPhotos(); $photo_info = $pa->getPhotoInfo($pid); $comments = $pa->getComments($pid, true); //Set pages/submenu $_pages[AT_PA_BASENAME . 'albums.php?id=' . $aid]['title'] = _AT('pa_albums') . ' - ' . $info['name']; $_pages[AT_PA_BASENAME . 'albums.php?id=' . $aid]['parent'] = AT_PA_BASENAME . 'index.php'; $_pages[AT_PA_BASENAME . 'albums.php?id=' . $aid]['children'] = array(AT_PA_BASENAME . 'photo.php'); $_pages[AT_PA_BASENAME . 'photo.php']['parent'] = AT_PA_BASENAME . 'albums.php?id=' . $aid; //TODO: Validate users, using permission and course album control. if ($info['member_id'] != $_SESSION['member_id'] && $info['type_id'] != AT_PA_TYPE_PERSONAL) { $visible_albums = $pa->getAlbums($_SESSION['member_id'], $info['type_id']); if (!isset($visible_albums[$aid]) && $info['permission'] == AT_PA_PRIVATE_ALBUM) { //TODO msg; $msg->addError("ACCESS_DENIED"); header('location: index.php'); exit; }
$album_file_path_tn = $album_file_path . '_tn' . DIRECTORY_SEPARATOR; $album_file_path .= DIRECTORY_SEPARATOR; if (!is_dir(AT_PA_CONTENT_DIR . $album_file_path)) { mkdir(AT_PA_CONTENT_DIR . $album_file_path); } if (!is_dir(AT_PA_CONTENT_DIR . $album_file_path_tn)) { mkdir(AT_PA_CONTENT_DIR . $album_file_path_tn); } //add the photo $added_photo_id = $pa->addPhoto($_FILES['photo']['name'], $_POST['photo_comment'], $_SESSION['member_id']); if ($added_photo_id <= 0) { $msg->addError('PA_ADD_PHOTO_FAILED'); } if (!$msg->containsErrors()) { //get photo filepath $photo_info = $pa->getPhotoInfo($added_photo_id); $photo_file_path = getPhotoFilePath($added_photo_id, $_FILES['photo']['name'], $photo_info['created_date']); //resize images to a specific size, and its thumbnail $si = new SimpleImage(); $si->load($_FILES['photo']['tmp_name']); $image_w = $si->getWidth(); $image_h = $si->getHeight(); //picture is horizontal if ($image_w > $image_h) { //don't stretch images if ($image_w > AT_PA_IMAGE) { $si->resizeToWidth(AT_PA_IMAGE); $si->save(AT_PA_CONTENT_DIR . $album_file_path . $photo_file_path); } else { move_uploaded_file($_FILES['photo']['tmp_name'], AT_PA_CONTENT_DIR . $album_file_path . $photo_file_path); }
} if (isset($_POST['pid'])) { $pid = intval($_POST['pid']); } //initialization $pa = new PhotoAlbum($aid); //validation if (!($pa->checkPhotoPriv($pid, $_SESSION['member_id']) || $pa->checkAlbumPriv($_SESSION['member_id']))) { $msg->addError("ACCESS_DENIED"); header('location: index.php'); exit; } //get details if ($pid > 0) { //get only 1 photo $photos = array($pa->getPhotoInfo($pid)); } else { $photos = $pa->getAlbumPhotos(); } $album_info = $pa->getAlbumInfo(); $isadmin = FALSE; $_pages[AT_PA_BASENAME . 'albums.php?id=' . $aid]['title'] = _AT('pa_albums') . ' - ' . $album_info['name']; $_pages[AT_PA_BASENAME . 'albums.php?id=' . $aid]['parent'] = AT_PA_BASENAME . 'index.php'; $_pages[AT_PA_BASENAME . 'albums.php?id=' . $aid]['children'] = array(AT_PA_BASENAME . 'edit_photos.php'); $_pages[AT_PA_BASENAME . 'edit_photos.php']['parent'] = AT_PA_BASENAME . 'albums.php?id=' . $aid; if ($isadmin) { $_pages[AT_PA_BASENAME . 'albums.php?id=' . $aid]['parent'] = AT_PA_BASENAME . 'index_admin.php'; } //handle organize if (isset($_GET['org'])) { $_custom_head .= '<script type="text/javascript" src="' . AT_PA_BASENAME . 'include/imageReorderer.js"></script>';
/** * Return the total personal data usage (in bytes) */ function memoryUsage($member_id) { global $db; $member_id = intval($member_id); if ($member_id < 1) { return false; } $memory_usage = 0; $sql = 'SELECT p.* FROM ' . TABLE_PREFIX . 'pa_photos p LEFT JOIN ' . TABLE_PREFIX . "pa_course_album ca ON p.album_id=ca.album_id WHERE member_id={$member_id} AND ca.course_id IS NULL"; $result = mysql_query($sql, $db); if ($result) { while ($row = mysql_fetch_assoc($result)) { $pa = new PhotoAlbum($row['album_id']); $album_info = $pa->getAlbumInfo(); $photo_info = $pa->getPhotoInfo($row['id']); $album_file_path = getAlbumFilePath($album_info['id'], $album_info['created_date']); $photo_file_path = getPhotoFilePath($photo_info['id'], $photo_info['name'], $photo_info['created_date']); $file = AT_PA_CONTENT_DIR . $album_file_path . DIRECTORY_SEPARATOR . $photo_file_path; if (file_exists($file)) { $memory_usage += filesize($file); } } } return $memory_usage; }
include AT_PA_INCLUDE . 'classes/PhotoAlbum.class.php'; //run a check to see if any personal album exists, if not, create one. $sql = 'SELECT * FROM ' . TABLE_PREFIX . 'pa_albums WHERE member_id=' . $_SESSION['member_id'] . ' AND type_id=' . AT_PA_TYPE_PERSONAL; $result = mysql_query($sql, $db); if ($result) { //precondition: Profile Album always exists. $row = mysql_fetch_assoc($result); //album info. $profile_aid = $row['id']; //current profile album id } $pa_profile = new PhotoAlbum($profile_aid); // album id of the GET requests (via set profile picture link) $pa = new PhotoAlbum($aid); $album_info = $pa->getAlbumInfo(); $photo_info = $pa->getPhotoInfo($pid); //Validate users, using permission and course album control. $visible_albums = $pa->getAlbums($_SESSION['member_id'], $photo_info['type_id']); if (!isset($visible_albums[$aid]) && $album_info['permission'] == AT_PA_PRIVATE_ALBUM) { //TODO msg; $msg->addError("ACCESS_DENIED"); header('location: index.php'); exit; } // get the current photo info, and paths $album_file_path = getAlbumFilePath($album_info['id'], $album_info['created_date']); $album_file_path_tn = $album_file_path . '_tn' . DIRECTORY_SEPARATOR; $album_file_path .= DIRECTORY_SEPARATOR; $photo_file_path = getPhotoFilePath($photo_info['id'], $photo_info['name'], $photo_info['created_date']); $photo_location = AT_PA_CONTENT_DIR . $album_file_path . $photo_file_path; $photo_tn_location = AT_PA_CONTENT_DIR . $album_file_path_tn . $photo_file_path;
/** * Return the total personal data usage (in bytes) */ function memoryUsage($member_id) { global $db; $member_id = intval($member_id); if ($member_id < 1) { return false; } $memory_usage = 0; $sql = "SELECT p.* FROM %spa_photos p LEFT JOIN %spa_course_album ca ON p.album_id=ca.album_id WHERE member_id=%d AND ca.course_id IS NULL"; $rows_photos = queryDB($sql, array(TABLE_PREFIX, TABLE_PREFIX, $member_id)); if (count($rows_photos) > 0) { foreach ($rows_photos as $row) { $pa = new PhotoAlbum($row['album_id']); $album_info = $pa->getAlbumInfo(); $photo_info = $pa->getPhotoInfo($row['id']); $album_file_path = getAlbumFilePath($album_info['id'], $album_info['created_date']); $photo_file_path = getPhotoFilePath($photo_info['id'], $photo_info['name'], $photo_info['created_date']); $file = AT_PA_CONTENT_DIR . $album_file_path . DIRECTORY_SEPARATOR . $photo_file_path; if (file_exists($file)) { $memory_usage += filesize($file); } } } return $memory_usage; }
?> </div> <!-- loop through this --> <?php if (!empty($this->albums)) { ?> <?php foreach ($this->albums as $index => $row) { $pa = new PhotoAlbum($index); ?> <div class="album"> <!-- TODO: If photo is not presense, print another image? --> <div class="image"> <?php $photo_info = $pa->getPhotoInfo($row['photo_id']); if (!empty($photo_info)) { ?> <a href="<?php echo AT_PA_BASENAME . 'albums.php?id=' . $row['id']; ?> "><img src="<?php echo AT_PA_BASENAME . 'get_photo.php?aid=' . $row['id'] . SEP . 'pid=' . $row['photo_id'] . SEP . 'ph=' . getPhotoFilePath($photo_info['id'], '', $photo_info['created_date']); ?> " title="<?php echo AT_print($photo_info['description'], 'input.text'); ?> " alt="<?php echo AT_print($row['name'], 'input.text'); ?> " /></a>
?> #n" onclick="slide('right');"><img src="<?php echo AT_PA_BASENAME; ?> images/prev.png" alt="<?php echo _AT('previous'); ?> " /></a></div> <?php } ?> <div class="search_slider search_slider_a" id="search_slider_a"> <ul> <?php foreach ($this->albums as $index => $album) { $photo_info = $pa->getPhotoInfo($album['photo_id']); ?> <li> <div class="search_photo_frame"> <?php if (!empty($photo_info)) { ?> <a href="<?php echo AT_PA_BASENAME . 'albums.php?id=' . $album['id']; ?> "><img src="<?php echo AT_PA_BASENAME . 'get_photo.php?aid=' . $album['id'] . SEP . 'pid=' . $album['photo_id'] . SEP . 'ph=' . getPhotoFilePath($photo_info['id'], '', $photo_info['created_date']); ?> " title="<?php echo AT_print($photo_info['description'], 'input.text'); ?>