function recursive_directory_size($directory, $format = FALSE)
{
    $size = 0;
    if (substr($directory, -1) == '/') {
        $directory = substr($directory, 0, -1);
    }
    if (!file_exists($directory) || !is_dir($directory) || !is_readable($directory)) {
        return -1;
    }
    if ($handle = opendir($directory)) {
        while (($file = readdir($handle)) !== false) {
            $path = $directory . '/' . $file;
            if ($file != '.' && $file != '..') {
                if (is_file($path)) {
                    $size += filesize($path);
                } elseif (is_dir($path)) {
                    $handlesize = recursive_directory_size($path);
                    if ($handlesize >= 0) {
                        $size += $handlesize;
                    } else {
                        return -1;
                    }
                }
            }
        }
        closedir($handle);
    }
    if ($format == TRUE) {
        return formatfilesize($size);
    } else {
        return $size;
    }
}
echo $lang["searchitemsdiskusage"];
?>
</h1>

<div class="Question">
<label><?php 
echo $lang["matchingresourceslabel"];
?>
</label>
<div class="Fixed"><?php 
echo number_format($count);
?>
</div>
<div class="clearerleft"></div>
</div>

<div class="Question">
<label><?php 
echo $lang["diskusage"];
?>
</label>
<div class="Fixed"><strong> <?php 
echo formatfilesize($disk_usage);
?>
</strong></div>
<div class="clearerleft"></div>
</div>


<?php 
include "../include/footer.php";
Example #3
0
function resize($filename, $resize_width, $resize_height, $texttype = false, $filename_src)
{
    global $config, $_POST, $error;
    $ext = strtolower(strrchr(basename($filename), "."));
    // Получаем формат уменьшаемого изображения
    $info = getimagesize($filename);
    // Возвращает ширину и высоту картинки
    $width = $info['0'];
    $height = $info['1'];
    if ($resize_height > $height or $resize_width > $width) {
        $error[] = "Нельзя уменьшать изображение в большую сторону";
    } else {
        list($resize_width, $resize_height) = get_resize_proportions($height, $width, $resize_height, $resize_width);
        $type = '';
        if (!$info['mime']) {
            switch ($ext) {
                case '.gif':
                    $type = 'gif';
                    break;
                case '.png':
                    $type = 'png';
                    break;
                case '.jpg':
                    $type = 'jpg';
                    break;
                case '.jpeg':
                    $type = 'jpg';
                    break;
                    //case '.bmp' : $type='bmp'; break; - здесь уже не должно быть BMP
            }
        } else {
            switch ($info['mime']) {
                case 'image/gif':
                    $type = 'gif';
                    break;
                case 'image/pjpeg':
                    $type = 'jpg';
                    break;
                case 'image/jpeg':
                    $type = 'jpg';
                    break;
                case 'image/x-png':
                    $type = 'png';
                    break;
                case 'image/png':
                    $type = 'png';
                    break;
                    //case 'image/bmp'  : $type='bmp'; break;  - здесь уже не должно быть BMP
                    //case 'image/x-ms-bmp' : $type='bmp'; break;
            }
        }
        if ($type != '') {
            include_once 'gdenhancer/GDEnhancer.php';
            //path of GDEnhancer.php
            $image = new GDEnhancer($filename);
            $image->backgroundResize($resize_width, $resize_height, 'shrink');
            //option shrink
            //текст на превью
            if (isset($texttype) and $texttype and $texttype != "nothing") {
                $filesize = formatfilesize(filesize($filename));
                if ($texttype == 'dimensions') {
                    $text = $width . 'x' . $height . '(' . $filesize . ')';
                } else {
                    $text = $_POST['text'];
                }
                $DARKNESS = 70;
                //FIXME: вынести в конфиг!
                //"полупрозрачный" слой подложки под текст
                $imglayer = imagecreatetruecolor($width, 15);
                imagesavealpha($imglayer, true);
                $color = imagecolorallocatealpha($imglayer, 0, 0, 0, $DARKNESS);
                imagefill($imglayer, 0, 0, $color);
                ob_start();
                imagepng($imglayer);
                $image_data = ob_get_contents();
                ob_end_clean();
                imagedestroy($imglayer);
                $image->layerImage($image_data);
                $image->layerMove(0, "top", 0, $resize_height - 15);
                $save = $image->save();
                unset($image);
                //сам текст
                $image = new GDEnhancer($save['contents']);
                $image->layerText($text, $config['site_dir'] . "/K1FS.ttf", '10', '#FFFFFF', 0, 1);
                $image->layerMove(0, "top", 2, $resize_height - 14);
            }
            $save = $image->save();
            file_put_contents($filename, $save['contents']);
            unset($image);
        }
    }
    //else resize_height>height
}
	<!--List Item-->
	<tr>
	<td><?php 
    echo htmlspecialchars($files[$n]["name"]);
    ?>
</td>	
	<td><?php 
    echo htmlspecialchars($files[$n]["description"]);
    ?>
&nbsp;</td>	
	<td><?php 
    echo $files[$n]["file_extension"] == "" ? $lang["notuploaded"] : htmlspecialchars(str_replace_formatted_placeholder("%extension", $files[$n]["file_extension"], $lang["cell-fileoftype"]));
    ?>
</td>	
	<td><?php 
    echo formatfilesize($files[$n]["file_size"]);
    ?>
</td>	
	<td><?php 
    echo nicedate($files[$n]["creation_date"], true);
    ?>
</td>
	<?php 
    if (count($alt_types) > 1) {
        ?>
<td><?php 
        echo $files[$n]["alt_type"];
        ?>
</td><?php 
    }
    ?>
# get all resources in the DB
$resources = sql_query("select ref,field" . $view_title_field . ",file_extension from resource where ref>0 order by ref DESC");
//loop:
foreach ($resources as $resource) {
    $resource_path = get_resource_path($resource['ref'], true, "", false, $resource['file_extension']);
    if (file_exists($resource_path)) {
        $filesize = filesize_unlimited($resource_path);
        sql_query("update resource_dimensions set file_size={$filesize} where resource='" . $resource['ref'] . "'");
        echo "Ref: " . $resource['ref'] . " - " . $resource['field' . $view_title_field] . " - updating resource_dimensions file_size column - " . formatfilesize($filesize);
        echo "<br />";
    }
    $alt_files = sql_query("select file_extension,file_name,ref from resource_alt_files where resource=" . $resource['ref']);
    if (count($alt_files) > 0) {
        foreach ($alt_files as $alt) {
            $alt_path = get_resource_path($resource['ref'], true, "", false, $alt['file_extension'], -1, 1, false, "", $alt['ref']);
            if (file_exists($alt_path)) {
                // allow to re-run script without re-copying files
                $filesize = filesize_unlimited($alt_path);
                sql_query("update resource_alt_files set file_size={$filesize} where resource='" . $resource['ref'] . "' and ref='" . $alt['ref'] . "'");
                echo "&nbsp;&nbsp;&nbsp;&nbsp;ALT - " . $alt['file_name'] . " - updating alt file size - " . formatfilesize($filesize);
                echo "<br />";
            }
        }
    }
    update_disk_usage($resource['ref']);
    echo "updating disk usage";
    echo "<br />";
    echo "<br />";
    flush();
    ob_flush();
}
Example #6
0
<div class="Fixed">
<?php
if ($resource["has_image"]==1)
	{
	?><img align="top" src="<?php echo get_resource_path($ref,false,($edit_large_preview?"pre":"thm"),false,$resource["preview_extension"],-1,1,checkperm("w"))?>" class="ImageBorder" style="margin-right:10px;"/><br />
	<?php
	}
else
	{
	# Show the no-preview icon
	?>
	<img src="../gfx/<?php echo get_nopreview_icon($resource["resource_type"],$resource["file_extension"],true)?>" />
	<br />
	<?php
	}
if ($resource["file_extension"]!="") { ?><strong><?php echo str_replace_formatted_placeholder("%extension", $resource["file_extension"], $lang["cell-fileoftype"]) . " (" . formatfilesize(@filesize_unlimited(get_resource_path($ref,true,"",false,$resource["file_extension"]))) . ")" ?></strong><br /><?php } ?>

	<?php if ($resource["has_image"]!=1) { ?>
	<a href="<?php echo $baseurl_short?>pages/upload.php?ref=<?php echo urlencode($ref) ?>&search=<?php echo urlencode($search)?>&offset=<?php echo urlencode($offset) ?>&order_by=<?php echo urlencode($order_by) ?>&sort=<?php echo urlencode($sort) ?>&archive=<?php echo urlencode($archive) ?>&upload_a_file=true" onClick="return CentralSpaceLoad(this,true);">&gt;&nbsp;<?php echo $lang["uploadafile"]?></a>
	<?php } else { ?>
	<a href="<?php echo $baseurl_short?>pages/upload_<?php echo $top_nav_upload_type ?>.php?ref=<?php echo urlencode($ref) ?>&search=<?php echo urlencode($search)?>&offset=<?php echo urlencode($offset) ?>&order_by=<?php echo urlencode($order_by) ?>&sort=<?php echo urlencode($sort) ?>&archive=<?php echo urlencode($archive) ?>&replace_resource=<?php echo urlencode($ref)  ?>&resource_type=<?php echo $resource['resource_type']?>" onClick="return CentralSpaceLoad(this,true);">&gt;&nbsp;<?php echo $lang["replacefile"]?></a>
	<?php hook("afterreplacefile"); ?>
	<?php } ?>
	<?php if (! $disable_upload_preview) { ?><br />
	<a href="<?php echo $baseurl_short?>pages/upload_preview.php?ref=<?php echo urlencode($ref) ?>&search=<?php echo urlencode($search)?>&offset=<?php echo urlencode($offset) ?>&order_by=<?php echo urlencode($order_by) ?>&sort=<?php echo urlencode($sort) ?>&archive=<?php echo urlencode($archive) ?>" onClick="return CentralSpaceLoad(this,true);">&gt;&nbsp;<?php echo $lang["uploadpreview"]?></a><?php } ?>
	<?php if (! $disable_alternative_files) { ?><br />
	<a href="<?php echo $baseurl_short?>pages/alternative_files.php?ref=<?php echo urlencode($ref) ?>&search=<?php echo urlencode($search)?>&offset=<?php echo urlencode($offset) ?>&order_by=<?php echo urlencode($order_by) ?>&sort=<?php echo urlencode($sort) ?>&archive=<?php echo urlencode($archive) ?>"  onClick="return CentralSpaceLoad(this,true);">&gt;&nbsp;<?php echo $lang["managealternativefiles"]?></a><?php } ?>
	<?php if ($allow_metadata_revert){?><br />
	<a href="<?php echo $baseurl_short?>pages/edit.php?ref=<?php echo urlencode($ref) ?>&exif=true&search=<?php echo urlencode($search)?>&offset=<?php echo urlencode($offset) ?>&order_by=<?php echo urlencode($order_by) ?>&sort=<?php echo urlencode($sort) ?>&archive=<?php echo urlencode($archive) ?>" onClick="return confirm('<?php echo $lang["confirm-revertmetadata"]?>');">&gt; 
	<?php echo $lang["action-revertmetadata"]?></a><?php } ?>
	<?php hook("afterfileoptions"); ?>
Example #7
0
: <b><?php 
    echo round(($avail ? $used / $avail : 0) * 100, 0);
    ?>
%</b> (<?php 
    echo $lang["available"];
    ?>
: <?php 
    echo formatfilesize($avail);
    ?>
; <?php 
    echo $lang["used"];
    ?>
: <?php 
    echo formatfilesize($used);
    ?>
; <?php 
    echo $lang["free"];
    ?>
:  <?php 
    echo formatfilesize($free);
    ?>
)
</p>
<?php 
}
?>

</div>

<?php 
include "../../include/footer.php";
Example #8
0
        }
    }
}
if ($original) {
    for ($i = 0; $i < count($results); $i++) {
        $access = get_resource_access($results[$i]);
        $filepath = get_resource_path($results[$i]['ref'], TRUE, '', FALSE, $results[$i]['file_extension'], -1, 1, FALSE, '', -1);
        $original_link = get_resource_path($results[$i]['ref'], FALSE, '', FALSE, $results[$i]['file_extension'], -1, 1, FALSE, '', -1);
        if (file_exists($filepath)) {
            $results[$i]['original_link'] = $original_link;
        } else {
            $results[$i]['original_link'] = 'No original link available.';
        }
        // Get the size of the original file:
        $original_size = get_original_imagesize($results[$i]['ref'], $filepath, $results[$i]['file_extension']);
        $original_size = formatfilesize($original_size[0]);
        $original_size = str_replace('&nbsp;', ' ', $original_size);
        $results[$i]['original_size'] = $original_size;
    }
}
// flv file and thumb if available
if (getval("flvfile", "") != "") {
    for ($n = 0; $n < count($results); $n++) {
        // flv previews
        $flvfile = get_resource_path($results[$n]['ref'], true, "pre", false, $ffmpeg_preview_extension);
        if (!file_exists($flvfile)) {
            $flvfile = get_resource_path($results[$n]['ref'], true, "", false, $ffmpeg_preview_extension);
        }
        if (!(isset($results[$n]['is_transcoding']) && $results[$n]['is_transcoding'] == 1) && file_exists($flvfile) && strpos(strtolower($flvfile), "." . $ffmpeg_preview_extension) !== false) {
            if (file_exists(get_resource_path($results[$n]['ref'], true, "pre", false, $ffmpeg_preview_extension))) {
                $flashpath = get_resource_path($results[$n]['ref'], false, "pre", false, $ffmpeg_preview_extension, -1, 1, false, "", -1, false);
Example #9
0
}
if (!defined('SUB_PAGE')) {
    define('SUB_PAGE', 'Reports &amp; Stats');
}
$vid_dir = get_directory_size(VIDEOS_DIR);
$thumb_dir = get_directory_size(THUMBS_DIR);
$orig_dir = get_directory_size(ORIGINAL_DIR);
$user_thumbs = get_directory_size(USER_THUMBS_DIR);
$user_bg = get_directory_size(USER_BG_DIR);
$grp_thumbs = get_directory_size(GP_THUMB_DIR);
$cat_thumbs = get_directory_size(CAT_THUMB_DIR);
assign('vid_dir', $vid_dir);
assign('thumb_dir', $thumb_dir);
assign('orig_dir', $orig_dir);
assign('user_thumbs', $user_thumbs);
assign('user_bg', $user_bg);
assign('grp_thumbs', $grp_thumbs);
assign('cat_thumbs', $cat_thumbs);
if (!defined('MAIN_PAGE')) {
    define('MAIN_PAGE', 'Stats And Configurations');
}
if (!defined('SUB_PAGE')) {
    if ($_GET['view'] == 'search') {
        define('SUB_PAGE', 'Search Members');
    } else {
        define('SUB_PAGE', 'Reports & Stats');
    }
}
assign('db_size', formatfilesize(get_db_size()));
template_files('reports.html');
display_it();
Example #10
0
			if (file_exists($alt_pre_file))
				{
				# Get web path for preview (pass creation date to help cache refresh)
				$alt_pre=get_resource_path($ref,false,"pre",false,"jpg",-1,1,false,$altfiles[$n]["creation_date"],$altfiles[$n]["ref"]);
				}
			}
		?>
		<tr class="DownloadDBlend" <?php if ($alt_pre!="" && $alternative_file_previews_mouseover) { ?>onMouseOver="orig_preview=jQuery('#previewimage').attr('src');orig_width=jQuery('#previewimage').width();jQuery('#previewimage').attr('src','<?php echo $alt_pre ?>');jQuery('#previewimage').width(orig_width);" onMouseOut="jQuery('#previewimage').attr('src',orig_preview);"<?php } ?>>
		<td>
		<?php if(!hook("renderaltthumb")): ?>
		<?php if ($alt_thm!="") { ?><a href="<?php echo $baseurl_short?>pages/preview.php?ref=<?php echo urlencode($ref)?>&alternative=<?php echo $altfiles[$n]["ref"]?>&k=<?php echo urlencode($k)?>&search=<?php echo urlencode($search)?>&offset=<?php echo urlencode($offset)?>&order_by=<?php echo urlencode($order_by)?>&sort=<?php echo urlencode($sort)?>&archive=<?php echo urlencode($archive)?>&<?php echo hook("previewextraurl") ?>"><img src="<?php echo $alt_thm?>" class="AltThumb"></a><?php } ?>
		<?php endif; ?>
		<h2><?php echo htmlspecialchars($altfiles[$n]["name"])?></h2>
		<p><?php echo htmlspecialchars($altfiles[$n]["description"])?></p>
		</td>
		<td><?php echo formatfilesize($altfiles[$n]["file_size"])?></td>
		
		<?php if ($userrequestmode==2 || $userrequestmode==3) { ?><td></td><?php } # Blank spacer column if displaying a price above (basket mode).
		?>
		
		<?php if ($access==0){?>
		<td class="DownloadButton">
		<?php if (!$direct_download || $save_as){?>
		<a <?php if (!hook("downloadlink","",array("ref=" . $ref . "&alternative=" . $altfiles[$n]["ref"] . "&k=" . $k . "&ext=" . $altfiles[$n]["file_extension"]))) { ?>href="<?php echo $baseurl_short?>pages/terms.php?ref=<?php echo urlencode($ref)?>&k=<?php echo urlencode($k)?>&search=<?php echo urlencode($search) ?>&url=<?php echo urlencode("pages/download_progress.php?ref=" . $ref . "&ext=" . $altfiles[$n]["file_extension"] . "&k=" . $k . "&alternative=" . $altfiles[$n]["ref"] . "&search=" . urlencode($search) . "&offset=" . $offset . "&archive=" . $archive . "&sort=".$sort."&order_by=" . urlencode($order_by))?>"<?php } ?> onClick="return CentralSpaceLoad(this,true);"><?php echo $lang["action-download"] ?></a>
		<?php } else { ?>
			<a href="#" onclick="directDownload('<?php echo $baseurl_short?>pages/download_progress.php?ref=<?php echo urlencode($ref)?>&ext=<?php echo $altfiles[$n]["file_extension"]?>&k=<?php echo urlencode($k)?>&alternative=<?php echo $altfiles[$n]["ref"]?>')"><?php echo $lang["action-download"]?></a>
		<?php } // end if direct_download ?></td></td>
		<?php } else { ?>
		<td class="DownloadButton DownloadDisabled"><?php echo $lang["access1"]?></td>
		<?php } ?>
		</tr>
Example #11
0
$search=getvalescaped("search","");
$offset=getvalescaped("offset","",true);
$order_by=getvalescaped("order_by","");
$archive=getvalescaped("archive","",true);
$restypes=getvalescaped("restypes","");
$starsearch=getvalescaped("starsearch","");
if (strpos($search,"!")!==false) {$restypes="";}

$default_sort="DESC";
if (substr($order_by,0,5)=="field"){$default_sort="ASC";}
$sort=getval("sort",$default_sort);

$results=do_search(getval("search",""),getvalescaped("restypes",""),"relevance",getval("archive",""),-1,"desc",false,$starsearch,false,true);
$disk_usage=$results[0]["total_disk_usage"];
$count=$results[0]["total_resources"];

include ("../include/header.php");

?>
<p><a onClick="return CentralSpaceLoad(this,true);" href="<?php echo $baseurl_short?>pages/search.php?search=<?php echo urlencode(getval("search","")) ?>&offset=<?php echo urlencode($offset)?>&order_by=<?php echo urlencode($order_by)?>&sort=<?php echo urlencode($sort)?>&archive=<?php echo urlencode($archive)?>&k=<?php echo urlencode($k)?>">&lt; <?php echo $lang["back"] ?></a></p>

<h1><?php echo $lang["searchitemsdiskusage"] ?></h1>
<p><?php echo $lang["matchingresourceslabel"] . ": " . number_format($count)  ?>
<br />
<?php echo $lang["diskusage"] . ": <strong>" . formatfilesize($disk_usage) . "</strong>" ?></p>

<?php


include ("../include/footer.php");
Example #12
0
				<thead><tr>
				<th scope="col" width="150" style="border-width: 0px 0;color:#636363;font-size: 10pt; font-weight: bold; line-height:normal; text-align: left; border-bottom: 0.2em solid #09f;">Script:</th>
				<th scope="col" width="125" style="border-width: 0px 0;color:#636363;font-size: 10pt; font-weight: bold; line-height:normal; text-align: left; border-bottom: 0.2em solid #09f;">Date:</th>
				<th scope="col" width="100" style="border-width: 0px 0;color:#636363;font-size: 10pt; font-weight: bold; line-height:normal; text-align: left; border-bottom: 0.2em solid #09f;">Start:</th>
				<th scope="col" width="100" style="border-width: 0px 0;color:#636363;font-size: 10pt; font-weight: bold; line-height:normal; text-align: left; border-bottom: 0.2em solid #09f;">End:</th>
				<th scope="col" width="100" style="border-width: 0px 0;color:#636363;font-size: 10pt; font-weight: bold; line-height:normal; text-align: left; border-bottom: 0.2em solid #09f;">YQL Queries:</th>
				<th scope="col" width="100" style="border-width: 0px 0;color:#636363;font-size: 10pt; font-weight: bold; line-height:normal; text-align: left; border-bottom: 0.2em solid #09f;">No Records:</th>
				<th scope="col" width="450" style="border-width: 0px 0;color:#636363;font-size: 10pt; font-weight: bold; line-height:normal; text-align: left; border-bottom: 0.2em solid #09f;">Info:</th>
				</tr>
				</thead>
				<tbody>';
while ($row = mysql_fetch_array($query, MYSQL_ASSOC)) {
    $report .= '<tr>
						<td style="text-align: left; vertical-align: bottom; white-space: nowrap; font: 10pt Verdana, Helvetica; border-spacing: 0; border-collapse: separate; margin: 0 0 0 0; color:#636363;">' . $row['script'] . '</td>
						<td style="text-align: left; vertical-align: bottom; white-space: nowrap; font: 10pt Verdana, Helvetica; border-spacing: 0; border-collapse: separate; margin: 0 0 0 0; color:#636363;">' . $row['date'] . '</td>
						<td style="text-align: left; vertical-align: bottom; white-space: nowrap; font: 10pt Verdana, Helvetica; border-spacing: 0; border-collapse: separate; margin: 0 0 0 0; color:#636363;">' . $row['start'] . '</td>
						<td style="text-align: left; vertical-align: bottom; white-space: nowrap; font: 10pt Verdana, Helvetica; border-spacing: 0; border-collapse: separate; margin: 0 0 0 0; color:#636363;">' . $row['end'] . '</td>
						<td style="text-align: left; vertical-align: bottom; white-space: nowrap; font: 10pt Verdana, Helvetica; border-spacing: 0; border-collapse: separate; margin: 0 0 0 0; color:#636363;">' . $row['yqlqty'] . '</td>
						<td style="text-align: left; vertical-align: bottom; white-space: nowrap; font: 10pt Verdana, Helvetica; border-spacing: 0; border-collapse: separate; margin: 0 0 0 0; color:#636363;">' . $row['records'] . '</td>
						<td style="text-align: left; vertical-align: bottom; white-space: nowrap; font: 10pt Verdana, Helvetica; border-spacing: 0; border-collapse: separate; margin: 0 0 0 0; color:#636363;">' . $row['info'] . '</td>
						</tr>';
}
$report .= '</table><br><font style="text-align: left; vertical-align: bottom; white-space: nowrap; font: 10pt Verdana, Helvetica; border-spacing: 0; border-collapse: separate; margin: 0 0 0 0; color:#636363;">The size of the database is ' . formatfilesize($dbsize) . '</font></td></tr></table><br><br>' . $emailFooter . '</body></html>';
echo $report;
// Sent email with results:
if ($cronMailDailyReport > 0) {
    $subject = 'Daily Database Activity Report';
    $headers = 'From: ' . $fromEmail . '' . "\r\n" . 'Reply-To: no-reply@MyIchimoku.eu' . "\r\n" . 'MIME-Version: 1.0' . "\r\n" . 'Content-type: text/html; charset=iso-8859-1' . "\r\n" . 'X-Mailer: PHP/' . phpversion();
    mail($adminEmail, $subject, $report, $headers);
}
mysql_close($conn);
<?php

include "../../include/db.php";
include "../../include/general.php";
include "../../include/resource_functions.php";
$uniqid = getvalescaped("id", "");
$progress_file = get_temp_dir(false, $uniqid) . "/progress_file.txt";
if (!file_exists($progress_file)) {
    touch($progress_file);
}
$content = file_get_contents($progress_file);
if ($content == "") {
    echo $lang['preparingzip'];
} else {
    if ($content == "zipping") {
        $files = scandir(get_temp_dir(false, $uniqid));
        foreach ($files as $file) {
            if (strpos($file, "zip.zip") !== false) {
                echo "zipping " . formatfilesize(filesize(get_temp_dir(false, $uniqid) . "/" . $file));
            }
        }
    } else {
        ob_start();
        echo $content;
        ob_flush();
        exit;
    }
}
// echo whatever the script has placed here.
include "../../include/resource_functions.php";
$uniqid = getvalescaped("id", "");
$user = getvalescaped("user", "");
// Need to get this from query string since we haven't authenticated
$usertempdir = get_temp_dir(false, "rs_" . $user . "_" . $uniqid);
$progress_file = $usertempdir . "/progress_file.txt";
//$progress_file=get_temp_dir(false,$uniqid) . "/progress_file.txt";
if (!file_exists($progress_file)) {
    touch($progress_file);
}
$content = file_get_contents($progress_file);
if ($content == "") {
    echo $lang['preparingzip'];
} else {
    if ($content == "zipping") {
        $files = scandir($usertempdir);
        echo "zipping";
        foreach ($files as $file) {
            //echo $file;
            if (strpos($file, ".zip") !== false) {
                echo formatfilesize(filesize($usertempdir . "/" . $file));
            }
        }
    } else {
        ob_start();
        echo $content;
        ob_flush();
        exit;
    }
}
// echo whatever the script has placed here.
?>
</h1>
<h2><?php 
echo $titleh2;
?>
</h2>
<div id="plupload_instructions"><p><?php 
echo $intro;
?>
</p></div>
<?php 
if (isset($plupload_max_file_size)) {
    if (is_numeric($plupload_max_file_size)) {
        $sizeText = formatfilesize($plupload_max_file_size);
    } else {
        $sizeText = formatfilesize(filesize2bytes($plupload_max_file_size));
    }
    echo ' ' . sprintf($lang['plupload-maxfilesize'], $sizeText);
}
hook("additionaluploadtext");
if ($allowed_extensions != "") {
    $allowed_extensions = str_replace(", ", ",", $allowed_extensions);
    $list = explode(",", trim($allowed_extensions));
    sort($list);
    $allowed_extensions = implode(",", $list);
    ?>
<p><?php 
    echo str_replace_formatted_placeholder("%extensions", str_replace(",", ", ", $allowed_extensions), $lang['allowedextensions-extensions']);
    ?>
</p><?php 
}
Example #16
0
    //Bytes Transfered
    $cur_speed = $now_file_size - $byte_size;
    //Time Eta
    $download_bytes = $total_size - $now_file_size;
    if ($cur_speed > 0) {
        $time_eta = $download_bytes / $cur_speed;
    } else {
        $time_eta = 0;
    }
    //Time Took
    $time_took = time() - $started;
    $curl_info = array('total_size' => $total_size, 'downloaded' => $now_file_size, 'speed_download' => $cur_speed, 'time_eta' => $time_eta, 'time_took' => $time_took, 'file_name' => $file);
    $fo = fopen($log_file, 'w+');
    fwrite($fo, json_encode($curl_info));
    fclose($fo);
    $fo = fopen($dummy_file, 'w+');
    fwrite($fo, json_encode($data));
    fclose($fo);
    if ($total_size == $now_file_size) {
        unlink($dummy_file);
    }
}
if (file_exists($log_file)) {
    $details = file_get_contents($log_file);
    $details = json_decode($details, true);
    $details['total_size_fm'] = formatfilesize($details['total_size']);
    $details['downloaded_fm'] = formatfilesize($details['downloaded']);
    $details['time_eta_fm'] = SetTime($details['time_eta']);
    $details['time_took_fm'] = SetTime($details['time_took']);
    echo json_encode($details);
}
Example #17
0
function get_image_sizes($ref,$internal=false,$extension="jpg",$onlyifexists=true)
	{
	# Returns a table of available image sizes for resource $ref. The standard image sizes are translated using $lang. Custom image sizes are i18n translated.
	# The original image file assumes the name of the 'nearest size (up)' in the table

	global $imagemagick_calculate_sizes;

	# Work out resource type
	$resource_type=sql_value("select resource_type value from resource where ref='$ref'","");

	# add the original image
	$return=array();
	$lastname=sql_value("select name value from preview_size where width=(select max(width) from preview_size)",""); # Start with the highest resolution.
	$lastpreview=0;$lastrestricted=0;
	$path2=get_resource_path($ref,true,'',false,$extension);

	if (file_exists($path2) && !checkperm("T" . $resource_type . "_"))
	{ 
		$returnline=array();
		$returnline["name"]=lang_or_i18n_get_translated($lastname, "imagesize-");
		$returnline["allow_preview"]=$lastpreview;
		$returnline["allow_restricted"]=$lastrestricted;
		$returnline["path"]=$path2;
		$returnline["id"]="";
		$dimensions = sql_query("select width,height,file_size,resolution,unit from resource_dimensions where resource=". $ref);
		
		if (count($dimensions))
			{
			$sw = $dimensions[0]['width']; if ($sw==0) {$sw="?";}
			$sh = $dimensions[0]['height']; if ($sh==0) {$sh="?";}
			$filesize=$dimensions[0]['file_size'];
			# resolution and unit are not necessarily available, set to empty string if so.
			$resolution = ($dimensions[0]['resolution'])?$dimensions[0]['resolution']:"";
			$unit = ($dimensions[0]['unit'])?$dimensions[0]['unit']:"";
			}
		else
			{
			global $imagemagick_path;
			$file=$path2;
			$filesize=filesize_unlimited($file);
			
			# imagemagick_calculate_sizes is normally turned off 
			if (isset($imagemagick_path) && $imagemagick_calculate_sizes)
				{
				# Use ImageMagick to calculate the size
				
				$prefix = '';
				# Camera RAW images need prefix
				if (preg_match('/^(dng|nef|x3f|cr2|crw|mrw|orf|raf|dcr)$/i', $extension, $rawext)) { $prefix = $rawext[0] .':'; }

				# Locate imagemagick.
                $identify_fullpath = get_utility_path("im-identify");
                if ($identify_fullpath==false) {exit("Could not find ImageMagick 'identify' utility at location '$imagemagick_path'.");}	
				# Get image's dimensions.
                $identcommand = $identify_fullpath . ' -format %wx%h '. escapeshellarg($prefix . $file) .'[0]';
				$identoutput=run_command($identcommand);
				preg_match('/^([0-9]+)x([0-9]+)$/ims',$identoutput,$smatches);
				@list(,$sw,$sh) = $smatches;
				if (($sw!='') && ($sh!=''))
				  {
					sql_query("insert into resource_dimensions (resource, width, height, file_size) values('". $ref ."', '". $sw ."', '". $sh ."', '" . $filesize . "')");
					}
				}	
			else 
				{
				# check if this is a raw file.	
				$rawfile = false;
				if (preg_match('/^(dng|nef|x3f|cr2|crw|mrw|orf|raf|dcr)$/i', $extension, $rawext)){$rawfile=true;}
					
				# Use GD to calculate the size
				if (!((@list($sw,$sh) = @getimagesize($file))===false)&& !$rawfile)
				 	{		
					sql_query("insert into resource_dimensions (resource, width, height, file_size) values('". $ref ."', '". $sw ."', '". $sh ."', '" . $filesize . "')");
					}
				else
					{
					# Size cannot be calculated.
					$sw="?";$sh="?";
					
					# Insert a dummy row to prevent recalculation on every view.
					sql_query("insert into resource_dimensions (resource, width, height, file_size) values('". $ref ."','0', '0', '" . $filesize . "')");
					}
				}
			}
		if (!is_numeric($filesize)) {$returnline["filesize"]="?";$returnline["filedown"]="?";}
		else {$returnline["filedown"]=ceil($filesize/50000) . " seconds @ broadband";$returnline["filesize"]=formatfilesize($filesize);}
		$returnline["width"]=$sw;			
		$returnline["height"]=$sh;
		$returnline["extension"]=$extension;
		(isset($resolution))?$returnline["resolution"]=$resolution:$returnline["resolution"]="";
		(isset($unit))?$returnline["unit"]=$unit:$returnline["unit"]="";
		$return[]=$returnline;
	}
	# loop through all image sizes
	$sizes=sql_query("select * from preview_size order by width desc");
	for ($n=0;$n<count($sizes);$n++)
		{
		$path=get_resource_path($ref,true,$sizes[$n]["id"],false,"jpg");

		$resource_type=sql_value("select resource_type value from resource where ref='$ref'","");
		if ((file_exists($path) || (!$onlyifexists)) && !checkperm("T" . $resource_type . "_" . $sizes[$n]["id"]))
			{
			if (($sizes[$n]["internal"]==0) || ($internal))
				{
				$returnline=array();
				$returnline["name"]=lang_or_i18n_get_translated($sizes[$n]["name"], "imagesize-");
				$returnline["allow_preview"]=$sizes[$n]["allow_preview"];

				# The ability to restrict download size by user group and resource type.
				if (checkperm("X" . $resource_type . "_" . $sizes[$n]["id"]))
					{
					# Permission set. Always restrict this download if this resource is restricted.
					$returnline["allow_restricted"]=false;
					}
				else
					{
					# Take the restriction from the settings for this download size.
					$returnline["allow_restricted"]=$sizes[$n]["allow_restricted"];
					}
				$returnline["path"]=$path;
				$returnline["id"]=$sizes[$n]["id"];
				if ((list($sw,$sh) = @getimagesize($path))===false) {$sw=0;$sh=0;}
				if (($filesize=@filesize_unlimited($path))===false) {$returnline["filesize"]="?";$returnline["filedown"]="?";}
				else {$returnline["filedown"]=ceil($filesize/50000) . " seconds @ broadband";$filesize=formatfilesize($filesize);}
				$returnline["filesize"]=$filesize;			
				$returnline["width"]=$sw;			
				$returnline["height"]=$sh;
				$returnline["extension"]='jpg';
				$return[]=$returnline;
				}
			}
		$lastname=lang_or_i18n_get_translated($sizes[$n]["name"], "imagesize-");
		$lastpreview=$sizes[$n]["allow_preview"];
		$lastrestricted=$sizes[$n]["allow_restricted"];
		}
	return $return;
	}
Example #18
0
?>
</a></dd>
			<dt><?php 
echo __("Staff:", $module);
?>
</dt>
			<dd><?php 
echo $this->administration->no_active_users();
?>
</dd>
			<dt><?php 
echo __("Database size:", $module);
?>
</dt>
			<dd><?php 
echo formatfilesize($this->administration->db_size());
?>
</dd>
			<dt>C<?php 
echo __("Cache size:", $module);
?>
 <?php 
echo anchor('admin/clear_cache', __("Clear", $module));
?>
</dt>
			<dd><?php 
echo recursive_directory_size($this->config->item('cache_path'), TRUE);
?>
</dd>
		</dl>
	</div>
Example #19
0
}
$parse_main['{width_preview_elements}'] = '';
$parse_main['{height_preview_elements}'] = '';
if (isset($config['width_preview_elements']) and $config['width_preview_elements'] != '') {
    $parse_main['{width_preview_elements}'] = 'value="' . $config['width_preview_elements'] . '" ';
} elseif (isset($config['height_preview_elements']) and $config['height_preview_elements'] != '') {
    $parse_main['{height_preview_elements}'] = 'value="' . $config['height_preview_elements'] . '" ';
}
if (isset($error) and is_array($error)) {
    $parse_main['{error}'] = parse_template(get_template('info'), array("{type}" => 'error', "{title}" => "Ошибка!", "{text}" => implode("<br />", $error)));
} else {
    $parse_main['{error}'] = '';
}
$cachefile = $config['cachefile'];
if (!file_exists($cachefile) or time() - @filemtime($cachefile) > $config['cache_time']) {
    touch($cachefile);
    //чтобы только один пользователь запускал подсчет
    list($size, $images_total, $images_h24) = get_dir_size($config['uploaddir']);
    $size = formatfilesize($size);
    file_put_contents($cachefile, "{$images_total}|{$size}|{$images_h24}");
} elseif (file_exists($cachefile)) {
    list($images_total, $size, $images_h24) = explode("|", file_get_contents($cachefile));
}
$parse_main['{size}'] = $size;
$parse_main['{images}'] = $images_total;
$parse_main['{images24}'] = $images_h24;
$parse_main['{site_http_path}'] = $config['site_url'];
if (!$parse_main['{content}']) {
    $parse_main['{content}'] = '';
}
echo parse_template(get_template('index'), $parse_main);
include "../../include/db.php";
include "../../include/general.php";
include "../../include/resource_functions.php";

$uniqid=getvalescaped("id","");
$user=getvalescaped("user",""); // Need to get this from query string since we haven't authenticated
$usertempdir=get_temp_dir(false,"rs_" . $user . "_" . $uniqid);
$progress_file=$usertempdir . "/progress_file.txt";
//$progress_file=get_temp_dir(false,$uniqid) . "/progress_file.txt";

if (!file_exists($progress_file)){
	touch($progress_file);
}

$content= file_get_contents($progress_file);
if ($content==""){echo $lang['preparingzip'];}

else if ($content=="zipping"){
	$files=scandir($usertempdir);
		foreach ($files as $file){
			echo $file;
			if (strpos($file,"zip.zip")!==false){
				echo "zipping ".formatfilesize(filesize($usertempdir."/".$file));
			}
		}
	}

else {
	ob_start();echo $content;ob_flush();exit();} // echo whatever the script has placed here.
Example #21
0
<?php 
    if (get_cron_running()) {
        echo '<li><div id="BP_startupdate">' . T_('The update is running') . '</div></li>';
    } else {
        echo '<li><div id="BP_stopupdate">' . T_('The update is stopped') . '</div></li>';
    }
    if (file_exists(dirname(__FILE__) . '/../inc/STOP')) {
        echo '<li><div id="BP_disableupdate">' . T_('The update is disabled') . '</div></li>';
    }
    if ($blog_settings->get('planet_index_update')) {
        echo '<li><div id="BP_index_update">' . T_('The update on loading of index page enabled') . '</div></li>';
    }
    ?>
			<li><div id="BP_stats_db"><?php 
    echo T_('Current size of the database :');
    echo ' <strong>' . formatfilesize(get_database_size()) . '</strong>';
    ?>
</div></li>
			<li><div id="BP_nb_articles"><?php 
    echo T_('Number of articles in the DB :');
    echo ' <strong>' . $nb_posts . '</strong>';
    ?>
</div></li>
			<li><div id="BP_nb_votes"><?php 
    echo T_('Number of votes in the DB :');
    echo ' <strong>' . $nb_votes . '</strong>';
    ?>
</div></li>
			<li><div id="BP_nb_members"><?php 
    echo T_('Number of members in the DB :');
    echo ' <strong>' . $nb_users . '</strong>';
Example #22
0
            # Show the no-preview icon
            ?>
	<img src="<?php 
            echo $baseurl_short;
            ?>
gfx/<?php 
            echo get_nopreview_icon($resource["resource_type"], $resource["file_extension"], true);
            ?>
" />
	<br />
	<?php 
        }
        if ($resource["file_extension"] != "") {
            ?>
<strong><?php 
            echo str_replace_formatted_placeholder("%extension", $resource["file_extension"], $lang["cell-fileoftype"]) . " (" . formatfilesize(@filesize_unlimited(get_resource_path($ref, true, "", false, $resource["file_extension"]))) . ")";
            ?>
</strong><?php 
            if (checkperm("w") && $resource["has_image"] == 1 && file_exists($wmpath)) {
                ?>
 &nbsp;&nbsp;<a href="#" onclick="jQuery('#wmpreview').toggle();jQuery('#preview').toggle();if (jQuery(this).text()=='<?php 
                echo $lang['showwatermark'];
                ?>
'){jQuery(this).text('<?php 
                echo $lang['hidewatermark'];
                ?>
');} else {jQuery(this).text('<?php 
                echo $lang['showwatermark'];
                ?>
');}"><?php 
                echo $lang['showwatermark'];
Example #23
0
	<?php if (checkperm("a")) { ?>
	<?php if ($use_plugins_manager == true){ ?>
	<li><a href="<?php echo $baseurl?>/pages/team/team_plugins.php" onClick="return CentralSpaceLoad(this,true);"><?php echo $lang["pluginssetup"]?></a></li>
	<?php } ?>
	<li><a href="<?php echo $baseurl?>/pages/admin/index.php"><?php echo $lang["systemsetup"]?></a></li>
    <li><a href="<?php echo $baseurl?>/pages/team/team_reportbug.php" onClick="return CentralSpaceLoad(this,true);"><?php echo $lang["reportbug"]?></a></li>
	<?php hook("customteamfunctionadmin")?>
	<?php } ?>
	
	</ul>
	</div>
	
<?php if (checkperm("u") && !checkperm("U")) { # Full admin access only to user/disk quota status
?>
<p><?php echo $lang["usersonline"]?>:
<?php
$active=get_active_users();
for ($n=0;$n<count($active);$n++) {if($n>0) {echo", ";}echo "<b>" . $active[$n]["username"] . "</b> (" . $active[$n]["t"] . ")";}
?>
</p>	

<p><?php echo $lang["diskusage"]?>: <b><?php echo round(($avail?$used/$avail:0)*100,0)?>%</b> (<?php echo $lang["available"]?>: <?php echo formatfilesize($avail)?>; <?php echo $lang["used"]?>: <?php echo formatfilesize($used)?>; <?php echo $lang["free"]?>:  <?php echo formatfilesize($free)?>)
</p>
<?php } ?>

</div>

<?php
include "../../include/footer.php";
?>
 if (isset($disksize)) {
     # Use disk quota rather than real disk size
     $avail = $disksize * (1024 * 1024 * 1024);
     $used = get_total_disk_usage();
     $free = $avail - $used;
 } else {
     $avail = disk_total_space($storagedir);
     $free = disk_free_space($storagedir);
     $used = $avail - $free;
 }
 if ($free < 0) {
     $free = 0;
 }
 $avail_format = str_replace("&nbsp;", " ", formatfilesize($avail));
 $used_format = str_replace("&nbsp;", " ", formatfilesize($used));
 $free_format = str_replace("&nbsp;", " ", formatfilesize($free));
 $used_percent = round(($avail ? $used / $avail : 0) * 100, 0);
 echo $lang["diskusage"] . ": " . $used_percent . "%\n" . $lang["available"] . ": " . $avail_format . "\n" . $lang["used"] . ": " . $used_format . "\n" . $lang["free"] . ": " . $free_format . "<br/><br/>";
 if (isset($disk_quota_notification_limit_percent_warning)) {
     $send_email = false;
     if ($used_percent >= $disk_quota_notification_limit_percent_warning) {
         // Check the last time this notice was sent
         echo "Percentage used is greater than or equal to " . $disk_quota_notification_limit_percent_warning . "%.";
         if (!isset($disk_quota_notification_interval)) {
             $send_email = true;
         } else {
             $last_sent = sql_value("select value from sysvars where name='last_sent_disk_quota'", "");
             echo "Last Sent:" . strtotime($last_sent) . " - " . $last_sent . "<br/>";
             echo "Now:" . time() . " - " . date("Y-m-d H:i:s") . "<br/>";
             echo "Interval:" . $disk_quota_notification_interval * 60 * 60 . "<br/>";
             if ($last_sent == '' || time() - strtotime($last_sent) > $disk_quota_notification_interval * 60 * 60) {
Example #25
0
			if (file_exists($alt_pre_file))
				{
				# Get web path for preview (pass creation date to help cache refresh)
				$alt_pre=get_resource_path($ref,false,"pre",false,"jpg",-1,1,false,$altfiles[$n]["creation_date"],$altfiles[$n]["ref"]);
				}
			}
		?>
		<tr class="DownloadDBlend" <?php if ($alt_pre!="" && $alternative_file_previews_mouseover) { ?>onMouseOver="orig_preview=jQuery('#previewimage').attr('src');orig_width=jQuery('#previewimage').width();jQuery('#previewimage').attr('src','<?php echo $alt_pre ?>');jQuery('#previewimage').width(orig_width);" onMouseOut="jQuery('#previewimage').attr('src',orig_preview);"<?php } ?>>
		<td class="DownloadFileName">
		<?php if(!hook("renderaltthumb")): ?>
		<?php if ($alt_thm!="") { ?><a href="<?php echo $baseurl_short?>pages/preview.php?ref=<?php echo urlencode($ref)?>&alternative=<?php echo $altfiles[$n]["ref"]?>&k=<?php echo urlencode($k)?>&search=<?php echo urlencode($search)?>&offset=<?php echo urlencode($offset)?>&order_by=<?php echo urlencode($order_by)?>&sort=<?php echo urlencode($sort)?>&archive=<?php echo urlencode($archive)?>&<?php echo hook("previewextraurl") ?>"><img src="<?php echo $alt_thm?>" class="AltThumb"></a><?php } ?>
		<?php endif; ?>
		<h2 class="breakall"><?php echo htmlspecialchars($altfiles[$n]["name"])?></h2>
		<p><?php echo htmlspecialchars($altfiles[$n]["description"])?></p>
		</td>
		<td class="DownloadFileSize"><?php echo formatfilesize($altfiles[$n]["file_size"])?></td>
		
		<?php if ($userrequestmode==2 || $userrequestmode==3) { ?><td></td><?php } # Blank spacer column if displaying a price above (basket mode).
		?>
		
		<?php if ($access==0){?>
		<td class="DownloadButton">
		<?php 		
		if (!$direct_download || $save_as)
			{
			if(!hook("downloadbuttonreplace"))
				{
				?><a <?php if (!hook("downloadlink","",array("ref=" . $ref . "&alternative=" . $altfiles[$n]["ref"] . "&k=" . $k . "&ext=" . $altfiles[$n]["file_extension"]))) { ?>href="<?php echo $baseurl_short?>pages/terms.php?ref=<?php echo urlencode($ref)?>&k=<?php echo urlencode($k)?>&search=<?php echo urlencode($search) ?>&url=<?php echo urlencode("pages/download_progress.php?ref=" . $ref . "&ext=" . $altfiles[$n]["file_extension"] . "&k=" . $k . "&alternative=" . $altfiles[$n]["ref"] . "&search=" . urlencode($search) . "&offset=" . $offset . "&archive=" . $archive . "&sort=".$sort."&order_by=" . urlencode($order_by))?>"<?php } ?> onClick="return CentralSpaceLoad(this,true);"><?php echo $lang["action-download"] ?></a><?php 
				}
			}
		else { ?>
Example #26
0
function HookFormat_chooserViewReplacedownloadoptions()
{
    global $resource, $ref, $counter, $headline, $lang, $download_multisize, $showprice, $save_as, $direct_link_previews, $hide_restricted_download_sizes, $format_chooser_output_formats, $baseurl_short, $search, $offset, $k, $order_by, $sort, $archive, $direct_download;
    $inputFormat = $resource['file_extension'];
    if ($resource["has_image"] != 1 || !$download_multisize || $save_as || !supportsInputFormat($inputFormat)) {
        return false;
    }
    $defaultFormat = getDefaultOutputFormat($inputFormat);
    $tableHeadersDrawn = false;
    ?>
<table cellpadding="0" cellspacing="0"><?php 
    hook("formatchooserbeforedownloads");
    $sizes = get_image_sizes($ref, false, $resource['file_extension'], false);
    $downloadCount = 0;
    $originalSize = -1;
    # Show original file download
    for ($n = 0; $n < count($sizes); $n++) {
        $downloadthissize = resource_download_allowed($ref, $sizes[$n]["id"], $resource["resource_type"]);
        $counter++;
        if ($sizes[$n]['id'] != '') {
            if ($downloadthissize) {
                $downloadCount++;
            }
            continue;
        }
        # Is this the original file? Set that the user can download the original file
        # so the request box does not appear.
        $fulldownload = false;
        if ($sizes[$n]["id"] == "") {
            $fulldownload = true;
        }
        $originalSize = $sizes[$n];
        $headline = $lang['collection_download_original'];
        if ($direct_link_previews && $downloadthissize) {
            $headline = make_download_preview_link($ref, $sizes[$n]);
        }
        if ($hide_restricted_download_sizes && !$downloadthissize && !checkperm("q")) {
            continue;
        }
        if (!$tableHeadersDrawn) {
            show_table_headers($showprice);
            $tableHeadersDrawn = true;
        }
        ?>
<tr class="DownloadDBlend" id="DownloadBox<?php 
        echo $n;
        ?>
">
		<td class="DownloadFileName"><h2><?php 
        echo $headline;
        ?>
</h2><p><?php 
        echo $sizes[$n]["filesize"];
        if (is_numeric($sizes[$n]["width"])) {
            echo preg_replace('/^<p>/', ', ', get_size_info($sizes[$n]), 1);
        }
        ?>
</p><td class="DownloadFileFormat"><?php 
        echo str_replace_formatted_placeholder("%extension", $resource["file_extension"], $lang["field-fileextension"]);
        ?>
</td><?php 
        if ($showprice) {
            ?>
<td><?php 
            echo get_display_price($ref, $sizes[$n]);
            ?>
</td><?php 
        }
        add_download_column($ref, $sizes[$n], $downloadthissize);
    }
    # Add drop down for all other sizes
    $closestSize = 0;
    if ($downloadCount > 0) {
        if (!$tableHeadersDrawn) {
            show_table_headers($showprice);
        }
        ?>
<tr class="DownloadDBlend">
		<td class="DownloadFileSizePicker"><select id="size"><?php 
        $sizes = get_all_image_sizes();
        # Filter out all sizes that are larger than our image size, but not the closest one
        for ($n = 0; $n < count($sizes); $n++) {
            if (intval($sizes[$n]['width']) >= intval($originalSize['width']) && intval($sizes[$n]['height']) >= intval($originalSize['height']) && ($closestSize == 0 || $closestSize > (int) $sizes[$n]['width'])) {
                $closestSize = (int) $sizes[$n]['width'];
            }
        }
        for ($n = 0; $n < count($sizes); $n++) {
            if (intval($sizes[$n]['width']) != $closestSize && intval($sizes[$n]['width']) > intval($originalSize['width']) && intval($sizes[$n]['height']) > intval($originalSize['height'])) {
                unset($sizes[$n]);
            }
        }
        foreach ($sizes as $n => $size) {
            # Only add choice if allowed
            $downloadthissize = resource_download_allowed($ref, $size["id"], $resource["resource_type"]);
            if (!$downloadthissize) {
                continue;
            }
            $name = $size['name'];
            if ($size['width'] == $closestSize) {
                $name = $lang['format_chooser_original_size'];
            }
            ?>
<option value="<?php 
            echo $n;
            ?>
"><?php 
            echo $name;
            ?>
</option><?php 
        }
        ?>
</select><p id="sizeInfo"></p></td><?php 
        if ($showprice) {
            ?>
<td>-</td><?php 
        }
        ?>
<td class="DownloadFileFormatPicker" style="vertical-align: top;"><select id="format"><?php 
        foreach ($format_chooser_output_formats as $format) {
            ?>
<option value="<?php 
            echo $format;
            ?>
" <?php 
            if ($format == $defaultFormat) {
                ?>
selected="selected"<?php 
            }
            ?>
><?php 
            echo str_replace_formatted_placeholder("%extension", $format, $lang["field-fileextension"]);
            ?>
</option><?php 
        }
        ?>
</select><?php 
        showProfileChooser();
        ?>
</td>
		<td class="DownloadButton"><a id="convertDownload" onClick="return CentralSpaceLoad(this,true);"><?php 
        echo $lang['action-download'];
        ?>
</a></td>
		</tr><?php 
    }
    ?>
</table><?php 
    hook("formatchooseraftertable");
    if ($downloadCount > 0) {
        ?>
<script type="text/javascript">
			// Store size info in JavaScript array
			var sizeInfo = {
				<?php 
        foreach ($sizes as $n => $size) {
            if ($size['width'] == $closestSize) {
                $size = $originalSize;
            }
            ?>
				<?php 
            echo $n;
            ?>
: {
					'info': '<?php 
            echo get_size_info($size, $originalSize);
            ?>
',
					'id': '<?php 
            echo $size['id'];
            ?>
',
				},
				<?php 
        }
        ?>
			};
			function updateSizeInfo() {
				var selected = jQuery('select#size').find(":selected").val();
				jQuery('#sizeInfo').html(sizeInfo[selected]['info']);
			}
			function updateDownloadLink() {
				var index = jQuery('select#size').find(":selected").val();
				var selectedFormat = jQuery('select#format').find(":selected").val();
				var profile = jQuery('select#profile').find(":selected").val();
				if (profile)
					profile = "&profile=" + profile;
				else
					profile = '';

				basePage = 'pages/download_progress.php?ref=<?php 
        echo $ref;
        ?>
&ext='
						+ selectedFormat.toLowerCase() + profile + '&size=' + sizeInfo[index]['id']
						+ '&search=<?php 
        echo urlencode($search);
        ?>
&offset=<?php 
        echo $offset;
        ?>
'
						+ '&k=<?php 
        echo $k;
        ?>
&archive=<?php 
        echo $archive;
        ?>
&sort='
						+ '<?php 
        echo $sort;
        ?>
&order_by=<?php 
        echo $order_by;
        ?>
';

				jQuery('a#convertDownload').attr('href', '<?php 
        echo $baseurl_short;
        if (!$direct_download) {
            echo 'pages/terms.php?ref=' . $ref . '&search=' . $search . '&k=' . $k . '&url=';
        }
        ?>
' + <?php 
        echo $direct_download ? 'basePage' : 'encodeURIComponent(basePage)';
        ?>
						);
			}
			jQuery(document).ready(function() {
				updateSizeInfo();
				updateDownloadLink();
			});
			jQuery('select#size').change(function() {
				updateSizeInfo();
				updateDownloadLink();
			});
			jQuery('select#format').change(function() {
				updateDownloadLink();
			});
			jQuery('select#profile').change(function() {
				updateDownloadLink();
			});
		</script>
		<?php 
    }
    global $access, $alt_types_organize, $alternative_file_previews, $userrequestmode;
    # Alternative files listing
    $alt_access = hook("altfilesaccess");
    if ($access == 0) {
        $alt_access = true;
    }
    # open access (not restricted)
    if ($alt_access) {
        $alt_order_by = "";
        $alt_sort = "";
        if ($alt_types_organize) {
            $alt_order_by = "alt_type";
            $alt_sort = "asc";
        }
        $altfiles = get_alternative_files($ref, $alt_order_by, $alt_sort);
        hook("processaltfiles");
        $last_alt_type = "-";
        ?>
	<table>
	<?php 
        for ($n = 0; $n < count($altfiles); $n++) {
            $alt_type = $altfiles[$n]['alt_type'];
            if ($alt_types_organize) {
                if ($alt_type != $last_alt_type) {
                    $alt_type_header = $alt_type;
                    if ($alt_type_header == "") {
                        $alt_type_header = $lang["alternativefiles"];
                    }
                    hook("viewbeforealtheader");
                    ?>
				<tr class="DownloadDBlend">
				<td colspan="3" id="altfileheader"><h2><?php 
                    echo $alt_type_header;
                    ?>
</h2></td>
				</tr>
				<?php 
                }
                $last_alt_type = $alt_type;
            } else {
                if ($n == 0) {
                    hook("viewbeforealtheader");
                    ?>
			<tr>
			<td colspan="3" id="altfileheader"><?php 
                    echo $lang["alternativefiles"];
                    ?>
</td>
			</tr>
			<?php 
                }
            }
            $alt_thm = "";
            $alt_pre = "";
            if ($alternative_file_previews) {
                $alt_thm_file = get_resource_path($ref, true, "col", false, "jpg", -1, 1, false, "", $altfiles[$n]["ref"]);
                if (file_exists($alt_thm_file)) {
                    # Get web path for thumb (pass creation date to help cache refresh)
                    $alt_thm = get_resource_path($ref, false, "col", false, "jpg", -1, 1, false, $altfiles[$n]["creation_date"], $altfiles[$n]["ref"]);
                }
                $alt_pre_file = get_resource_path($ref, true, "pre", false, "jpg", -1, 1, false, "", $altfiles[$n]["ref"]);
                if (file_exists($alt_pre_file)) {
                    # Get web path for preview (pass creation date to help cache refresh)
                    $alt_pre = get_resource_path($ref, false, "pre", false, "jpg", -1, 1, false, $altfiles[$n]["creation_date"], $altfiles[$n]["ref"]);
                }
            }
            ?>
		<tr class="DownloadDBlend" <?php 
            if ($alt_pre != "" && isset($alternative_file_previews_mouseover) && $alternative_file_previews_mouseover) {
                ?>
onMouseOver="orig_preview=jQuery('#previewimage').attr('src');orig_width=jQuery('#previewimage').width();jQuery('#previewimage').attr('src','<?php 
                echo $alt_pre;
                ?>
');jQuery('#previewimage').width(orig_width);" onMouseOut="jQuery('#previewimage').attr('src',orig_preview);"<?php 
            }
            ?>
>
		<td class="DownloadFileName">
		<?php 
            if (!hook("renderaltthumb")) {
                ?>
		<?php 
                if ($alt_thm != "") {
                    ?>
<a href="<?php 
                    echo $baseurl_short;
                    ?>
pages/preview.php?ref=<?php 
                    echo urlencode($ref);
                    ?>
&alternative=<?php 
                    echo $altfiles[$n]["ref"];
                    ?>
&k=<?php 
                    echo urlencode($k);
                    ?>
&search=<?php 
                    echo urlencode($search);
                    ?>
&offset=<?php 
                    echo urlencode($offset);
                    ?>
&order_by=<?php 
                    echo urlencode($order_by);
                    ?>
&sort=<?php 
                    echo urlencode($sort);
                    ?>
&archive=<?php 
                    echo urlencode($archive);
                    ?>
&<?php 
                    echo hook("previewextraurl");
                    ?>
"><img src="<?php 
                    echo $alt_thm;
                    ?>
" class="AltThumb"></a><?php 
                }
                ?>
		<?php 
            }
            ?>
		<h2 class="breakall"><?php 
            echo htmlspecialchars($altfiles[$n]["name"]);
            ?>
</h2>
		<p><?php 
            echo htmlspecialchars($altfiles[$n]["description"]);
            ?>
</p>
		</td>
		<td class="DownloadFileSize"><?php 
            echo formatfilesize($altfiles[$n]["file_size"]);
            ?>
</td>
		
		<?php 
            if ($userrequestmode == 2 || $userrequestmode == 3) {
                ?>
<td></td><?php 
            }
            # Blank spacer column if displaying a price above (basket mode).
            ?>
		
		<?php 
            if ($access == 0) {
                ?>
		<td class="DownloadButton">
		<?php 
                if (!$direct_download || $save_as) {
                    if (!hook("downloadbuttonreplace")) {
                        ?>
<a <?php 
                        if (!hook("downloadlink", "", array("ref=" . $ref . "&alternative=" . $altfiles[$n]["ref"] . "&k=" . $k . "&ext=" . $altfiles[$n]["file_extension"]))) {
                            ?>
href="<?php 
                            echo $baseurl_short;
                            ?>
pages/terms.php?ref=<?php 
                            echo urlencode($ref);
                            ?>
&k=<?php 
                            echo urlencode($k);
                            ?>
&search=<?php 
                            echo urlencode($search);
                            ?>
&url=<?php 
                            echo urlencode("pages/download_progress.php?ref=" . $ref . "&ext=" . $altfiles[$n]["file_extension"] . "&k=" . $k . "&alternative=" . $altfiles[$n]["ref"] . "&search=" . urlencode($search) . "&offset=" . $offset . "&archive=" . $archive . "&sort=" . $sort . "&order_by=" . urlencode($order_by));
                            ?>
"<?php 
                        }
                        ?>
 onClick="return CentralSpaceLoad(this,true);"><?php 
                        echo $lang["action-download"];
                        ?>
</a><?php 
                    }
                } else {
                    ?>
			<a href="#" onclick="directDownload('<?php 
                    echo $baseurl_short;
                    ?>
pages/download_progress.php?ref=<?php 
                    echo urlencode($ref);
                    ?>
&ext=<?php 
                    echo $altfiles[$n]["file_extension"];
                    ?>
&k=<?php 
                    echo urlencode($k);
                    ?>
&alternative=<?php 
                    echo $altfiles[$n]["ref"];
                    ?>
')"><?php 
                    echo $lang["action-download"];
                    ?>
</a>
		<?php 
                }
                // end if direct_download
                ?>
</td></td>
		<?php 
            } else {
                ?>
		<td class="DownloadButton DownloadDisabled"><?php 
                echo $lang["access1"];
                ?>
</td>
		<?php 
            }
            ?>
		</tr>
		<?php 
        }
        hook("morealtdownload");
        ?>
   	</table>
   	<?php 
    }
    # --- end of alternative files listing
    return true;
}
Example #27
0
if (isset($images_array)) {
    $urls_quantity = count($images_array);
} else {
    $urls_quantity = 0;
}
if ($urls_quantity >= 1) {
    $view_one_template = get_template('view_one');
    foreach ($images_array as $img_filename => $img) {
        if ($img['error']) {
            $parse_main['{content}'] .= parse_template(get_template('info'), array("{type}" => 'error', "{title}" => "Ошибка!", "{text}" => "Изображение не загружено. " . $img['error']));
        } else {
            $info = getimagesize($img['local_path']);
            $stat = stat($img['local_path']);
            $width = $info['0'];
            $height = $info['1'];
            $size = formatfilesize($stat['size']);
            if (isset($config['show_upload_date']) and $config['show_upload_date']) {
                $size .= " , " . date("d.m.Y H:i", filemtime($img['local_path']));
            }
            if ($width < $config['view_one_width']) {
                $viewpage_img_width = '';
            } else {
                $viewpage_img_width = $config['view_one_width'];
            }
            if ($urls_quantity == 1) {
                $parse_one_img['{img}'] = '<a href="' . $img['url_img'] . '"><img src=' . $img['url_img'] . ' rw="' . $width . '" rh="' . $height . '" width="' . $viewpage_img_width . '"></a>';
            } else {
                $parse_one_img['{img}'] = '<a href="' . $img['url_img'] . '"><img src=' . $img['url_img'] . ' rw="' . $width . '" rh="' . $height . '" width="' . $config['view_multi_width'] . '"></a>';
            }
            $parse_one_img['{view_img}'] = $img['view_img_page'];
            //ссылка на страницу просмотра
Example #28
0
function get_image_sizes($ref, $internal = false, $extension = "jpg", $onlyifexists = true)
{
    # Returns a table of available image sizes for resource $ref. The standard image sizes are translated using $lang. Custom image sizes are i18n translated.
    # The original image file assumes the name of the 'nearest size (up)' in the table
    global $imagemagick_calculate_sizes;
    # Work out resource type
    $resource_type = sql_value("select resource_type value from resource where ref='{$ref}'", "");
    # add the original image
    $return = array();
    $lastname = sql_value("select name value from preview_size where width=(select max(width) from preview_size)", "");
    # Start with the highest resolution.
    $lastpreview = 0;
    $lastrestricted = 0;
    $path2 = get_resource_path($ref, true, '', false, $extension);
    if (file_exists($path2) && !checkperm("T" . $resource_type . "_")) {
        $returnline = array();
        $returnline["name"] = lang_or_i18n_get_translated($lastname, "imagesize-");
        $returnline["allow_preview"] = $lastpreview;
        $returnline["allow_restricted"] = $lastrestricted;
        $returnline["path"] = $path2;
        $returnline["id"] = "";
        $dimensions = sql_query("select width,height,file_size,resolution,unit from resource_dimensions where resource=" . $ref);
        if (count($dimensions)) {
            $sw = $dimensions[0]['width'];
            if ($sw == 0) {
                $sw = "?";
            }
            $sh = $dimensions[0]['height'];
            if ($sh == 0) {
                $sh = "?";
            }
            $filesize = $dimensions[0]['file_size'];
            # resolution and unit are not necessarily available, set to empty string if so.
            $resolution = $dimensions[0]['resolution'] ? $dimensions[0]['resolution'] : "";
            $unit = $dimensions[0]['unit'] ? $dimensions[0]['unit'] : "";
        } else {
            $fileinfo = get_original_imagesize($ref, $path2, $extension);
            $filesize = $fileinfo[0];
            $sw = $fileinfo[1];
            $sh = $fileinfo[2];
        }
        if (!is_numeric($filesize)) {
            $returnline["filesize"] = "?";
            $returnline["filedown"] = "?";
        } else {
            $returnline["filedown"] = ceil($filesize / 50000) . " seconds @ broadband";
            $returnline["filesize"] = formatfilesize($filesize);
        }
        $returnline["width"] = $sw;
        $returnline["height"] = $sh;
        $returnline["extension"] = $extension;
        isset($resolution) ? $returnline["resolution"] = $resolution : ($returnline["resolution"] = "");
        isset($unit) ? $returnline["unit"] = $unit : ($returnline["unit"] = "");
        $return[] = $returnline;
    }
    # loop through all image sizes
    $sizes = sql_query("select * from preview_size order by width desc");
    for ($n = 0; $n < count($sizes); $n++) {
        $path = get_resource_path($ref, true, $sizes[$n]["id"], false, "jpg");
        $file_exists = file_exists($path);
        if (($file_exists || !$onlyifexists) && !checkperm("T" . $resource_type . "_" . $sizes[$n]["id"])) {
            if ($sizes[$n]["internal"] == 0 || $internal) {
                $returnline = array();
                $returnline["name"] = lang_or_i18n_get_translated($sizes[$n]["name"], "imagesize-");
                $returnline["allow_preview"] = $sizes[$n]["allow_preview"];
                # The ability to restrict download size by user group and resource type.
                if (checkperm("X" . $resource_type . "_" . $sizes[$n]["id"])) {
                    # Permission set. Always restrict this download if this resource is restricted.
                    $returnline["allow_restricted"] = false;
                } else {
                    # Take the restriction from the settings for this download size.
                    $returnline["allow_restricted"] = $sizes[$n]["allow_restricted"];
                }
                $returnline["path"] = $path;
                $returnline["id"] = $sizes[$n]["id"];
                if ((list($sw, $sh) = @getimagesize($path)) === false) {
                    $sw = 0;
                    $sh = 0;
                }
                if ($file_exists) {
                    $filesize = @filesize_unlimited($path);
                } else {
                    $filesize = 0;
                }
                if ($filesize === false) {
                    $returnline["filesize"] = "?";
                    $returnline["filedown"] = "?";
                } else {
                    $returnline["filedown"] = ceil($filesize / 50000) . " seconds @ broadband";
                    $filesize = formatfilesize($filesize);
                }
                $returnline["filesize"] = $filesize;
                $returnline["width"] = $sw;
                $returnline["height"] = $sh;
                $returnline["extension"] = 'jpg';
                $return[] = $returnline;
            }
        }
        $lastname = lang_or_i18n_get_translated($sizes[$n]["name"], "imagesize-");
        $lastpreview = $sizes[$n]["allow_preview"];
        $lastrestricted = $sizes[$n]["allow_restricted"];
    }
    return $return;
}
Example #29
0
                 $tcd = $lFiles[$k]->name;
             } else {
                 $tcd = $cd . "/" . $lFiles[$k]->name;
             }
             $template_dir .= "<a href='" . genUrl($ref, $args, "cd", $tcd) . "'><b><i>" . $lFiles[$k]->name . "</i></b></a>";
             $template_dir .= "</TD>\n";
             $template_dir .= "<TD ID='td04'>---</TD>\n";
         } else {
             //$template_dir.= $lFiles[ $k ]->name;
             if (file_exists($config['thumbdir'] . "/" . $cd . "/" . $lFiles[$k]->name)) {
                 $template_dir .= "<a href='" . $config['thumbs_url'] . $cd . "/" . $lFiles[$k]->name . "' class='preview'>" . $lFiles[$k]->name . "</a>";
             } else {
                 $template_dir .= "<a href='" . $config['img_url'] . $cd . "/" . $lFiles[$k]->name . "' class='preview'>" . $lFiles[$k]->name . "</a>";
             }
             $template_dir .= "</TD>\n";
             $template_dir .= "<TD ID='td04'>" . formatfilesize($lFiles[$k]->formatSize()) . "</TD>\n";
         }
         //	$template_dir.= "<TD ID='td05'>".$lFiles[ $k ]->ext  ."</TD>\n";
         $template_dir .= "<TD ID='td06'>" . date($dform, $lFiles[$k]->mtime) . "</TD>\n";
         $template_dir .= "<TD ID='td07'>" . date($dform, $lFiles[$k]->atime) . "</TD>\n";
         //$template_dir.= "<TD ID='td08'>".date( $dform, $lFiles[ $k ]->ctime )."</TD>\n";
         $template_dir .= "<TD ID='td09'>" . formperms($lFiles[$k]->perms, $lFiles[$k]->owner) . "</TD>\n";
         //	$template_dir.= "<TD ID='td10'>".$lFiles[ $k ]->group."</TD>\n";
         //	$template_dir.= "<TD ID='td11'>".$lFiles[ $k ]->owner."</TD>\n";
         //	$template_dir.= "<TD ID='td12'>".$lFiles[ $k ]->inode."</TD>\n";
         $template_dir .= "</TR>\n";
     }
 }
 $template_dir .= "</TABLE>\n";
 $from = $from - $step;
 if (isset($cd)) {