function wppa_do_filmthumb($id, $idx, $do_for_feed = false, $glue = false) { $thumb = wppa_cache_thumb($id); $result = ''; $src = wppa_fix_poster_ext(wppa_get_thumb_path($thumb['id']), $thumb['id']); $max_size = wppa_opt('film_thumbsize'); if (wppa_in_widget()) { $max_size /= 2; } $com_alt = wppa('is_comten') && wppa_switch('comten_alt_display') && !wppa_in_widget(); $imgattr_a = wppa_get_imgstyle_a($thumb['id'], $src, $max_size, 'optional', 'fthumb'); $imgstyle = $imgattr_a['style']; $imgwidth = $imgattr_a['width']; $imgheight = $imgattr_a['height']; $cursor = $imgattr_a['cursor']; $url = wppa_fix_poster_ext(wppa_get_thumb_url($thumb['id'], '', $imgwidth, $imgheight), $thumb['id']); $furl = str_replace('/thumbs', '', $url); $events = wppa_get_imgevents('film', $thumb['id'], 'nopopup', $idx); $thumbname = wppa_get_photo_name($thumb['id']); $target = wppa_switch('film_blank') || $thumb['linktarget'] == '_blank' ? 'target="_blank" ' : ''; $psotitle = $thumb['linktitle'] ? 'title="' . esc_attr($thumb['linktitle']) . '" ' : ''; $psourl = wppa_switch('film_overrule') && $thumb['linkurl'] ? 'href="' . $thumb['linkurl'] . '" ' . $target . $psotitle : ''; $imgalt = wppa_get_imgalt($thumb['id']); if (wppa_opt('film_linktype') == 'lightbox') { // $title = esc_attr( wppa_zoom_in( $thumb['id'] ) ); } else { $events .= ' onclick="wppaGotoKeepState( ' . wppa('mocc') . ', ' . $idx . ' )"'; $events .= ' ondblclick="wppaStartStop( ' . wppa('mocc') . ', -1 )"'; } if (is_feed()) { if ($do_for_feed) { $style_a = wppa_get_imgstyle_a($thumb['id'], $src, '100', '4', 'thumb'); $style = $style_a['style']; $result .= '<a href="' . get_permalink() . '">' . '<img' . ' src="' . $url . '"' . ' ' . $imgalt . ' title="' . $thumbname . '"' . ' style="' . $style . '"' . ' />' . '</a>'; } } else { // If ! $do_for_feed: pre-or post-ambule. To avoid dup id change it in that case $tmp = $do_for_feed ? 'film' : 'pre'; $style = $glue ? 'style="' . wppa_get_thumb_frame_style($glue, 'film') . '"' : 'style="' . wppa_get_thumb_frame_style(false, 'film') . '"'; $result .= '<div' . ' id="' . $tmp . '_wppatnf_' . wppa_encrypt_photo($thumb['id']) . '_' . wppa('mocc') . '"' . ' class="thumbnail-frame"' . ' ' . $style . ' >'; if ($psourl) { // True only when pso activated and data present $result .= '<a ' . $psourl . '>'; // $psourl contains url, target and title } elseif (wppa_opt('film_linktype') == 'lightbox' && $tmp == 'film') { $title = wppa_get_lbtitle('slide', $thumb['id']); $videohtml = esc_attr(wppa_get_video_body($thumb['id'])); $audiohtml = esc_attr(wppa_get_audio_body($thumb['id'])); $result .= '<a href="' . $furl . '"' . ($videohtml ? ' data-videohtml="' . $videohtml . '"' . ' data-videonatwidth="' . wppa_get_videox($thumb['id']) . '"' . ' data-videonatheight="' . wppa_get_videoy($thumb['id']) . '"' : '') . ($audiohtml ? ' data-audiohtml="' . $audiohtml . '"' : '') . ' ' . wppa('rel') . '="' . wppa_opt('lightbox_name') . '[occ' . wppa('mocc') . ']"' . ($title ? ' ' . wppa('lbtitle') . '="' . $title . '"' : '') . ' >'; } if ($tmp == 'pre' && wppa_opt('film_linktype') == 'lightbox') { $cursor = 'cursor:default;'; } if ($tmp == 'film' && !$com_alt && !wppa_cdn('front') && !wppa_switch('lazy_or_htmlcomp')) { $result .= '<!--'; } if (wppa_is_video($thumb['id'])) { $result .= wppa_get_video_html(array('id' => $thumb['id'], 'width' => $imgattr_a['width'], 'height' => $imgattr_a['height'], 'controls' => false, 'margin_top' => $imgattr_a['margin-top'], 'margin_bottom' => $imgattr_a['margin-bottom'], 'cursor' => $imgattr_a['cursor'], 'events' => $events, 'tagid' => 'wppa-' . $tmp . '-' . $idx . '-' . wppa('mocc'))); } else { $result .= '<img' . ' id="wppa-' . $tmp . '-' . $idx . '-' . wppa('mocc') . '"' . ' class="wppa-' . $tmp . '-' . wppa('mocc') . '"' . ' src="' . $url . '"' . ' ' . $imgalt . ' style="' . $imgstyle . $cursor . '"' . ' ' . $events . ' data-title="' . ($psourl ? esc_attr($thumb['linktitle']) : '') . '"' . ' />'; } if ($tmp == 'film' && !$com_alt && !wppa_cdn('front') && !wppa_switch('lazy_or_htmlcomp')) { $result .= '-->'; } if ($psourl) { // True only when pso activated and data present $result .= '</a>'; // $psourl contains url, target and title } elseif (wppa_opt('film_linktype') == 'lightbox' && $tmp == 'film') { $result .= '</a>'; } $result .= '</div>'; } wppa_out($result); }
function wppa_get_rating_range_html($id = 0, $is_lightbox = false, $class = '') { global $wpdb; // Not on a feed if (is_feed()) { return ''; } // On lightbox: only if in visibility settings set. if ($is_lightbox) { if (!wppa_switch('ovl_rating')) { return ''; } } if ($id) { $wait_text = wppa_get_rating_wait_text($id, wppa_get_user()); if ($wait_text) { return '<span class="' . $class . '" style="color:red" >' . $wait_text . '</span>'; } if (wppa_get_photo_item($id, 'owner') == wppa_get_user() && !wppa_switch('allow_owner_votes')) { return '<span class="' . $class . '" >' . __('Sorry, you can not rate your own photos', 'wp-photo-album-plus') . '</span>'; } $mylast = $wpdb->get_row($wpdb->prepare('SELECT * FROM `' . WPPA_RATING . '` WHERE `photo` = %s AND `user` = %s ORDER BY `id` DESC LIMIT 1', $id, wppa_get_user()), ARRAY_A); if ($mylast && !wppa_switch('rating_change') && !wppa_switch('rating_multi')) { return '<span class="' . $class . '" >' . __('Sorry, you can rate a photo only once', 'wp-photo-album-plus') . '</span>'; } } // Mphoto, xphoto and lightbox use a different js function than slideshow. // In slideshow the id is not known and retrieved from _wppaCurIdx[mocc]. // There is also a difference in css. $idorlb = $id || $is_lightbox; // If on xphoto, reload after $reload = wppa('is_xphoto') ? 'true' : 'false'; $result = ''; $fs = wppa_opt('fontsize_nav'); if ($fs) { $fs += 3; } else { $fs = '15'; } // iconsize = fontsize+3, Default to 15 $dh = $fs + '6'; $size = 'font-size:' . $fs . 'px;'; // Open the rating box $result .= '<div' . ' id="wppa-rating-' . wppa('mocc') . '"' . ' class="' . ($idorlb ? $class : 'wppa-box wppa-nav wppa-nav-text') . '"' . ' style="' . ($idorlb ? 'padding:4px;' : __wcs('wppa-box') . __wcs('wppa-nav') . __wcs('wppa-nav-text')) . $size . ' text-align:center;"' . '> '; // Graphic display ? if (wppa_opt('rating_display_type') == 'graphic') { if (wppa_opt('rating_max') == '5') { $r['1'] = __('very low', 'wp-photo-album-plus'); $r['2'] = __('low', 'wp-photo-album-plus'); $r['3'] = __('average', 'wp-photo-album-plus'); $r['4'] = __('high', 'wp-photo-album-plus'); $r['5'] = __('very high', 'wp-photo-album-plus'); } else { for ($i = '1'; $i <= '10'; $i++) { $r[$i] = $i; } } $style = 'height:' . $fs . 'px; margin:0 0 -3px 0; padding:0; box-shadow:none; display:inline;background-color:transparent;'; $icon = 'star.ico'; // Display avg rating if (wppa_switch('show_avg_rating')) { if ($id) { $avgrat = wppa_get_rating_by_id($id, 'nolabel'); $opac = array(); $i = '1'; while ($i <= wppa_opt('rating_max')) { if ($avgrat >= $i) { $opac[$i] = 'opacity:1;'; } else { if ($avgrat <= $i - '1') { $opac[$i] = 'opacity:0.2;'; } else { $opac[$i] = 'opacity:' . (0.2 + 0.8 * ($avgrat - $i + '1')); } } $i++; } } $result .= '<span' . ' id="wppa-avg-rat-' . wppa('mocc') . '"' . ' class="wppa-rating-label"' . ' >' . __('Average rating', 'wp-photo-album-plus') . '</span> '; $i = '1'; while ($i <= wppa_opt('rating_max')) { $result .= '<img' . ' id="wppa-avg-' . wppa('mocc') . '-' . $i . '"' . ' class="wppa-avg-' . wppa('mocc') . '-' . $i . ' wppa-avg-' . wppa('mocc') . ' no-shadow"' . ' style="' . $style . ($id ? $opac[$i] : '') . '"' . ' src="' . wppa_get_imgdir() . $icon . '"' . ' alt=" ' . $i . '"' . ' title="' . __('Average rating', 'wp-photo-album-plus') . ': ' . $r[$i] . '"' . ' />'; $i++; } } $result .= '<img' . ' id="wppa-filler-' . wppa('mocc') . '"' . ' src="' . wppa_get_imgdir() . 'transp.png"' . ' alt="f"' . ' style="width:' . wppa_opt('ratspacing') . 'px; height:15px; box-shadow:none; padding:0; margin:0; border:none;"' . ' />'; // Display my rating // Logged in or don't care if (!wppa_switch('rating_login') || is_user_logged_in()) { // Show dislike icon? $pad = round((wppa_opt('ratspacing') - $fs) / 2); if ($pad < 5) { $pad = '5'; } if (wppa_opt('dislike_mail_every')) { $confirm = esc_attr(str_replace('"', "'", __('Are you sure you want to mark this image as inappropriate?', 'wp-photo-album-plus'))); $result .= '<img' . ' id="wppa-dislike-' . wppa('mocc') . '"' . ' title="' . __('Click this if you do NOT like this image!', 'wp-photo-album-plus') . '"' . ' src="' . wppa_get_imgdir() . 'thumbdown.png"' . ' alt="d"' . ' style="height:' . $fs . 'px; margin:0 0 -3px 0; padding:0 ' . $pad . 'px; box-shadow:none; display:inline;"' . ' class="no-shadow"' . ' onmouseover="jQuery(this).stop().fadeTo(100, 1.0)"' . ' onmouseout="jQuery(this).stop().fadeTo(100, wppaStarOpacity)"' . ' onclick="'; if ($idorlb) { $result .= 'if (confirm(\'' . $confirm . '\')) { wppaOvlRateIt( \'' . wppa_encrypt_photo($id) . '\', -1, ' . ($id ? wppa('mocc') : '0') . ' ); }'; } else { $result .= 'if (confirm(\'' . $confirm . '\')) { wppaRateIt( ' . wppa('mocc') . ', -1); }'; } $result .= '"' . ' />'; if ($idorlb) { $mylast = wppa_get_my_last_vote($id); if ($mylast == '-1') { $result .= '<script type="text/javascript" >jQuery(\'#wppa-dislike-' . wppa('mocc') . '\').css(\'display\'. \'none\');</script>'; } else { $result .= '<script type="text/javascript" >jQuery(\'#wppa-dislike-' . wppa('mocc') . '\').fadeTo(100,' . wppa_opt('star_opacity') / 100 . ');</script>'; } } if (wppa_switch('dislike_show_count')) { $result .= '<span' . ' id="wppa-discount-' . wppa('mocc') . '"' . ' style="cursor:default"' . ' title="' . __('Number of people who marked this photo as inappropriate', 'wp-photo-album-plus') . '"' . ' >' . '</span>'; } } // Text left if no avg rating if (!wppa_switch('show_avg_rating')) { $result .= __('My rating', 'wp-photo-album-plus') . ': '; } // Display the my rating stars if ($id) { $myavgrat = wppa_get_my_rating_by_id($id, 'nolabel'); $opac = array(); $i = '1'; while ($i <= wppa_opt('rating_max')) { if ($myavgrat >= $i) { $opac[$i] = 'opacity:1;'; } else { if ($myavgrat <= $i - '1') { $opac[$i] = 'opacity:0.2;'; } else { $opac[$i] = 'opacity:' . (0.2 + 0.8 * ($myavgrat - $i + '1')); } } $i++; } } $i = '1'; while ($i <= wppa_opt('rating_max')) { $result .= '<img' . ' id="wppa-rate-' . wppa('mocc') . '-' . $i . '"' . ' class="wppa-rate-' . wppa('mocc') . '-' . $i . ' wppa-rate-' . wppa('mocc') . ' no-shadow"' . ' style="' . $style . ($id ? $opac[$i] : '') . '"' . ' src="' . wppa_get_imgdir() . $icon . '"' . ' alt="' . $i . '"' . ' title="' . __('My rating', 'wp-photo-album-plus') . ': ' . $r[$i] . '"' . ($id ? ' onmouseover="wppaOvlFollowMe(' . wppa('mocc') . ', ' . $i . ', ' . $myavgrat . ' )"' . ' onmouseout="wppaOvlLeaveMe(' . wppa('mocc') . ', ' . $i . ', ' . $myavgrat . ' )"' : ' onmouseover="wppaFollowMe(' . wppa('mocc') . ', ' . $i . ')"' . ' onmouseout="wppaLeaveMe(' . wppa('mocc') . ', ' . $i . ')"') . ($idorlb ? ' onclick="wppaOvlRateIt(\'' . wppa_encrypt_photo($id) . '\', ' . $i . ', ' . ($id ? wppa('mocc') : '0') . ', ' . $reload . ' )"' : ' onclick="wppaRateIt(' . wppa('mocc') . ', ' . $i . ')"') . ' />'; $i++; } // Text right if avg rating diaplayed if (wppa_switch('show_avg_rating')) { $result .= ' ' . '<span' . ' id="wppa-my-rat-' . wppa('mocc') . '" ' . ' class="wppa-rating-label"' . '>' . __('My rating', 'wp-photo-album-plus') . '</span>'; } } else { if (wppa_switch('login_links')) { $result .= sprintf(__('You must <a href="%s">login</a> to vote', 'wp-photo-album-plus'), site_url('wp-login.php', 'login')); } else { $result .= __('You must login to vote', 'wp-photo-album-plus'); } } } elseif (wppa_opt('rating_display_type') == 'numeric') { // Display avg rating if (wppa_switch('show_avg_rating')) { $result .= __('Average rating', 'wp-photo-album-plus') . ': ' . '<span id="wppa-numrate-avg-' . wppa('mocc') . '"></span>' . ' •'; } // Display my rating // Logged in or don't care if (!wppa_switch('rating_login') || is_user_logged_in()) { // Show dislike icon? $pad = round((wppa_opt('ratspacing') - $fs) / 2); if ($pad < 5) { $pad = '5'; } if (wppa_opt('dislike_mail_every')) { $result .= '<div' . ' id="wppa-dislike-imgdiv-' . wppa('mocc') . '"' . ' style="display:inline"' . ' >'; $confirm = esc_attr(str_replace('"', "'", __('Are you sure you want to mark this image as inappropriate?', 'wp-photo-album-plus'))); $result .= '<img' . ' id="wppa-dislike-' . wppa('mocc') . '"' . ' title="' . __('Click this if you do NOT like this image!', 'wp-photo-album-plus') . '"' . ' src="' . wppa_get_imgdir() . 'thumbdown.png"' . ' alt="d"' . ' style="height:' . $fs . 'px; margin:0 0 -3px 0; padding:0 ' . $pad . 'px; box-shadow:none; display:inline;"' . ' class="no-shadow"' . ' onmouseover="jQuery(this).stop().fadeTo(100, 1.0)"' . ' onmouseout="jQuery(this).stop().fadeTo(100, wppaStarOpacity)"' . ' onclick="'; if ($idorlb) { $result .= 'if (confirm(\'' . $confirm . '\')) { wppaOvlRateIt( \'' . wppa_encrypt_photo($id) . '\', -1, ' . ($id ? wppa('mocc') : '0') . ' ); }'; } else { $result .= 'if (confirm(\'' . $confirm . '\')) { wppaRateIt( ' . wppa('mocc') . ', -1); }'; } $result .= '"' . ' />'; $result .= '</div>'; if (wppa_switch('dislike_show_count')) { $result .= '<span' . ' id="wppa-discount-' . wppa('mocc') . '"' . ' style="cursor:default"' . ' title="' . __('Number of people who marked this photo as inappropriate', 'wp-photo-album-plus') . '"' . ' >' . '</span>'; } } $result .= ' ' . __('My rating:', 'wp-photo-album-plus'); $result .= '<span id="wppa-numrate-mine-' . wppa('mocc') . '" ></span>'; } else { if (wppa_switch('login_links')) { $result .= sprintf(__('You must <a href="%s">login</a> to vote', 'wp-photo-album-plus'), site_url('wp-login.php', 'login')); } else { $result .= __('You must login to vote', 'wp-photo-album-plus'); } } } // Close rating box $result .= '</div>'; return $result; }
function wppa_get_lbtitle($type, $id) { if (!is_numeric($id) || $id < '1') { wppa_dbg_msg('Invalid arg wppa_get_lbtitle( ' . $id . ' )', 'red'); } $thumb = wppa_cache_thumb($id); $do_download = wppa_is_video($id) ? false : wppa_switch('art_monkey_on_lightbox'); if ($type == 'xphoto') { $type = 'mphoto'; } $do_name = wppa_switch('ovl_' . $type . '_name') || wppa_switch('ovl_add_owner'); $do_desc = wppa_switch('ovl_' . $type . '_desc'); $do_sm = wppa_switch('share_on_lightbox'); $result = ''; if ($do_download) { if (wppa_opt('art_monkey_display') == 'button') { $result .= '<input' . ' type="button"' . ' title="' . __('Download', 'wp-photo-album-plus') . '"' . ' style="cursor:pointer; margin-bottom:0px; max-width:500px;"' . ' class="wppa-download-button wppa-ovl-button"' . ' onclick="wppaAjaxMakeOrigName( ' . wppa('mocc') . ', \'' . wppa_encrypt_photo($id) . '\' );"' . ' value="' . rtrim(__('Download', 'wp-photo-album-plus') . ' ' . wppa_get_photo_name($id, wppa_switch('ovl_add_owner'), false, false, wppa_switch('ovl_' . $type . '_name'))) . '"' . ' />'; } else { $result .= '<a' . ' title="' . __('Download', 'wp-photo-album-plus') . '"' . ' style="cursor:pointer;"' . ' onclick="wppaAjaxMakeOrigName( ' . wppa('mocc') . ', \'' . wppa_encrypt_photo($id) . '\' );"' . ' >' . rtrim(__('Download', 'wp-photo-album-plus') . ' ' . wppa_get_photo_name($id, wppa_switch('ovl_add_owner'), false, false, wppa_switch('ovl_' . $type . '_name'))) . '</a>'; } } else { if ($do_name) { $result .= wppa_get_photo_name($id, wppa_switch('ovl_add_owner'), false, false, wppa_switch('ovl_' . $type . '_name')); } } if ($do_name && $do_desc) { $result .= '<br />'; } if ($do_desc) { $result .= wppa_get_photo_desc($thumb['id']); } if (($do_name || $do_desc) && $do_sm) { $result .= '<br />'; } if (wppa_opt('rating_max') != '1' && wppa_opt('rating_display_type') == 'graphic') { $result .= wppa_get_rating_range_html($id, true); } elseif (wppa_opt('rating_display_type') == 'likes' && wppa_switch('ovl_rating')) { $result .= wppa_get_slide_rating_vote_only('always', $id, 'is_lightbox'); } if ($do_sm) { $result .= wppa_get_share_html($thumb['id'], 'lightbox'); } if (wppa_may_user_fe_edit($id)) { if ($type == 'slide') { $parg = esc_js('\'' . wppa_encrypt_photo($id) . '\''); } else { $parg = '\'' . wppa_encrypt_photo($id) . '\''; } if (wppa_opt('upload_edit') == 'classic') { $result .= ' <input' . ' type="button"' . ' style="float:right; margin-right:6px;"' . ' class="wppa-ovl-button"' . ' onclick="' . ($type == 'slide' ? '_wppaStop( ' . wppa('mocc') . ' );' : '') . 'wppaEditPhoto( ' . wppa('mocc') . ', ' . $parg . ' );"' . ' value="' . esc_attr(__(wppa_opt('fe_edit_button'))) . '"' . ' />'; } } $result = esc_attr($result); return $result; }
function wppa_encrypt_url($url) { // Feature enabled? if (!wppa_switch('use_encrypted_links')) { return $url; } // Querystring present? if (strpos($url, '?') === false) { return $url; } // Has it & 's ? if (strpos($url, '&') === false) { $hasamp = false; } else { $hasamp = true; } // Disassemble url $temp = explode('?', $url); // Has it a querystring? if (count($temp) == '1') { return $url; } // Disassemble querystring $qarray = explode('&', str_replace('&', '&', $temp['1'])); // Search and replace album and photo ids by crypts $i = 0; while ($i < count($qarray)) { $item = $qarray[$i]; $t = explode('=', $item); if (isset($t['1'])) { switch ($t['0']) { case 'wppa-album': case 'album': if (!$t['1']) { $t['1'] = '0'; } $t['1'] = wppa_encrypt_album($t['1']); if ($t['1'] === false) { wppa_dbg_msg('Error: Illegal album specification: ' . $item . ' (wppa_encrypt_url)', 'red', 'force'); exit; } break; case 'wppa-photo': case 'photo': $t['1'] = wppa_encrypt_photo($t['1']); if ($t['1'] === false) { wppa_dbg_msg('Error: Illegal photo specification: ' . $item . ' (wppa_encrypt_url)', 'red', 'force'); exit; } break; } } $item = implode('=', $t); $qarray[$i] = $item; $i++; } // Re-assemble url $temp['1'] = implode('&', $qarray); $newurl = implode('?', $temp); if ($hasamp) { $newurl = str_replace('&', '&', $newurl); } return $newurl; }