function wppa_load_footer()
{
    global $wpdb;
    global $wppa_session;
    echo '
		<!-- start WPPA+ Footer data -->
		';
    // Do they use our lightbox?
    if (wppa_opt('lightbox_name') == 'wppa') {
        $fontsize_lightbox = wppa_opt('fontsize_lightbox') ? wppa_opt('fontsize_lightbox') : '10';
        $d = wppa_switch('ovl_show_counter') ? 1 : 0;
        $ovlh = wppa_opt('ovl_txt_lines') == 'auto' ? 'auto' : (wppa_opt('ovl_txt_lines') + $d) * ($fontsize_lightbox + 2);
        $txtcol = wppa_opt('ovl_theme') == 'black' ? '#a7a7a7' : '#272727';
        $dark = wppa('is_mobile') ? '0.1' : '0.1';
        // The lightbox overlay background
        echo '<div' . ' id="wppa-overlay-bg"' . ' style="' . 'text-align:center;' . 'display:none;' . 'position:fixed;' . 'top:0;' . 'left:0;' . 'z-index:100090;' . 'width:100%;' . 'height:2048px;' . 'background-color:' . wppa_opt('ovl_bgcolor') . ';' . '"' . ' onclick="wppaOvlOnclick(event)"' . ' >';
        // Display legenda
        if (wppa_switch('ovl_show_legenda') && !wppa('is_mobile')) {
            echo '<div' . ' id="wppa-ovl-legenda-1"' . ' onmouseover="jQuery(this).css(\'visibility\',\'visible\');"' . ' onmouseout="jQuery(this).css(\'visibility\',\'hidden\');"' . ' style="' . 'position:absolute;' . 'left:0;' . 'top:0;' . 'background-color:' . wppa_opt('ovl_theme') . ';' . 'color:' . $txtcol . ';' . 'visibility:visible;' . '"' . ' >
					' . __('Press f for fullscreen.', 'wp-photo-album-plus') . '
				</div>';
        }
        // The 'exit' icon
        echo '<div' . ' id="wppa-exit-btn"' . ' style="height:48px;z-index:100098;position:fixed;top:0;right:0;opacity:0.75;"' . ' onclick="wppaOvlHide()"' . ' onmouseover="jQuery(this).stop().fadeTo(300,1);"' . ' onmouseout="jQuery(this).stop().fadeTo(300,' . $dark . ');"' . ' >' . wppa_get_svghtml('Exit', '48px', true, true, '0', '0', '0', '0') . '</div>' . '<script>' . 'jQuery(\'#wppa-exit-btn\').on(\'touchstart\',function(){jQuery(\'#wppa-exit-btn\').stop().fadeTo(300,1);});' . 'jQuery(\'#wppa-exit-btn\').on(\'touchend\',function(){jQuery(\'#wppa-exit-btn\').stop().fadeTo(300,' . $dark . ');});' . '</script>';
        // The 'fullscreen' icon
        echo '<div' . ' id="wppa-fulls-btn"' . ' style="height:48px;z-index:100092;position:fixed;top:0;right:48px;opacity:0.75;"' . ' onclick="wppaOvlFull()"' . ' onmouseover="jQuery(this).stop().fadeTo(300,1);"' . ' onmouseout="jQuery(this).stop().fadeTo(300,' . $dark . ');"' . ' >' . wppa_get_svghtml('Full-Screen', '48px', true, true, '0', '0', '0', '0') . '</div>' . '<script>' . 'jQuery(\'#wppa-fulls-btn\').on(\'touchstart\',function(){jQuery(\'#wppa-fulls-btn\').stop().fadeTo(300,1);});' . 'jQuery(\'#wppa-fulls-btn\').on(\'touchend\',function(){jQuery(\'#wppa-fulls-btn\').stop().fadeTo(300,' . $dark . ');});' . '</script>';
        // Close lightbox overlay background
        echo '</div>';
        // The Lightbox Image container
        echo '<div' . ' id="wppa-overlay-ic"' . ' style="' . 'position:fixed;' . 'top:50%;' . 'left:50%;' . 'z-index:100095;' . 'opacity:1;' . 'box-shadow:none;' . 'box-sizing:content-box;' . '"' . ' >' . '</div>';
        // The Spinner image
        echo '<img' . ' id="wppa-overlay-sp"' . ' alt="spinner"' . ' style="' . 'position:fixed;' . 'top:50%;' . 'margin-top:-16px;' . 'left:50%;' . 'margin-left:-16px;' . 'z-index:100100;' . 'opacity:1;' . 'visibility:hidden;' . 'box-shadow:none;' . '"' . ' src="' . wppa_get_imgdir() . 'loading.gif"' . ' />';
        // The init vars
        echo '
		<script type="text/javascript">
			jQuery("#wppa-overlay-bg").css({height:window.innerHeight});
			wppaOvlModeInitial = "' . (wppa('is_mobile') ? wppa_opt('ovl_mode_initial_mob') : wppa_opt('ovl_mode_initial')) . '";
			wppaOvlTxtHeight = "' . $ovlh . '";
			wppaOvlOpacity = ' . wppa_opt('ovl_opacity') / 100 . ';
			wppaOvlOnclickType = "' . wppa_opt('ovl_onclick') . '";
			wppaOvlTheme = "' . wppa_opt('ovl_theme') . '";
			wppaOvlAnimSpeed = ' . wppa_opt('ovl_anim') . ';
			wppaOvlSlideSpeed = ' . wppa_opt('ovl_slide') . ';
			wppaVer4WindowWidth = 800;
			wppaVer4WindowHeight = 600;
			wppaOvlShowCounter = ' . (wppa_switch('ovl_show_counter') ? 'true' : 'false') . ';
			' . (wppa_opt('fontfamily_lightbox') ? 'wppaOvlFontFamily = "' . wppa_opt('fontfamily_lightbox') . '"' : '') . '
			wppaOvlFontSize = "' . $fontsize_lightbox . '";
			' . (wppa_opt('fontcolor_lightbox') ? 'wppaOvlFontColor = "' . wppa_opt('fontcolor_lightbox') . '"' : '') . '
			' . (wppa_opt('fontweight_lightbox') ? 'wppaOvlFontWeight = "' . wppa_opt('fontweight_lightbox') . '"' : '') . '
			' . (wppa_opt('fontsize_lightbox') ? 'wppaOvlLineHeight = "' . (wppa_opt('fontsize_lightbox') + '2') . '"' : '') . '
			wppaOvlFullLegenda = "' . __('Keys: f = next mode; q,x = exit; p = previous, n = next, s = start/stop, d = dismiss this notice.', 'wp-photo-album-plus') . '";
			wppaOvlFullLegendaSingle = "' . __('Keys: f = next mode; q,x = exit; d = dismiss this notice.', 'wp-photo-album-plus') . '";
			wppaOvlVideoStart = ' . (wppa_switch('ovl_video_start') ? 'true' : 'false') . ';
			wppaOvlAudioStart = ' . (wppa_switch('ovl_audio_start') ? 'true' : 'false') . ';
			wppaOvlShowLegenda = ' . (wppa_switch('ovl_show_legenda') && !wppa('is_mobile') ? 'true' : 'false') . ';
			wppaOvlShowStartStop = ' . (wppa_switch('ovl_show_startstop') ? 'true' : 'false') . ';
			wppaToggleFullScreen = "' . __('Toggle fullscreen', 'wp-photo-album-plus') . '";
			wppaIsMobile = ' . (wppa_is_mobile() ? 'true' : 'false') . ';
		</script>
		';
    }
    // The photo views cache
    echo '
	<script type="text/javascript">';
    if (isset($wppa_session['photo'])) {
        foreach (array_keys($wppa_session['photo']) as $p) {
            echo '
				wppaPhotoView[' . $p . '] = true;';
        }
    }
    echo '
	</script>
<!-- end WPPA+ Footer data -->
';
    // Debugging, show queries
    wppa_dbg_cachecounts('print');
    // Debugging, show active plugins
    if (wppa('debug')) {
        $plugins = get_option('active_plugins');
        wppa_dbg_msg('Active Plugins');
        foreach ($plugins as $plugin) {
            wppa_dbg_msg($plugin);
        }
        wppa_dbg_msg('End Active Plugins');
    }
    echo '
<!-- Nonce for various wppa actions -->';
    // Nonce field for Ajax bump view counter from lightbox, and rating
    wp_nonce_field('wppa-check', 'wppa-nonce', false, true);
    echo '
<!-- Do user upload -->';
    // Do the upload if required and not yet done
    wppa_user_upload();
    // Done
    echo '
<!-- Done user upload -->';
}
Exemplo n.º 2
0
function wppa_cache_thumb($id, $data = '')
{
    global $wpdb;
    static $thumb;
    static $thumb_cache_2;
    // $id?
    if (!$id) {
        return false;
    }
    // Invalidate ?
    if ($id == 'invalidate') {
        if (isset($thumb_cache_2[$data])) {
            unset($thumb_cache_2[$data]);
        }
        $thumb = false;
        return false;
    }
    // Add ?
    if ($id == 'add') {
        if (!$data) {
            // Nothing to add
            return false;
        } elseif (isset($data['id'])) {
            // Add a single thumb to 2nd level cache
            if (count($data) < 31) {
                wppa_log('Err', 'Attempt to cache add incomplete photo item ' . $data['id'] . '. Only ' . count($data) . ' items supplied.');
                return false;
            }
            $thumb_cache_2[$data['id']] = $data;
            // Looks valid
        } elseif (count($data) > 10000) {
            return false;
            // Too many, may cause out of memory error
        } else {
            foreach ($data as $thumb) {
                // Add multiple
                if (isset($thumb['id'])) {
                    // Looks valid
                    if (count($thumb) < 31) {
                        wppa_log('Err', 'Attempt to cache add incomplete photo item ' . $thumb['id'] . '. Only ' . count($thumb) . ' items supplied.');
                        return false;
                    }
                    $thumb_cache_2[$thumb['id']] = $thumb;
                }
            }
        }
        return false;
    }
    // Count ?
    if ($id == 'count') {
        if (is_array($thumb_cache_2)) {
            return count($thumb_cache_2);
        } else {
            return false;
        }
    }
    // Error in arg?
    if (!wppa_is_int($id) || $id < '1') {
        wppa_dbg_msg('Invalid arg wppa_cache_thumb(' . $id . ')', 'red');
        $thumb = false;
        wppa('current_photo', false);
        return false;
    }
    // In first level cache?
    if (isset($thumb['id']) && $thumb['id'] == $id) {
        wppa_dbg_cachecounts('photohit');
        wppa('current_photo', $thumb);
        return $thumb;
    }
    // In  second level cache?
    if (!empty($thumb_cache_2)) {
        if (in_array($id, array_keys($thumb_cache_2))) {
            $thumb = $thumb_cache_2[$id];
            wppa('current_photo', $thumb);
            wppa_dbg_cachecounts('photohit');
            return $thumb;
        }
    }
    // Not in cache, do query
    $thumb = $wpdb->get_row($wpdb->prepare("SELECT * FROM `" . WPPA_PHOTOS . "` WHERE `id` = %s", $id), ARRAY_A);
    wppa_dbg_cachecounts('photomis');
    // Found one?
    if ($thumb) {
        // Store in second level cache
        $thumb_cache_2[$id] = $thumb;
        wppa('current_photo', $thumb);
        return $thumb;
    } else {
        wppa_dbg_msg('Photo ' . $id . ' does not exist', 'red');
        wppa('current_photo', false);
        return false;
    }
}