/**
 * Prints the jQuery JS setup for the upload limiting
 *
 * @return string
 */
function uploadLimiterJS($defaultJS)
{
    $js = '';
    if (!zp_loggedin(MANAGE_ALL_ALBUM_RIGHTS)) {
        $target = 'function uploadify_onSelectOnce(event, data) {';
        $i = strpos($defaultJS, $target);
        if ($i !== false) {
            $j = strpos($defaultJS, '}', $i + strlen($target));
            $body = trim(substr($defaultJS, $i + strlen($target), $j));
            if (!empty($dody)) {
                echo gettext("There is a plugin conflict with <em>image_upload_limiter</em>");
            }
            $js = substr($defaultJS, 0, $i) . substr($defaultJS, $j + 1);
        }
        $albumlist = array();
        genAlbumUploadList($albumlist);
        $rootrights = accessAllAlbums(UPLOAD_RIGHTS);
        $uploadtype = zp_getcookie('uploadtype');
        $limitalbums = getUploadLimitedAlbums($albumlist);
        $imagenumber = getUploadImagesInAlbum($albumlist);
        if ($uploadtype == "httpupload") {
            $js .= "\$(document).ready(function() {\n\t\t\t\t\t\t\t\t\t\t\$('#albumselect').hide();\n\t\t\t\t\t\t\t});";
        } else {
            $js .= "\$(document).ready(function() {\n\t\t\t\t\t\t\t\t\t\t\$('#uploadswitch').hide();\n\t\t\t\t\t\t\t});";
        }
        if (getOption('imageuploadlimit_newalbum')) {
            $js .= "\n\t\t\t\tjQuery(document).ready(function() {\n\t\t\t\t\t\$('#newalbumbox,#albumtext').hide();\n\t\t\t\t});";
        }
        $js .= "\n\tfunction generateUploadlimit(selectedalbum,limitalbums) {\n\t\t\$('#uploadlimitmessage').remove();\n\t\tvar imagenumber = new Array(" . $imagenumber . ");\n\t\tvar message = '';\n\t\tvar uploadlimit = " . getOption('imageuploadlimit') . ";\n\t\tvar imagesleft = '';\n\t\t\$.each(limitalbums, function(key,value) {\n\t\t\tif(value == selectedalbum) {\n\t\t\t\tif(imagenumber[key] >= uploadlimit) {\n\t\t\t\t\timagesleft = 0;\n\t\t\t\t} else if (imagenumber[key] < uploadlimit) {\n\t\t\t\t\timagesleft = uploadlimit - imagenumber[key];\n\t\t\t\t}\n\t\t\t\tif(imagesleft === 0) {\n\t\t\t   \t\$('#fileUploadbuttons').hide();\n\t\t\t   \tqueuelimit = 0;\n\t\t\t   \tmessage = '" . gettext('The album exceeded the image number limit. You cannot upload more images!') . "';\n\t\t\t\t\t//alert(message);\n\t\t\t\t\t\$('#albumselect').prepend('<span id=\"uploadlimitmessage\" style=\"color:red;\">'+message+'<br /><br /></span>');\n\t\t\t\t} else {\n\t\t\t\t\tqueuelimit = imagesleft;\n\t\t\t\t\tmessage = '" . gettext("Maximum number of images left for this album: ") . "'+imagesleft;\n\t\t\t\t\t//alert(message);\n\t\t\t\t \$('#albumselect').prepend('<span id=\"uploadlimitmessage\" style=\"color:green\">'+message+'<br /><br /></span>');\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t\treturn queuelimit;\n\t}";
        /*
        if($uploadtype == "httpupload") {
        	$js .= "$('#albumselect').hide();";
        }
        */
        $js .= "var limitalbums = new Array(" . $limitalbums . ");";
        if (isset($_GET['album']) && !empty($_GET['album'])) {
            // if we upload
            $selectedalbum = sanitize($_GET['album']);
            $js .= "var selectedalbum = '" . $selectedalbum . "';";
        } else {
            if ($rootrights) {
                $js .= "var selectedalbum = '';";
                // choose the first entry of the select list if nothing is selected and the user has root rights (so root no message...)
            } else {
                $js .= "var selectedalbum = limitalbums[0];";
                // choose the first entry of the select list if nothing is selected and no rootrights
            }
        }
        $js .= "\n\tvar queuelimit = generateUploadlimit(selectedalbum,limitalbums);\n\tvar value = '';\n\tvar newalbum = '';\n\n\t\$(document).ready(function() {\n\t\t// normal album selection\n\t\t\$('#albumselectmenu').change(function() {\n\t\t\t\$('#fileUpload').uploadifyClearQueue(); // to be sure that no selections for other albums are kept\n\t\t\tselectedalbum = \$('#albumselectmenu').val();\n\t\t\tqueuelimit = generateUploadlimit(selectedalbum,limitalbums);\n\t\t});\n\t\t// new toplevel album\n\t\t\$('#albumtitle').keyup(function () {\n\t\t\t\tvalue = \$('#albumtitle').val();\n\t\t\t\tif(value != '') {\n\t\t\t\t\tqueuelimit = " . getOption('imageuploadlimit') . ";\n\t\t\t\t}\n\t\t});\n\t\t// new subalbum\n\t\t\$('#newalbumcheckbox').change(function() {\n\t\t\t\$('#albumtitle').keyup(function () {\n\t\t\t\tvalue = \$('#albumtitle').val();\n\t\t\t\tqueuelimit = " . getOption('imageuploadlimit') . ";\n\t\t\t});\n\t\t});\n\t\t\$('#fileUpload').uploadifySettings('queueSizeLimit'," . getOption('imageuploadlimit') . ");\n\t});\n\t";
    }
    return $js;
}
Example #2
0
}
if (SAFE_MODE) {
    ?>
				<div class="warningbox fade-message">
					<h2><?php 
    echo gettext("PHP Safe Mode Restrictions in effect!");
    ?>
</h2>
					<p><?php 
    echo gettext("These restrictions may prevent PHP scripts from uploading files.");
    ?>
</p>
				</div>
				<?php 
}
$rootrights = zp_apply_filter('upload_root_ui', accessAllAlbums(UPLOAD_RIGHTS));
if ($rootrights || !empty($albumlist)) {
    echo gettext("Upload to:");
    if (isset($_GET['new'])) {
        $checked = ' checked="checked"';
    } else {
        $checked = '';
    }
    ?>
				<script type="text/javascript">
					// <!-- <![CDATA[
	<?php 
    seoFriendlyJS();
    ?>
					function buttonstate(good) {
						$('#albumtitleslot').val($('#albumtitle').val());
Example #3
0
			<td>
				<input type="text" size="40" name="album" value="<?php 
echo html_encode($albumname);
?>
" />
			</td>
		</tr>
		<tr>
			<td><?php 
echo gettext("Create in:");
?>
</td>
			<td>
				<select id="albumselectmenu" name="albumselect">
					<?php 
if (accessAllAlbums(UPLOAD_RIGHTS)) {
    ?>
						<option value="" style="font-weight: bold;">/</option>
						<?php 
}
$parentalbum = '';
if (isset($_GET['folder'])) {
    $parentalbum = sanitize($_GET['folder']);
}
$bglevels = array('#fff', '#f8f8f8', '#efefef', '#e8e8e8', '#dfdfdf', '#d8d8d8', '#cfcfcf', '#c8c8c8');
foreach ($albumlist as $fullfolder => $albumtitle) {
    $singlefolder = $fullfolder;
    $saprefix = "";
    $salevel = 0;
    // Get rid of the slashes in the subalbum, while also making a subalbum prefix for the menu.
    while (strstr($singlefolder, '/') !== false) {