Beispiel #1
0
function wppa_get_user_upload_html($alb, $width, $where = '', $mcr = false)
{
    static $seqno;
    // Init
    $result = '';
    $mocc = wppa('mocc');
    $occur = wppa('occur');
    // Using seqno to distinguish from different places within one occurrence because
    // the album no is not known when there is a selection box.
    if ($seqno) {
        $seqno++;
    } else {
        $seqno = '1';
    }
    // Feature enabled?
    if (!wppa_switch('user_upload_on')) {
        return '';
    }
    // Login required?
    if (wppa_switch('user_upload_login')) {
        if (!is_user_logged_in()) {
            return '';
        }
    }
    // I should have access to this album ( $alb > 0 ).
    if ($alb > '0') {
        $album_owner = wppa_get_album_item($alb, 'owner');
        if ($album_owner != wppa_get_user() && $album_owner != '--- public ---' && !wppa_have_access($alb)) {
            return '';
        }
    } else {
        if (!wppa_have_access()) {
            return '';
        }
    }
    // Find max files for the user
    $allow_me = wppa_allow_user_uploads();
    if (!$allow_me) {
        if (wppa_switch('show_album_full')) {
            $result .= '<div style="clear:both"></div>' . '<span style="color:red">' . __('Max uploads reached', 'wp-photo-album-plus') . wppa_time_to_wait_html('0', true) . '</span>';
        }
        return $result;
    }
    // Find max files for the album
    $allow_alb = wppa_allow_uploads($alb);
    if (!$allow_alb) {
        if (wppa_switch('show_album_full')) {
            $result .= '<div style="clear:both"></div>' . '<span style="color:red">' . __('Max uploads reached', 'wp-photo-album-plus') . wppa_time_to_wait_html($alb) . '</span>';
        }
        return $result;
    }
    if (wppa_is_user_blacklisted()) {
        return '';
    }
    // Find max files for the system
    $allow_sys = ini_get('max_file_uploads');
    // THE max
    if ($allow_me == '-1') {
        $allow_me = $allow_sys;
    }
    if ($allow_alb == '-1') {
        $allow_alb = $allow_sys;
    }
    $max = min($allow_me, $allow_alb, $allow_sys);
    // In a widget or multi column responsive?
    $small = wppa_in_widget() == 'upload' || $mcr;
    // Ajax upload?
    $ajax_upload = wppa_switch('ajax_upload') && wppa_browser_can_html5();
    //					&&
    // WINDOWS 10 / Edge bug
    //					! strpos( $_SERVER["HTTP_USER_AGENT"], 'Edge' ) &&
    //					! strpos( $_SERVER["HTTP_USER_AGENT"], 'Windows NT 10.0' );
    // Create the return url
    if ($ajax_upload) {
        $returnurl = wppa_switch('ajax_non_admin') ? WPPA_URL . '/wppa-ajax-front.php' : admin_url('admin-ajax.php');
        $returnurl .= '?action=wppa&amp;wppa-action=do-fe-upload';
    } else {
        $returnurl = wppa_get_permalink();
        if ($where == 'cover') {
            $returnurl .= 'wppa-album=' . $alb . '&amp;wppa-cover=0&amp;wppa-occur=' . $occur;
        } elseif ($where == 'thumb') {
            $returnurl .= 'wppa-album=' . $alb . '&amp;wppa-cover=0&amp;wppa-occur=' . $occur;
        } elseif ($where == 'widget' || $where == 'uploadbox') {
        }
        if (wppa('page')) {
            $returnurl .= '&amp;wppa-page=' . wppa('page');
        }
        $returnurl = trim($returnurl, '?');
        $returnurl = wppa_trim_wppa_($returnurl);
    }
    // Make the HTML
    $t = $mcr ? 'mcr-' : '';
    $result .= '<div style="clear:both"></div>' . '<a' . ' id="wppa-up-' . $alb . '-' . $mocc . '"' . ' class="wppa-upload-' . $where . '"' . ' onclick="' . 'jQuery( \'#wppa-file-' . $t . $alb . '-' . $mocc . '\' ).css( \'display\',\'block\' );' . 'jQuery( \'#wppa-up-' . $alb . '-' . $mocc . '\' ).css( \'display\',\'none\' );' . 'jQuery( \'#wppa-cr-' . $alb . '-' . $mocc . '\' ).css( \'display\',\'none\' );' . 'jQuery( \'#wppa-ea-' . $alb . '-' . $mocc . '\' ).css( \'display\',\'none\' );' . 'jQuery( \'#wppa-cats-' . $alb . '-' . $mocc . '\' ).css( \'display\',\'none\' );' . 'jQuery( \'#_wppa-up-' . $alb . '-' . $mocc . '\' ).css( \'display\',\'block\' );' . '_wppaDoAutocol( ' . $mocc . ' )' . '"' . ' style="float:left; cursor:pointer;' . '" >' . __('Upload Photo', 'wp-photo-album-plus') . '</a>' . '<a' . ' id="_wppa-up-' . $alb . '-' . $mocc . '"' . ' class="wppa-upload-' . $where . '"' . ' onclick="' . 'jQuery( \'#wppa-file-' . $t . $alb . '-' . $mocc . '\' ).css( \'display\',\'none\' );' . 'jQuery( \'#wppa-cr-' . $alb . '-' . $mocc . '\' ).css( \'display\',\'block\' );' . 'jQuery( \'#wppa-up-' . $alb . '-' . $mocc . '\' ).css( \'display\',\'block\' );' . 'jQuery( \'#wppa-ea-' . $alb . '-' . $mocc . '\' ).css( \'display\',\'block\' );' . 'jQuery( \'#wppa-cats-' . $alb . '-' . $mocc . '\' ).css( \'display\',\'block\' );' . 'jQuery( \'#_wppa-up-' . $alb . '-' . $mocc . '\' ).css( \'display\',\'none\' );' . '_wppaDoAutocol( ' . $mocc . ' )' . '"' . ' style="float:right; cursor:pointer;display:none;' . '" >' . __(wppa_opt('close_text'), 'wp-photo-album-plus') . '</a>' . '<div' . ' id="wppa-file-' . $t . $alb . '-' . $mocc . '"' . ' class="wppa-file-' . $t . $mocc . '"' . ' style="width:' . $width . 'px;text-align:center;display:none; clear:both;"' . ' >' . '<form' . ' id="wppa-uplform-' . $alb . '-' . $mocc . '"' . ' action="' . $returnurl . '"' . ' method="post"' . ' enctype="multipart/form-data"' . ' >' . wppa_nonce_field('wppa-check', 'wppa-nonce', false, false, $alb);
    // If no album given: select one
    if (!$alb) {
        $result .= '<select' . ' id="wppa-upload-album-' . $mocc . '-' . $seqno . '"' . ' name="wppa-upload-album"' . ' style="float:left; max-width: ' . $width . 'px;"' . ' onchange="jQuery( \'#wppa-sel-' . $alb . '-' . $mocc . '\' ).trigger( \'onchange\' )"' . ' >' . wppa_album_select_a(array('addpleaseselect' => true, 'checkowner' => true, 'checkupload' => true, 'path' => wppa_switch('hier_albsel'))) . '</select>' . '<br />';
    } else {
        $result .= '<input' . ' type="hidden"' . ' id="wppa-upload-album-' . $mocc . '-' . $seqno . '"' . ' name="wppa-upload-album"' . ' value="' . $alb . '"' . ' />';
    }
    // One only ?
    if (wppa_switch('upload_one_only') && !current_user_can('administrator')) {
        $result .= '<input' . ' type="file"' . ' accept="image/*"' . (wppa_switch('camera_connect') ? ' capture="capture"' : '') . ' class="wppa-user-file"' . ' style="' . 'width:auto;' . 'max-width:' . $width . ';' . 'margin:6px 0;' . 'float:left;' . __wcs('wppa-box-text') . '"' . ' id="wppa-user-upload-' . $alb . '-' . $mocc . '"' . ' name="wppa-user-upload-' . $alb . '-' . $mocc . '[]"' . ' onchange="jQuery( \'#wppa-user-submit-' . $alb . '-' . $mocc . '\' ).css( \'display\', \'block\' )"' . ' />';
    } else {
        $result .= '<input' . ' type="file"' . ' accept="image/*"' . (wppa_switch('camera_connect') ? ' capture="capture"' : '') . ' multiple="multiple"' . ' class="wppa-user-file"' . ' style="' . 'width:auto;' . 'max-width:' . $width . ';' . 'margin:6px 0;' . 'float:left;' . __wcs('wppa-box-text') . '"' . ' id="wppa-user-upload-' . $alb . '-' . $mocc . '"' . ' name="wppa-user-upload-' . $alb . '-' . $mocc . '[]"' . ' onchange="jQuery( \'#wppa-user-submit-' . $alb . '-' . $mocc . '\' ).css( \'display\', \'block\' )"' . ' />';
    }
    // Explanation
    if (!wppa_switch('upload_one_only') && !current_user_can('administrator')) {
        if ($max) {
            $result .= '<span style="font-size:10px;" >' . sprintf(_n('You may upload %d photo', 'You may upload up to %d photos at once if your browser supports HTML-5 multiple file upload', $max, 'wp-photo-album-plus'), $max) . '</span>';
            $maxsize = wppa_check_memory_limit(false);
            if (is_array($maxsize)) {
                $result .= '<br />' . '<span style="font-size:10px;" >' . sprintf(__('Max photo size: %d x %d (%2.1f MegaPixel)', 'wp-photo-album-plus'), $maxsize['maxx'], $maxsize['maxy'], $maxsize['maxp'] / (1024 * 1024)) . '</span>';
            }
        }
    }
    // Copyright notice
    if (wppa_switch('copyright_on')) {
        $result .= '<div style="clear:both;" >' . __(wppa_opt('copyright_notice'), 'wp-photo-album-plus') . '</div>';
    }
    // Watermark
    if (wppa_switch('watermark_on') && wppa_switch('watermark_user')) {
        $result .= '<table' . ' class="wppa-watermark wppa-box-text"' . ' style="margin:0; border:0; ' . __wcs('wppa-box-text') . '"' . ' >' . '<tbody>' . '<tr valign="top" style="border: 0 none; " >' . '<td' . ' class="wppa-box-text wppa-td"' . ' style="' . __wcs('wppa-box-text') . __wcs('wppa-td') . '"' . ' >' . __('Apply watermark file:', 'wp-photo-album-plus') . '</td>' . '</tr>' . '<tr>' . '<td' . ' class="wppa-box-text wppa-td"' . ' style="width: ' . $width . ';' . __wcs('wppa-box-text') . __wcs('wppa-td') . '"' . ' >' . '<select' . ' style="margin:0; padding:0; text-align:left; width:auto; "' . ' name="wppa-watermark-file"' . ' id="wppa-watermark-file"' . ' >' . wppa_watermark_file_select() . '</select>' . '</td>' . '</tr>' . '<tr valign="top" style="border: 0 none; " >' . '<td' . ' class="wppa-box-text wppa-td"' . ' style="width: ' . $width . ';' . __wcs('wppa-box-text') . __wcs('wppa-td') . '"' . ' >' . __('Position:', 'wp-photo-album-plus') . '</td>' . ($small ? '</tr><tr>' : '') . '<td' . ' class="wppa-box-text wppa-td"' . ' style="width: ' . $width . ';' . __wcs('wppa-box-text') . __wcs('wppa-td') . '"' . ' >' . '<select' . ' style="margin:0; padding:0; text-align:left; width:auto; "' . ' name="wppa-watermark-pos"' . ' id="wppa-watermark-pos"' . ' >' . wppa_watermark_pos_select() . '</select>' . '</td>' . '</tr>' . '</tbody>' . '</table>';
    }
    // Name
    if (wppa_switch('name_user')) {
        switch (wppa_opt('newphoto_name_method')) {
            case 'none':
                $expl = '';
                break;
            case '2#005':
                $expl = __('If you leave this blank, iptc tag 005 (Graphic name) will be used as photoname if available, else the original filename will be used as photo name.', 'wp-photo-album-plus');
                break;
            case '2#120':
                $expl = __('If you leave this blank, iptc tag 120 (Caption) will be used as photoname if available, else the original filename will be used as photo name.', 'wp-photo-album-plus');
                break;
            default:
                $expl = __('If you leave this blank, the original filename will be used as photo name.', 'wp-photo-album-plus');
        }
        $result .= '<div' . ' class="wppa-box-text wppa-td"' . ' style="' . 'clear:both;' . 'float:left;' . 'text-align:left;' . __wcs('wppa-box-text') . __wcs('wppa-td') . '"' . ' >' . __('Enter photo name', 'wp-photo-album-plus') . '&nbsp;' . '<span style="font-size:10px;" >' . $expl . '</span>' . '</div>' . '<input' . ' type="text"' . ' class="wppa-box-text wppa-file-' . $t . $mocc . '"' . ' style="padding:0; width:' . ($width - 6) . 'px; ' . __wcs('wppa-box-text') . '"' . ' name="wppa-user-name"' . ' />';
    }
    // Description user fillable ?
    if (wppa_switch('desc_user')) {
        $desc = wppa_switch('apply_newphoto_desc_user') ? stripslashes(wppa_opt('newphoto_description')) : '';
        $result .= '<div' . ' class="wppa-box-text wppa-td"' . ' style="clear:both; float:left; text-align:left; ' . __wcs('wppa-box-text') . __wcs('wppa-td') . '"' . ' >' . __('Enter/modify photo description', 'wp-photo-album-plus') . '</div>' . '<textarea' . ' class="wppa-user-textarea wppa-box-text wppa-file-' . $t . $mocc . '"' . ' style="height:120px; width:' . ($width - 6) . 'px; ' . __wcs('wppa-box-text') . '"' . ' name="wppa-user-desc"' . ' >' . $desc . '</textarea>';
    } elseif (wppa_switch('apply_newphoto_desc_user')) {
        $result .= '<input' . ' type="hidden"' . ' value="' . esc_attr(wppa_opt('newphoto_description')) . '"' . ' name="wppa-user-desc"' . ' />';
    }
    // Custom fields
    if (wppa_switch('fe_custom_fields')) {
        for ($i = '0'; $i < '10'; $i++) {
            if (wppa_opt('custom_caption_' . $i)) {
                $result .= '<div' . ' class="wppa-box-text wppa-td"' . ' style="clear:both; float:left; text-align:left; ' . __wcs('wppa-box-text') . __wcs('wppa-td') . '"' . ' >' . __(wppa_opt('custom_caption_' . $i), 'wp-photo-album-plus') . ': ' . (wppa_switch('custom_visible_' . $i) ? '' : '&nbsp;<small><i>(&nbsp;' . __('hidden', 'wp-photo-album-plus') . '&nbsp;)</i></small>') . '</div>' . '<input' . ' type="text"' . ' class="wppa-box-text wppa-file-' . $t . $mocc . '"' . ' style="padding:0; width:' . ($width - 6) . 'px; ' . __wcs('wppa-box-text') . '"' . ' name="wppa-user-custom-' . $i . '"' . ' />';
            }
        }
    }
    // Tags
    if (wppa_switch('fe_upload_tags')) {
        // Prepare onclick action
        $onc = 'wppaPrevTags(\'wppa-sel-' . $alb . '-' . $mocc . '\', \'wppa-inp-' . $alb . '-' . $mocc . '\', \'wppa-upload-album-' . $mocc . '-' . $seqno . '\', \'wppa-prev-' . $alb . '-' . $mocc . '\')';
        // Open the tag enter area
        $result .= '<div class="wppa-box-text wppa-td" style="clear:both; float:left; text-align:left; ' . __wcs('wppa-box-text') . __wcs('wppa-td') . '" >';
        // Selection boxes 1..3
        for ($i = '1'; $i < '4'; $i++) {
            if (wppa_switch('up_tagselbox_on_' . $i)) {
                $result .= '<div style="float:left; margin-right:4px;" >' . '<small>' . __(wppa_opt('up_tagselbox_title_' . $i), 'wp-photo-album-plus') . '</small><br />' . '<select' . ' id="wppa-sel-' . $alb . '-' . $mocc . '-' . $i . '"' . ' style="float:left; margin-right: 4px;"' . ' name="wppa-user-tags-' . $i . '[]"' . (wppa_switch('up_tagselbox_multi_' . $i) ? ' multiple' : '') . ' onchange="' . $onc . '"' . ' >';
                if (wppa_opt('up_tagselbox_content_' . $i)) {
                    // List of tags supplied
                    $tags = explode(',', wppa_opt('up_tagselbox_content_' . $i));
                    $result .= '<option value="" >&nbsp;</option>';
                    if (is_array($tags)) {
                        foreach ($tags as $tag) {
                            $result .= '<option class="wppa-sel-' . $alb . '-' . $mocc . '" value="' . $tag . '">' . $tag . '</option>';
                        }
                    }
                } else {
                    // All existing tags
                    $tags = wppa_get_taglist();
                    $result .= '<option value="" >&nbsp;</option>';
                    if (is_array($tags)) {
                        foreach ($tags as $tag) {
                            $result .= '<option class="wppa-sel-' . $alb . '-' . $mocc . '" value="' . $tag['tag'] . '">' . $tag['tag'] . '</option>';
                        }
                    }
                }
                $result .= '</select>' . '</div>';
            }
        }
        // New tags
        if (wppa_switch('up_tag_input_on')) {
            $result .= '<div style="float:left; margin-right:4px;" >' . '<small>' . __(wppa_opt('up_tag_input_title'), 'wp-photo-album-plus') . '</small><br />' . '<input' . ' id="wppa-inp-' . $alb . '-' . $mocc . '"' . ' type="text"' . ' class="wppa-box-text"' . ' style="padding:0; width:150px; ' . __wcs('wppa-box-text') . '"' . ' name="wppa-new-tags"' . ' onchange="' . $onc . '"' . ' />' . '</div>';
        }
        // Preview area
        if (wppa_switch('up_tag_preview')) {
            $result .= '<div style="margin:0; clear:both;" >' . __('Preview tags:', 'wp-photo-album-plus') . ' <small id="wppa-prev-' . $alb . '-' . $mocc . '"></small>' . '</div>' . '<script type="text/javascript" >jQuery( document ).ready(function() {' . $onc . '})</script>';
        }
        // Close tag enter area
        $result .= '</div>';
    }
    /* start submit section */
    // Onclick submit verify album is known
    if (!$alb) {
        $onclick = ' onclick="if ( document.getElementById( \'wppa-upload-album-' . $mocc . '-' . $seqno . '\' ).value == 0 )' . ' {alert( \'' . esc_js(__('Please select an album and try again', 'wp-photo-album-plus')) . '\' );return false;}"';
    } else {
        $onclick = '';
    }
    // The submit button
    $result .= '<input' . ' type="submit"' . ' id="wppa-user-submit-' . $alb . '-' . $mocc . '"' . $onclick . ' style="display:none; margin: 6px 0; float:right; ' . __wcs('wppa-box-text') . '"' . ' class="wppa-user-submit"' . ' name="wppa-user-submit-' . $alb . '-' . $mocc . '" value="' . __('Upload photo', 'wp-photo-album-plus') . '"' . ' />' . '<div style="clear:both"></div>';
    // if ajax: progression bar
    if ($ajax_upload) {
        $result .= '<div' . ' id="progress-' . $alb . '-' . $mocc . '"' . ' class="wppa-progress"' . ' style="border-color:' . wppa_opt('bcolor_upload') . '"' . ' >' . '<div id="bar-' . $alb . '-' . $mocc . '" class="wppa-bar" ></div>' . '<div id="percent-' . $alb . '-' . $mocc . '" class="wppa-percent" >0%</div >' . '</div>' . '<div id="message-' . $alb . '-' . $mocc . '" class="wppa-message" ></div>';
    }
    /* End submit section */
    // Done
    $result .= '</form></div>';
    // Ajax upload script
    if ($ajax_upload) {
        $result .= '<script>' . 'jQuery(document).ready(function() {

					var options = {
						beforeSend: function() {
							jQuery("#progress-' . $alb . '-' . $mocc . '").show();
							//clear everything
							jQuery("#bar-' . $alb . '-' . $mocc . '").width(\'0%\');
							jQuery("#message-' . $alb . '-' . $mocc . '").html("");
							jQuery("#percent-' . $alb . '-' . $mocc . '").html("");
						},
						uploadProgress: function(event, position, total, percentComplete) {
							jQuery("#bar-' . $alb . '-' . $mocc . '").width(percentComplete+\'%\');
							if ( percentComplete < 95 ) {
								jQuery("#percent-' . $alb . '-' . $mocc . '").html(percentComplete+\'%\');
							}
							else {
								jQuery("#percent-' . $alb . '-' . $mocc . '").html(\'Processing...\');
							}
						},
						success: function() {
							jQuery("#bar-' . $alb . '-' . $mocc . '").width(\'100%\');
							jQuery("#percent-' . $alb . '-' . $mocc . '").html(\'Done!\');
						},
						complete: function(response) {
							jQuery("#message-' . $alb . '-' . $mocc . '").html( \'<span style="font-size: 10px;" >\'+response.responseText+\'</span>\' );' . ($where == 'thumb' ? 'document.location.reload(true)' : '') . '
						},
						error: function() {
							jQuery("#message-' . $alb . '-' . $mocc . '").html( \'<span style="color: red;" >' . __('ERROR: unable to upload files.', 'wp-photo-album-plus') . '</span>\' );
						}
					};

					jQuery("#wppa-uplform-' . $alb . '-' . $mocc . '").ajaxForm(options);
				});
			</script>';
    }
    return $result;
}
function wppa_container($action)
{
    global $wppa_version;
    // The theme version ( wppa_theme.php )
    global $wppa_microtime;
    global $wppa_microtime_cum;
    global $wppa_err_displayed;
    global $wppa_loadtime;
    global $wppa_initruntimetime;
    static $wppa_numqueries;
    static $auto;
    global $blog_id;
    if (is_feed()) {
        return;
    }
    // Need no container in RSS feeds
    if ($action == 'open') {
        $wppa_numqueries = get_num_queries();
        // Open the container
        if (!wppa('ajax')) {
            //			wppa( 'out' ) .= '<!-- Start WPPA+ generated code'.( is_multisite() ? ', Multi site, id='.$blog_id : ', Single site' ).' -->';
            //			if ( wppa( 'shortcode_content' ) ) {
            //				wppa( 'out' ) .= '<!-- ' . wppa( 'shortcode_content' ) . ' -->';
            //			}
            wppa_out('<div' . ' id="wppa-container-' . wppa('mocc') . '"' . ' style="' . wppa_get_container_style() . '"' . ' class="' . 'wppa-container' . ' ' . 'wppa-container-' . wppa('mocc') . ' ' . 'wppa-rev-' . wppa('revno') . ' ' . 'wppa-prevrev-' . wppa_opt('prevrev') . ' ' . 'wppa-theme-' . $wppa_version . ' ' . 'wppa-api-' . wppa('api_version') . '"' . ' >');
        }
        // Spinner for Ajax
        if (wppa_switch('allow_ajax')) {
            if (!wppa_in_widget()) {
                wppa_out('<img' . ' id="wppa-ajax-spin-' . wppa('mocc') . '"' . ' src="' . wppa_get_imgdir() . 'loader.gif"' . ' alt="spinner"' . ' style="' . 'box-shadow:none;' . 'z-index:1010;' . 'position:fixed;' . 'top:50%;' . 'margin-top:-32px;' . 'left:50%;' . 'margin-left:-32px;' . 'display:none;' . '"' . ' />');
            }
        }
        // Start timer if in debug mode
        if (wppa('debug')) {
            $wppa_microtime = -microtime(true);
            wppa_dbg_q('init');
        }
        if (wppa('mocc') == '1') {
            wppa_dbg_msg('Plugin load time :' . substr($wppa_loadtime, 0, 5) . 's.');
            wppa_dbg_msg('Init runtime time :' . substr($wppa_initruntimetime, 0, 5) . 's.');
            wppa_dbg_msg('Num queries before wppa :' . get_num_queries());
        }
        /* Check if wppa.js and jQuery are present */
        if (!$wppa_err_displayed && (WPPA_DEBUG || wppa_get_get('debug') || WP_DEBUG) && !wppa_switch('defer_javascript')) {
            wppa_out('<script type="text/javascript">/* <![CDATA[ */');
            wppa_out("if ( typeof( _wppaSlides ) == 'undefined' ) " . "alert( 'There is a problem with your theme. The file wppa.js is not loaded when it is expected ( Errloc = wppa_container ).' );");
            wppa_out("if ( typeof( jQuery ) == 'undefined' ) " . "alert( 'There is a problem with your theme. The jQuery library is not loaded when it is expected ( Errloc = wppa_container ).' );");
            wppa_out("/* ]]> */</script>");
            $wppa_err_displayed = true;
        }
        /* Check if init is properly done */
        if (!wppa_opt('fullsize')) {
            wppa_out('<script type="text/javascript">/* <![CDATA[ */');
            wppa_out("alert( 'The initialisation of wppa+ is not complete yet. " . "You will probably see division by zero errors. " . "Please run Photo Albums -> Settings admin page Table VIII-A1. ( Errloc = wppa_container ).' );");
            wppa_out("/* ]]> */</script>");
        }
        // Nonce field check for rating security
        if (wppa('mocc') == '1') {
            if (wppa_get_get('rating')) {
                $nonce = wppa_get_get('nonce');
                $ok = wp_verify_nonce($nonce, 'wppa-check');
                if ($ok) {
                    wppa_dbg_msg('Rating nonce ok');
                    if (!is_user_logged_in()) {
                        sleep(2);
                    }
                } else {
                    die('<b>' . __('ERROR: Illegal attempt to enter a rating.', 'wp-photo-album-plus') . '</b>');
                }
            }
        }
        // Nonce field check for comment security
        if (wppa('mocc') == '1') {
            if (wppa_get_post('comment')) {
                $nonce = wppa_get_post('nonce');
                $ok = wp_verify_nonce($nonce, 'wppa-check');
                if ($ok) {
                    wppa_dbg_msg('Comment nonce ok');
                    if (!is_user_logged_in()) {
                        sleep(2);
                    }
                } else {
                    die('<b>' . __('ERROR: Illegal attempt to enter a comment.', 'wp-photo-album-plus') . '</b>');
                }
            }
        }
        wppa_out(wppa_nonce_field('wppa-check', 'wppa-nonce', false, false));
        if (wppa_page('oneofone')) {
            wppa('portrait_only', true);
        }
        wppa('alt', 'alt');
        // Javascript occurrence dependant stuff
        wppa_add_js_page_data("\n" . '<script type="text/javascript">');
        // wppa( 'auto_colwidth' ) is set by the filter or by wppa_albums in case called directly
        // wppa_opt( 'colwidth' ) is the option setting
        // script or call has precedence over option setting
        // so: if set by script or call: auto, else if set by option: auto
        $auto = false;
        $contw = wppa_get_container_width();
        if (wppa('auto_colwidth')) {
            $auto = true;
        } elseif (wppa_opt('colwidth') == 'auto') {
            $auto = true;
        } elseif ($contw > 0 && $contw <= 1.0) {
            $auto = true;
        }
        if ($auto) {
            wppa_add_js_page_data("\n" . 'wppaAutoColumnWidth[' . wppa('mocc') . '] = true;');
            if ($contw > 0 && $contw <= 1.0) {
                wppa_add_js_page_data("\n" . 'wppaAutoColumnFrac[' . wppa('mocc') . '] = ' . $contw . ';');
            } else {
                wppa_add_js_page_data("\n" . 'wppaAutoColumnFrac[' . wppa('mocc') . '] = 1.0;');
            }
            wppa_add_js_page_data("\n" . 'wppaColWidth[' . wppa('mocc') . '] = 0;');
        } else {
            wppa_add_js_page_data("\n" . 'wppaAutoColumnWidth[' . wppa('mocc') . '] = false;');
            wppa_add_js_page_data("\n" . 'wppaColWidth[' . wppa('mocc') . '] = ' . wppa_get_container_width() . ';');
        }
        wppa_add_js_page_data("\n" . 'wppaTopMoc = ' . wppa('mocc') . ';');
        if (wppa_opt('thumbtype') == 'masonry-v') {
            wppa_add_js_page_data("\n" . 'wppaMasonryCols[' . wppa('mocc') . '] = ' . ceil(wppa_get_container_width() / wppa_opt('thumbsize')) . ';');
        } else {
            wppa_add_js_page_data("\n" . 'wppaMasonryCols[' . wppa('mocc') . '] = 0;');
        }
        if (wppa('src_script')) {
            wppa_add_js_page_data("\n" . wppa('src_script'));
        }
        // Aspect ratio and fullsize
        if (wppa_in_widget() == 'ss' && is_numeric(wppa('in_widget_frame_width')) && wppa('in_widget_frame_width') > '0') {
            $asp = wppa('in_widget_frame_height') / wppa('in_widget_frame_width');
            $fls = wppa('in_widget_frame_width');
        } else {
            $asp = wppa_opt('maxheight') / wppa_opt('fullsize');
            $fls = wppa_opt('fullsize');
        }
        wppa_add_js_page_data("\n" . 'wppaAspectRatio[' . wppa('mocc') . '] = ' . $asp . ';');
        wppa_add_js_page_data("\n" . 'wppaFullSize[' . wppa('mocc') . '] = ' . $fls . ';');
        // last minute change: fullvalign with border needs a height correction in slideframe
        if (wppa_opt('fullimage_border_width') != '' && !wppa_in_widget()) {
            $delta = (1 + wppa_opt('fullimage_border_width')) * 2;
        } else {
            $delta = 0;
        }
        wppa_add_js_page_data("\n" . 'wppaFullFrameDelta[' . wppa('mocc') . '] = ' . $delta . ';');
        // last minute change: script %%size != default colwidth
        $temp = wppa_get_container_width() - (2 * 6 + 2 * 36 + 2 * wppa_opt('bwidth'));
        if (wppa_in_widget()) {
            $temp = wppa_get_container_width() - (2 * 6 + 2 * 18 + 2 * wppa_opt('bwidth'));
        }
        wppa_add_js_page_data("\n" . 'wppaFilmStripLength[' . wppa('mocc') . '] = ' . $temp . ';');
        // last minute change: filmstrip sizes and related stuff. In widget: half size.
        $temp = wppa_opt('tf_width') + wppa_opt('tn_margin');
        if (wppa_in_widget()) {
            $temp /= 2;
        }
        wppa_add_js_page_data("\n" . 'wppaThumbnailPitch[' . wppa('mocc') . '] = ' . $temp . ';');
        $temp = wppa_opt('tn_margin') / 2;
        if (wppa_in_widget()) {
            $temp /= 2;
        }
        wppa_add_js_page_data("\n" . 'wppaFilmStripMargin[' . wppa('mocc') . '] = ' . $temp . ';');
        $temp = 2 * 6 + 2 * 42 + 2 * wppa_opt('bwidth');
        if (wppa_in_widget()) {
            $temp = 2 * 6 + 2 * 21 + 2 * wppa_opt('bwidth');
        }
        wppa_add_js_page_data("\n" . 'wppaFilmStripAreaDelta[' . wppa('mocc') . '] = ' . $temp . ';');
        if (wppa_in_widget()) {
            wppa_add_js_page_data("\n" . 'wppaIsMini[' . wppa('mocc') . '] = true;');
        } else {
            wppa_add_js_page_data("\n" . 'wppaIsMini[' . wppa('mocc') . '] = false;');
        }
        $target = false;
        if (wppa_in_widget() == 'ss' && wppa_switch('sswidget_blank')) {
            $target = true;
        }
        if (!wppa_in_widget() && wppa_switch('slideshow_blank')) {
            $target = true;
        }
        if ($target) {
            wppa_add_js_page_data("\n" . 'wppaSlideBlank[' . wppa('mocc') . '] = true;');
        } else {
            wppa_add_js_page_data("\n" . 'wppaSlideBlank[' . wppa('mocc') . '] = false;');
        }
        wppa_add_js_page_data("\n" . 'wppaLightBox[' . wppa('mocc') . '] = "xxx";');
        // If this occur is a slideshow, determine if its link is to lightbox. This may differ between normal slideshow or ss widget
        $is_slphoto = wppa('is_slide') && wppa('start_photo') && wppa('is_single');
        if ('ss' == wppa_in_widget() || wppa_page('slide') || $is_slphoto) {
            $ss_linktype = 'ss' == wppa_in_widget() ? wppa_opt('slideonly_widget_linktype') : wppa_opt('slideshow_linktype');
            switch ($ss_linktype) {
                case 'file':
                    $lbkey = 'file';
                    // gives anchor tag with rel="file"
                    break;
                case 'lightbox':
                case 'lightboxsingle':
                    $lbkey = wppa_opt('lightbox_name');
                    // gives anchor tag with rel="lightbox" or the like
                    break;
                default:
                    $lbkey = '';
                    // results in omitting the anchor tag
                    break;
            }
            wppa_add_js_page_data("\n" . 'wppaLightBox[' . wppa('mocc') . '] = "' . $lbkey . '";' . "\n" . 'wppaConsoleLog("mocc:' . wppa('mocc') . ' lbkey:"+wppaLightBox[' . wppa('mocc') . '] );');
            wppa_add_js_page_data("\n" . 'wppaLightboxSingle[' . wppa('mocc') . '] = ' . (wppa_opt('slideshow_linktype') == 'lightboxsingle' ? 'true' : 'false') . ';');
        }
        wppa_add_js_page_data("\n" . '</script>');
    } elseif ($action == 'close') {
        if (wppa_page('oneofone')) {
            wppa('portrait_only', false);
        }
        if (!wppa_in_widget()) {
            wppa_out('<div style="clear:both;"></div>');
        }
        // Add diagnostic <p> if debug is 1
        if (wppa('debug') == '1' && wppa('mocc') == '1') {
            wppa_out('<p id="wppa-debug-' . wppa('mocc') . '" style="font-size:9px; color:#070; line-size:12px;" ></p>');
        }
        // Init lightbox intermediate to facillitate premature clicks to lightbox when not yet document.complete
        wppa_out("\n" . '<script type="text/javascript" >if ( typeof(wppaInitOverlay) != "undefined" ) { wppaInitOverlay(); }</script>');
        if (!wppa('ajax')) {
            wppa_out('<div id="wppa-container-' . wppa('mocc') . '-end" ></div>');
            wppa_out('</div>');
        }
        if (wppa('debug')) {
            $laptim = $wppa_microtime + microtime(true);
            $wppa_numqueries = get_num_queries() - $wppa_numqueries;
            if (!is_numeric($wppa_microtime_cum)) {
                $wppa_mcrotime_cum = '0';
            }
            $wppa_microtime_cum += $laptim;
            wppa_dbg_msg('Time elapsed occ ' . wppa('mocc') . ':' . substr($laptim, 0, 5) . 's. Tot:' . substr($wppa_microtime_cum, 0, 5) . 's.');
            wppa_dbg_msg('Number of queries occ ' . wppa('mocc') . ':' . $wppa_numqueries, 'green');
            wppa_dbg_q('print');
        }
    } else {
        wppa_out("\n" . '<span style="color:red;">Error, wppa_container() called with wrong argument: ' . $action . '. Possible values: \'open\' or \'close\'</span>');
    }
}
function wppa_get_user_upload_html($xalb, $width, $where = '', $mcr = false)
{
    global $wpdb;
    global $wppa_supported_video_extensions;
    global $wppa_supported_audio_extensions;
    static $seqno;
    static $albums_granted;
    $albums_created = array();
    // Create granted albums only if not done yet i a previous occurance,
    // and an album id is given not being '0'
    if (wppa_is_int($xalb) && $xalb > '0') {
        if (!in_array($xalb, (array) $albums_granted, true)) {
            // This function will check if $xalb is a grant parent,
            // and make my subalbum if it does not already exist.
            $ta = wppa_grant_albums($xalb);
            if (!empty($ta)) {
                $albums_created = array_merge($albums_created, $ta);
            }
            // Remember we processed this possible grant parent
            $albums_granted[] = $xalb;
        }
    } elseif (wppa_is_enum($xalb)) {
        $temp = explode('.', wppa_expand_enum($xalb));
        foreach ($temp as $t) {
            if (!in_array($t, (array) $albums_granted, true)) {
                $ta = wppa_grant_albums($t);
                if (!empty($ta)) {
                    $albums_created = array_merge($albums_created, $ta);
                }
                $albums_granted[] = $t;
            }
        }
    }
    // If albums created, add them to the list, so they appear immediately
    $alb = $xalb;
    if (!empty($albums_created)) {
        foreach ($albums_created as $a) {
            $alb .= '.' . $a;
        }
    }
    // Init
    $mocc = wppa('mocc');
    $occur = wppa('occur');
    $yalb = str_replace('.', '', $xalb);
    // Open wrapper
    $result = '<div style="clear:both"></div>';
    //<div id="fe-upl-wrap-' . $mocc . '" style="background-color:#FFC;" >';
    // Using seqno to distinguish from different places within one occurrence because
    // the album no is not known when there is a selection box.
    if ($seqno) {
        $seqno++;
    } else {
        $seqno = '1';
    }
    // Feature enabled?
    if (!wppa_switch('user_upload_on')) {
        return '';
    }
    // Login required?
    if (wppa_switch('user_upload_login')) {
        if (!is_user_logged_in()) {
            return '';
        }
    } elseif (!is_user_logged_in()) {
        $public_exist = $wpdb->get_var("SELECT COUNT(*) " . "FROM `" . WPPA_ALBUMS . "` " . "WHERE `owner` = '--- public ---' ");
        if (!$public_exist) {
            return '';
        }
    }
    // Basically there are 3 possibilities for supplied album id(s)
    // 1. A single album
    // 2. '' or '0', meaning 'any'
    // 3. An album enumerations
    //
    // Now we are going to test if the visitor has access
    // Case 1. A single album. I should have access to this album ( $alb > 0 ).
    if (wppa_is_int($alb) && $alb > '0') {
        if (!wppa_have_access($alb)) {
            if (wppa_switch('upload_owner_only')) {
                return '';
            }
        }
    } elseif (!$alb) {
        $alb = trim(wppa_alb_to_enum_children('0') . '.' . wppa_alb_to_enum_children('-1'), '.');
    }
    // Case 3. An enumeration. Test for all albums in the enumeration, and remove the albums that he has no access to.
    // In this event, if a single album remains, there will not be a selectionbox, but its treated as if a single album was supplied.
    if (wppa_is_enum($alb)) {
        $albarr = explode('.', wppa_expand_enum($alb));
        foreach (array_keys($albarr) as $key) {
            if (!wppa_have_access($albarr[$key])) {
                if (wppa_switch('upload_owner_only')) {
                    unset($albarr[$key]);
                }
            }
        }
        if (empty($albarr)) {
            $alb = '';
        }
        if (count($albarr) == 1) {
            $alb = reset($albarr);
        } else {
            $alb = $albarr;
        }
    }
    // If no more albums left, no access, quit this proc.
    if (!$alb) {
        return '';
    }
    // The result is: $alb is either an album id, or an array of album ids. Always with upload access.
    // Find max files for the user
    $allow_me = wppa_allow_user_uploads();
    if (!$allow_me) {
        if (wppa_switch('show_album_full')) {
            $result .= '<h6 style="color:red">' . __('Max uploads reached', 'wp-photo-album-plus') . wppa_time_to_wait_html('0', true) . '</h6>';
        }
        return $result;
    }
    // Find max files for the album
    if (wppa_is_int($alb)) {
        $allow_alb = wppa_allow_uploads($alb);
        if (!$allow_alb) {
            if (wppa_switch('show_album_full')) {
                $result .= '<h6 style="color:red">' . __('Max uploads reached', 'wp-photo-album-plus') . wppa_time_to_wait_html($alb) . '</h6>';
            }
            return $result;
        }
    } else {
        $allow_alb = '-1';
    }
    if (wppa_is_user_blacklisted()) {
        return '';
    }
    // Find max files for the system
    $allow_sys = ini_get('max_file_uploads');
    // THE max
    if ($allow_me == '-1') {
        $allow_me = $allow_sys;
    }
    if ($allow_alb == '-1') {
        $allow_alb = $allow_sys;
    }
    $max = min($allow_me, $allow_alb, $allow_sys);
    // In a widget or multi column responsive?
    $small = wppa_in_widget() == 'upload' || $mcr;
    // Ajax upload?
    $ajax_upload = wppa_switch('ajax_upload') && wppa_browser_can_html5();
    // Create the return url
    if ($ajax_upload) {
        $returnurl = wppa_switch('ajax_non_admin') ? WPPA_URL . '/wppa-ajax-front.php' : admin_url('admin-ajax.php');
        $returnurl .= '?action=wppa&amp;wppa-action=do-fe-upload';
    } else {
        $returnurl = wppa_get_permalink();
        if ($where == 'cover') {
            $returnurl .= 'wppa-album=' . $alb . '&amp;wppa-cover=0&amp;wppa-occur=' . $occur;
        } elseif ($where == 'thumb') {
            $returnurl .= 'wppa-album=' . $alb . '&amp;wppa-cover=0&amp;wppa-occur=' . $occur;
        } elseif ($where == 'widget' || $where == 'uploadbox') {
        }
        if (wppa('page')) {
            $returnurl .= '&amp;wppa-page=' . wppa('page');
        }
        $returnurl = trim($returnurl, '?');
        $returnurl = wppa_trim_wppa_($returnurl);
    }
    // Make the HTML
    $t = $mcr ? 'mcr-' : '';
    $result .= '<a' . ' id="wppa-up-' . str_replace('.', '-', $yalb) . '-' . $mocc . '"' . ' class="wppa-upload-' . $where . ' wppa-album-cover-link"' . ' onclick="' . 'jQuery( \'#wppa-file-' . $t . str_replace('.', '-', $yalb) . '-' . $mocc . '\' ).css( \'display\',\'block\' );' . 'jQuery( \'#wppa-up-' . str_replace('.', '-', $yalb) . '-' . $mocc . '\' ).css( \'display\',\'none\' );' . 'jQuery( \'#wppa-cr-' . str_replace('.', '-', $yalb) . '-' . $mocc . '\' ).css( \'display\',\'none\' );' . 'jQuery( \'#wppa-ea-' . str_replace('.', '-', $yalb) . '-' . $mocc . '\' ).css( \'display\',\'none\' );' . 'jQuery( \'#wppa-cats-' . str_replace('.', '-', $yalb) . '-' . $mocc . '\' ).css( \'display\',\'none\' );' . 'jQuery( \'#_wppa-up-' . str_replace('.', '-', $yalb) . '-' . $mocc . '\' ).css( \'display\',\'block\' );' . '_wppaDoAutocol( ' . $mocc . ' )' . '"' . ' style="float:left; cursor:pointer;' . '" >' . __('Upload Photo', 'wp-photo-album-plus') . '</a>' . '<a' . ' id="_wppa-up-' . str_replace('.', '-', $yalb) . '-' . $mocc . '"' . ' class="wppa-upload-' . $where . ' wppa-album-cover-link"' . ' onclick="' . 'jQuery( \'#wppa-file-' . $t . str_replace('.', '-', $yalb) . '-' . $mocc . '\' ).css( \'display\',\'none\' );' . 'jQuery( \'#wppa-cr-' . str_replace('.', '-', $yalb) . '-' . $mocc . '\' ).css( \'display\',\'block\' );' . 'jQuery( \'#wppa-up-' . str_replace('.', '-', $yalb) . '-' . $mocc . '\' ).css( \'display\',\'block\' );' . 'jQuery( \'#wppa-ea-' . str_replace('.', '-', $yalb) . '-' . $mocc . '\' ).css( \'display\',\'block\' );' . 'jQuery( \'#wppa-cats-' . str_replace('.', '-', $yalb) . '-' . $mocc . '\' ).css( \'display\',\'block\' );' . 'jQuery( \'#_wppa-up-' . str_replace('.', '-', $yalb) . '-' . $mocc . '\' ).css( \'display\',\'none\' );' . '_wppaDoAutocol( ' . $mocc . ' )' . '"' . ' style="float:right; cursor:pointer;display:none;' . '" >' . __(wppa_opt('close_text'), 'wp-photo-album-plus') . '</a>' . '<div' . ' id="wppa-file-' . $t . str_replace('.', '-', $yalb) . '-' . $mocc . '"' . ' class=""' . ' style="width:100%;text-align:center;display:none; clear:both;"' . ' >' . '<form' . ' id="wppa-uplform-' . $yalb . '-' . $mocc . '"' . ' action="' . $returnurl . '"' . ' method="post"' . ' enctype="multipart/form-data"' . ' >' . wppa_nonce_field('wppa-check', 'wppa-nonce', false, false, $yalb);
    // Single Album given
    if (wppa_is_int($alb)) {
        $result .= '<input' . ' type="hidden"' . ' id="wppa-upload-album-' . $mocc . '-' . $seqno . '"' . ' name="wppa-upload-album"' . ' value="' . $alb . '"' . ' />';
    } else {
        if (!is_array($alb)) {
            $alb = explode('.', wppa_expand_enum($alb));
        }
        // Can an selection box be displayed?
        if (!wppa_opt('fe_upload_max_albums') || wppa_opt('fe_upload_max_albums') > wppa_get_uploadable_album_count($alb)) {
            // Below max
            $result .= '<select' . ' id="wppa-upload-album-' . $mocc . '-' . $seqno . '"' . ' name="wppa-upload-album"' . ' style="float:left; max-width: 100%;"' . ' onchange="jQuery( \'#wppa-sel-' . $yalb . '-' . $mocc . '\' ).trigger( \'onchange\' )"' . ' >' . wppa_album_select_a(array('addpleaseselect' => true, 'checkowner' => true, 'checkupload' => true, 'path' => wppa_switch('hier_albsel'), 'checkarray' => count($alb) > 1, 'array' => $alb)) . '</select>' . '<br />';
        } else {
            $result .= '<input' . ' id="wppa-upload-album-' . $mocc . '-' . $seqno . '"' . ' type="number"' . ' placeholder="' . esc_attr(__('Enter album id', 'wp-photo-album-plus')) . '"' . ' name="wppa-upload-album"' . ' style="float:left; max-width: 100%;"' . ' onchange="jQuery( \'#wppa-sel-' . $yalb . '-' . $mocc . '\' ).trigger( \'onchange\' )"' . ' />' . '<br />';
        }
    }
    $one_only = wppa_switch('upload_one_only');
    $multiple = !$one_only;
    $on_camera = wppa_switch('camera_connect');
    $may_video = wppa_switch('user_upload_video_on');
    $may_audio = wppa_switch('user_upload_audio_on');
    $accept = '.jpg,.gif,.png';
    if ($may_video) {
        $accept .= ',.' . implode(',.', $wppa_supported_video_extensions);
    }
    if ($may_audio) {
        $accept .= ',.' . implode(',.', $wppa_supported_audio_extensions);
    }
    if ($one_only) {
        if ($on_camera) {
            if ($may_video) {
                $value = esc_attr(__('Select Photo / Video / Camera', 'wp-photo-album-plus'));
            } else {
                $value = esc_attr(__('Select Photo / Camera', 'wp-photo-album-plus'));
            }
        } else {
            if ($may_video) {
                $value = esc_attr(__('Select Photo / Video', 'wp-photo-album-plus'));
            } else {
                $value = esc_attr(__('Select Photo', 'wp-photo-album-plus'));
            }
        }
    } else {
        if ($on_camera) {
            if ($may_video) {
                $value = esc_attr(__('Select Photos / Video / Camera', 'wp-photo-album-plus'));
            } else {
                $value = esc_attr(__('Select Photos / Camera', 'wp-photo-album-plus'));
            }
        } else {
            if ($may_video) {
                $value = esc_attr(__('Select Photos / Video', 'wp-photo-album-plus'));
            } else {
                $value = esc_attr(__('Select Photos', 'wp-photo-album-plus'));
            }
        }
    }
    $result .= '<input' . ' type="file"' . ' accept="' . $accept . '"' . ($multiple ? ' multiple="multiple"' : '') . ' style="' . 'display:none;' . '"' . ' id="wppa-user-upload-' . $yalb . '-' . $mocc . '"' . ' name="wppa-user-upload-' . $yalb . '-' . $mocc . '[]"' . ' onchange="' . 'jQuery( \'#wppa-user-submit-' . $yalb . '-' . $mocc . '\' ).css( \'display\', \'block\' );' . 'wppaDisplaySelectedFiles(\'wppa-user-upload-' . $yalb . '-' . $mocc . '\')' . '"' . ' />';
    if ($on_camera) {
        $result .= '<script>jQuery(\'#wppa-user-upload-' . $yalb . '-' . $mocc . '\').attr(\'capture\',\'capture\')</script>';
    }
    $result .= '<input' . ' type="button"' . ' style="width:100%;margin-top:8px;margin-bottom:8px;padding-left:0;padding-right:0;"' . ' id="wppa-user-upload-' . $yalb . '-' . $mocc . '-display"' . ' value="' . $value . '"' . ' onclick="jQuery( \'#wppa-user-upload-' . $yalb . '-' . $mocc . '\' ).click();"' . '/>';
    // Explanation
    if (!wppa_switch('upload_one_only')) {
        if ($max) {
            $result .= '<div style="font-size:10px;" >' . sprintf(_n('You may upload %d photo', 'You may upload up to %d photos at once if your browser supports HTML-5 multiple file upload', $max, 'wp-photo-album-plus'), $max) . '</div>';
            $maxsize = wppa_check_memory_limit(false);
            if (is_array($maxsize)) {
                $result .= '<div style="font-size:10px;" >' . sprintf(__('Max photo size: %d x %d (%2.1f MegaPixel)', 'wp-photo-album-plus'), $maxsize['maxx'], $maxsize['maxy'], $maxsize['maxp'] / (1024 * 1024)) . '</div>';
            }
        }
    }
    // Copyright notice
    if (wppa_switch('copyright_on')) {
        $result .= '<div style="width:100%;clear:both;" >' . __(wppa_opt('copyright_notice'), 'wp-photo-album-plus') . '</div>';
    }
    // Watermark
    if (wppa_switch('watermark_on') && wppa_switch('watermark_user')) {
        $result .= '<table' . ' class="wppa-watermark wppa-box-text"' . ' style="margin:0; border:0; ' . __wcs('wppa-box-text') . '"' . ' >' . '<tbody>' . '<tr valign="top" style="border: 0 none; " >' . '<td' . ' class="wppa-box-text wppa-td"' . ' style="' . __wcs('wppa-box-text') . __wcs('wppa-td') . '"' . ' >' . __('Apply watermark file:', 'wp-photo-album-plus') . '</td>' . '</tr>' . '<tr>' . '<td' . ' class="wppa-box-text wppa-td"' . ' style="width: ' . $width . ';' . __wcs('wppa-box-text') . __wcs('wppa-td') . '"' . ' >' . '<select' . ' style="margin:0; padding:0; text-align:left; width:auto; "' . ' name="wppa-watermark-file"' . ' id="wppa-watermark-file"' . ' >' . wppa_watermark_file_select() . '</select>' . '</td>' . '</tr>' . '<tr valign="top" style="border: 0 none; " >' . '<td' . ' class="wppa-box-text wppa-td"' . ' style="width: ' . $width . ';' . __wcs('wppa-box-text') . __wcs('wppa-td') . '"' . ' >' . __('Position:', 'wp-photo-album-plus') . '</td>' . ($small ? '</tr><tr>' : '') . '<td' . ' class="wppa-box-text wppa-td"' . ' style="width: ' . $width . ';' . __wcs('wppa-box-text') . __wcs('wppa-td') . '"' . ' >' . '<select' . ' style="margin:0; padding:0; text-align:left; width:auto; "' . ' name="wppa-watermark-pos"' . ' id="wppa-watermark-pos"' . ' >' . wppa_watermark_pos_select() . '</select>' . '</td>' . '</tr>' . '</tbody>' . '</table>';
    }
    // Name
    if (wppa_switch('name_user')) {
        switch (wppa_opt('newphoto_name_method')) {
            case 'none':
                $expl = '';
                break;
            case '2#005':
                $expl = __('If you leave this blank, iptc tag 005 (Graphic name) will be used as photoname if available, else the original filename will be used as photo name.', 'wp-photo-album-plus');
                break;
            case '2#120':
                $expl = __('If you leave this blank, iptc tag 120 (Caption) will be used as photoname if available, else the original filename will be used as photo name.', 'wp-photo-album-plus');
                break;
            default:
                $expl = __('If you leave this blank, the original filename will be used as photo name.', 'wp-photo-album-plus');
        }
        $result .= '<h6>' . __('Photo name', 'wp-photo-album-plus') . '</h6>' . '<div style="clear:left;font-size:10px;" >' . $expl . '</div>' . '<input' . ' type="text"' . ' class="wppa-box-text"' . ' style="border:1 px solid ' . wppa_opt('bcolor_upload') . ';clear:left; padding:0; width:100%; ' . __wcs('wppa-box-text') . '"' . ' name="wppa-user-name"' . ' />';
    }
    // Description user fillable ?
    if (wppa_switch('desc_user')) {
        $desc = wppa_switch('apply_newphoto_desc_user') ? stripslashes(wppa_opt('newphoto_description')) : '';
        $result .= '<h6>' . __('Photo description', 'wp-photo-album-plus') . '</h6>' . '<textarea' . ' class="wppa-user-textarea wppa-box-text"' . ' style="border:1 px solid ' . wppa_opt('bcolor_upload') . ';clear:left; padding:0; height:120px; width:100%; ' . __wcs('wppa-box-text') . '"' . ' name="wppa-user-desc"' . ' >' . $desc . '</textarea>';
    } elseif (wppa_switch('apply_newphoto_desc_user')) {
        $result .= '<input' . ' type="hidden"' . ' value="' . esc_attr(wppa_opt('newphoto_description')) . '"' . ' name="wppa-user-desc"' . ' />';
    }
    // Custom fields
    if (wppa_switch('fe_custom_fields')) {
        for ($i = '0'; $i < '10'; $i++) {
            if (wppa_opt('custom_caption_' . $i)) {
                $result .= '<h6>' . __(wppa_opt('custom_caption_' . $i), 'wp-photo-album-plus') . ': ' . (wppa_switch('custom_visible_' . $i) ? '' : '&nbsp;<small><i>(&nbsp;' . __('hidden', 'wp-photo-album-plus') . '&nbsp;)</i></small>') . '</h6>' . '<input' . ' type="text"' . ' class="wppa-box-text"' . ' style="border:1 px solid ' . wppa_opt('bcolor_upload') . ';clear:left; padding:0; width:100%; ' . __wcs('wppa-box-text') . '"' . ' name="wppa-user-custom-' . $i . '"' . ' />';
            }
        }
    }
    // Tags
    if (wppa_switch('fe_upload_tags')) {
        // Prepare onclick action
        $onc = 'wppaPrevTags(\'wppa-sel-' . $yalb . '-' . $mocc . '\', \'wppa-inp-' . $yalb . '-' . $mocc . '\', \'wppa-upload-album-' . $mocc . '-' . $seqno . '\', \'wppa-prev-' . $yalb . '-' . $mocc . '\')';
        // Open the tag enter area
        $result .= '<div style="clear:both;" >';
        // Selection boxes 1..3
        for ($i = '1'; $i < '4'; $i++) {
            if (wppa_switch('up_tagselbox_on_' . $i)) {
                $result .= '<h6>' . __(wppa_opt('up_tagselbox_title_' . $i), 'wp-photo-album-plus') . '</h6>' . '<select' . ' id="wppa-sel-' . $yalb . '-' . $mocc . '-' . $i . '"' . ' name="wppa-user-tags-' . $i . '[]"' . (wppa_switch('up_tagselbox_multi_' . $i) ? ' multiple' : '') . ' onchange="' . $onc . '"' . ' >';
                if (wppa_opt('up_tagselbox_content_' . $i)) {
                    // List of tags supplied
                    $tags = explode(',', wppa_opt('up_tagselbox_content_' . $i));
                    $result .= '<option value="" >&nbsp;</option>';
                    if (is_array($tags)) {
                        foreach ($tags as $tag) {
                            $result .= '<option class="wppa-sel-' . $yalb . '-' . $mocc . '" value="' . urlencode($tag) . '">' . $tag . '</option>';
                        }
                    }
                } else {
                    // All existing tags
                    $tags = wppa_get_taglist();
                    $result .= '<option value="" >&nbsp;</option>';
                    if (is_array($tags)) {
                        foreach ($tags as $tag) {
                            $result .= '<option class="wppa-sel-' . $yalb . '-' . $mocc . '" value="' . urlencode($tag['tag']) . '">' . $tag['tag'] . '</option>';
                        }
                    }
                }
                $result .= '</select><div style="clear:both;" ></div>';
            }
        }
        // New tags
        if (wppa_switch('up_tag_input_on')) {
            $result .= '<h6>' . __(wppa_opt('up_tag_input_title'), 'wp-photo-album-plus') . '</h6>' . '<input' . ' id="wppa-inp-' . $yalb . '-' . $mocc . '"' . ' type="text"' . ' class="wppa-box-text "' . ' style="padding:0; width:100%; ' . __wcs('wppa-box-text') . '"' . ' name="wppa-new-tags"' . ' onchange="' . $onc . '"' . ' />';
        }
        // Preview area
        if (wppa_switch('up_tag_preview')) {
            $result .= '<h6>' . __('Preview tags:', 'wp-photo-album-plus') . ' <small id="wppa-prev-' . $yalb . '-' . $mocc . '"></small>' . '</h6>' . '<script type="text/javascript" >jQuery( document ).ready(function() {' . $onc . '})</script>';
        }
        // Close tag enter area
        $result .= '</div>';
    }
    /* The Blogit section */
    if (($where == 'widget' || $where == 'uploadbox') && current_user_can('edit_posts') && wppa_switch('blog_it')) {
        $result .= '<div style="margin-top:6px;" >' . '<input' . ' type="button"' . ' value="' . esc_attr(__('Blog it?', 'wp-photo-album-plus')) . '"' . ' onclick="jQuery(\'#wppa-blogit-' . $yalb . '-' . $mocc . '\').trigger(\'click\')"' . ' />' . ' <input' . ' type="checkbox"' . ' id="wppa-blogit-' . $yalb . '-' . $mocc . '"' . ' name="wppa-blogit"' . ' style="display:none;"' . ' onchange="if ( jQuery(this).attr(\'checked\') ) { ' . 'jQuery(\'#blog-div-' . $yalb . '-' . $mocc . '\').css(\'display\',\'block\'); ' . 'jQuery(\'#wppa-user-submit-' . $yalb . '-' . $mocc . '\').attr(\'value\', \'' . esc_js(__('Upload and blog', 'wp-photo-album-plus')) . '\'); ' . '} ' . 'else { ' . 'jQuery(\'#blog-div-' . $yalb . '-' . $mocc . '\').css(\'display\',\'none\'); ' . 'jQuery(\'#wppa-user-submit-' . $yalb . '-' . $mocc . '\').attr(\'value\', \'' . esc_js(__('Upload photo', 'wp-photo-album-plus')) . '\'); ' . '} "' . ' />' . '<div' . ' id="blog-div-' . $yalb . '-' . $mocc . '"' . ' style="display:none;"' . ' />' . '<h6>' . __('Post title:', 'wp-photo-album-plus') . '</h6>' . '<input' . ' id="wppa-blogit-title-' . $yalb . '-' . $mocc . '"' . ' type="text"' . ' class="wppa-box-text "' . ' style="padding:0; width:100%; ' . __wcs('wppa-box-text') . '"' . ' name="wppa-post-title"' . ' />' . '<h6>' . __('Text BEFORE the image:', 'wp-photo-album-plus') . '</h6>' . '<textarea' . ' id="wppa-blogit-pretext-' . $yalb . '-' . $mocc . '"' . ' name="wppa-blogit-pretext"' . ' class=wppa-user-textarea wppa-box-text"' . ' style="border:1 px solid ' . wppa_opt('bcolor_upload') . ';clear:left; padding:0; height:120px; width:100%; ' . __wcs('wppa-box-text') . '"' . ' >' . '</textarea>' . '<h6>' . __('Text AFTER the image:', 'wp-photo-album-plus') . '</h6>' . '<textarea' . ' id="wppa-blogit-posttext-' . $yalb . '-' . $mocc . '"' . ' name="wppa-blogit-posttext"' . ' class=wppa-user-textarea wppa-box-text"' . ' style="border:1 px solid ' . wppa_opt('bcolor_upload') . ';clear:left; padding:0; height:120px; width:100%; ' . __wcs('wppa-box-text') . '"' . '>' . '</textarea>' . '</div>' . '</div>';
    }
    /* start submit section */
    // Onclick submit verify album is known
    if (!$alb) {
        $onclick = ' onclick="if ( document.getElementById( \'wppa-upload-album-' . $mocc . '-' . $seqno . '\' ).value == 0 )' . ' {alert( \'' . esc_js(__('Please select an album and try again', 'wp-photo-album-plus')) . '\' );return false;}"';
    } else {
        $onclick = '';
    }
    // The submit button
    $result .= '<div style="height:6px;;clear:both;" ></div>' . '<input' . ' type="submit"' . ' id="wppa-user-submit-' . $yalb . '-' . $mocc . '"' . $onclick . ' style="display:none; margin: 6px 0; float:right;"' . ' class="wppa-user-submit"' . ' name="wppa-user-submit-' . $yalb . '-' . $mocc . '" value="' . esc_attr(__('Upload photo', 'wp-photo-album-plus')) . '"' . ' />' . '<div style="height:6px;clear:both;"></div>';
    // if ajax: progression bar
    if ($ajax_upload) {
        $result .= '<div' . ' id="progress-' . $yalb . '-' . $mocc . '"' . ' class="wppa-progress "' . ' style="width:100%;border-color:' . wppa_opt('bcolor_upload') . '"' . ' >' . '<div id="bar-' . $yalb . '-' . $mocc . '" class="wppa-bar" ></div>' . '<div id="percent-' . $yalb . '-' . $mocc . '" class="wppa-percent" >0%</div >' . '</div>' . '<div id="message-' . $yalb . '-' . $mocc . '" class="wppa-message" ></div>';
    }
    /* End submit section */
    // Done
    $result .= '</form></div>';
    // Ajax upload script
    if ($ajax_upload) {
        $result .= '<script>' . 'jQuery(document).ready(function() {

					var options = {
						beforeSend: function() {
							jQuery("#progress-' . $yalb . '-' . $mocc . '").show();
							//clear everything
							jQuery("#bar-' . $yalb . '-' . $mocc . '").width(\'0%\');
							jQuery("#message-' . $yalb . '-' . $mocc . '").html("");
							jQuery("#percent-' . $yalb . '-' . $mocc . '").html("");
						},
						uploadProgress: function(event, position, total, percentComplete) {
							jQuery("#bar-' . $yalb . '-' . $mocc . '").width(percentComplete+\'%\');
							if ( percentComplete < 95 ) {
								jQuery("#percent-' . $yalb . '-' . $mocc . '").html(percentComplete+\'%\');
							}
							else {
								jQuery("#percent-' . $yalb . '-' . $mocc . '").html(\'Processing...\');
							}
						},
						success: function() {
							jQuery("#bar-' . $yalb . '-' . $mocc . '").width(\'100%\');
							jQuery("#percent-' . $yalb . '-' . $mocc . '").html(\'Done!\');
						},
						complete: function(response) {
							jQuery("#message-' . $yalb . '-' . $mocc . '").html( \'<span style="font-size: 10px;" >\'+response.responseText+\'</span>\' );' . ($where == 'thumb' ? 'document.location.reload(true)' : '') . '
						},
						error: function() {
							jQuery("#message-' . $yalb . '-' . $mocc . '").html( \'<span style="color: red;" >' . __('ERROR: unable to upload files.', 'wp-photo-album-plus') . '</span>\' );
						}
					};

					jQuery("#wppa-uplform-' . $yalb . '-' . $mocc . '").ajaxForm(options);
				});
			</script>';
    }
    // Close wrapper
    //	$result .= '</div>';
    return $result;
}