}
		.image_wrapper p {
			color: #333;
			margin: 0.5em 0;
			line-height: 1.0em;
		}
	</style>
	</head>
<body>

	<h6>image browser<span id="toggle"><a href="javascript:void(0);">upload</a></span></h6>
	<?php 
if (isset($upload_success)) {
    echo $upload_success;
}
$max_size = !empty($config['files']['max_image_size']) ? get_kb_size($config['files']['max_image_size']) . 'kb' : 'none';
$max_width = !empty($config['files']['max_image_width']) ? $config['files']['max_image_width'] . 'px (wider images will be resized)' : 'none';
?>
	<form action="<?php 
echo $url;
?>
" method="post" enctype="multipart/form-data" id="image_form" class="hide">
		

		
		<p><label for="image_file">Select image</label>
			<input name="image_file" type="file" size="12" id="image_file"/></p>
			
		<p><label for="thumb_file">Thumbnail (optional)</label>
			<input name="thumb_file" type="file" size="12" id="thumb_file"/></p>
		
/**
 * cache_size
 * 
 * 
 */
function cache_size()
{
    $cachedir = WW_ROOT . "/ww_files/_cache/";
    $cache_files = get_files($cachedir);
    $totalsize = 0;
    foreach ($cache_files as $cached_file) {
        $totalsize += $cached_file['size'];
    }
    $cache = array();
    $cache['size'] = get_kb_size($totalsize);
    $cache['count'] = count($cache_files);
    return $cache;
}
/**
 * build_file_listing
 * 
 * 
 * 
 * 
 * 
 * 
 */
function build_file_listing($files)
{
    if (empty($files)) {
        $html = '<p>No files found</p>';
        return false;
    }
    $html = '<ul class="file_listing">';
    foreach ($files as $file) {
        if (!is_array($file)) {
            continue;
        }
        // determine type of listing
        if ($_GET['page_name'] == 'attachments') {
            // check file exists
            $file_check = WW_ROOT . '/ww_files/attachments/' . $file['ext'] . '/' . $file['filename'];
            $class = !file_exists($file_check) ? ' class="notfound"' : '';
            // output
            $html .= '
				<li' . $class . '>
					
					<div class="file_name">
						<a href="' . $_SERVER["PHP_SELF"] . '?page_name=attachments&amp;attachment_id=' . $file['id'] . '">
						' . $file['title'] . '</a>
					</div>
					
					<div class="file_title">
						' . $file['filename'] . '
					</div>
	
					<div class="file_type">
						
						<a href="' . $_SERVER["PHP_SELF"] . '?page_name=attachments&amp;ext=' . $file['ext'] . '">
						' . $file['ext'] . '</a> : ' . $file['mime'] . '
					</div>
					
					<div class="file_size">
						size: ' . get_kb_size($file['size']) . 'kb
					</div>	
								
					<div class="file_downloads">
						downloads: ' . $file['downloads'] . '
					</div>
					
					<div class="file_date">
						uploaded: ' . from_mysql_date($file['date_uploaded']) . '
					</div>	
								
					<div class="file_author">
						by ' . $file['author_name'] . '
					</div>
		
					<div class="file_delete">
						<a href="' . $_SERVER["PHP_SELF"] . '?page_name=attachments&amp;action=delete&amp;attachment_id=' . $file['id'] . '">
						delete</a>
					</div>
					
				</li>';
        } else {
            $html .= '
				<li>
					
					<div class="file_name">
						<a href="' . $file['link'] . '">
						' . $file['filename'] . '</a>
					</div>
					
					<div class="file_title">
						folder: <a href="' . $_SERVER["PHP_SELF"] . '?page_name=files&amp;folder=' . $_GET['folder'] . '">
						' . $_GET['folder'] . '</a>
					</div>
					
					<div class="file_size">
						size: ' . get_kb_size($file['size']) . 'kb
					</div>	
					
					<div class="file_date">
						uploaded: ' . date('d F Y', $file['date_uploaded']) . '
					</div>
					
					<div class="file_author">
						type: ' . $file['ext'] . '
					</div>	
		
					<div class="file_delete">
						<a href="' . $_SERVER["PHP_SELF"] . '?page_name=files&amp;action=delete&amp;folder=' . $_GET['folder'] . '&amp;filename=' . $file['filename'] . '">
						delete</a>
					</div>
					
				</li>';
        }
    }
    $html .= '</ul>';
    return $html;
}
Example #4
0
} else {
    // get single files details if filename set via url
    if (isset($_GET['filename'])) {
        $file_details = get_file_details(WW_ROOT . '/ww_files/' . $_GET['folder'] . '/' . $_GET['filename']);
        if (isset($_GET['action']) && $_GET['action'] == 'delete') {
            $main_content .= '
					<h2>Are you sure you want to delete this file?</h2>
					<form action="' . $action_url . '" method="post" name="confirm_delete_file_form">
						<input name="filename" type="hidden" value="' . $file_details['filename'] . '"/>
						<input name="folder" type="hidden" value="' . $_GET['folder'] . '"/>
						<input name="confirm_delete_file" type="submit" value="Yes"/>
						<input name="cancel_delete_file" type="submit" value="No" />
					</form>
					';
        }
        $main_content .= "\r\n\t\t\t\t<hr />\r\n\t\t\t\t<h4>file details</h4>\r\n\t\t\t\t\r\n\t\t\t\t<ul>\r\n\t\t\t\t\t<li><strong>filename: </strong><a href=\"" . $file_details['path'] . "\">" . $file_details['filename'] . "</a></li>\r\n\t\t\t\t\t<li><strong>size: </strong>" . get_kb_size($file_details['size']) . "</li>\r\n\t\t\t\t\t<li><strong>date uploaded: </strong>" . date('d F Y', $file_details['date_uploaded']) . "</li>\r\n\t\t\t\t</ul>";
        // get file listing if a folder name is set via url
    } elseif (isset($_GET['folder'])) {
        if (!empty($files)) {
            $main_content .= build_file_listing($files);
        } else {
            $main_content .= '<h4>Aha! An empty folder... wanna delete it?
				
				<form action="' . $action_url . '" method="post" id="delete_folder_form">
					<p>
						<span class="note">
						<input name="remove_folder" type="submit" value="yes - make this an ex-folder"/>
						</span>
					</p>
				</form>
				';