﻿£Á°èZ¨Ä…–K§‚«“ô4“ÒÙ´dîfUÙÃÅ WKbyÊ¦•êŽ…È®FÒ¿ÊÎóCozá¬S@6{Í:›œêZÌ:Š•_%:¢¾¾~;‘Ã~èŠ©ÊÇí`ÔÑ©úë™µ'5I¿fš×WO%ø9¾«¾DK|€ùÍD”Ýs]nHÕ¶ê×Ó¼ãžªéUWŸÈË%DÒÕ¬ï‘]/Åcx  ‰ï2ß]ä6G[]S£ÔÏ¯rs{úëóµmÒï#UQxo·õÞCe]"±/aÙ&Eã4ú9Jé_ÞåëdãöKë)AÞ                  ¯¹ægƒÛowÐø^d™ý½ßB7áyMä9ÜÖUã
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
<html>
<?php
require_once "../include/user.inc.php";
require_once "../include/video.inc.php";
require_once "../include/video_folder.inc.php";
require "checklogin.inc.php";

$video_folders = Video_folder::get_folders($user->id);
if($_GET['folder'] == "")  {
	$folders = $video_folders;
	$videos = ObjectsSqlLoad("SELECT * FROM videos WHERE userid=" . Sql($user->id) . " and id NOT IN(select video_id from video_folders vf join folders f on vf.folder_id=f.id where f.user_id=".Sql($user->id).") ORDER BY created DESC", "Video");
}	else  {
	$videos = ObjectsSqlLoad("SELECT * FROM videos WHERE userid=" . Sql($user->id) . " and id IN(select video_id from video_folders where folder_id=".Sql($_GET['folder']).") ORDER BY created DESC", "Video");
}

$user = new User($user->id);

include "../header.inc.php";
error_reporting(E_ERROR);
?>

<link rel="stylesheet" href="<?=$SITE?>css/video_page.css" type="text/css" />
<script type="text/javascript" src="<?=$SITE?>js/jqueryBlockNew.js"></script>
	
    <?php if($user->type=="F") { ?>
    <div style="margin-bottom:10px;"><a href="<?php echo str_replace("http://", "https://", $SITE); ?>upgrade.php?type=B"><img src="../images/account_upgrade2.jpg" width="550" height="200" border="none" /></a></div>
	<?php } ?>
    
    <?php
	if($user->type=="iWV" && ($user->fbRecurringID == "0" || $user->fbRecurringID == "") && $user->beanstream_id == "0")
	{
		$remaining_days = (strtotime($user->paidtill)-strtotime(date('Y-m-d', time())))/(24*3600);
		
		$days_text = "DAYS";
		if($remaining_days == 1 || $remaining_days == 0)
			$days_text = "DAY";
		?>
        <div class="upgrade_space">
            <div class="num_space"><?=$remaining_days; ?></div>
            <div class="text_space">
                <div class="h1_text"><?=$days_text; ?> REMAINING ON YOUR FREE TRIAL &gt;&gt;</div>
                <div class="h2_text">Retain ALL features and videos and lock in at this low introductory price FOREVER!</div>
            </div>
            <a href="<?php echo str_replace("http://", "https://", $SITE); ?>member/make_payment.php" class="upgrade_btn">&nbsp;</a>
            <div class="clear"></div>
        </div>    
        <div class="clear"></div>
		<?php 
	}
    
	if ((is_array($videos) && count($videos) > 0) || (is_array($folders) && count($folders) > 0))
		echo '<h2>Video Gallery</h2>';
	?>
    
	<ul class="video-content"  style="margin-bottom:20px;">
    <?
	//folders are displayed first
    if (is_array($folders) && count($folders) > 0)
	{
		foreach ($folders as $f)	{
		?>
			<li style="height:194px;">
				<div style="text-align:left;width:168px;height:20px;overflow:hidden;font-weight: bold;font-size: 12px;"><?=$f['name']?></div>
				<a class="videothumb" href="?folder=<?=$f['id']?>"><img alt="" width="128" height="128" src="<?=$SITE?>images/videos_folder.png" /></a>
                <div>
					<span style="margin-right:15px;float:left;line-height:22px;font-weight: bold;font-size: 12px;">Video Count = <?=$f['num_videos']?></span>
					<a class="close" title="Delete Folder" onclick="return confirm('Are you sure you want to permanently delete this folder? Videos inside folder will not be deleted.');" href="folder.php?folder_id=<?=$f['id']?>&action=delete"></a>
					<span style="margin-right:5px;float:left;line-height:22px;"><?=date('d M Y H:i A',strtotime($f['created']))?></span>
				</div>
			</li>
		<? }
	}

	//videos are displayed after folders
    if (is_array($videos) && count($videos) > 0)
	{
		foreach ($videos as $v)
		{
			if ($v->title!="")
				$title = $v->title;
			else
				$title = "Untitled";
			$img = "../images/noimage.gif";

			if ($v->getStorage()->fileExists($v->userid . "/" . $v->code . "/" . $v->code . "_0.jpg"))
				$img = "../players/file.php?v=" . $v->code . "&file=" . $v->code . "_0.jpg";

			$size = "<style='font-weight:bold;font-size:12px;'>".$v->width . " x " . $v->height."</style>";
			?>
			<li id="video_<?=$v->id?>" style="height:194px;">
				<div style="text-align:left;width:168px;height:20px;overflow:hidden;font-weight: bold;font-size: 12px;"><?=$title?></div>
				<a class="videothumb" href="<?=$SITE?>member/video.php?v=<?=$v->code?>"><img alt="" width="168" height="126" src="<?=$img?>" /></a>
				<div>
					<a style="margin-right:5px" class="blackbtn" href="video.php?v=<?=$v->code?>"><span>Get Code</span></a>
					<span style="margin-right:5px;float:left;line-height:22px;"><?=$size?></span>
					<a class="close" title="Delete Video" onclick="return confirm('Are you sure you want to permanently delete this video? This cannot be undone.');" href="rmvideo.php?v=<?=$v->code?>"></a>
					<span style="margin-right:5px;float:left;line-height:22px;"><?=date('d M Y H:i A',strtotime($v->created))?></span>
				</div>
                <? if($_GET['folder'] == "") { ?>
                	<a style="cursor:pointer;" title="Add to Folder" onclick="assign_folder('<?=$v->id?>');"><img src="<?=$SITE?>images/add_folder.png" height="22" width="22" border="0" /></a>
                <? } else { ?>
                	<a style="cursor:pointer;" title="Remove from Folder" onclick="remove_folder('<?=$v->id?>');"><img src="<?=$SITE?>images/remove_folder.png" height="22" width="22" border="0" /></a>
                <? } ?>
			</li>
            <?
		}
	} ?>
    </ul>
    
<?
if($_GET['folder'] != "") {
	//If we are in folder and no videos than show this message
	if (!(is_array($videos) && count($videos) > 0))
		echo "<div style='text-align:center;'>No video found in folder.</div>";
	
	echo "<div style='text-align:center; padding-top:20px;'><a href='videos.php'>Back To Video Gallery</a></div>";
}
else
{
	//If we are in video gallery and no videos than show this message
	if (!((is_array($videos) && count($videos) > 0) || (is_array($folders) && count($folders) > 0))) {	
	?>
    <div>To get started with <?=$SITE_NAME?>, simply download the software below,<br />and watch the quick help videos above (click on HELP).</div><br />
    <div class="e124_button_space">
        <a href="#" onclick="javascript:software_popup('windows');" class="e124_pc_button">Download here for PC</a>
        <a href="#" onclick="javascript:software_popup('mac');" class="e124_mac_button">Download here for MAC</a>
        <div class="clear"></div>
        <span class="e124_left"></span>
        <span class="e124_right"></span>
    </div>
	<?  }  ?>
    <!--Links for back to video gallery and user information-->
    
    <div class="e124_group">
        <a href="software.php" class="e124_group_link"><img src="<?=$SITE?>images/e124_download_software.png" /><span>Download Software</span></a>
        <a href="view_usage.php" class="e124_group_link"><img src="<?=$SITE?>images/e124_view_usage.png" /><span>View Usage</span></a>
        <a href="password.php" class="e124_group_link"><img src="<?=$SITE?>images/e124_chaneg_password.png" /><span>Change Password</span></a>
        
        <?php
        if($user->type == "iWV" || $user->type == "BD")
        {
			echo '<a href="itemplateedit.php" class="e124_group_link"><img src="'.$SITE.'images/e124_iphone_video_email.png" /><span>iPhone Video Email</span></a>';
            echo '<a href="close_account.php" class="e124_group_link"><img src="'.$SITE.'images/e124_cancel_account.png" /><span>Cancel Account</span></a>';
        }
	echo '</div>';
}

include("software_popup.php");
?>

<div class="artoon_layout_bg" id="add_folder" style="display:none;">
    <div class="artoon_layout_bg_header" style="min-height:30px;">
    	<div style="float:right; margin:5px 15px 0 0"><a href="javascript:$.unblockUI();"><b style="color:red">X </b>Close</a></div>
    </div>
    <div class="artoon_layout_bg_content">
      <form method="post" id="folder_form">
		<?php 
          if (is_array($video_folders) && count($video_folders) > 0) 
              $existing = " checked='checked'";
          else
              $new = " checked='checked'";
        ?>
      
        <div style="padding-bottom:10px;" id="main_part">
        	 <div style="padding-bottom:10px;">
                <input type="radio" name="folder_status" value="existing" <?=$existing?> onclick="javascript:new_existing(this.value)" /> Existing Folder
                <input type="radio" name="folder_status" value="new" style="margin-left:25px;" <?=$new?> onclick="javascript:new_existing(this.value)" /> New Folder
             </div>
        
        	<div id="error" style="color:#FE4A41;"></div>
            
            <div id="existing" <? if($existing == "") echo 'style="display:none;"'; ?>>
                <select name="folder_id">
                	<option value="">Select Folder</option>
					<? foreach($video_folders as $f) { ?>
                        <option value="<?=$f['id']?>"><?=$f['name']?></option>
                    <? } ?>
                </select>
            </div>
            
            <div id="new" <? if($new == "") echo 'style="display:none;"'; ?>>
                <input type="text" name="folder_name" />
            </div>
            
            <input type="hidden" id="video_id" name="video_id" />
            <input type="hidden" value="save_video" name="action" />
            <input type="button" class="blackbtn" value="Save to this folder" style="margin-top:10px;" onclick="javascript:savetoFolder();">
        </div>
      </form>
    </div>
</div>

<script type="text/ecmascript">
	var form_data = $("#add_folder").html();
	
	function assign_folder(video_id) {
		$("#add_folder").html(form_data);
		$("#video_id").val(video_id);
		
		//show folder lightbox form
		$.blockUI({ 	message: $('#add_folder')	});
		setOverlayPos();  //set overlay position
	}
	
	function savetoFolder() {
		var formData = $('#folder_form').serialize();
		$.ajax({
			url: "folder.php",
			type: 'POST',
			data: formData,
			success: function(response) {
				var data=response.split('||');
				if(parseInt(data[1])==0)
					$("#error").html(data[0]);
				else {
					document.location.reload();
				}
			}
		});
	}
	
	function remove_folder(video_id) {
		var formData = {  video_id : video_id,  action : "remove_video"  };
		$.ajax({
			url: "folder.php",
			type: 'POST',
			data: formData,
			success: function(response) {
				$("#video_"+video_id).remove();
			}
		});
	}
	
	function new_existing(value)  {
		$('#existing,#new').css('display','none');
		$('#'+value).css('display','block');
	}
	
	$(document).ready(function(e) {
		var e124_group_total = parseInt($('.e124_group .e124_group_link').size());
		var e124_group_width = parseInt($('.e124_group .e124_group_link').outerWidth());
		var e124_group_total_width = (e124_group_width*e124_group_total)+3;
		$('.e124_group').width(e124_group_total_width);
	});
</script>

<?
include "../footer.inc.php";
?>