333 lines
13 KiB
PHP
333 lines
13 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
/* $Id: album_file.php 44 2009-01-30 03:45:23Z john $ */
|
||
|
|
|
||
|
|
$page = "album_file";
|
||
|
|
include "header.php";
|
||
|
|
//if(SE_DEBUG1){$page = "video1";}
|
||
|
|
// DISPLAY ERROR PAGE IF USER IS NOT LOGGED IN AND ADMIN SETTING REQUIRES REGISTRATION
|
||
|
|
if( !$user->user_exists && !$setting['setting_permission_album'] )
|
||
|
|
{
|
||
|
|
$page = "error";
|
||
|
|
$smarty->assign('error_header', "a7");
|
||
|
|
$smarty->assign('error_message', 656);
|
||
|
|
$smarty->assign('error_submit', 641);
|
||
|
|
include "footer.php";
|
||
|
|
}
|
||
|
|
|
||
|
|
// DISPLAY ERROR PAGE IF NO OWNER
|
||
|
|
if( !$owner->user_exists|| $owner->user_info["user_enabled"]<=0 )
|
||
|
|
{
|
||
|
|
$page = "error";
|
||
|
|
$smarty->assign('error_header', "a7");
|
||
|
|
$smarty->assign('error_message', 828);
|
||
|
|
$smarty->assign('error_submit', 641);
|
||
|
|
include "footer.php";
|
||
|
|
}
|
||
|
|
|
||
|
|
// ENSURE ALBUMS ARE ENABLED FOR THIS USER
|
||
|
|
if( !$owner->level_info['level_album_allow'] )
|
||
|
|
{
|
||
|
|
header("Location: ".$url->url_create('profile', $owner->user_info['user_username']));
|
||
|
|
exit();
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
// PARSE GET/POST
|
||
|
|
if(isset($_POST['task'])) { $task = $_POST['task']; } elseif(isset($_GET['task'])) { $task = $_GET['task']; } else { $task = "main"; }
|
||
|
|
if(isset($_POST['media_id'])) { $media_id = $_POST['media_id']; } elseif(isset($_GET['media_id'])) { $media_id = $_GET['media_id']; } else { $media_id = 0; }
|
||
|
|
if(isset($_POST['album_id'])) { $album_id = $_POST['album_id']; } elseif(isset($_GET['album_id'])) { $album_id = $_GET['album_id']; } else { $album_id = ""; }
|
||
|
|
if(isset($_POST['task'])) { $task = $_POST['task']; } elseif(isset($_GET['task'])) { $task = $_GET['task']; } else { $task = ""; }
|
||
|
|
// MAKE SURE MEDIA EXISTS
|
||
|
|
$media_query = $database->database_query("SELECT * FROM se_media WHERE media_id='{$media_id}' LIMIT 1");
|
||
|
|
if($database->database_num_rows($media_query) != 1) {
|
||
|
|
|
||
|
|
header("Location: ".$url->url_create('albums', $owner->user_info['user_username'])); exit();
|
||
|
|
}
|
||
|
|
$media_info = $database->database_fetch_assoc($media_query);
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
if($task == "updatemedia") {
|
||
|
|
|
||
|
|
// GET TOTAL FILES
|
||
|
|
$album = $database->database_query("SELECT * FROM se_albums WHERE album_id='".$database->database_real_escape_string($media_info["media_album_id"])."' AND album_user_id='".$user->user_info[user_id]."'");
|
||
|
|
if($database->database_num_rows($album) != 1) { header("Location: user_album.php"); exit(); }
|
||
|
|
|
||
|
|
// DELETE NECESSARY FILES
|
||
|
|
|
||
|
|
// UPDATE NECESSARY FILES
|
||
|
|
|
||
|
|
$var1 = "media_title";
|
||
|
|
$var2 = "media_desc";
|
||
|
|
$var3 = "media_album_id";
|
||
|
|
$media_title = censor($_POST[$var1]);
|
||
|
|
$media_desc = censor(str_replace("\r\n", "<br>", $_POST[$var2]));
|
||
|
|
$media_album_id = $_POST[$var3];
|
||
|
|
$database->database_query("UPDATE se_media SET media_title='$media_title', media_desc='$media_desc', media_album_id='$media_album_id' WHERE media_id='".$database->database_real_escape_string($_POST["media_id"])."'");
|
||
|
|
$tags=array_filter(preg_split('/[\s,;]+?/', $tags));
|
||
|
|
$tags=explode(",", $_POST["tags"]);
|
||
|
|
|
||
|
|
foreach($tags as $tag)
|
||
|
|
{
|
||
|
|
|
||
|
|
$to_user = new SEUser(array(NULL, $tag));
|
||
|
|
$checkusers=$database->database_query("SELECT mediatag_id FROM se_mediatags WHERE mediatag_media_id='".$database->database_real_escape_string($_POST["media_id"])."' AND mediatag_user_id='".$database->database_real_escape_string($to_user->user_info["user_id"])."'");
|
||
|
|
if($database->database_num_rows($checkusers)==0&&$to_user->user_info["user_id"]>0){
|
||
|
|
$database->database_query("INSERT INTO se_mediatags SET mediatag_media_id='".$database->database_real_escape_string($_POST["media_id"])."', mediatag_user_id='".$database->database_real_escape_string($to_user->user_info["user_id"])."', mediatag_date='".time()."'");
|
||
|
|
|
||
|
|
$notify->notify_add($to_user->user_info["user_id"], 'phototag', $_POST["media_id"], Array($user->user_info["user_username"], $_POST["media_id"]), Array($user->user_info["user_username"], $_POST["media_id"]));
|
||
|
|
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
// SET ALBUM COVER AND UPDATE DATE
|
||
|
|
$newdate = time();
|
||
|
|
|
||
|
|
// UPDATE LAST UPDATE DATE (SAY THAT 10 TIMES FAST)
|
||
|
|
$user->user_lastupdate();
|
||
|
|
|
||
|
|
// SHOW SUCCESS MESSAGE
|
||
|
|
$result = 1;
|
||
|
|
$media_query = $database->database_query("SELECT * FROM se_media WHERE media_id='{$media_id}' LIMIT 1");
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
$media_info = $database->database_fetch_assoc($media_query);
|
||
|
|
|
||
|
|
|
||
|
|
// MOVE MEDIA UP
|
||
|
|
}
|
||
|
|
|
||
|
|
// BE SURE ALBUM BELONGS TO THIS USER
|
||
|
|
$album = $database->database_query("SELECT * FROM se_albums WHERE album_id='{$media_info['media_album_id']}' AND album_user_id='{$owner->user_info['user_id']}'");
|
||
|
|
if($database->database_num_rows($album) != 1) { header("Location: ".$url->url_create('albums', $owner->user_info[user_username])); exit(); }
|
||
|
|
$album_info = $database->database_fetch_assoc($album);
|
||
|
|
|
||
|
|
// CHECK PRIVACY
|
||
|
|
$privacy_max = $owner->user_privacy_max($user);
|
||
|
|
if( !($album_info['album_privacy'] & $privacy_max) )
|
||
|
|
{
|
||
|
|
$page = "error";
|
||
|
|
$smarty->assign('error_header', "a7");
|
||
|
|
$smarty->assign('error_message', 1000125);
|
||
|
|
$smarty->assign('error_submit', 641);
|
||
|
|
include "footer.php";
|
||
|
|
}
|
||
|
|
|
||
|
|
// GET CUSTOM ALBUM STYLE IF ALLOWED
|
||
|
|
if( $owner->level_info['level_album_style'] )
|
||
|
|
{
|
||
|
|
$albumstyle_info = $database->database_fetch_assoc($database->database_query("SELECT albumstyle_css FROM se_albumstyles WHERE albumstyle_user_id='{$owner->user_info['user_id']}' LIMIT 1"));
|
||
|
|
$global_css = $albumstyle_info['albumstyle_css'];
|
||
|
|
}
|
||
|
|
|
||
|
|
// GET MEDIA IN ALBUM FOR CAROUSEL
|
||
|
|
$media_array = Array();
|
||
|
|
$media_query = $database->database_query("SELECT media_id, media_ext, '{$owner->user_info['user_id']}' AS album_user_id FROM se_media WHERE media_album_id='{$album_info['album_id']}' ORDER BY media_order ASC");
|
||
|
|
$x=0;
|
||
|
|
$u=0;
|
||
|
|
while($thismedia = $database->database_fetch_array($media_query)) {
|
||
|
|
|
||
|
|
|
||
|
|
$media_array1[] = $thismedia;
|
||
|
|
$thisid[]=$thismedia['media_id'];
|
||
|
|
if($media_id==$thismedia['media_id']){
|
||
|
|
|
||
|
|
|
||
|
|
$start1=$thisid[$x-3];
|
||
|
|
$startid=$x-3;
|
||
|
|
if(($startid)<0){
|
||
|
|
|
||
|
|
$start1=$thisid[$x-2];
|
||
|
|
$startid=$x-2;
|
||
|
|
if(($startid)<0){
|
||
|
|
|
||
|
|
$start1=$thisid[$x-1];
|
||
|
|
$startid=$x-1;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
if(($startid)<0){
|
||
|
|
$start1=$thisid[$x]; $startid=0;
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
$endid=$x+4;
|
||
|
|
|
||
|
|
//$end=$thisid[$x+5];
|
||
|
|
|
||
|
|
$u=1;
|
||
|
|
|
||
|
|
|
||
|
|
}
|
||
|
|
if($x==$endid&&$endid!=""){$end=$thisid[$x]; }
|
||
|
|
|
||
|
|
|
||
|
|
$media_array[$thismedia['media_id']] = $thismedia;
|
||
|
|
$x++;
|
||
|
|
|
||
|
|
|
||
|
|
}
|
||
|
|
$totalnum=count($media_array);
|
||
|
|
|
||
|
|
//if($end>count($media_array1)){$end=count($media_array1);}
|
||
|
|
$countitems=count($media_array1);
|
||
|
|
$start=$start1*1;
|
||
|
|
$y=$startid;
|
||
|
|
|
||
|
|
$media_array=array();
|
||
|
|
|
||
|
|
while($end!=$thisid[$y]) {
|
||
|
|
$t=$thisid[$y-1]*1;
|
||
|
|
$r=$thisid[$y+1]*1;
|
||
|
|
if($media_id==$thisid[$y]){
|
||
|
|
$thismediaid=$y;
|
||
|
|
$previd=$r;
|
||
|
|
$nextid=$t*1;
|
||
|
|
}
|
||
|
|
|
||
|
|
//$media_array[] = $media_array1[$y];
|
||
|
|
if( $media_array1[$y]==""){break;}
|
||
|
|
$media_array[$thisid[$y]] = $media_array1[$y];
|
||
|
|
|
||
|
|
$y++;
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
//$nextid=$media_array[$nextid]["media_id"];
|
||
|
|
//$nextid=$t;
|
||
|
|
//$previd=$p;
|
||
|
|
//$previd=$media_array[$previousid]["media_id"];
|
||
|
|
if($previd<0){$previd=0;}
|
||
|
|
|
||
|
|
|
||
|
|
// GET MEDIA WIDTH/HEIGHT
|
||
|
|
$mediasize = @getimagesize($url->url_userdir($owner->user_info['user_id']).$media_info['media_id'].'.'.$media_info['media_ext']);
|
||
|
|
$media_info[media_width] = $mediasize[0];
|
||
|
|
$media_info[media_height] = $mediasize[1];
|
||
|
|
|
||
|
|
|
||
|
|
// GET ALBUM TAG PRIVACY
|
||
|
|
$allowed_to_tag = ($privacy_max & $album_info['album_tag']);
|
||
|
|
|
||
|
|
// GET ALBUM COMMENT PRIVACY
|
||
|
|
$allowed_to_comment = ($privacy_max & $album_info['album_comments']);
|
||
|
|
|
||
|
|
|
||
|
|
// GET MEDIA COMMENTS
|
||
|
|
$comment = new se_comment('media', 'media_id', $media_info['media_id']);
|
||
|
|
$total_comments = $comment->comment_total();
|
||
|
|
|
||
|
|
|
||
|
|
// UPDATE ALBUM VIEWS
|
||
|
|
if($user->user_info[user_id] != $owner->user_info['user_id'])
|
||
|
|
{
|
||
|
|
$album_views_new = $album_info[album_views] + 1;
|
||
|
|
$database->database_query("UPDATE se_albums SET album_views='{$album_views_new}' WHERE album_id='{$album_info['album_id']}' LIMIT 1");
|
||
|
|
}
|
||
|
|
|
||
|
|
// UPDATE NOTIFICATIONS
|
||
|
|
if($user->user_info['user_id'] == $owner->user_info['user_id'])
|
||
|
|
{
|
||
|
|
//$database->database_query("DELETE FROM se_notifys USING se_notifys LEFT JOIN se_notifytypes ON se_notifys.notify_notifytype_id=se_notifytypes.notifytype_id WHERE se_notifys.notify_user_id='{$owner->user_info['user_id']}' AND (se_notifytypes.notifytype_name='mediacomment' OR se_notifytypes.notifytype_name='mediatag' OR se_notifytypes.notifytype_name='newtag') AND notify_object_id='{$media_info['media_id']}'");
|
||
|
|
|
||
|
|
$database->database_query("UPDATE se_notifys LEFT JOIN se_notifytypes ON se_notifys.notify_notifytype_id=se_notifytypes.notifytype_id SET isread=1 WHERE se_notifys.notify_user_id='{$owner->user_info['user_id']}' AND (se_notifytypes.notifytype_name='mediacomment' OR se_notifytypes.notifytype_name='mediatag' OR se_notifytypes.notifytype_name='newtag') AND notify_object_id='{$media_info['media_id']}'");
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
/*
|
||
|
|
// RETRIEVE TAGS FOR THIS PHOTO
|
||
|
|
$tag_array = Array();
|
||
|
|
$tags = $database->database_query("SELECT se_mediatags.*, se_users.user_id, se_users.user_username, se_users.user_fname, se_users.user_lname FROM se_mediatags LEFT JOIN se_users ON se_mediatags.mediatag_user_id=se_users.user_id WHERE mediatag_media_id='{$media_info['media_id']}' ORDER BY mediatag_id ASC");
|
||
|
|
while($tag = $database->database_fetch_assoc($tags))
|
||
|
|
{
|
||
|
|
$taggeduser = new se_user();
|
||
|
|
if($tag[user_id] != NULL)
|
||
|
|
{
|
||
|
|
$taggeduser->user_exists = 1;
|
||
|
|
$taggeduser->user_info['user_id'] = $tag['user_id'];
|
||
|
|
$taggeduser->user_info['user_username'] = $tag['user_username'];
|
||
|
|
$taggeduser->user_info['user_fname'] = $tag['user_fname'];
|
||
|
|
$taggeduser->user_info['user_lname'] = $tag['user_lname'];
|
||
|
|
$taggeduser->user_displayname();
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
$taggeduser->user_exists = 0;
|
||
|
|
}
|
||
|
|
|
||
|
|
$tag[tagged_user] = $taggeduser;
|
||
|
|
$tag_array[] = $tag;
|
||
|
|
}*/
|
||
|
|
|
||
|
|
function grabcomments()
|
||
|
|
{
|
||
|
|
global $url, $media_id, $database;
|
||
|
|
$query = $database->database_query("SELECT * FROM se_mediacomments WHERE mediacomment_media_id='".$media_id."' ORDER BY mediacomment_id DESC");
|
||
|
|
while($row=$database->database_fetch_array($query))
|
||
|
|
{
|
||
|
|
$owner1=new SEUser(Array($row["mediacomment_authoruser_id"]));
|
||
|
|
|
||
|
|
?>
|
||
|
|
<div style="margin-top: 10px; margin-bottom: 20px;"><div style="float: left; text-align: center; width: 90px;"><a href="<?=$url->url_create('profile', $owner1->user_info["user_username"])?>"><img src="<?=$owner1->user_photo("./images/nophoto.png")?>" class="photo" width="75" border="0"></a></div><div style="overflow: hidden;"><div class="profile_comment_author"><a href="<?=$url->url_create('profile', $owner1->user_info["user_username"])?>"><b><?=$owner1->user_displayname?></b></a></div><div class="profile_comment_date"><?=date('n/j/Y g:i A', $row["mediacomment_date"])?></div><div class="profile_comment_body" id="profile_comment_body_14612"><?=$row["mediacomment_body"]?></div><div class="profile_comment_links"><a href="user_messages_new.php?to_user=<?=$owner1->user_info["user_username"]?>&to_id=<?=$owner1->user_info["user_username"]?>" data-toggle="modal" data-target="#myModal" >message</a> </div></div></div><div class="clear"></div>
|
||
|
|
<?
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
$commentcount = $database->database_result($database->database_query("SELECT COUNT(*) FROM se_mediacomments WHERE mediacomment_media_id='".$media_id."'"),0);
|
||
|
|
|
||
|
|
$smarty->assign('commentcount', $commentcount);
|
||
|
|
if(isset($_POST['favorites'])) { $fave = $_POST['favorites']; } elseif(isset($_GET['favorites'])) { $fave = $_GET['favorites']; } else { $fave = 0; }
|
||
|
|
|
||
|
|
if($fave==="delete"){
|
||
|
|
|
||
|
|
$database->database_query("DELETE FROM favorites WHERE user='".$user->user_info["user_id"]."' AND type='picture' AND owner='".$owner->user_info["user_id"]."' AND objectid='".$media_id."'");
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
if($fave==="addto"){
|
||
|
|
$query=$database->database_query("SELECT * FROM favorites WHERE user='".$user->user_info["user_id"]."' AND type='picture' AND owner='".$owner->user_info["user_id"]."' AND objectid='".$media_id."'");
|
||
|
|
|
||
|
|
if($database->database_num_rows($query)==0){
|
||
|
|
$database->database_query("INSERT INTO favorites SET user='".$user->user_info["user_id"]."', type='picture', owner='".$owner->user_info["user_id"]."', objectid='".$media_id."'");
|
||
|
|
}
|
||
|
|
}
|
||
|
|
$query=$database->database_query("SELECT * FROM favorites WHERE user='".$user->user_info["user_id"]."' AND type='picture' AND owner='".$owner->user_info["user_id"]."' AND objectid='".$media_id."'");
|
||
|
|
if($database->database_num_rows($query)>0){$smarty->assign('favorites1', 1);}
|
||
|
|
|
||
|
|
$smarty->assign('favorites', 0);
|
||
|
|
// SET GLOBAL PAGE TITLE
|
||
|
|
$global_page_title[0] = 1000158;
|
||
|
|
$global_page_title[1] = $owner->user_displayname;
|
||
|
|
$global_page_title[2] = $media_info['media_title'];
|
||
|
|
$global_page_description[0] = 1000159;
|
||
|
|
$global_page_description[1] = $media_info['media_desc'];
|
||
|
|
|
||
|
|
// ASSIGN VARIABLES AND DISPLAY ALBUM FILE PAGE
|
||
|
|
|
||
|
|
$smarty->assign('countitems', $countitems);
|
||
|
|
|
||
|
|
$smarty->assign('objectid', $media_info['media_id']);
|
||
|
|
$smarty->assign('type',"photo");
|
||
|
|
|
||
|
|
$smarty->assign('list',"0");
|
||
|
|
$smarty->assign('specialfooter', "1");
|
||
|
|
$smarty->assign('totalnum', $totalnum);
|
||
|
|
$smarty->assign('thismediaid', $thismediaid+1);
|
||
|
|
$smarty->assign('album_info', $album_info);
|
||
|
|
$smarty->assign('nextid', $nextid);
|
||
|
|
$smarty->assign('previd', $previd);
|
||
|
|
$smarty->assign('media_info', $media_info);
|
||
|
|
$smarty->assign('total_comments', $total_comments);
|
||
|
|
$smarty->assign('allowed_to_comment', $allowed_to_comment);
|
||
|
|
$smarty->assign('allowed_to_tag', $allowed_to_tag);
|
||
|
|
$smarty->assign('media', $media_array);
|
||
|
|
$smarty->assign('media_keys', array_keys($media_array));
|
||
|
|
$smarty->assign('tags', $tag_array);
|
||
|
|
include "footer.php";
|
||
|
|
?>
|