function wppa_get_imglnk_a($wich, $id, $lnk = '', $tit = '', $onc = '', $noalb = false, $album = '') { global $wpdb; // make sure the photo data ia available $thumb = wppa_cache_thumb($id); if (!$thumb) { return false; } // Is it a video? $is_video = wppa_is_video($id, true); // Photo Specific Overrule? if ($wich == 'sphoto' && wppa_switch('sphoto_overrule') || $wich == 'mphoto' && wppa_switch('mphoto_overrule') || $wich == 'thumb' && wppa_switch('thumb_overrule') || $wich == 'topten' && wppa_switch('topten_overrule') || $wich == 'featen' && wppa_switch('featen_overrule') || $wich == 'lasten' && wppa_switch('lasten_overrule') || $wich == 'sswidget' && wppa_switch('sswidget_overrule') || $wich == 'potdwidget' && wppa_switch('potdwidget_overrule') || $wich == 'coverimg' && wppa_switch('coverimg_overrule') || $wich == 'comten' && wppa_switch('comment_overrule') || $wich == 'slideshow' && wppa_switch('slideshow_overrule') || $wich == 'tnwidget' && wppa_switch('thumbnail_widget_overrule')) { // Look for a photo specific link if ($thumb) { // If it is there... if ($thumb['linkurl']) { // Use it. It superceeds other settings $result['url'] = esc_attr($thumb['linkurl']); $result['title'] = esc_attr(__(stripslashes($thumb['linktitle']))); $result['is_url'] = true; $result['is_lightbox'] = false; $result['onclick'] = ''; $result['target'] = $thumb['linktarget']; return $result; } } } $result['target'] = '_self'; $result['title'] = ''; $result['onclick'] = ''; switch ($wich) { case 'sphoto': $type = wppa_opt('sphoto_linktype'); $page = wppa_opt('sphoto_linkpage'); if ($page == '0') { $page = '-1'; } if (wppa_switch('sphoto_blank')) { $result['target'] = '_blank'; } break; case 'mphoto': $type = wppa_opt('mphoto_linktype'); $page = wppa_opt('mphoto_linkpage'); if ($page == '0') { $page = '-1'; } if (wppa_switch('mphoto_blank')) { $result['target'] = '_blank'; } break; case 'thumb': $type = wppa_opt('thumb_linktype'); $page = wppa_opt('thumb_linkpage'); if (wppa_switch('thumb_blank')) { $result['target'] = '_blank'; } break; case 'topten': $type = wppa_opt('topten_widget_linktype'); $page = wppa_opt('topten_widget_linkpage'); if ($page == '0') { $page = '-1'; } if (wppa_switch('topten_blank')) { $result['target'] = '_blank'; } break; case 'featen': $type = wppa_opt('featen_widget_linktype'); $page = wppa_opt('featen_widget_linkpage'); if ($page == '0') { $page = '-1'; } if (wppa_switch('featen_blank')) { $result['target'] = '_blank'; } break; case 'lasten': $type = wppa_opt('lasten_widget_linktype'); $page = wppa_opt('lasten_widget_linkpage'); if ($page == '0') { $page = '-1'; } if (wppa_switch('lasten_blank')) { $result['target'] = '_blank'; } break; case 'comten': $type = wppa_opt('comment_widget_linktype'); $page = wppa_opt('comment_widget_linkpage'); if ($page == '0') { $page = '-1'; } if (wppa_switch('comment_blank')) { $result['target'] = '_blank'; } break; case 'sswidget': $type = wppa_opt('slideonly_widget_linktype'); $page = wppa_opt('slideonly_widget_linkpage'); if ($page == '0') { $page = '-1'; } if (wppa_switch('sswidget_blank')) { $result['target'] = '_blank'; } $result['url'] = ''; if ($type == 'lightbox' || $type == 'lightboxsingle' || $type == 'file') { $result['title'] = wppa_zoom_in($id); $result['target'] = ''; return $result; } break; case 'potdwidget': $type = wppa_opt('widget_linktype'); $page = wppa_opt('widget_linkpage'); if ($page == '0') { $page = '-1'; } if (wppa_switch('potd_blank')) { $result['target'] = '_blank'; } break; case 'coverimg': $type = wppa_opt('coverimg_linktype'); $page = wppa_opt('coverimg_linkpage'); if ($page == '0') { $page = '-1'; } if (wppa_switch('coverimg_blank')) { $result['target'] = '_blank'; } if ($type == 'slideshowstartatimage') { $result['url'] = wppa_get_slideshow_url($album, $page, $id); $result['is_url'] = true; $result['is_lightbox'] = false; return $result; } break; case 'tnwidget': $type = wppa_opt('thumbnail_widget_linktype'); $page = wppa_opt('thumbnail_widget_linkpage'); if ($page == '0') { $page = '-1'; } if (wppa_switch('thumbnail_widget_blank')) { $result['target'] = '_blank'; } break; case 'slideshow': $type = wppa_opt('slideshow_linktype'); //''; $page = wppa_opt('slideshow_linkpage'); $result['url'] = ''; if ($type == 'lightbox' || $type == 'lightboxsingle' || $type == 'file') { $result['title'] = wppa_zoom_in($id); $result['target'] = ''; return $result; } if ($type == 'thumbs') { $result['url'] = wppa_get_ss_to_tn_link($page, $id); $result['title'] = __('View thumbnails', 'wp-photo-album-plus'); $result['is_url'] = true; $result['is_lightbox'] = false; if (wppa_switch('slideshow_blank')) { $result['target'] = '_blank'; } return $result; } if ($type == 'none') { return; } // Continue for 'single' break; case 'albwidget': $type = wppa_opt('album_widget_linktype'); $page = wppa_opt('album_widget_linkpage'); if ($page == '0') { $page = '-1'; } if (wppa_switch('album_widget_blank')) { $result['target'] = '_blank'; } break; default: return false; break; } if (!$album) { $album = wppa('start_album'); } if ($album == '' && !wppa('is_upldr')) { /**/ $album = wppa_get_album_id_by_photo_id($id); } if (is_numeric($album)) { $album_name = wppa_get_album_name($album); } else { $album_name = ''; } if (!$album) { $album = '0'; } if ($wich == 'comten') { $album = '0'; } if (wppa('is_tag')) { $album = '0'; } if (wppa('supersearch')) { $album = '0'; } if (wppa('calendar')) { $album = wppa('start_album') ? wppa('start_album') : '0'; } // if ( wppa( 'is_upldr' ) ) $album = '0'; // probeersel upldr parent if ($id) { $photo_name = wppa_get_photo_name($id); } else { $photo_name = ''; } $photo_name_js = esc_js($photo_name); $photo_name = esc_attr($photo_name); if ($id) { $photo_desc = esc_attr(wppa_get_photo_desc($id)); } else { $photo_desc = ''; } $title = __($photo_name, 'wp-photo-album-plus'); $result['onclick'] = ''; // Init switch ($type) { case 'none': // No link at all return false; break; case 'file': // The plain file if ($is_video) { $siz = array(wppa_get_videox($id), wppa_get_videoy($id)); $result['url'] = wppa_get_photo_url($id, '', $siz['0'], $siz['1']); reset($is_video); $result['url'] = str_replace('xxx', current($is_video), $result['url']); } else { $siz = array(wppa_get_photox($id), wppa_get_photoy($id)); $result['url'] = wppa_get_photo_url($id, '', $siz['0'], $siz['1']); } $result['title'] = $title; $result['is_url'] = true; $result['is_lightbox'] = false; return $result; break; case 'lightbox': case 'lightboxsingle': if ($is_video) { $siz = array(wppa_get_videox($id), wppa_get_videoy($id)); $result['url'] = wppa_get_photo_url($id, '', $siz['0'], $siz['1']); //$result['url'] = str_replace( 'xxx', $is_video['0'], $result['url'] ); } else { if (wppa_switch('lb_hres')) { $result['url'] = wppa_get_hires_url($id); } else { $siz = array(wppa_get_photox($id), wppa_get_photoy($id)); $result['url'] = wppa_get_photo_url($id, '', $siz['0'], $siz['1']); } } $result['title'] = $title; $result['is_url'] = false; $result['is_lightbox'] = true; $result['url'] = wppa_fix_poster_ext($result['url'], $id); return $result; case 'widget': // Defined at widget activation $result['url'] = wppa('in_widget_linkurl'); $result['title'] = esc_attr(wppa('in_widget_linktitle')); $result['is_url'] = true; $result['is_lightbox'] = false; return $result; break; case 'album': // The albums thumbnails // The albums thumbnails case 'content': // For album widget switch ($page) { case '-1': return false; break; case '0': if ($noalb) { $result['url'] = wppa_get_permalink() . 'wppa-album=0&wppa-cover=0'; $result['title'] = ''; // $album_name; $result['is_url'] = true; $result['is_lightbox'] = false; } else { $result['url'] = wppa_get_permalink() . 'wppa-album=' . $album . '&wppa-cover=0'; $result['title'] = $album_name; $result['is_url'] = true; $result['is_lightbox'] = false; } break; default: if ($noalb) { $result['url'] = wppa_get_permalink($page) . 'wppa-album=0&wppa-cover=0'; $result['title'] = ''; //$album_name;//'a++'; $result['is_url'] = true; $result['is_lightbox'] = false; } else { $result['url'] = wppa_get_permalink($page) . 'wppa-album=' . $album . '&wppa-cover=0'; $result['title'] = $album_name; //'a++'; $result['is_url'] = true; $result['is_lightbox'] = false; } break; } break; case 'thumbalbum': $album = $thumb['album']; $album_name = wppa_get_album_name($album); switch ($page) { case '-1': return false; break; case '0': $result['url'] = wppa_get_permalink() . 'wppa-album=' . $album . '&wppa-cover=0'; $result['title'] = $album_name; $result['is_url'] = true; $result['is_lightbox'] = false; break; default: $result['url'] = wppa_get_permalink($page) . 'wppa-album=' . $album . '&wppa-cover=0'; $result['title'] = $album_name; //'a++'; $result['is_url'] = true; $result['is_lightbox'] = false; break; } break; case 'photo': // This means: The fullsize photo in a slideshow // This means: The fullsize photo in a slideshow case 'slphoto': // This means: The single photo in the style of a slideshow if ($type == 'slphoto') { $si = '&wppa-single=1'; } else { $si = ''; } switch ($page) { case '-1': return false; break; case '0': if ($noalb) { $result['url'] = wppa_get_permalink() . 'wppa-album=0&wppa-photo=' . $id . $si; $result['title'] = $title; $result['is_url'] = true; $result['is_lightbox'] = false; } else { $result['url'] = wppa_get_permalink() . 'wppa-album=' . $album . '&wppa-photo=' . $id . $si; $result['title'] = $title; $result['is_url'] = true; $result['is_lightbox'] = false; } break; default: if ($noalb) { $result['url'] = wppa_get_permalink($page) . 'wppa-album=0&wppa-photo=' . $id . $si; $result['title'] = $title; $result['is_url'] = true; $result['is_lightbox'] = false; } else { $result['url'] = wppa_get_permalink($page) . 'wppa-album=' . $album . '&wppa-photo=' . $id . $si; $result['title'] = $title; $result['is_url'] = true; $result['is_lightbox'] = false; } break; } break; case 'single': switch ($page) { case '-1': return false; break; case '0': $result['url'] = wppa_get_permalink() . 'wppa-photo=' . $id; $result['title'] = $title; $result['is_url'] = true; $result['is_lightbox'] = false; break; default: $result['url'] = wppa_get_permalink($page) . 'wppa-photo=' . $id; $result['title'] = $title; $result['is_url'] = true; $result['is_lightbox'] = false; break; } break; case 'same': $result['url'] = $lnk; $result['title'] = $tit; $result['is_url'] = true; $result['is_lightbox'] = false; $result['onclick'] = $onc; return $result; break; case 'fullpopup': if ($is_video) { // A video can not be printed or downloaded $result['url'] = esc_attr('alert( "' . esc_js(__('A video can not be printed or downloaded', 'wp-photo-album-plus')) . '" )'); } else { $wid = wppa_get_photox($id); $hig = wppa_get_photoy($id); /* $imgsize = getimagesize( wppa_get_photo_path( $id ) ); if ( $imgsize ) { $wid = $imgsize['0']; $hig = $imgsize['1']; } else { $wid = '0'; $hig = '0'; } */ $url = wppa_fix_poster_ext(wppa_get_photo_url($id, '', $wid, $hig), $id); $result['url'] = esc_attr('wppaFullPopUp( ' . wppa('mocc') . ', ' . $id . ', "' . $url . '", ' . $wid . ', ' . $hig . ' )'); } $result['title'] = $title; $result['is_url'] = false; $result['is_lightbox'] = false; return $result; break; case 'custom': if ($wich == 'potdwidget') { $result['url'] = wppa_opt('widget_linkurl'); $result['title'] = wppa_opt('widget_linktitle'); $result['is_url'] = true; $result['is_lightbox'] = false; return $result; } break; case 'slide': // for album widget $result['url'] = wppa_get_permalink(wppa_opt('album_widget_linkpage')) . 'wppa-album=' . $album . '&slide'; $result['title'] = ''; $result['is_url'] = true; $result['is_lightbox'] = false; break; case 'autopage': if (!wppa_switch('auto_page')) { wppa_dbg_msg('Auto page has been switched off, but there are still links to it (' . $wich . ')', 'red', 'force'); $result['url'] = ''; } else { $result['url'] = wppa_get_permalink(wppa_get_the_auto_page($id)); } $result['title'] = ''; $result['is_url'] = true; $result['is_lightbox'] = false; break; case 'plainpage': $result['url'] = get_permalink($page); $result['title'] = $wpdb->get_var($wpdb->prepare("SELECT `post_title` FROM `" . $wpdb->prefix . "posts` WHERE `ID` = %s", $page)); $result['is_url'] = true; $result['is_lightbox'] = false; return $result; break; default: wppa_dbg_msg('Error, wrong type: ' . $type . ' in wppa_get_imglink_a', 'red'); return false; break; } if ($type != 'thumbalbum') { if (wppa('calendar')) { $result['url'] .= '&wppa-calendar=' . wppa('calendar') . '&wppa-caldate=' . wppa('caldate'); } if (wppa('supersearch')) { $result['url'] .= '&wppa-supersearch=' . urlencode(wppa('supersearch')); } if (wppa('src') && !wppa('is_related') && !wppa_in_widget()) { $result['url'] .= '&wppa-searchstring=' . urlencode(wppa('searchstring')); } if ($wich == 'topten') { $result['url'] .= '&wppa-topten=' . wppa_opt('topten_count'); } elseif (wppa('is_topten')) { $result['url'] .= '&wppa-topten=' . wppa('topten_count'); } if ($wich == 'lasten') { $result['url'] .= '&wppa-lasten=' . wppa_opt('lasten_count'); } elseif (wppa('is_lasten')) { $result['url'] .= '&wppa-lasten=' . wppa('lasten_count'); } if ($wich == 'comten') { $result['url'] .= '&wppa-comten=' . wppa_opt('comten_count'); } elseif (wppa('is_comten')) { $result['url'] .= '&wppa-comten=' . wppa('comten_count'); } if ($wich == 'featen') { $result['url'] .= '&wppa-featen=' . wppa_opt('featen_count'); } elseif (wppa('is_featen')) { $result['url'] .= '&wppa-featen=' . wppa('featen_count'); } if (wppa('is_related')) { $result['url'] .= '&wppa-rel=' . wppa('is_related') . '&wppa-relcount=' . wppa('related_count'); } elseif (wppa('is_tag')) { $result['url'] .= '&wppa-tag=' . wppa('is_tag'); } if (wppa('is_upldr')) { $result['url'] .= '&wppa-upldr=' . wppa('is_upldr'); } if (wppa('is_inverse')) { $result['url'] .= '&wppa-inv=1'; } } if ($page != '0') { // on a different page $occur = '1'; $w = ''; } else { // on the same page, post or widget $occur = wppa_in_widget() ? wppa('widget_occur') : wppa('occur'); $w = wppa_in_widget() ? 'w' : ''; } $result['url'] .= '&wppa-' . $w . 'occur=' . $occur; $result['url'] = wppa_convert_to_pretty($result['url']); if ($result['title'] == '') { $result['title'] = $tit; } // If still nothing, try arg return $result; }
function wppa_do_maintenance_proc($slug) { global $wpdb; global $thumb; global $wppa_opt; global $wppa_session; global $wppa_supported_video_extensions; global $wppa_supported_audio_extensions; // Check for multiple maintenance procs if (!wppa_switch('wppa_maint_ignore_concurrency_error')) { $all_slugs = array('wppa_remake_index_albums', 'wppa_remove_empty_albums', 'wppa_remake_index_photos', 'wppa_apply_new_photodesc_all', 'wppa_append_to_photodesc', 'wppa_remove_from_photodesc', 'wppa_remove_file_extensions', 'wppa_readd_file_extensions', 'wppa_regen_thumbs', 'wppa_rerate', 'wppa_recup', 'wppa_file_system', 'wppa_cleanup', 'wppa_remake', 'wppa_list_index', 'wppa_blacklist_user', 'wppa_un_blacklist_user', 'wppa_rating_clear', 'wppa_viewcount_clear', 'wppa_iptc_clear', 'wppa_exif_clear', 'wppa_watermark_all', 'wppa_create_all_autopages', 'wppa_leading_zeros', 'wppa_add_gpx_tag', 'wppa_optimize_ewww', 'wppa_comp_sizes', 'wppa_edit_tag'); foreach (array_keys($all_slugs) as $key) { if ($all_slugs[$key] != $slug) { if (get_option($all_slugs[$key] . '_togo', '0')) { // Process running return __('You can run only one maintenance procedure at a time', 'wppa') . '||' . $slug . '||' . __('Error', 'wppa') . '||' . '' . '||' . ''; } } } } // Lock this proc update_option($slug . '_user', wppa_get_user()); // Initialize $endtime = time() + '5'; // Allow for 5 seconds $chunksize = '1000'; $lastid = strval(intval(get_option($slug . '_last', '0'))); $errtxt = ''; $id = '0'; $topid = '0'; $reload = ''; if (!isset($wppa_session)) { $wppa_session = array(); } if (!isset($wppa_session[$slug . '_fixed'])) { $wppa_session[$slug . '_fixed'] = '0'; } if (!isset($wppa_session[$slug . '_deleted'])) { $wppa_session[$slug . '_deleted'] = '0'; } if (!isset($wppa_session[$slug . '_skipped'])) { $wppa_session[$slug . '_skipped'] = '0'; } if ($lastid == '0') { $wppa_session[$slug . '_fixed'] = '0'; $wppa_session[$slug . '_deleted'] = '0'; $wppa_session[$slug . '_skipped'] = '0'; } // Pre-processing needed? if ($lastid == '0') { switch ($slug) { case 'wppa_remake_index_albums': $wpdb->query("UPDATE `" . WPPA_INDEX . "` SET `albums` = ''"); break; case 'wppa_remake_index_photos': $wpdb->query("UPDATE `" . WPPA_INDEX . "` SET `photos` = ''"); wppa_index_compute_skips(); break; case 'wppa_recup': $wpdb->query("DELETE FROM `" . WPPA_IPTC . "` WHERE `photo` <> '0'"); $wpdb->query("DELETE FROM `" . WPPA_EXIF . "` WHERE `photo` <> '0'"); break; case 'wppa_file_system': if (get_option('wppa_file_system') == 'flat') { update_option('wppa_file_system', 'to-tree'); } if (get_option('wppa_file_system') == 'tree') { update_option('wppa_file_system', 'to-flat'); } break; case 'wppa_cleanup': $orphan_album = get_option('wppa_orphan_album', '0'); $album_exists = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM`" . WPPA_ALBUMS . "` WHERE `id` = %s", $orphan_album)); if (!$album_exists) { $orphan_album = false; } if (!$orphan_album) { $orphan_album = wppa_create_album_entry(array('name' => __('Orphan photos', 'wppa'), 'a_parent' => '-1', 'description' => __('This album contains refound lost photos', 'wppa'))); update_option('wppa_orphan_album', $orphan_album); } break; } } // Dispatch on albums / photos / single actions switch ($slug) { case 'wppa_remake_index_albums': case 'wppa_remove_empty_albums': // Process albums $table = WPPA_ALBUMS; $topid = $wpdb->get_var("SELECT `id` FROM `" . WPPA_ALBUMS . "` ORDER BY `id` DESC LIMIT 1"); $albums = $wpdb->get_results("SELECT * FROM `" . WPPA_ALBUMS . "` WHERE `id` > " . $lastid . " ORDER BY `id` LIMIT 100", ARRAY_A); wppa_cache_album('add', $albums); if ($albums) { foreach ($albums as $album) { $id = $album['id']; switch ($slug) { case 'wppa_remake_index_albums': wppa_index_add('album', $id); break; case 'wppa_remove_empty_albums': $p = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM `" . WPPA_PHOTOS . "` WHERE `album` = %s", $id)); $a = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM `" . WPPA_ALBUMS . "` WHERE `a_parent` = %s", $id)); if (!$a && !$p) { $wpdb->query($wpdb->prepare("DELETE FROM `" . WPPA_ALBUMS . "` WHERE `id` = %s", $id)); wppa_delete_album_source($id); wppa_flush_treecounts($id); wppa_index_remove('album', $id); } break; } // Test for timeout / ready $lastid = $id; update_option($slug . '_last', $lastid); if (time() > $endtime) { break; } // Time out } } else { // Nothing to do, Done anyway $lastid = $topid; } break; // End process albums // End process albums case 'wppa_remake_index_photos': $chunksize = '100'; case 'wppa_apply_new_photodesc_all': case 'wppa_append_to_photodesc': case 'wppa_remove_from_photodesc': case 'wppa_remove_file_extensions': case 'wppa_readd_file_extensions': case 'wppa_regen_thumbs': case 'wppa_rerate': case 'wppa_recup': case 'wppa_file_system': case 'wppa_cleanup': case 'wppa_remake': case 'wppa_watermark_all': case 'wppa_create_all_autopages': case 'wppa_leading_zeros': case 'wppa_add_gpx_tag': case 'wppa_optimize_ewww': case 'wppa_comp_sizes': case 'wppa_edit_tag': // Process photos $table = WPPA_PHOTOS; if ($slug == 'wppa_cleanup') { $topid = get_option('wppa_' . WPPA_PHOTOS . '_lastkey', '1') * 10; $photos = array(); for ($i = $lastid + '1'; $i <= $topid; $i++) { $photos[]['id'] = $i; } } else { $topid = $wpdb->get_var("SELECT `id` FROM `" . WPPA_PHOTOS . "` ORDER BY `id` DESC LIMIT 1"); $photos = $wpdb->get_results("SELECT * FROM `" . WPPA_PHOTOS . "` WHERE `id` > " . $lastid . " ORDER BY `id` LIMIT " . $chunksize, ARRAY_A); } if ($slug == 'wppa_edit_tag') { $edit_tag = get_option('wppa_tag_to_edit'); $new_tag = get_option('wppa_new_tag_value'); } if (!$photos && $slug == 'wppa_file_system') { $fs = get_option('wppa_file_system'); if ($fs == 'to-tree') { $to = 'tree'; } elseif ($fs == 'to-flat') { $to = 'flat'; } else { $to = $fs; } } if ($photos) { foreach ($photos as $photo) { $thumb = $photo; // Make globally known $id = $photo['id']; switch ($slug) { case 'wppa_remake_index_photos': wppa_index_add('photo', $id); break; case 'wppa_apply_new_photodesc_all': $value = $wppa_opt['wppa_newphoto_description']; $description = trim($value); if ($description != $photo['description']) { // Modified photo description $wpdb->query($wpdb->prepare("UPDATE `" . WPPA_PHOTOS . "` SET `description` = %s WHERE `id` = %s", $description, $id)); } break; case 'wppa_append_to_photodesc': $value = trim($wppa_opt['wppa_append_text']); if (!$value) { return 'Unexpected error: missing text to append||' . $slug . '||Error||0'; } $description = rtrim($photo['description'] . ' ' . $value); if ($description != $photo['description']) { // Modified photo description $wpdb->query($wpdb->prepare("UPDATE `" . WPPA_PHOTOS . "` SET `description` = %s WHERE `id` = %s", $description, $id)); } break; case 'wppa_remove_from_photodesc': $value = trim($wppa_opt['wppa_remove_text']); if (!$value) { return 'Unexpected error: missing text to remove||' . $slug . '||Error||0'; } $description = rtrim(str_replace($value, '', $photo['description'])); if ($description != $photo['description']) { // Modified photo description $wpdb->query($wpdb->prepare("UPDATE `" . WPPA_PHOTOS . "` SET `description` = %s WHERE `id` = %s", $description, $id)); } break; case 'wppa_remove_file_extensions': if (!wppa_is_video($id)) { $name = str_replace(array('.jpg', '.png', '.gif', '.JPG', '.PNG', '.GIF'), '', $photo['name']); if ($name != $photo['name']) { // Modified photo name $wpdb->query($wpdb->prepare("UPDATE `" . WPPA_PHOTOS . "` SET `name` = %s WHERE `id` = %s", $name, $id)); } } break; case 'wppa_readd_file_extensions': if (!wppa_is_video($id)) { $name = str_replace(array('.jpg', '.png', 'gif', '.JPG', '.PNG', '.GIF'), '', $photo['name']); if ($name == $photo['name']) { // Name had no fileextension $wpdb->query($wpdb->prepare("UPDATE `" . WPPA_PHOTOS . "` SET `name` = %s WHERE `id` = %s", $name . '.' . $photo['ext'], $id)); } } break; case 'wppa_regen_thumbs': if (!wppa_is_video($id) || file_exists(str_replace('xxx', 'jpg', wppa_get_photo_path($id)))) { wppa_create_thumbnail($id); } break; case 'wppa_rerate': wppa_rate_photo($id); break; case 'wppa_recup': $a_ret = wppa_recuperate($id); if ($a_ret['iptcfix']) { $wppa_session[$slug . '_fixed']++; } if ($a_ret['exiffix']) { $wppa_session[$slug . '_fixed']++; } break; case 'wppa_file_system': $fs = get_option('wppa_file_system'); if ($fs == 'to-tree' || $fs == 'to-flat') { if ($fs == 'to-tree') { $from = 'flat'; $to = 'tree'; } else { $from = 'tree'; $to = 'flat'; } // Media files if (wppa_is_multi($id)) { // Can NOT use wppa_has_audio() or wppa_is_video(), they use wppa_get_photo_path() without fs switch!! $exts = array_merge($wppa_supported_video_extensions, $wppa_supported_audio_extensions); $pathfrom = wppa_get_photo_path($id, $from); $pathto = wppa_get_photo_path($id, $to); // wppa_log( 'dbg', 'Trying: '.$pathfrom ); foreach ($exts as $ext) { if (is_file(str_replace('.xxx', '.' . $ext, $pathfrom))) { // wppa_log( 'dbg', str_replace( '.xxx', '.'.$ext, $pathfrom ).' -> '.str_replace( '.xxx', '.'.$ext, $pathto )); @rename(str_replace('.xxx', '.' . $ext, $pathfrom), str_replace('.xxx', '.' . $ext, $pathto)); } } } // Poster / photo if (file_exists(wppa_fix_poster_ext(wppa_get_photo_path($id, $from), $id))) { @rename(wppa_fix_poster_ext(wppa_get_photo_path($id, $from), $id), wppa_fix_poster_ext(wppa_get_photo_path($id, $to), $id)); } // Thumbnail if (file_exists(wppa_fix_poster_ext(wppa_get_thumb_path($id, $from), $id))) { @rename(wppa_fix_poster_ext(wppa_get_thumb_path($id, $from), $id), wppa_fix_poster_ext(wppa_get_thumb_path($id, $to), $id)); } } break; case 'wppa_cleanup': $photo_files = glob(WPPA_UPLOAD_PATH . '/' . $id . '.*'); // Remove dirs if ($photo_files) { foreach (array_keys($photo_files) as $key) { if (is_dir($photo_files[$key])) { unset($photo_files[$key]); } } } // files left? process if ($photo_files) { foreach ($photo_files as $photo_file) { $basename = basename($photo_file); $ext = substr($basename, strpos($basename, '.') + '1'); if (!$wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM `" . WPPA_PHOTOS . "` WHERE `id` = %s", $id))) { // no db entry for this photo if (wppa_is_id_free(WPPA_PHOTOS, $id)) { if (wppa_create_photo_entry(array('id' => $id, 'album' => $orphan_album, 'ext' => $ext, 'filename' => $basename))) { // Can create entry $wppa_session[$slug . '_fixed']++; // Bump counter wppa_log('Debug', 'Lost photo file ' . $photo_file . ' recovered'); } else { wppa_log('Debug', 'Unable to recover lost photo file ' . $photo_file . ' Create photo entry failed'); } } else { wppa_log('Debug', 'Could not recover lost photo file ' . $photo_file . ' The id is not free'); } } } } break; case 'wppa_remake': if (wppa_remake_files('', $id)) { $wppa_session[$slug . '_fixed']++; } else { $wppa_session[$slug . '_skipped']++; } break; case 'wppa_watermark_all': if (!wppa_is_video($id)) { if (wppa_add_watermark($id)) { wppa_create_thumbnail($id); // create new thumb $wppa_session[$slug . '_fixed']++; } else { $wppa_session[$slug . '_skipped']++; } } else { $wppa_session[$slug . '_skipped']++; } break; case 'wppa_create_all_autopages': wppa_get_the_auto_page($id); break; case 'wppa_leading_zeros': $name = $photo['name']; if (wppa_is_int($name)) { $target_len = wppa_opt('wppa_zero_numbers'); $name = strval(intval($name)); while (strlen($name) < $target_len) { $name = '0' . $name; } } if ($name !== $photo['name']) { $wpdb->query($wpdb->prepare("UPDATE `" . WPPA_PHOTOS . "` SET `name` = %s WHERE `id` = %s", $name, $id)); } break; case 'wppa_add_gpx_tag': $tags = $photo['tags']; $temp = explode('/', $photo['location']); if (!isset($temp['2'])) { $temp['2'] = false; } if (!isset($temp['3'])) { $temp['3'] = false; } $lat = $temp['2']; $lon = $temp['3']; if ($lat < 0.01 && $lat > -0.01 && $lon < 0.01 && $lon > -0.01) { $lat = false; $lon = false; } if ($photo['location'] && strpos($tags, 'Gpx') === false && $lat && $lon) { // Add it $tags = wppa_sanitize_tags($tags . ',Gpx'); wppa_update_photo(array('id' => $photo['id'], 'tags' => $tags)); wppa_index_update('photo', $photo['id']); wppa_clear_taglist(); } elseif (strpos($tags, 'Gpx') !== false && !$lat && !$lon) { // Remove it $tags = wppa_sanitize_tags(str_replace('Gpx', '', $tags)); wppa_update_photo(array('id' => $photo['id'], 'tags' => $tags)); wppa_index_update('photo', $photo['id']); wppa_clear_taglist(); } break; case 'wppa_optimize_ewww': $file = wppa_get_photo_path($photo['id']); if (is_file($file)) { ewww_image_optimizer($file, 4, false, false, false); } $file = wppa_get_thumb_path($photo['id']); if (is_file($file)) { ewww_image_optimizer($file, 4, false, false, false); } break; case 'wppa_comp_sizes': $tx = 0; $ty = 0; $px = 0; $py = 0; $file = wppa_get_photo_path($photo['id']); if (is_file($file)) { $temp = getimagesize($file); if (is_array($temp)) { $px = $temp[0]; $py = $temp[1]; } } $file = wppa_get_thumb_path($photo['id']); if (is_file($file)) { $temp = getimagesize($file); if (is_array($temp)) { $tx = $temp[0]; $ty = $temp[1]; } } wppa_update_photo(array('id' => $photo['id'], 'thumbx' => $tx, 'thumby' => $ty, 'photox' => $px, 'photoy' => $py)); break; case 'wppa_edit_tag': $phototags = explode(',', wppa_get_photo_item($photo['id'], 'tags')); if (in_array($edit_tag, $phototags)) { foreach (array_keys($phototags) as $key) { if ($phototags[$key] == $edit_tag) { $phototags[$key] = $new_tag; } } $tags = wppa_sanitize_tags(implode(',', $phototags)); wppa_update_photo(array('id' => $photo['id'], 'tags' => $tags)); $wppa_session[$slug . '_fixed']++; } else { $wppa_session[$slug . '_skipped']++; } break; } // Test for timeout / ready $lastid = $id; update_option($slug . '_last', $lastid); if (time() > $endtime) { break; } // Time out } } else { // Nothing to do, Done anyway $lastid = $topid; wppa_log('Debug', 'Maintenance proc ' . $slug . ': Done!'); } break; // End process photos // Single action maintenance modules // case 'wppa_list_index': // break; // case 'wppa_blacklist_user': // break; // case 'wppa_un_blacklist_user': // break; // case 'wppa_rating_clear': // break; // case 'wppa_viewcount_clear': // break; // case 'wppa_iptc_clear': // break; // case 'wppa_exif_clear': // break; // End process photos // Single action maintenance modules // case 'wppa_list_index': // break; // case 'wppa_blacklist_user': // break; // case 'wppa_un_blacklist_user': // break; // case 'wppa_rating_clear': // break; // case 'wppa_viewcount_clear': // break; // case 'wppa_iptc_clear': // break; // case 'wppa_exif_clear': // break; default: $errtxt = 'Unimplemented maintenance slug: ' . strip_tags($slug); } // either $albums / $photos has been exhousted ( for this try ) or time is up if ($slug == 'wppa_cleanup') { $togo = $topid - $lastid; } else { $togo = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM `" . $table . "` WHERE `id` > %s ", $lastid)); } $status = $togo ? 'Pending' : 'Ready'; if ($togo) { update_option($slug . '_togo', $togo); update_option($slug . '_status', $status); } else { // Really done // Report fixed/skipped/deleted if ($wppa_session[$slug . '_fixed']) { $status .= ' fixed:' . $wppa_session[$slug . '_fixed']; unset($wppa_session[$slug . '_fixed']); } if ($wppa_session[$slug . '_skipped']) { $status .= ' skipped:' . $wppa_session[$slug . '_skipped']; unset($wppa_session[$slug . '_skipped']); } if ($wppa_session[$slug . '_deleted']) { $status .= ' deleted:' . $wppa_session[$slug . '_deleted']; unset($wppa_session[$slug . '_deleted']); } // Re-Init options delete_option($slug . '_togo', ''); delete_option($slug . '_status', ''); delete_option($slug . '_last', '0'); delete_option($slug . '_user', ''); // Post-processing needed? switch ($slug) { case 'wppa_remake_index_albums': case 'wppa_remake_index_photos': $wpdb->query("DELETE FROM `" . WPPA_INDEX . "` WHERE `albums` = '' AND `photos` = ''"); // Remove empty entries delete_option('wppa_index_need_remake'); break; case 'wppa_apply_new_photodesc_all': case 'wppa_append_to_photodesc': case 'wppa_remove_from_photodesc': update_option('wppa_remake_index_photos_status', __('Required', 'wppa')); break; case 'wppa_regen_thumbs': wppa_bump_thumb_rev(); break; case 'wppa_file_system': wppa_update_option('wppa_file_system', $to); $reload = 'reload'; break; case 'wppa_remake': wppa_bump_photo_rev(); wppa_bump_thumb_rev(); break; case 'wppa_edit_tag': wppa_clear_taglist(); $reload = 'reload'; break; } } return $errtxt . '||' . $slug . '||' . $status . '||' . $togo . '||' . $reload; }
function wppa_auto_page_links($where) { global $wpdb; $m = $where == 'bottom' ? 'margin-top:8px;' : ''; $mustwhere = wppa_opt('auto_page_links'); if (($mustwhere == 'top' || $mustwhere == 'both') && $where == 'top' || ($mustwhere == 'bottom' || $mustwhere == 'both') && $where == 'bottom') { wppa_out(' <div' . ' id="prevnext1-' . wppa('mocc') . '"' . ' class="wppa-box wppa-nav wppa-nav-text"' . ' style="text-align: center; ' . __wcs('wppa-box') . __wcs('wppa-nav') . __wcs('wppa-nav-text') . $m . '"' . ' >'); $photo = wppa('single_photo'); $thumb = wppa_cache_thumb($photo); $album = $thumb['album']; $photos = $wpdb->get_results($wpdb->prepare("SELECT `id`, `page_id` FROM `" . WPPA_PHOTOS . "` WHERE `album` = %s " . wppa_get_photo_order($album), $album), ARRAY_A); wppa_dbg_q('Q-Ppag'); $prevpag = '0'; $nextpag = '0'; $curpag = get_the_ID(); $count = count($photos); $count_ = $count - 1; $current = '0'; if ($photos) { foreach (array_keys($photos) as $idx) { if ($photos[$idx]['page_id'] == $curpag) { if ($idx != '0') { $prevpag = wppa_get_the_auto_page($photos[$idx - 1]['id']); } // ['page_id']; if ($idx != $count_) { $nextpag = wppa_get_the_auto_page($photos[$idx + 1]['id']); } // ['page_id']; $current = $idx; } } } if ($prevpag) { wppa_out('<a href="' . get_permalink($prevpag) . '" style="float:left" >' . __('< Previous', 'wp-photo-album-plus') . '</a>'); } else { wppa_out('<span style="visibility:hidden" >' . __('< Previous', 'wp-photo-album-plus') . '</span>'); } wppa_out(++$current . '/' . $count); if ($nextpag) { wppa_out('<a href="' . get_permalink($nextpag) . '" style="float:right" >' . __('Next >', 'wp-photo-album-plus') . '</a>'); } else { wppa_out('<span style="visibility:hidden" >' . __('Next >', 'wp-photo-album-plus') . '</span>'); } wppa_out('</div><div style="clear:both"></div>'); } }
function wppa_album_photos($album = '', $photo = '', $owner = '', $moderate = false) { global $wpdb; // Check input wppa_vfy_arg('wppa-page'); $pagesize = wppa_opt('photo_admin_pagesize'); $page = isset($_GET['wppa-page']) ? $_GET['wppa-page'] : '1'; $skip = ($page - '1') * $pagesize; $limit = $pagesize < '1' ? '' : ' LIMIT ' . $skip . ',' . $pagesize; if ($album) { if ($album == 'search') { $count = wppa_get_edit_search_photos('', 'count_only'); $photos = wppa_get_edit_search_photos($limit); $link = wppa_dbg_url(get_admin_url() . 'admin.php?page=wppa_admin_menu&tab=edit&edit_id=' . $album . '&wppa-searchstring=' . wppa_sanitize_searchstring($_REQUEST['wppa-searchstring'])); } else { $counts = wppa_treecount_a($album); $count = $counts['selfphotos'] + $counts['pendphotos']; $photos = $wpdb->get_results($wpdb->prepare('SELECT * FROM `' . WPPA_PHOTOS . '` WHERE `album` = %s ' . wppa_get_photo_order($album, 'norandom') . $limit, $album), ARRAY_A); $link = wppa_dbg_url(get_admin_url() . 'admin.php?page=wppa_admin_menu&tab=edit&edit_id=' . $album); } } elseif ($photo && !$moderate) { $count = '1'; $photos = $wpdb->get_results($wpdb->prepare('SELECT * FROM `' . WPPA_PHOTOS . '` WHERE `id` = %s', $photo), ARRAY_A); $link = ''; } elseif ($owner) { $count = $wpdb->get_var($wpdb->prepare('SELECT COUNT(*) FROM `' . WPPA_PHOTOS . '` WHERE `owner` = %s', $owner)); $photos = $wpdb->get_results($wpdb->prepare('SELECT * FROM `' . WPPA_PHOTOS . '` WHERE `owner` = %s ORDER BY `timestamp` DESC' . $limit, $owner), ARRAY_A); $link = wppa_dbg_url(get_admin_url() . 'admin.php?page=wppa_edit_photo'); } elseif ($moderate) { if (!current_user_can('wppa_moderate')) { wp_die(__('You do not have the rights to do this', 'wp-photo-album-plus')); } if ($photo) { $count = '1'; $photos = $wpdb->get_results($wpdb->prepare('SELECT * FROM `' . WPPA_PHOTOS . '` WHERE `id` = %s', $photo), ARRAY_A); $link = ''; } else { // Photos with pending comments? $cmt = $wpdb->get_results("SELECT `photo` FROM `" . WPPA_COMMENTS . "` WHERE `status` = 'pending'", ARRAY_A); if ($cmt) { $orphotois = ''; foreach ($cmt as $c) { $orphotois .= "OR `id` = " . $c['photo'] . " "; } } else { $orphotois = ''; } $count = $wpdb->get_var($wpdb->prepare('SELECT COUNT(*) FROM `' . WPPA_PHOTOS . '` WHERE `status` = %s ' . $orphotois, 'pending')); $photos = $wpdb->get_results($wpdb->prepare('SELECT * FROM `' . WPPA_PHOTOS . '` WHERE `status` = %s ' . $orphotois . ' ORDER BY `timestamp` DESC' . $limit, 'pending'), ARRAY_A); $link = wppa_dbg_url(get_admin_url() . 'admin.php?page=wppa_moderate_photos'); } if (empty($photos)) { if ($photo) { echo '<p>' . __('This photo is no longer awaiting moderation.', 'wp-photo-album-plus') . '</p>'; } else { echo '<p>' . __('There are no photos awaiting moderation at this time.', 'wp-photo-album-plus') . '</p>'; } if (current_user_can('administrator')) { echo '<h3>' . __('Manage all photos by timestamp', 'wp-photo-album-plus') . '</h3>'; $count = $wpdb->get_var("SELECT COUNT(*) FROM `" . WPPA_PHOTOS . "`"); $photos = $wpdb->get_results("SELECT * FROM `" . WPPA_PHOTOS . "` ORDER BY `timestamp` DESC" . $limit, ARRAY_A); $link = wppa_dbg_url(get_admin_url() . 'admin.php?page=wppa_moderate_photos'); } else { return; } } } else { wppa_dbg_msg('Missing required argument in wppa_album_photos() 1', 'red', 'force'); } if ($link && isset($_REQUEST['quick'])) { $link .= '&quick'; } wppa_show_search_statistics(); if (empty($photos)) { if ($photo) { echo '<div id="photoitem-' . $photo . '" class="photoitem" style="width: 99%; background-color: rgb( 255, 255, 224 ); border-color: rgb( 230, 219, 85 );"> <span style="color:red">' . sprintf(__('Photo %s has been removed.', 'wp-photo-album-plus'), $photo) . '</span> </div>'; } else { if (isset($_REQUEST['wppa-searchstring'])) { echo '<h3>' . __('No photos matching your search criteria.', 'wp-photo-album-plus') . '</h3>'; } else { echo '<h3>' . __('No photos yet in this album.', 'wp-photo-album-plus') . '</h3>'; } } } else { $wms = array('toplft' => __('top - left', 'wp-photo-album-plus'), 'topcen' => __('top - center', 'wp-photo-album-plus'), 'toprht' => __('top - right', 'wp-photo-album-plus'), 'cenlft' => __('center - left', 'wp-photo-album-plus'), 'cencen' => __('center - center', 'wp-photo-album-plus'), 'cenrht' => __('center - right', 'wp-photo-album-plus'), 'botlft' => __('bottom - left', 'wp-photo-album-plus'), 'botcen' => __('bottom - center', 'wp-photo-album-plus'), 'botrht' => __('bottom - right', 'wp-photo-album-plus')); $temp = wppa_get_water_file_and_pos('0'); $wmfile = isset($temp['select']) ? $temp['select'] : ''; $wmpos = isset($temp['pos']) && isset($wms[$temp['pos']]) ? $wms[$temp['pos']] : ''; wppa_admin_page_links($page, $pagesize, $count, $link); foreach ($photos as $photo) { $is_multi = wppa_is_multi($photo['id']); $is_video = wppa_is_video($photo['id']); $has_audio = wppa_has_audio($photo['id']); ?> <a id="photo_<?php echo $photo['id']; ?> " name="photo_<?php echo $photo['id']; ?> "></a> <div class="widefat wppa-table-wrap" id="photoitem-<?php echo $photo['id']; ?> " style="width:99%; position: relative;" > <!-- Left half starts here --> <div style="width:49.5%; float:left; border-right:1px solid #ccc; margin-right:0;"> <input type="hidden" id="photo-nonce-<?php echo $photo['id']; ?> " value="<?php echo wp_create_nonce('wppa_nonce_' . $photo['id']); ?> " /> <table class="wppa-table wppa-photo-table" style="width:98%" > <tbody> <!-- Preview --> <tr> <th> <label ><?php echo 'ID = ' . $photo['id'] . '. ' . __('Preview:', 'wp-photo-album-plus'); ?> </label> <br /> <?php echo sprintf(__('Album: %d<br />(%s)', 'wp-photo-album-plus'), $photo['album'], wppa_get_album_name($photo['album'])); ?> <br /><br /> <?php if (!$is_video) { ?> <?php _e('Rotate', 'wp-photo-album-plus'); ?> <a onclick="if ( confirm( '<?php _e('Are you sure you want to rotate this photo left?', 'wp-photo-album-plus'); ?> ' ) ) wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'rotleft', 0, <?php echo wppa('front_edit') ? 'false' : 'true'; ?> ); " ><?php _e('left', 'wp-photo-album-plus'); ?> </a> <a onclick="if ( confirm( '<?php _e('Are you sure you want to rotate this photo 180°?', 'wp-photo-album-plus'); ?> ' ) ) wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'rot180', 0, <?php echo wppa('front_edit') ? 'false' : 'true'; ?> ); " ><?php _e('180°', 'wp-photo-album-plus'); ?> </a> <a onclick="if ( confirm( '<?php _e('Are you sure you want to rotate this photo right?', 'wp-photo-album-plus'); ?> ' ) ) wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'rotright', 0, <?php echo wppa('front_edit') ? 'false' : 'true'; ?> ); " ><?php _e('right', 'wp-photo-album-plus'); ?> </a> <br /> <span style="font-size: 9px; line-height: 10px; color:#666;"> <?php if (wppa('front_edit')) { _e('If it says \'Photo rotated\', the photo is rotated.', 'wp-photo-album-plus'); } else { $refresh = '<a onclick="wppaReload()" >' . __('Refresh', 'wp-photo-album-plus') . '</a>'; echo sprintf(__('If it says \'Photo rotated\', the photo is rotated. %s the page.', 'wp-photo-album-plus'), $refresh); } ?> </span> <?php } ?> </th> <td> <?php $src = wppa_get_thumb_url($photo['id']); $big = wppa_get_photo_url($photo['id']); if ($is_video) { reset($is_video); $big = str_replace('xxx', current($is_video), $big); ?> <a href="<?php echo $big; ?> " target="_blank" title="<?php _e('Preview fullsize video', 'wp-photo-album-plus'); ?> " > <?php echo wppa_get_video_html(array('id' => $photo['id'], 'width' => '160', 'height' => '160' * wppa_get_videoy($photo['id']) / wppa_get_videox($photo['id']), 'controls' => false, 'use_thumb' => true)); ?> </a><?php } else { if ($has_audio) { $big = wppa_fix_poster_ext($big, $photo['id']); $src = wppa_fix_poster_ext($src, $photo['id']); } ?> <a href="<?php echo $big; ?> " target="_blank" title="<?php _e('Preview fullsize photo', 'wp-photo-album-plus'); ?> " > <img src="<?php echo $src; ?> " alt="<?php echo $photo['name']; ?> " style="max-width: 160px; vertical-align:middle;" /> </a><?php if ($has_audio) { $audio = wppa_get_audio_html(array('id' => $photo['id'], 'width' => '160', 'controls' => true)); ?> <br /> <?php if ($audio) { echo $audio; } else { echo '<span style="color:red;">' . __('Audio disabled', 'wp-photo-album-plus') . '</span>'; } } } ?> </td> </tr> <!-- Upload --> <tr> <th > <label><?php _e('Upload:', 'wp-photo-album-plus'); ?> </label> </th> <td> <?php $timestamp = $photo['timestamp']; if ($timestamp) { echo wppa_local_date(get_option('date_format', "F j, Y,") . ' ' . get_option('time_format', "g:i a"), $timestamp) . ' ' . __('local time', 'wp-photo-album-plus') . ' '; } if ($photo['owner']) { if (wppa_switch('photo_owner_change') && wppa_user_is('administrator')) { echo '</td></tr><tr><th><label>' . __('Owned by:', 'wp-photo-album-plus') . '</label></th><td>'; echo '<input type="text" onkeyup="wppaAjaxUpdatePhoto( \'' . $photo['id'] . '\', \'owner\', this )" onchange="wppaAjaxUpdatePhoto( \'' . $photo['id'] . '\', \'owner\', this )" value="' . $photo['owner'] . '" />'; } else { echo __('By:', 'wp-photo-album-plus') . ' ' . $photo['owner']; } } ?> </td> </tr> <!-- Modified --> <tr> <th> <label><?php _e('Modified:', 'wp-photo-album-plus'); ?> </label> </th> <td> <?php $modified = $photo['modified']; if ($modified > $timestamp) { echo wppa_local_date(get_option('date_format', "F j, Y,") . ' ' . get_option('time_format', "g:i a"), $modified) . ' ' . __('local time', 'wp-photo-album-plus'); } else { _e('Not modified', 'wp-photo-album-plus'); } ?> </td> </tr> <!-- EXIF Date --> <tr> <th> <label><?php _e('EXIF Date', 'wp-photo-album-plus'); ?> </label> </th> <td> <?php if (wppa_user_is('administrator')) { echo '<input type="text" onkeyup="wppaAjaxUpdatePhoto( \'' . $photo['id'] . '\', \'exifdtm\', this )" onchange="wppaAjaxUpdatePhoto( \'' . $photo['id'] . '\', \'exifdtm\', this )" value="' . $photo['exifdtm'] . '" />'; } else { echo $photo['exifdtm']; } ?> </td> </tr> <!-- Rating --> <tr > <th > <label><?php _e('Rating:', 'wp-photo-album-plus'); ?> </label> </th> <td class="wppa-rating" > <?php $entries = wppa_get_rating_count_by_id($photo['id']); if ($entries) { echo __('Entries:', 'wp-photo-album-plus') . ' ' . $entries . '. ' . __('Mean value:', 'wp-photo-album-plus') . ' ' . wppa_get_rating_by_id($photo['id'], 'nolabel') . '.'; } else { _e('No ratings for this photo.', 'wp-photo-album-plus'); } $dislikes = wppa_dislike_get($photo['id']); if ($dislikes) { echo ' <span style="color:red" >' . sprintf(__('Disliked by %d visitors', 'wp-photo-album-plus'), $dislikes) . '</span>'; } $pending = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM `" . WPPA_RATING . "` WHERE `photo` = %s AND `status` = 'pending'", $photo['id'])); if ($pending) { echo ' <span style="color:orange" >' . sprintf(__('%d pending votes.', 'wp-photo-album-plus'), $pending) . '</span>'; } ?> </td> </tr> <!-- Views --> <tr > <th > <label><?php _e('Views', 'wp-photo-album-plus'); ?> </label> </th> <td > <?php echo $photo['views']; ?> </td> </tr> <!-- P_order --> <?php if (!wppa_switch('porder_restricted') || current_user_can('administrator')) { ?> <tr > <th > <label><?php _e('Photo sort order #:', 'wp-photo-album-plus'); ?> </label> </th> <td > <input type="text" id="porder-<?php echo $photo['id']; ?> " value="<?php echo $photo['p_order']; ?> " style="width: 50px" onkeyup="wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'p_order', this )" onchange="wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'p_order', this )" /> </td> </tr> <?php } ?> <?php if (!isset($_REQUEST['quick'])) { ?> <?php if (!isset($album_select[$photo['album']])) { $album_select[$photo['album']] = wppa_album_select_a(array('checkaccess' => true, 'path' => wppa_switch('hier_albsel'), 'exclude' => $photo['album'], 'selected' => '0', 'addpleaseselect' => true)); } ?> <!-- Move --> <tr > <th > <input type="button" style="" onclick="if( document.getElementById( 'moveto-<?php echo $photo['id']; ?> ' ).value != 0 ) { if ( confirm( '<?php _e('Are you sure you want to move this photo?', 'wp-photo-album-plus'); ?> ' ) ) wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'moveto', document.getElementById( 'moveto-<?php echo $photo['id']; ?> ' ) ) } else { alert( '<?php _e('Please select an album to move the photo to first.', 'wp-photo-album-plus'); ?> ' ); return false;}" value="<?php echo esc_attr(__('Move photo to', 'wp-photo-album-plus')); ?> " /> </th> <td > <select id="moveto-<?php echo $photo['id']; ?> " style="width:100%;" ><?php echo $album_select[$photo['album']]; ?> </select> </td> </tr> <!-- Copy --> <tr > <th > <input type="button" style="" onclick="if ( document.getElementById( 'copyto-<?php echo $photo['id']; ?> ' ).value != 0 ) { if ( confirm( '<?php _e('Are you sure you want to copy this photo?', 'wp-photo-album-plus'); ?> ' ) ) wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'copyto', document.getElementById( 'copyto-<?php echo $photo['id']; ?> ' ) ) } else { alert( '<?php _e('Please select an album to copy the photo to first.', 'wp-photo-album-plus'); ?> ' ); return false;}" value="<?php echo esc_attr(__('Copy photo to', 'wp-photo-album-plus')); ?> " /> </th> <td > <select id="copyto-<?php echo $photo['id']; ?> " style="width:100%;" ><?php echo $album_select[$photo['album']]; ?> </select> </td> </tr> <?php } ?> <!-- Delete --> <?php if (!wppa('front_edit')) { ?> <tr > <th style="padding-top:0; padding-bottom:4px;"> <input type="button" style="color:red;" onclick="if ( confirm( '<?php _e('Are you sure you want to delete this photo?', 'wp-photo-album-plus'); ?> ' ) ) wppaAjaxDeletePhoto( <?php echo $photo['id']; ?> )" value="<?php echo esc_attr(__('Delete photo', 'wp-photo-album-plus')); ?> " /> </th> </tr> <?php } ?> <!-- Auto Page --> <?php if (wppa_switch('auto_page') && (current_user_can('edit_posts') || current_user_can('edit_pages'))) { ?> <tr style=="vertical-align:bottom;" > <th style="padding-top:0; padding-bottom:4px;"> <label> <?php _e('Autopage Permalink:', 'wp-photo-album-plus'); ?> </label> </th> <td > <?php echo get_permalink(wppa_get_the_auto_page($photo['id'])); ?> </td> </tr> <?php } ?> <!-- Link url --> <?php if (!wppa_switch('link_is_restricted') || current_user_can('administrator')) { ?> <tr > <th > <label><?php _e('Link url:', 'wp-photo-album-plus'); ?> </label> </th> <td > <input type="text" style="width:60%;" onkeyup="wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'linkurl', this )" onchange="wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'linkurl', this )" value="<?php echo stripslashes($photo['linkurl']); ?> " /> <select style="float:right;" onchange="wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'linktarget', this )" > <option value="_self" <?php if ($photo['linktarget'] == '_self') { echo 'selected="selected"'; } ?> ><?php _e('Same tab', 'wp-photo-album-plus'); ?> </option> <option value="_blank" <?php if ($photo['linktarget'] == '_blank') { echo 'selected="selected"'; } ?> ><?php _e('New tab', 'wp-photo-album-plus'); ?> </option> </select> </td> </tr> <!-- Link title --> <tr > <th > <label><?php _e('Link title:', 'wp-photo-album-plus'); ?> </label> </th> <td > <input type="text" style="width:97%;" onkeyup="wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'linktitle', this )" onchange="wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'linktitle', this )" value="<?php echo stripslashes($photo['linktitle']); ?> " /> </td> </tr> <?php if (current_user_can('wppa_settings')) { ?> <tr style="padding-left:10px; font-size:9px; line-height:10px; color:#666;" > <td colspan="2" style="padding-top:0" > <?php _e('If you want this link to be used, check \'PS Overrule\' checkbox in table VI.', 'wp-photo-album-plus'); ?> </td> </tr> <?php } ?> <?php } ?> <!-- Alt custom field --> <?php if (wppa_opt('alt_type') == 'custom') { ?> <tr > <th > <label><?php _e('HTML Alt attribute:', 'wp-photo-album-plus'); ?> </label> </th> <td > <input type="text" style="width:100%;" onkeyup="wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'alt', this )" onchange="wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'alt', this )" value="<?php echo stripslashes($photo['alt']); ?> " /> </td> </tr> <?php } ?> </tbody> </table> </div> <!-- Right half starts here --> <div style="width:50%; float:left; border-left:1px solid #ccc; margin-left:-1px;"> <table class="wppa-table wppa-photo-table" > <tbody> <!-- Filename --> <tr> <th> <label><?php _e('Filename:', 'wp-photo-album-plus'); ?> </label> </th> <td> <?php echo $photo['filename']; if (wppa_user_is('administrator') || !wppa_switch('reup_is_restricted')) { ?> <input type="button" onclick="jQuery( '#re-up-<?php echo $photo['id']; ?> ' ).css( 'display', '' );" value="<?php _e('Update file', 'wp-photo-album-plus'); ?> " /> <?php } ?> </td> </tr> <?php if (wppa_user_is('administrator') || !wppa_switch('reup_is_restricted')) { ?> <tr id="re-up-<?php echo $photo['id']; ?> " style="display:none" > <th> </th> <td> <form id="wppa-re-up-form-<?php echo $photo['id']; ?> " onsubmit="wppaReUpload( event,<?php echo $photo['id']; ?> , '<?php echo $photo['filename']; ?> ' )" > <input type="file" id="wppa-re-up-file-<?php echo $photo['id']; ?> " /> <input type="submit" id="wppa-re-up-butn-<?php echo $photo['id']; ?> " value="<?php _e('Upload', 'wp-photo-album-plus'); ?> " /> </form> </td> </tr> <?php } ?> <!--- Video sizes --> <?php if ($is_video) { ?> <tr> <th> <label><?php _e('Video size:', 'wp-photo-album-plus'); ?> </th> <td> <table class="wppa-subtable" > <tr> <td> <?php _e('Width:', 'wp-photo-album-plus'); ?> </td> <td> <input style="width:50px;margin:0 4px;" onkeyup="wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'videox', this ); " onchange="wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'videox', this ); " value="<?php echo $photo['videox']; ?> " /><?php echo sprintf(__('pix, (0=default:%s)', 'wp-photo-album-plus'), wppa_opt('video_width')); ?> </td> </tr> <tr> <td> <?php _e('Height:', 'wp-photo-album-plus'); ?> </td> <td> <input style="width:50px;margin:0 4px;" onkeyup="wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'videoy', this ); " onchange="wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'videoy', this ); " value="<?php echo $photo['videoy']; ?> " /><?php echo sprintf(__('pix, (0=default:%s)', 'wp-photo-album-plus'), wppa_opt('video_height')); ?> </td> </tr> </table> </td> </tr> <tr> <th> <label><?php _e('Formats:', 'wp-photo-album-plus'); ?> </th> <td> <table class="wppa-subtable" > <?php foreach ($is_video as $fmt) { echo '<tr>' . '<td>' . $fmt . '</td>' . '<td>' . __('Filesize:', 'wp-photo-album-plus') . '</td>' . '<td>' . wppa_get_filesize(str_replace('xxx', $fmt, wppa_get_photo_path($photo['id']))) . '</td>' . '</tr>'; } ?> </table> </td> </tr> <?php } ?> <!-- Audio --> <?php if ($has_audio) { ?> <tr> <th> <label><?php _e('Formats:', 'wp-photo-album-plus'); ?> </th> <td> <table class="wppa-subtable" > <?php foreach ($has_audio as $fmt) { echo '<tr>' . '<td>' . $fmt . '</td>' . '<td>' . __('Filesize:', 'wp-photo-album-plus') . '</td>' . '<td>' . wppa_get_filesize(str_replace('xxx', $fmt, wppa_get_photo_path($photo['id']))) . '</td>' . '</tr>'; } ?> </table> </td> </tr> <?php } ?> <!-- Filesizes --> <tr> <th> <label><?php $is_video || $has_audio ? _e('Poster:', 'wp-photo-album-plus') : _e('Photo sizes:', 'wp-photo-album-plus'); ?> </label> </th> <td> <table class="wppa-subtable" > <tr> <td> <?php _e('Source file:', 'wp-photo-album-plus'); ?> </td> <?php $sp = wppa_get_source_path($photo['id']); if (is_file($sp)) { $ima = getimagesize($sp); ?> <td> <?php echo $ima['0'] . ' x ' . $ima['1'] . ' px.'; ?> </td> <td> <?php echo wppa_get_filesize($sp); ?> </td> <td> <a style="cursor:pointer; font-weight:bold;" title="<?php _e('Remake display file and thumbnail file', 'wp-photo-album-plus'); ?> " onclick="wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'remake', this )"><?php _e('Remake files', 'wp-photo-album-plus'); ?> </a> </td> <?php } else { ?> <td> <span style="color:orange;"><?php _e('Unavailable', 'wp-photo-album-plus'); ?> </span> </td> <td> </td> <td> </td> <?php } ?> </tr> <tr> <td> <?php _e('Display file:', 'wp-photo-album-plus'); ?> </td> <?php $dp = wppa_fix_poster_ext(wppa_get_photo_path($photo['id']), $photo['id']); if (is_file($dp)) { ?> <td> <?php echo floor(wppa_get_photox($photo['id'])) . ' x ' . floor(wppa_get_photoy($photo['id'])) . ' px.'; ?> </td> <td> <?php echo wppa_get_filesize($dp); ?> </td> <td> </td> <?php } else { ?> <td> <span style="color:red;"><?php _e('Unavailable', 'wp-photo-album-plus'); ?> </span> </td> <td> </td> <td> </td> <?php } ?> </tr> <tr> <td> <?php _e('Thumbnail file:', 'wp-photo-album-plus'); ?> </td> <?php $tp = wppa_fix_poster_ext(wppa_get_thumb_path($photo['id']), $photo['id']); if (is_file($tp)) { ?> <td> <?php echo floor(wppa_get_thumbx($photo['id'])) . ' x ' . floor(wppa_get_thumby($photo['id'])) . ' px.'; ?> </td> <td> <?php echo wppa_get_filesize($tp); ?> </td> <?php } else { ?> <td> <span style="color:red;"><?php _e('Unavailable', 'wp-photo-album-plus'); ?> </span> </td> <td> </td> <?php } ?> <td> <a style="cursor:pointer; font-weight:bold;" title="<?php _e('Remake thumbnail file', 'wp-photo-album-plus'); ?> " onclick="wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'remakethumb', this )"><?php _e('Remake', 'wp-photo-album-plus'); ?> </a> </td> </tr> </table> </td> </tr> <!-- Stereo --> <?php if (wppa_switch('enable_stereo')) { ?> <tr> <th> <label><?php _e('Stereophoto:', 'wp-photo-album-plus'); ?> </label> </th> <td> <select id="stereo-<?php echo $photo['id']; ?> " onchange="wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'stereo', this )" > <option value="0" <?php if ($photo['stereo'] == '0') { echo 'selected="selected" '; } ?> ><?php _e('no stereo image or ready anaglyph', 'wp-photo-album-plus'); ?> </option> <option value="1" <?php if ($photo['stereo'] == '1') { echo 'selected="selected" '; } ?> ><?php _e('Left - right stereo image', 'wp-photo-album-plus'); ?> </option> <option value="-1" <?php if ($photo['stereo'] == '-1') { echo 'selected="selected" '; } ?> ><?php _e('Right - left stereo image', 'wp-photo-album-plus'); ?> </option> <select> <td> </tr> <tr> <th> <label><?php _e('Images:', 'wp-photo-album-plus'); ?> </label> </th> <td> <?php $files = glob(WPPA_UPLOAD_PATH . '/stereo/' . $photo['id'] . '-*.*'); if (!empty($files)) { sort($files); $c = 0; echo '<table><tbody>'; foreach ($files as $file) { if (!$c) { echo '<tr>'; } if (is_file($file)) { echo '<td style="padding:0;" ><a href="' . str_replace(WPPA_UPLOAD_PATH, WPPA_UPLOAD_URL, $file) . '" target="_blank" >' . basename($file) . '</a></td>'; } if (strpos(basename($file), '_flat')) { $c++; } $c = ($c + 1) % 2; if (!$c) { echo '</tr>'; } } if ($c) { echo '<td style="padding:0;" ></td></tr>'; } echo '</tbody></table>'; } ?> </td> </tr> <?php } ?> <!-- Location --> <?php if ($photo['location'] || wppa_switch('geo_edit')) { ?> <tr> <th> <label><?php _e('Location:', 'wp-photo-album-plus'); ?> </label> </th> <td> <?php $loc = $photo['location'] ? $photo['location'] : '///'; $geo = explode('/', $loc); echo $geo['0'] . ' ' . $geo['1'] . ' '; if (wppa_switch('geo_edit')) { ?> <?php _e('Lat:', 'wp-photo-album-plus'); ?> <input type="text" style="width:100px;" id="lat-<?php echo $photo['id']; ?> " onkeyup="wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'lat', this );" onchange="wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'lat', this );" value="<?php echo $geo['2']; ?> " /> <?php _e('Lon:', 'wp-photo-album-plus'); ?> <input type="text" style="width:100px;" id="lon-<?php echo $photo['id']; ?> " onkeyup="wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'lon', this );" onchange="wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'lon', this );" value="<?php echo $geo['3']; ?> " /> <?php if (!wppa('front_edit')) { ?> <span class="description"><br /><?php _e('Refresh the page after changing to see the degrees being updated', 'wp-photo-album-plus'); ?> </span> <?php } ?> <?php } ?> </td> </tr> <?php } ?> <!-- Name --> <tr > <th > <label><?php _e('Photoname:', 'wp-photo-album-plus'); ?> </label> </th> <?php if (wppa_switch('use_wp_editor')) { ?> <td> <input type="text" style="width:100%;" id="pname-<?php echo $photo['id']; ?> " value="<?php echo esc_attr(stripslashes($photo['name'])); ?> " /> <input type="button" class="button-secundary" value="<?php _e('Update Photo name', 'wp-photo-album-plus'); ?> " onclick="wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'name', document.getElementById( 'pname-<?php echo $photo['id']; ?> ' ) );" /> </td> <?php } else { ?> <td> <input type="text" style="width:100%;" id="pname-<?php echo $photo['id']; ?> " onkeyup="wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'name', this );" onchange="wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'name', this );" value="<?php echo esc_attr(stripslashes($photo['name'])); ?> " /> </td> <?php } ?> </tr> <!-- Description --> <?php if (!wppa_switch('desc_is_restricted') || wppa_user_is('administrator')) { ?> <tr> <th> <label><?php _e('Description:', 'wp-photo-album-plus'); ?> </label> </th> <?php if (wppa_switch('use_wp_editor')) { ?> <td> <?php $alfaid = wppa_alfa_id($photo['id']); // $quicktags_settings = array( 'buttons' => 'strong,em,link,block,ins,ul,ol,li,code,close' ); wp_editor(stripslashes($photo['description']), 'wppaphotodesc' . $alfaid, array('wpautop' => true, 'media_buttons' => false, 'textarea_rows' => '6', 'tinymce' => true)); //, 'quicktags' => $quicktags_settings ) ); ?> <input type="button" class="button-secundary" value="<?php _e('Update Photo description', 'wp-photo-album-plus'); ?> " onclick="wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'description', document.getElementById( 'wppaphotodesc'+'<?php echo $alfaid; ?> ' ), false, '<?php echo $alfaid; ?> ' )" /> <img id="wppa-photo-spin-<?php echo $photo['id']; ?> " src="<?php echo wppa_get_imgdir() . 'wpspin.gif'; ?> " style="visibility:hidden" /> </td> <?php } else { ?> <td> <textarea style="width: 100%; height:120px;" onkeyup="wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'description', this )" onchange="wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'description', this )" ><?php echo stripslashes($photo['description']); ?> </textarea> </td> <?php } ?> </tr> <?php } else { ?> <tr> <th> <label><?php _e('Description:', 'wp-photo-album-plus'); ?> </label> </th> <td> <div style="width: 100%; height:120px; overflow:auto;" ><?php echo stripslashes($photo['description']); ?> </div> </td> </tr> <?php } ?> <!-- Custom --> <?php if (wppa_switch('custom_fields')) { $custom = wppa_get_photo_item($photo['id'], 'custom'); if ($custom) { $custom_data = unserialize($custom); } else { $custom_data = array('', '', '', '', '', '', '', '', '', ''); } foreach (array_keys($custom_data) as $key) { if (wppa_opt('custom_caption_' . $key)) { ?> <tr> <th> <label><?php echo wppa_opt('custom_caption_' . $key) . ':<br /><small>(w#cc' . $key . ')</small>'; ?> </label> </th> <td> <?php echo '<small>(w#cd' . $key . ')</small>'; ?> <input type="text" style="width:85%; float:right;" id="pname-<?php echo $photo['id']; ?> " onkeyup="wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'custom_<?php echo $key; ?> ', this );" onchange="wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'custom_<?php echo $key; ?> ', this );" value="<?php echo esc_attr(stripslashes($custom_data[$key])); ?> " /> </td> </tr> <?php } } } ?> <!-- Tags --> <tr style="vertical-align:middle;" > <th > <label ><?php _e('Tags:', 'wp-photo-album-plus'); ?> </label> <span class="description" > <br /> </span> </th> <td > <input id="tags-<?php echo $photo['id']; ?> " type="text" style="width:100%;" onchange="wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'tags', this )" value="<?php echo stripslashes(trim($photo['tags'], ',')); ?> " /> <span class="description" > <?php _e('Separate tags with commas.', 'wp-photo-album-plus'); ?> <?php _e('Examples:', 'wp-photo-album-plus'); ?> <select onchange="wppaAddTag( this.value, 'tags-<?php echo $photo['id']; ?> ' ); wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'tags', document.getElementById( 'tags-<?php echo $photo['id']; ?> ' ) )" > <?php $taglist = wppa_get_taglist(); if (is_array($taglist)) { echo '<option value="" >' . __('- select -', 'wp-photo-album-plus') . '</option>'; foreach ($taglist as $tag) { echo '<option value="' . $tag['tag'] . '" >' . $tag['tag'] . '</option>'; } } else { echo '<option value="0" >' . __('No tags yet', 'wp-photo-album-plus') . '</option>'; } ?> </select> <?php _e('Select to add', 'wp-photo-album-plus'); ?> </span> </td> </tr> <!-- Status --> <tr style="vertical-align:middle;" > <th> <label ><?php _e('Status:', 'wp-photo-album-plus'); ?> </label> </th> <td> <?php if ((current_user_can('wppa_admin') || current_user_can('wppa_moderate')) && !isset($_REQUEST['quick'])) { ?> <table> <tr> <td> <select id="status-<?php echo $photo['id']; ?> " onchange="wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'status', this ); wppaPhotoStatusChange( <?php echo $photo['id']; ?> ); "> <option value="pending" <?php if ($photo['status'] == 'pending') { echo 'selected="selected"'; } ?> ><?php _e('Pending', 'wp-photo-album-plus'); ?> </option> <option value="publish" <?php if ($photo['status'] == 'publish') { echo 'selected="selected"'; } ?> ><?php _e('Publish', 'wp-photo-album-plus'); ?> </option> <?php if (wppa_switch('ext_status_restricted') && !wppa_user_is('administrator')) { $dis = ' disabled'; } else { $dis = ''; } ?> <option value="featured" <?php if ($photo['status'] == 'featured') { echo 'selected="selected"'; } echo $dis; ?> ><?php _e('Featured', 'wp-photo-album-plus'); ?> </option> <option value="gold" <?php if ($photo['status'] == 'gold') { echo 'selected="selected"'; } echo $dis; ?> ><?php _e('Gold', 'wp-photo-album-plus'); ?> </option> <option value="silver" <?php if ($photo['status'] == 'silver') { echo 'selected="selected"'; } echo $dis; ?> ><?php _e('Silver', 'wp-photo-album-plus'); ?> </option> <option value="bronze" <?php if ($photo['status'] == 'bronze') { echo 'selected="selected"'; } echo $dis; ?> ><?php _e('Bronze', 'wp-photo-album-plus'); ?> </option> <option value="scheduled" <?php if ($photo['status'] == 'scheduled') { echo 'selected="selected"'; } echo $dis; ?> ><?php _e('Scheduled', 'wp-photo-album-plus'); ?> </option> <option value="private" <?php if ($photo['status'] == 'private') { echo 'selected="selected"'; } echo $dis; ?> ><?php _e('Private', 'wp-photo-album-plus'); ?> </option> </select> </td> <td class="wppa-datetime-<?php echo $photo['id']; ?> " > <?php echo wppa_get_date_time_select_html('photo', $photo['id'], true); ?> </td> </tr> </table> <?php } else { ?> <input type="hidden" id="status-<?php echo $photo['id']; ?> " value="<?php echo $photo['status']; ?> " /> <table> <tr> <td> <?php if ($photo['status'] == 'pending') { _e('Pending', 'wp-photo-album-plus'); } elseif ($photo['status'] == 'publish') { _e('Publish', 'wp-photo-album-plus'); } elseif ($photo['status'] == 'featured') { _e('Featured', 'wp-photo-album-plus'); } elseif ($photo['status'] == 'gold') { _e('Gold', 'wp-photo-album-plus'); } elseif ($photo['status'] == 'silver') { _e('Silver', 'wp-photo-album-plus'); } elseif ($photo['status'] == 'bronze') { _e('Bronze', 'wp-photo-album-plus'); } elseif ($photo['status'] == 'scheduled') { _e('Scheduled', 'wp-photo-album-plus'); } elseif ($photo['status'] == 'private') { _e('Private', 'wp-photo-album-plus'); } ?> </td> <td class="wppa-datetime-<?php echo $photo['id']; ?> " > <?php echo wppa_get_date_time_select_html('photo', $photo['id'], false); ?> </td> </tr> </table> <?php } ?> <span id="psdesc-<?php echo $photo['id']; ?> " class="description" style="display:none;" ><?php _e('Note: Featured photos should have a descriptive name; a name a search engine will look for!', 'wp-photo-album-plus'); ?> </span> </td> </tr> <!-- Watermark --> <?php if (!$is_video || is_file(wppa_fix_poster_ext(wppa_get_photo_path($photo['id']), $photo['id']))) { ?> <tr style="vertical-align:middle;" > <th > <label><?php _e('Watermark:', 'wp-photo-album-plus'); ?> </label> </th> <td> <?php $user = wppa_get_user(); if (wppa_switch('watermark_on')) { if (wppa_switch('watermark_user') || current_user_can('wppa_settings')) { echo __('File:', 'wppa', 'wp-photo-album-plus') . ' '; ?> <select id="wmfsel_<?php echo $photo['id']; ?> " onchange="wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'wppa_watermark_file_<?php echo $user; ?> ', this );" > <?php echo wppa_watermark_file_select(); ?> </select> <?php echo '<br />' . __('Pos:', 'wp-photo-album-plus') . ' '; ?> <select id="wmpsel_<?php echo $photo['id']; ?> " onchange="wppaAjaxUpdatePhoto( <?php echo $photo['id']; ?> , 'wppa_watermark_pos_<?php echo $user; ?> ', this );" > <?php echo wppa_watermark_pos_select(); ?> </select> <input type="button" class="button-secundary" value="<?php _e('Apply watermark', 'wp-photo-album-plus'); ?> " onclick="if ( confirm( '<?php echo esc_js(__('Are you sure? Once applied it can not be removed!', 'wp-photo-album-plus')) . '\\n\\n' . esc_js(__('And I do not know if there is already a watermark on this photo', 'wp-photo-album-plus')); ?> ' ) ) wppaAjaxApplyWatermark( <?php echo $photo['id']; ?> , document.getElementById( 'wmfsel_<?php echo $photo['id']; ?> ' ).value, document.getElementById( 'wmpsel_<?php echo $photo['id']; ?> ' ).value )" /> <?php } else { echo __('File:', 'wppa', 'wp-photo-album-plus') . ' ' . __($wmfile, 'wp-photo-album-plus'); if ($wmfile != '--- none ---') { echo ' ' . __('Pos:', 'wp-photo-album-plus') . ' ' . $wmpos; } } ?> <img id="wppa-water-spin-<?php echo $photo['id']; ?> " src="<?php echo wppa_get_imgdir() . 'wpspin.gif'; ?> " style="visibility:hidden" /><?php } else { _e('Not configured', 'wp-photo-album-plus'); } ?> </td> </tr> <?php } ?> <!-- Remark --> <tr style="vertical-align: middle;" > <th > <label style="color:#070"><?php _e('Remark:', 'wp-photo-album-plus'); ?> </label> </th> <td id="photostatus-<?php echo $photo['id']; ?> " style="padding-left:10px; width: 400px;"> <?php if (wppa_is_video($photo['id'])) { echo sprintf(__('Video %s is not modified yet', 'wp-photo-album-plus'), $photo['id']); } else { echo sprintf(__('Photo %s is not modified yet', 'wp-photo-album-plus'), $photo['id']); } ?> </td> </tr> </tbody> </table> <script type="text/javascript">wppaPhotoStatusChange( <?php echo $photo['id']; ?> )</script> </div> <div style="clear:both;"></div> <?php if (!isset($_REQUEST['quick'])) { ?> <div class="wppa-links" > <table style="width:100%" > <tbody> <?php if (current_user_can('edit_posts') || current_user_can('edit_pages')) { ?> <tr> <td><?php _e('Single image shortcode', 'wp-photo-album-plus'); ?> :</td> <td><?php echo esc_js('[wppa type="photo" photo="' . $photo['id'] . '" size="' . wppa_opt('fullsize') . '"][/wppa]'); ?> </td> </tr> <?php } ?> <?php if (is_file(wppa_get_source_path($photo['id']))) { ?> <tr> <td><?php _e('Permalink', 'wp-photo-album-plus'); ?> :</td> <td><?php echo wppa_get_source_pl($photo['id']); ?> </td> </tr> <?php } ?> <tr> <td><?php _e('Hi resolution url', 'wp-photo-album-plus'); ?> :</td> <td><?php echo wppa_get_hires_url($photo['id']); ?> </td> </tr> <?php if (is_file(wppa_get_photo_path($photo['id']))) { ?> <tr> <td><?php _e('Display file url', 'wp-photo-album-plus'); ?> :</td> <td><?php echo wppa_get_lores_url($photo['id']); ?> </td> </tr> <?php } ?> <?php if (is_file(wppa_get_thumb_path($photo['id']))) { ?> <tr> <td><?php _e('Thumbnail file url', 'wp-photo-album-plus'); ?> :</td> <td><?php echo wppa_get_tnres_url($photo['id']); ?> </td> </tr> <?php } ?> </tbody> </table> </div> <?php } ?> </div> <!-- Comments --> <?php $comments = $wpdb->get_results($wpdb->prepare("SELECT * FROM `" . WPPA_COMMENTS . "` WHERE `photo` = %s ORDER BY `timestamp` DESC", $photo['id']), ARRAY_A); if ($comments) { ?> <div class="widefat" style="width:99%; font-size:11px;" > <table class="wppa-table widefat wppa-setting-table" > <thead> <tr style="font-weight:bold;" > <td style="padding:0 4px;" >#</td> <td style="padding:0 4px;" >User</td> <td style="padding:0 4px;" >Time since</td> <td style="padding:0 4px;" >Status</td> <td style="padding:0 4px;" >Comment</td> </tr> </thead> <tbody> <?php foreach ($comments as $comment) { echo ' <tr> <td style="padding:0 4px;" >' . $comment['id'] . '</td> <td style="padding:0 4px;" >' . $comment['user'] . '</td> <td style="padding:0 4px;" >' . wppa_get_time_since($comment['timestamp']) . '</td>'; if (current_user_can('wppa_comments') || current_user_can('wppa_moderate') || wppa_get_user() == $photo['owner'] && wppa_switch('owner_moderate_comment')) { $p = $comment['status'] == 'pending' ? 'selected="selected" ' : ''; $a = $comment['status'] == 'approved' ? 'selected="selected" ' : ''; $s = $comment['status'] == 'spam' ? 'selected="selected" ' : ''; $t = $comment['status'] == 'trash' ? 'selected="selected" ' : ''; echo ' <td style="padding:0 4px;" > <select style="height: 20px; font-size: 11px; padding:0;" onchange="wppaAjaxUpdateCommentStatus( ' . $photo['id'] . ', ' . $comment['id'] . ', this.value )" > <option value="pending" ' . $p . '>' . __('Pending', 'wp-photo-album-plus') . '</option> <option value="approved" ' . $a . '>' . __('Approved', 'wp-photo-album-plus') . '</option> <option value="spam" ' . $s . '>' . __('Spam', 'wp-photo-album-plus') . '</option> <option value="trash" ' . $t . '>' . __('Trash', 'wp-photo-album-plus') . '</option> </select > </td> '; } else { echo '<td style="padding:0 4px;" >'; if ($comment['status'] == 'pending') { _e('Pending', 'wp-photo-album-plus'); } elseif ($comment['status'] == 'approved') { _e('Approved', 'wp-photo-album-plus'); } elseif ($comment['status'] == 'spam') { _e('Spam', 'wp-photo-album-plus'); } elseif ($comment['status'] == 'trash') { _e('Trash', 'wp-photo-album-plus'); } echo '</td>'; } echo '<td style="padding:0 4px;" >' . $comment['comment'] . '</td> </tr> '; } ?> </tbody> </table> </div> <?php } ?> <!-- </div> --> <div style="clear:both;margin-top:7px;"></div> <?php } /* foreach photo */ wppa_admin_page_links($page, $pagesize, $count, $link); } /* photos not empty */ }
function wppa_album_photos($album = '', $photo = '', $owner = '', $moderate = false) { global $wpdb; // Check input wppa_vfy_arg('wppa-page'); $pagesize = wppa_opt('photo_admin_pagesize'); $page = isset($_GET['wppa-page']) ? $_GET['wppa-page'] : '1'; $skip = ($page - '1') * $pagesize; $limit = $pagesize < '1' ? '' : ' LIMIT ' . $skip . ',' . $pagesize; // Edit the photos in a specific album if ($album) { // Special album case: search (see last album line in album table) if ($album == 'search') { $count = wppa_get_edit_search_photos('', 'count_only'); $photos = wppa_get_edit_search_photos($limit); $link = wppa_dbg_url(get_admin_url() . 'admin.php' . '?page=wppa_admin_menu' . '&tab=edit' . '&edit_id=' . $album . '&wppa-searchstring=' . wppa_sanitize_searchstring($_REQUEST['wppa-searchstring'])); } else { $counts = wppa_treecount_a($album); $count = $counts['selfphotos'] + $counts['pendphotos']; $photos = $wpdb->get_results($wpdb->prepare("SELECT * " . "FROM `" . WPPA_PHOTOS . "` " . "WHERE `album` = %s " . wppa_get_photo_order($album, 'norandom') . $limit, $album), ARRAY_A); $link = wppa_dbg_url(get_admin_url() . 'admin.php' . '?page=wppa_admin_menu' . '&tab=edit' . '&edit_id=' . $album); } } elseif ($photo && !$moderate) { $count = '1'; $photos = $wpdb->get_results($wpdb->prepare("SELECT * " . "FROM `" . WPPA_PHOTOS . "` " . "WHERE `id` = %s", $photo), ARRAY_A); $link = ''; } elseif ($owner) { $count = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) " . "FROM `" . WPPA_PHOTOS . "` " . "WHERE `owner` = %s", $owner)); $photos = $wpdb->get_results($wpdb->prepare("SELECT * " . "FROM `" . WPPA_PHOTOS . "` " . "WHERE `owner` = %s " . "ORDER BY `timestamp` DESC " . $limit, $owner), ARRAY_A); $link = wppa_dbg_url(get_admin_url() . 'admin.php' . '?page=wppa_edit_photo'); } elseif ($moderate) { // Can i moderate? if (!current_user_can('wppa_moderate')) { wp_die(__('You do not have the rights to do this', 'wp-photo-album-plus')); } // Moderate a single photo if ($photo) { $count = '1'; $photos = $wpdb->get_results($wpdb->prepare("SELECT * " . "FROM `" . WPPA_PHOTOS . "` " . "WHERE `id` = %s", $photo), ARRAY_A); $link = ''; } else { $cmt = $wpdb->get_results("SELECT `photo` " . "FROM `" . WPPA_COMMENTS . "` " . "WHERE `status` = 'pending' " . "OR `status` = 'spam'", ARRAY_A); if ($cmt) { $orphotois = ''; foreach ($cmt as $c) { $orphotois .= "OR `id` = " . $c['photo'] . " "; } } else { $orphotois = ''; } $count = $wpdb->get_var("SELECT COUNT(*) " . "FROM `" . WPPA_PHOTOS . "` " . "WHERE `status` = 'pending' " . $orphotois); $photos = $wpdb->get_results("SELECT * " . "FROM `" . WPPA_PHOTOS . "` " . "WHERE `status` = 'pending' " . $orphotois . " " . "ORDER BY `timestamp` DESC " . $limit, ARRAY_A); $link = wppa_dbg_url(get_admin_url() . 'admin.php' . '?page=wppa_moderate_photos'); } // No photos to moderate if (empty($photos)) { // Single photo moderate requested if ($photo) { echo '<p>' . __('This photo is no longer awaiting moderation.', 'wp-photo-album-plus') . '</p>'; } else { echo '<p>' . __('There are no photos awaiting moderation at this time.', 'wp-photo-album-plus') . '</p>'; } // If i am admin, i can edit all photos here, sorted by timestamp desc if (wppa_user_is('administrator')) { echo '<h3>' . __('Manage all photos by timestamp', 'wp-photo-album-plus') . '</h3>'; $count = $wpdb->get_var("SELECT COUNT(*) " . "FROM `" . WPPA_PHOTOS . "`"); $photos = $wpdb->get_results("SELECT * " . "FROM `" . WPPA_PHOTOS . "` " . "ORDER BY `timestamp` DESC" . $limit, ARRAY_A); $link = wppa_dbg_url(get_admin_url() . 'admin.php' . '?page=wppa_moderate_photos'); } else { return; } } } else { wppa_dbg_msg('Missing required argument in wppa_album_photos() 1', 'red', 'force'); return; } // Quick edit skips a few time consuming settings like copy and move to other album $quick = isset($_REQUEST['quick']); if ($link && $quick) { $link .= '&quick'; } // In case it is a seaerch and edit, show the search statistics wppa_show_search_statistics(); // If no photos selected produce apprpriate message and quit if (empty($photos)) { // A specific photo requested if ($photo) { echo '<div id="photoitem-' . $photo . '" class="photoitem" style="width:100%; background-color: rgb( 255, 255, 224 ); border-color: rgb( 230, 219, 85 );">' . '<span style="color:red">' . sprintf(__('Photo %s has been removed.', 'wp-photo-album-plus'), $photo) . '</span>' . '</div>'; } else { // Search if (isset($_REQUEST['wppa-searchstring'])) { echo '<h3>' . __('No photos matching your search criteria.', 'wp-photo-album-plus') . '</h3>'; } else { echo '<h3>' . __('No photos yet in this album.', 'wp-photo-album-plus') . '</h3>'; } } return; } else { // Local js functions placed here as long as there is not yet a possibility to translate texts in js files ?> <script> function wppaTryMove( id, video ) { var query; if ( ! jQuery( '#target-' + id ).val() ) { alert( '<?php echo esc_js(__('Please select an album to move to first.', 'wp-photo-album-plus')); ?> ' ); return false; } if ( video ) { query = '<?php echo esc_js(__('Are you sure you want to move this video?', 'wp-photo-album-plus')); ?> '; } else { query = '<?php echo esc_js(__('Are you sure you want to move this photo?', 'wp-photo-album-plus')); ?> '; } if ( confirm( query ) ) { wppaAjaxUpdatePhoto( id, 'moveto', document.getElementById( 'target-' + id ) ); } } function wppaTryCopy( id, video ) { var query; if ( ! jQuery( '#target-' + id ).val() ) { alert( '<?php echo esc_js(__('Please select an album to copy to first.', 'wp-photo-album-plus')); ?> ' ); return false; } if ( video ) { query = '<?php echo esc_js(__('Are you sure you want to copy this video?', 'wp-photo-album-plus')); ?> '; } else { query = '<?php echo esc_js(__('Are you sure you want to copy this photo?', 'wp-photo-album-plus')); ?> '; } if ( confirm( query ) ) { wppaAjaxUpdatePhoto( id, 'copyto', document.getElementById( 'target-' + id ) ); } } function wppaTryDelete( id, video ) { var query; if ( video ) { query = '<?php echo esc_js(__('Are you sure you want to delete this video?', 'wp-photo-album-plus')); ?> '; } else { query = '<?php echo esc_js(__('Are you sure you want to delete this photo?', 'wp-photo-album-plus')); ?> '; } if ( confirm( query ) ) { wppaAjaxDeletePhoto( id ) } } function wppaTryRotLeft( id ) { var query = '<?php echo esc_js(__('Are you sure you want to rotate this photo left?', 'wp-photo-album-plus')); ?> '; if ( confirm( query ) ) { wppaAjaxUpdatePhoto( id, 'rotleft', 0, <?php echo wppa('front_edit') ? 'false' : 'true'; ?> ); } } function wppaTryRot180( id ) { var query = '<?php echo esc_js(__('Are you sure you want to rotate this photo 180°?', 'wp-photo-album-plus')); ?> '; if ( confirm( query ) ) { wppaAjaxUpdatePhoto( id, 'rot180', 0, <?php echo wppa('front_edit') ? 'false' : 'true'; ?> ); } } function wppaTryRotRight( id ) { var query = '<?php echo esc_js(__('Are you sure you want to rotate this photo right?', 'wp-photo-album-plus')); ?> '; if ( confirm( query ) ) { wppaAjaxUpdatePhoto( id, 'rotright', 0, <?php echo wppa('front_edit') ? 'false' : 'true'; ?> ); } } function wppaTryFlip( id ) { var query = '<?php echo esc_js(__('Are you sure you want to flip this photo?', 'wp-photo-album-plus')); ?> '; if ( confirm( query ) ) { wppaAjaxUpdatePhoto( id, 'flip', 0, <?php echo wppa('front_edit') ? 'false' : 'true'; ?> ); } } function wppaTryWatermark( id ) { var wmFile = jQuery( '#wmfsel_' + id ).val(); if ( wmFile == '--- none ---' ) { alert( '<?php echo esc_js(__('No watermark selected', 'wp-photo-album-plus')); ?> ' ); return; } var query = '<?php echo esc_js(__('Are you sure? Once applied it can not be removed!', 'wp-photo-album-plus')); ?> '; query += '\n'; query += '<?php echo esc_js(__('And I do not know if there is already a watermark on this photo', 'wp-photo-album-plus')); ?> '; if ( confirm( query ) ) { wppaAjaxApplyWatermark( id, document.getElementById( 'wmfsel_' + id ).value, document.getElementById( 'wmpsel_' + id ).value ); } } </script> <?php // Get the current watermark file settings $wms = array('toplft' => __('top - left', 'wp-photo-album-plus'), 'topcen' => __('top - center', 'wp-photo-album-plus'), 'toprht' => __('top - right', 'wp-photo-album-plus'), 'cenlft' => __('center - left', 'wp-photo-album-plus'), 'cencen' => __('center - center', 'wp-photo-album-plus'), 'cenrht' => __('center - right', 'wp-photo-album-plus'), 'botlft' => __('bottom - left', 'wp-photo-album-plus'), 'botcen' => __('bottom - center', 'wp-photo-album-plus'), 'botrht' => __('bottom - right', 'wp-photo-album-plus')); $temp = wppa_get_water_file_and_pos('0'); $wmfile = isset($temp['select']) ? $temp['select'] : ''; $wmpos = isset($temp['pos']) && isset($wms[$temp['pos']]) ? $wms[$temp['pos']] : ''; $mvt = esc_attr(__('Move video', 'wp-photo-album-plus')); $mpt = esc_attr(__('Move photo', 'wp-photo-album-plus')); $cvt = esc_attr(__('Copy video', 'wp-photo-album-plus')); $cpt = esc_attr(__('Copy photo', 'wp-photo-album-plus')); // Display the pagelinks wppa_admin_page_links($page, $pagesize, $count, $link); // Display all photos foreach ($photos as $photo) { // We may not use extract(), so we do something like it here manually, hence controlled. $id = $photo['id']; $timestamp = $photo['timestamp']; $modified = $photo['modified']; $owner = $photo['owner']; $crypt = $photo['crypt']; $album = $photo['album']; $name = stripslashes($photo['name']); $description = stripslashes($photo['description']); $exifdtm = $photo['exifdtm']; $views = $photo['views']; $clicks = $photo['clicks']; $p_order = $photo['p_order']; $linktarget = $photo['linktarget']; $linkurl = $photo['linkurl']; $linktitle = stripslashes($photo['linktitle']); $alt = stripslashes($photo['alt']); $filename = $photo['filename']; $videox = $photo['videox']; $videoy = $photo['videoy']; $location = $photo['location']; $status = $photo['status']; $tags = trim(stripslashes($photo['tags']), ','); $stereo = $photo['stereo']; // See if item is a multimedia item $is_multi = wppa_is_multi($id); $is_video = wppa_is_video($id); // returns array of extensions $b_is_video = empty($is_video) ? 0 : 1; // boolean $has_audio = wppa_has_audio($id); // returns array of extensions $b_has_audio = empty($has_audio) ? 0 : 1; // boolean // Various usefull vars $owner_editable = wppa_switch('photo_owner_change') && wppa_user_is('administrator'); $sortby_orderno = wppa_get_album_item($album, 'p_order_by') == '1' || wppa_get_album_item($album, 'p_order_by') == '-1'; echo "\n" . '<a id="photo_' . $id . '" ></a>'; echo '<div' . ' id="photoitem-' . $id . '"' . ' class="wppa-table-wrap"' . ' style="width:100%;position:relative;"' . ' >'; echo '<input' . ' type="hidden"' . ' id="photo-nonce-' . $id . '"' . ' value="' . wp_create_nonce('wppa_nonce_' . $id) . '"' . ' />'; echo "\n" . '<!-- Section 1 -->' . '<table' . ' class="wppa-table wppa-photo-table"' . ' style="width:100%;"' . ' >' . '<tbody>'; // -- Preview thumbnail --- echo '<tr>' . '<td>'; $src = wppa_get_thumb_url($id); $big = wppa_get_photo_url($id); if ($is_video) { reset($is_video); $big = str_replace('xxx', current($is_video), $big); echo '<a' . ' href="' . $big . '"' . ' target="_blank"' . ' title="' . esc_attr(__('Preview fullsize video', 'wp-photo-album-plus')) . '"' . ' >' . wppa_get_video_html(array('id' => $id, 'tagid' => 'video-' . $id, 'width' => '160', 'height' => '160' * wppa_get_videoy($id) / wppa_get_videox($id), 'controls' => false, 'use_thumb' => true)) . '</a>'; } else { if ($has_audio) { $big = wppa_fix_poster_ext($big, $id); $src = wppa_fix_poster_ext($src, $id); } echo '<a' . ' href="' . $big . '"' . ' target="_blank"' . ' title="' . esc_attr(__('Preview fullsize photo', 'wp-photo-album-plus')) . '"' . ' >' . '<img' . ' src="' . $src . '"' . ' alt="' . esc_attr($name) . '"' . ' style="max-width: 160px; vertical-align:middle;"' . ' />' . '</a>'; if ($has_audio) { $audio = wppa_get_audio_html(array('id' => $id, 'tagid' => 'audio-' . $id, 'width' => '160', 'controls' => true)); echo '<br />' . ($audio ? $audio : '<span style="color:red;">' . __('Audio disabled', 'wp-photo-album-plus') . '</span>'); } } echo '</td>'; echo '<td>' . 'ID = ' . $id . '. ' . __('Crypt:', 'wp-photo-album-plus') . ' ' . $crypt . '. ' . __('Filename:', 'wp-photo-album-plus') . ' ' . $filename . '. ' . __('Upload:', 'wp-photo-album-plus') . ' ' . wppa_local_date('', $timestamp) . ' ' . __('local time', 'wp-photo-album-plus') . '. ' . ($owner_editable ? '' : __('By:', 'wp-photo-album-plus') . ' ' . $owner); if ($owner_editable) { echo __('Owned by:', 'wp-photo-album-plus') . '<input' . ' type="text"' . ' onkeyup="wppaAjaxUpdatePhoto( ' . $id . ', \'owner\', this )"' . ' onchange="wppaAjaxUpdatePhoto( ' . $id . ', \'owner\', this )"' . ' value="' . $owner . '"' . ' />'; } echo ' ' . sprintf(__('Album: %d (%s).', 'wp-photo-album-plus'), $album, wppa_get_album_name($album)); // Modified if ($modified > $timestamp) { echo ' ' . __('Modified:', 'wp-photo-album-plus') . ' ' . wppa_local_date('', $modified) . ' ' . __('local time', 'wp-photo-album-plus'); } else { echo ' ' . __('Not modified', 'wp-photo-album-plus'); } echo '. ' . __('EXIF Date:', 'wp-photo-album-plus'); if (wppa_user_is('administrator')) { // Admin may edit exif date echo '<input' . ' type="text"' . ' style="width:125px;"' . ' onkeyup="wppaAjaxUpdatePhoto( ' . $id . ', \'exifdtm\', this )"' . ' onchange="wppaAjaxUpdatePhoto( ' . $id . ', \'exifdtm\', this )"' . ' value="' . $exifdtm . '"' . ' />'; } else { echo $exifdtm . '.'; } echo ' '; // Location if ($photo['location'] || wppa_switch('geo_edit')) { echo __('Location:', 'wp-photo-album-plus') . ' '; $loc = $location ? $location : '///'; $geo = explode('/', $loc); echo $geo['0'] . ' ' . $geo['1'] . '. '; if (wppa_switch('geo_edit')) { echo __('Lat:', 'wp-photo-album-plus') . '<input' . ' type="text"' . ' style="width:100px;"' . ' id="lat-' . $id . '"' . ' onkeyup="wppaAjaxUpdatePhoto( ' . $id . ', \'lat\', this );"' . ' onchange="wppaAjaxUpdatePhoto( ' . $id . ', \'lat\', this );"' . ' value="' . $geo['2'] . '"' . ' />' . __('Lon:', 'wp-photo-album-plus') . '<input type="text"' . ' style="width:100px;"' . ' id="lon-' . $id . '"' . ' onkeyup="wppaAjaxUpdatePhoto( ' . $id . ', \'lon\', this );"' . ' onchange="wppaAjaxUpdatePhoto( ' . $id . ', \'lon\', this );"' . ' value="' . $geo['3'] . '"' . ' />'; } } // Changeable p_order echo __('Photo sort order #:', 'wp-photo-album-plus'); if ($sortby_orderno && (!wppa_switch('porder_restricted') || wppa_user_is('administrator'))) { echo '<input' . ' type="text"' . ' id="porder-' . $id . '"' . ' value="' . $p_order . '"' . ' style="width:30px;"' . ' onkeyup="wppaAjaxUpdatePhoto( ' . $id . ', \'p_order\', this )"' . ' onchange="wppaAjaxUpdatePhoto( ' . $id . ', \'p_order\', this )"' . ' />' . ' '; } else { echo $p_order . '. '; } // Rating $entries = wppa_get_rating_count_by_id($id); if ($entries) { if (wppa_opt('rating_display_type') == 'likes') { echo __('Likes:', 'wp-photo-album-plus') . ' ' . $entries . '. '; } else { echo __('Rating:', 'wp-photo-album-plus') . ' ' . __('Entries:', 'wp-photo-album-plus') . ' ' . $entries . ', ' . __('Mean value:', 'wp-photo-album-plus') . ' ' . wppa_get_rating_by_id($id, 'nolabel') . '. '; } } else { echo __('No ratings for this photo.', 'wp-photo-album-plus') . ' '; } $dislikes = wppa_dislike_get($id); if ($dislikes) { echo '<span style="color:red" >' . sprintf(__('Disliked by %d visitors', 'wp-photo-album-plus'), $dislikes) . '. ' . '</span>'; } $pending = wppa_pendrat_get($id); if ($pending) { echo '<span style="color:orange" >' . sprintf(__('%d pending votes.', 'wp-photo-album-plus'), $pending) . ' ' . '</span>'; } // Views if (wppa_switch('track_viewcounts')) { echo __('Views', 'wp-photo-album-plus') . ': ' . $views . '. '; } // Clicks if (wppa_switch('track_clickcounts')) { echo __('Clicks', 'wp-photo-album-plus') . ': ' . $clicks . '. '; } // Status echo '<br />' . __('Status:', 'wp-photo-album-plus') . ' '; if (current_user_can('wppa_admin') || current_user_can('wppa_moderate')) { if (wppa_switch('ext_status_restricted') && !wppa_user_is('administrator')) { $dis = ' disabled="disabled"'; } else { $dis = ''; } $sel = ' selected="selected"'; echo '<select' . ' id="status-' . $id . '"' . ' onchange="wppaAjaxUpdatePhoto( ' . $id . ', \'status\', this ); wppaPhotoStatusChange( ' . $id . ' );"' . ' >' . '<option value="pending"' . ($status == 'pending' ? $sel : '') . ' >' . __('Pending', 'wp-photo-album-plus') . '</option>' . '<option value="publish"' . ($status == 'publish' ? $sel : '') . ' >' . __('Publish', 'wp-photo-album-plus') . '</option>' . '<option value="featured"' . ($status == 'featured' ? $sel : '') . $dis . ' >' . __('Featured', 'wp-photo-album-plus') . '</option>' . '<option value="gold"' . ($status == 'gold' ? $sel : '') . $dis . ' >' . __('Gold', 'wp-photo-album-plus') . '</option>' . '<option value="silver"' . ($status == 'silver' ? $sel : '') . $dis . ' >' . __('Silver', 'wp-photo-album-plus') . '</option>' . '<option value="bronze"' . ($status == 'bronze' ? $sel : '') . $dis . ' >' . __('Bronze', 'wp-photo-album-plus') . '</option>' . '<option value="scheduled"' . ($status == 'scheduled' ? $sel : '') . $dis . ' >' . __('Scheduled', 'wp-photo-album-plus') . '</option>' . '<option value="private"' . ($status == 'private' ? $sel : '') . $dis . ' >' . __('Private', 'wp-photo-album-plus') . '</option>' . '</select>' . wppa_get_date_time_select_html('photo', $id, true); } else { echo '<input' . ' type="hidden"' . ' id="status-' . $id . '"' . ' value="' . $status . '"' . ' />'; if ($status == 'pending') { _e('Pending', 'wp-photo-album-plus'); } elseif ($status == 'publish') { _e('Publish', 'wp-photo-album-plus'); } elseif ($status == 'featured') { _e('Featured', 'wp-photo-album-plus'); } elseif ($status == 'gold') { _e('Gold', 'wp-photo-album-plus'); } elseif ($status == 'silver') { _e('Silver', 'wp-photo-album-plus'); } elseif ($status == 'bronze') { _e('Bronze', 'wp-photo-album-plus'); } elseif ($status == 'scheduled') { _e('Scheduled', 'wp-photo-album-plus'); } elseif ($status == 'private') { _e('Private', 'wp-photo-album-plus'); } echo wppa_get_date_time_select_html('photo', $id, false) . '<span id="psdesc-' . $id . '" class="description" style="display:none;" >' . __('Note: Featured photos should have a descriptive name; a name a search engine will look for!', 'wp-photo-album-plus') . '</span>'; } echo ' '; // Update status field echo __('Remark:', 'wp-photo-album-plus') . ' ' . '<span' . ' id="photostatus-' . $id . '"' . ' style="font-weight:bold;color:#00AA00;"' . ' >' . ($is_video ? sprintf(__('Video %s is not modified yet', 'wp-photo-album-plus'), $id) : sprintf(__('Photo %s is not modified yet', 'wp-photo-album-plus'), $id)) . '</span>'; // New Line echo '<br />'; // --- Available files --- echo __('Available files:', 'wp-photo-album-plus') . ' '; // Source echo __('Source file:', 'wp-photo-album-plus') . ' '; $sp = wppa_get_source_path($id); if (is_file($sp)) { $ima = getimagesize($sp); echo $ima['0'] . ' x ' . $ima['1'] . ' px, ' . wppa_get_filesize($sp) . '. '; } else { echo __('Unavailable', 'wp-photo-album-plus') . '. '; } // Display echo ($is_video || $has_audio ? __('Poster file:', 'wp-photo-album-plus') : __('Display file:', 'wp-photo-album-plus')) . ' '; $dp = wppa_fix_poster_ext(wppa_get_photo_path($id), $id); if (is_file($dp)) { echo floor(wppa_get_photox($id)) . ' x ' . floor(wppa_get_photoy($id)) . ' px, ' . wppa_get_filesize($dp) . '. '; } else { echo '<span style="color:red;" >' . __('Unavailable', 'wp-photo-album-plus') . '. ' . '</span>'; } // Thumbnail if (!$is_video) { echo __('Thumbnail file:', 'wp-photo-album-plus') . ' '; $tp = wppa_fix_poster_ext(wppa_get_thumb_path($id), $id); if (is_file($tp)) { echo floor(wppa_get_thumbx($id)) . ' x ' . floor(wppa_get_thumby($id)) . ' px, ' . wppa_get_filesize($tp) . '. '; } else { echo '<span style="color:red;" >' . __('Unavailable', 'wp-photo-album-plus') . '. ' . '</span>'; } } // New line echo '<br />'; // Video if ($b_is_video) { echo __('Video size:', 'wp-photo-album-plus') . ' ' . __('Width:', 'wp-photo-album-plus') . '<input' . ' style="width:50px;margin:0 4px;"' . ' onkeyup="wppaAjaxUpdatePhoto( ' . $id . ', \'videox\', this )"' . ' onchange="wppaAjaxUpdatePhoto( ' . $id . ', \'videox\', this )"' . ' value="' . $videox . '"' . ' />' . sprintf(__('pix, (0=default:%s)', 'wp-photo-album-plus'), wppa_opt('video_width')) . __('Height:', 'wp-photo-album-plus') . '<input' . ' style="width:50px;margin:0 4px;"' . ' onkeyup="wppaAjaxUpdatePhoto( ' . $id . ', \'videoy\', this )"' . ' onchange="wppaAjaxUpdatePhoto( ' . $id . ', \'videoy\', this )"' . ' value="' . $videoy . '"' . ' />' . sprintf(__('pix, (0=default:%s)', 'wp-photo-album-plus'), wppa_opt('video_height')) . ' ' . __('Formats:', 'wp-photo-album-plus') . ' '; $c = 0; foreach ($is_video as $fmt) { echo $fmt . ' ' . __('Filesize:', 'wp-photo-album-plus') . ' ' . wppa_get_filesize(str_replace('xxx', $fmt, wppa_get_photo_path($id))); $c++; if ($c == count($is_video)) { echo '. '; } else { echo ', '; } } } // Audio if ($b_has_audio) { echo __('Formats:', 'wp-photo-album-plus') . ' '; $c = 0; foreach ($has_audio as $fmt) { echo $fmt . ' ' . __('Filesize:', 'wp-photo-album-plus') . ' ' . wppa_get_filesize(str_replace('xxx', $fmt, wppa_get_photo_path($id))); $c++; if ($c == count($is_video)) { echo '. '; } else { echo ', '; } } } echo '</td>' . '</tr>' . '</tbody>' . '</table>'; echo "\n" . '<!-- Section 2 -->'; if (wppa_switch('enable_stereo') && !$is_multi || (!$is_multi || is_file(wppa_fix_poster_ext(wppa_get_photo_path($id), $id)))) { echo '<table' . ' class="wppa-table wppa-photo-table"' . ' style="width:100%;"' . ' >' . '<tbody>' . '<tr>' . '<td>'; // Stereo if (wppa_switch('enable_stereo') && !$is_multi) { echo __('Stereophoto:', 'wp-photo-album-plus') . ' ' . '<select' . ' id="stereo-' . $id . '"' . ' onchange="wppaAjaxUpdatePhoto( ' . $id . ', \'stereo\', this )"' . ' >' . '<option value="0"' . ($stereo == '0' ? ' selected="selected"' : '') . ' >' . __('no stereo image or ready anaglyph', 'wp-photo-album-plus') . '</option>' . '<option value="1"' . ($stereo == '1' ? ' selected="selected"' : '') . ' >' . __('Left - right stereo image', 'wp-photo-album-plus') . '</option>' . '<option value="-1"' . ($stereo == '-1' ? ' selected="selected"' : '') . ' >' . __('Right - left stereo image', 'wp-photo-album-plus') . '</option>' . '</select>' . ' '; __('Images:', 'wp-photo-album-plus') . ' '; $files = glob(WPPA_UPLOAD_PATH . '/stereo/' . $id . '-*.*'); $c = 0; if (!empty($files)) { sort($files); foreach ($files as $file) { echo '<a href="' . str_replace(WPPA_UPLOAD_PATH, WPPA_UPLOAD_URL, $file) . '" target="_blank" >' . basename($file) . '</a>'; $c++; if ($c == count($files)) { echo '. '; } else { echo ', '; } } } } // Watermark if (!$is_multi || is_file(wppa_fix_poster_ext(wppa_get_photo_path($id), $id))) { echo __('Watermark:', 'wp-photo-album-plus') . ' '; if (wppa_switch('watermark_on')) { $user = wppa_get_user(); if (wppa_switch('watermark_user') || current_user_can('wppa_settings')) { echo '<select' . ' id="wmfsel_' . $id . '"' . ' onchange="wppaAjaxUpdatePhoto( ' . $id . ', \'wppa_watermark_file_' . $user . '\', this );"' . ' >' . wppa_watermark_file_select() . '</select>' . __('Pos:', 'wp-photo-album-plus') . ' ' . '<select' . ' id="wmpsel_' . $id . '"' . ' onchange="wppaAjaxUpdatePhoto( ' . $id . ', \'wppa_watermark_pos_' . $user . '\', this );"' . ' >' . wppa_watermark_pos_select() . '</select>' . '<input' . ' type="button"' . ' class="button-secundary"' . ' value="' . esc_attr(__('Apply watermark', 'wp-photo-album-plus')) . '"' . ' onclick="wppaTryWatermark( ' . $id . ' )"' . ' />'; } else { echo __('File:', 'wp-photo-album-plus') . ' ' . __($wmfile, 'wp-photo-album-plus') . ' '; if ($wmfile != '--- none ---') { echo __('Pos:', 'wp-photo-album-plus') . ' ' . $wmpos; } } echo '<img' . ' id="wppa-water-spin-' . $id . '"' . ' src="' . wppa_get_imgdir() . 'spinner.gif' . '"' . ' alt="Spin"' . ' style="visibility:hidden"' . ' />'; } else { echo __('Not configured', 'wp-photo-album-plus'); } echo ' '; } echo '</td>' . '</tr>' . '</tbody>' . '</table>'; } echo "\n" . '<!-- Section 3 -->' . '<table' . ' class="wppa-table wppa-photo-table"' . ' style="width:100%;"' . ' >' . '<tbody>' . '<tr>' . '<td>'; // --- Actions --- // Rotate if (!$b_is_video) { echo '<input' . ' type="button"' . ' onclick="wppaTryRotLeft( ' . $id . ' )"' . ' value="' . esc_attr(__('Rotate left', 'wp-photo-album-plus')) . '"' . ' />' . ' ' . '<input' . ' type="button"' . ' onclick="wppaTryRot180( ' . $id . ' )"' . ' value="' . esc_attr(__('Rotate 180°', 'wp-photo-album-plus')) . '"' . ' />' . ' ' . '<input' . ' type="button"' . ' onclick="wppaTryRotRight( ' . $id . ' )"' . ' value="' . esc_attr(__('Rotate right', 'wp-photo-album-plus')) . '"' . ' />' . ' ' . '<input' . ' type="button"' . ' onclick="wppaTryFlip( ' . $id . ' )"' . ' value="' . esc_attr(__('Flip', 'wp-photo-album-plus')) . '"' . ' />' . ' '; } // Remake displayfiles if (!$is_video) { echo '<input' . ' type="button"' . ' title="' . esc_attr(__('Remake display file and thumbnail file', 'wp-photo-album-plus')) . '"' . ' onclick="wppaAjaxUpdatePhoto( ' . $id . ', \'remake\', this, ' . (wppa('front_edit') ? 'false' : 'true') . ' )"' . ' value="' . esc_attr(__('Remake files', 'wp-photo-album-plus')) . '"' . ' />' . ' '; } // Remake thumbnail if (!$is_video) { echo '<input' . ' type="button"' . ' title=' . esc_attr(__('Remake thumbnail file', 'wp-photo-album-plus')) . '"' . ' onclick="wppaAjaxUpdatePhoto( ' . $id . ', \'remakethumb\', this, ' . (wppa('front_edit') ? 'false' : 'true') . ' )"' . ' value="' . esc_attr(__('Remake thumbnail file', 'wp-photo-album-plus')) . '"' . ' />' . ' '; } // Move/copy if (!$quick) { $max = wppa_opt('photo_admin_max_albums'); if (!$max || wppa_get_total_album_count() < $max) { // If not done yet, get the album options html with the current album excluded if (!isset($album_select[$album])) { $album_select[$album] = wppa_album_select_a(array('checkaccess' => true, 'path' => wppa_switch('hier_albsel'), 'exclude' => $album, 'selected' => '0', 'addpleaseselect' => true)); } echo __('Target album for copy/move:', 'wp-photo-album-plus') . '<select' . ' id="target-' . $id . '"' . ' >' . $album_select[$album] . '</select>'; } else { echo __('Target album for copy/move:', 'wp-photo-album-plus') . '<input' . ' id="target-' . $id . '"' . ' type="number"' . ' style="height:20px;"' . ' placeholder="' . __('Album id', 'wp-photo-album-plus') . '"' . ' />'; } echo ' '; echo '<input' . ' type="button"' . ' onclick="wppaTryMove( ' . $id . ', ' . $b_is_video . ' )"' . ' value="' . ($b_is_video ? $mvt : $mpt) . '"' . ' />' . ' ' . '<input' . ' type="button"' . ' onclick="wppaTryCopy( ' . $id . ', ' . $b_is_video . ' )"' . ' value="' . ($b_is_video ? $cvt : $cpt) . '"' . ' />' . ' '; } // Delete if (!wppa('front_edit')) { echo '<input' . ' type="button"' . ' style="color:red;"' . ' onclick="wppaTryDelete( ' . $id . ', ' . $b_is_video . ' )"' . ' value="' . ($b_is_video ? esc_attr(__('Delete video', 'wp-photo-album-plus')) : esc_attr(__('Delete photo', 'wp-photo-album-plus'))) . '"' . ' />' . ' '; } // Re-upload if (wppa_user_is('administrator') || !wppa_switch('reup_is_restricted')) { echo '<input' . ' type="button"' . ' onclick="jQuery( \'#re-up-' . $id . '\' ).css( \'display\', \'inline-block\' )"' . ' value="' . esc_attr(__('Re-upload file', 'wp-photo-album-plus')) . '"' . ' />' . '<div id="re-up-' . $id . '" style="display:none" >' . '<form' . ' id="wppa-re-up-form-' . $id . '"' . ' onsubmit="wppaReUpload( event, ' . $id . ', \'' . $filename . '\' )"' . ' >' . '<input' . ' type="file"' . ' id="wppa-re-up-file-' . $id . '"' . ' />' . '<input' . ' type="submit"' . ' id="wppa-re-up-butn-' . $id . '"' . ' value="' . esc_attr(__('Upload', 'wp-photo-album-plus')) . '"' . ' />' . '</form>' . '</div>'; } // Refresh /* if ( ! wppa( 'front_edit' ) ) { echo '<input' . ' type="button"' . ' onclick="wppaReload( \'#photo_' . $id . '\')"' . ' value="' . esc_attr( __( 'Refresh page', 'wp-photo-album-plus' ) ) . '"' . ' />'; } */ echo '</td>' . '</tr>' . '</tbody>' . '</table>'; echo "\n" . '<!-- Section 4 -->' . '<table' . ' class="wppa-table wppa-photo-table"' . ' style="width:100%;"' . ' >' . '<tbody>'; // Name echo '<tr>' . '<td>' . __('Photoname:', 'wp-photo-album-plus') . '</td>' . '<td>' . '<input' . ' type="text"' . ' style="width:100%;"' . ' id="pname-' . $id . '"' . ' onkeyup="wppaAjaxUpdatePhoto( ' . $id . ', \'name\', this );"' . ' onchange="wppaAjaxUpdatePhoto( ' . $id . ', \'name\', this );"' . ' value="' . esc_attr(stripslashes($name)) . '"' . ' />' . '</td>' . '<td>' . '</td>' . '</tr>'; // Description if (!wppa_switch('desc_is_restricted') || wppa_user_is('administrator')) { echo '<tr>' . '<td>' . __('Description:', 'wp-photo-album-plus') . '</td>'; if (wppa_switch('use_wp_editor')) { $alfaid = wppa_alfa_id($id); echo '<td>'; wp_editor($description, 'wppaphotodesc' . $alfaid, array('wpautop' => true, 'media_buttons' => false, 'textarea_rows' => '6', 'tinymce' => true)); echo '</td>' . '<td>' . '<input' . ' type="button"' . ' class="button-secundary"' . ' value="' . esc_attr(__('Update Photo description', 'wp-photo-album-plus')) . '"' . ' onclick="wppaAjaxUpdatePhoto( ' . $id . ', \'description\', document.getElementById( \'wppaphotodesc' . $alfaid . '\' ), false, \'' . $alfaid . '\' )"' . ' />' . '<img' . ' id="wppa-photo-spin-' . $id . '"' . ' src="' . wppa_get_imgdir() . 'spinner.gif"' . ' style="visibility:hidden"' . ' />' . '</td>'; } else { echo '<td>' . '<textarea' . ' style="width:100%;height:60px;"' . ' onkeyup="wppaAjaxUpdatePhoto( ' . $id . ', \'description\', this )"' . ' onchange="wppaAjaxUpdatePhoto( ' . $id . ', \'description\', this )"' . ' >' . $description . '</textarea>' . '</td>' . '<td>' . '</td>'; } echo '</tr>'; } else { echo '<tr>' . '<td>' . __('Description:', 'wp-photo-album-plus') . '</td>' . '<td>' . $description . '</td>' . '<td>' . '</td>' . '</tr>'; } // Tags echo '<tr>' . '<td>' . __('Tags:', 'wp-photo-album-plus') . '</td>' . '<td>' . '<input' . ' id="tags-' . $id . '"' . ' type="text"' . ' style="width:100%;"' . ' onchange="wppaAjaxUpdatePhoto( ' . $id . ', \'tags\', this )"' . ' value="' . $tags . '"' . ' />' . '<br />' . '<span class="description" >' . __('Separate tags with commas.', 'wp-photo-album-plus') . '</span>' . '</td>' . '<td>' . '<select' . ' onchange="wppaAddTag( this.value, \'tags-' . $id . '\' ); wppaAjaxUpdatePhoto( ' . $id . ', \'tags\', document.getElementById( \'tags-' . $id . '\' ) )"' . ' >'; $taglist = wppa_get_taglist(); if (is_array($taglist)) { echo '<option value="" >' . __('- select -', 'wp-photo-album-plus') . '</option>'; foreach ($taglist as $tag) { echo '<option value="' . $tag['tag'] . '" >' . $tag['tag'] . '</option>'; } } else { echo '<option value="0" >' . __('No tags yet', 'wp-photo-album-plus') . '</option>'; } echo '</select>' . '<br />' . '<span class="description" >' . __('Select to add', 'wp-photo-album-plus') . '</span>' . '</td>' . '</tr>'; // Custom if (wppa_switch('custom_fields')) { $custom = wppa_get_photo_item($photo['id'], 'custom'); if ($custom) { $custom_data = unserialize($custom); } else { $custom_data = array('', '', '', '', '', '', '', '', '', ''); } foreach (array_keys($custom_data) as $key) { if (wppa_opt('custom_caption_' . $key)) { echo '<tr>' . '<td>' . apply_filters('translate_text', wppa_opt('custom_caption_' . $key)) . '<small style="float:right" >' . '(w#cc' . $key . ')' . '</small>:' . '</td>' . '<td>' . '<input' . ' type="text"' . ' style="width:100%;"' . ' id="custom_' . $key . '-' . $id . '"' . ' onkeyup="wppaAjaxUpdatePhoto( ' . $id . ', \'custom_' . $key . '\', this );"' . ' onchange="wppaAjaxUpdatePhoto( ' . $id . ', \'custom_' . $key . '\', this );"' . ' value="' . esc_attr(stripslashes($custom_data[$key])) . '"' . '/>' . '</td>' . '<td>' . '<small>(w#cd' . $key . ')</small>' . '</td> ' . '</tr>'; } } } // -- Auto Page -- if (wppa_switch('auto_page') && (current_user_can('edit_posts') || current_user_can('edit_pages'))) { $appl = get_permalink(wppa_get_the_auto_page($id)); echo '<tr>' . '<td>' . __('Autopage Permalink:', 'wp-photo-album-plus') . '</td>' . '<td>' . '<a href="' . $appl . '" target="_blank" >' . $appl . '</a>' . '</td>' . '<td>' . '</td>' . '</tr>'; } // -- Link url -- if (!wppa_switch('link_is_restricted') || wppa_user_is('administrator')) { echo '<tr>' . '<td>' . __('Photo specific link url:', 'wp-photo-album-plus') . '</td>' . '<td>' . '<input' . ' type="text"' . ' id="pislink-' . $id . '"' . ' style="width:100%;"' . ' onkeyup="wppaAjaxUpdatePhoto( ' . $id . ', \'linkurl\', this )"' . ' onchange="wppaAjaxUpdatePhoto( ' . $id . ', \'linkurl\', this )"' . ' value="' . esc_attr($linkurl) . '"' . ' />' . '</td>' . '<td>' . '<select' . ' id="pistarget-' . $id . '"' . ' onchange="wppaAjaxUpdatePhoto( ' . $id . ', \'linktarget\', this )"' . ' >' . '<option' . ' value="_self"' . ($linktarget == '_self' ? ' selected="selected"' : '') . ' >' . __('Same tab', 'wp-photo-album-plus') . '</option>' . '<option' . ' value="_blank"' . ($linktarget == '_blank' ? ' selected="selected"' : '') . ' >' . __('New tab', 'wp-photo-album-plus') . '</option>' . '</select>' . '<input' . ' type="button"' . ' onclick="window.open( jQuery( \'#pislink-' . $id . '\' ).val(), jQuery( \'#pistarget-' . $id . '\' ).val() );"' . ' value="' . __('Tryit!', 'wp-photo-album-plus') . '"' . ' />' . '</td>' . '</tr>'; // -- Link title -- echo '<tr>' . '<td>' . __('Photo specific link title:', 'wp-photo-album-plus') . '</td>' . '<td>' . '<input' . ' type="text"' . ' style="width:100%;"' . ' onkeyup="wppaAjaxUpdatePhoto( ' . $id . ', \'linktitle\', this )"' . ' onchange="wppaAjaxUpdatePhoto( ' . $id . ', \'linktitle\', this )"' . ' value="' . esc_attr($linktitle) . '"' . ' />'; if (current_user_can('wppa_settings')) { echo '<br />' . '<span class="description" >' . __('If you want this link to be used, check \'PS Overrule\' checkbox in table VI.', 'wp-photo-album-plus') . '</span>'; } echo '</td>' . '<td>' . '</td>' . '</tr>'; } // -- Custom ALT field -- if (wppa_opt('alt_type') == 'custom') { echo '<tr>' . '<td>' . __('HTML Alt attribute:', 'wp-photo-album-plus') . '</td>' . '<td>' . '<input' . ' type="text"' . ' style="width:100%;"' . ' onkeyup="wppaAjaxUpdatePhoto( ' . $id . ', \'alt\', this )"' . ' onchange="wppaAjaxUpdatePhoto( ' . $id . ', \'alt\', this )"' . ' value="' . esc_attr($alt) . '"' . ' />' . '</td>' . '<td>' . '</td>' . '</tr>'; } // If Quick, skip the following items for speed and space if (!$quick) { // Shortcode if (current_user_can('edit_posts') || current_user_can('edit_pages')) { echo '<tr>' . '<td>' . __('Single image shortcode', 'wp-photo-album-plus') . ':' . '</td>' . '<td>' . '[wppa type="photo" photo="' . $id . '"][/wppa]' . '</td>' . '<td>' . '<small>' . sprintf(__('See %s The documentation %s for more shortcode options.', 'wp-photo-album-plus'), '<a href="http://wppa.nl/shortcode-reference/" target="_blank" >', '</a>') . '</small>' . '</td>' . '</tr>'; } // Source permalink if (is_file(wppa_get_source_path($id))) { $spl = wppa_get_source_pl($id); echo '<tr>' . '<td>' . __('Permalink', 'wp-photo-album-plus') . ':' . '</td>' . '<td>' . '<a href="' . $spl . '" target="_blank" >' . $spl . '</a>' . '</td>' . '<td>' . '</td>' . '</tr>'; } // High resolution url $hru = wppa_get_hires_url($id); echo '<tr>' . '<td>' . __('Hi resolution url', 'wp-photo-album-plus') . ':' . '</td>' . '<td>' . '<a href="' . $hru . '" target="_blank" >' . $hru . '</a>' . '</td>' . '<td>' . '</td>' . '</tr>'; // Display file if (is_file(wppa_fix_poster_ext(wppa_get_photo_path($id), $id))) { $lru = wppa_fix_poster_ext(wppa_get_lores_url($id), $id); echo '<tr>' . '<td>' . __('Display file url', 'wp-photo-album-plus') . ':' . '</td>' . '<td>' . '<a href="' . $lru . '" target="_blank" >' . $lru . '</a>' . '</td>' . '<td>' . '</td>' . '</tr>'; } // Thumbnail if (is_file(wppa_fix_poster_ext(wppa_get_thumb_path($id), $id))) { $tnu = wppa_fix_poster_ext(wppa_get_tnres_url($id), $id); echo '<tr>' . '<td>' . __('Thumbnail file url', 'wp-photo-album-plus') . ':' . '</td>' . '<td>' . '<a href="' . $tnu . '" target="_blank" >' . $tnu . '</a>' . '</td>' . '<td>' . '</td>' . '</tr>'; } } echo '</tbody>' . '</table>'; echo "\n" . '<!-- Section 5 -->'; // Comments $comments = $wpdb->get_results($wpdb->prepare("SELECT * FROM `" . WPPA_COMMENTS . "` WHERE `photo` = %s ORDER BY `timestamp` DESC", $id), ARRAY_A); if ($comments && !$quick) { echo '<table' . ' class="wppa-table wppa-photo-table"' . ' style="width:100%;"' . ' >' . '<thead>' . '<tr style="font-weight:bold;" >' . '<td style="padding:0 4px;" >#</td>' . '<td style="padding:0 4px;" >User</td>' . '<td style="padding:0 4px;" >Time since</td>' . '<td style="padding:0 4px;" >Status</td>' . '<td style="padding:0 4px;" >Comment</td>' . '</tr>' . '</thead>' . '<tbody>'; foreach ($comments as $comment) { echo ' <tr id="com-tr-' . $comment['id'] . '" > <td style="padding:0 4px;" >' . $comment['id'] . '</td> <td style="padding:0 4px;" >' . $comment['user'] . '</td> <td style="padding:0 4px;" >' . wppa_get_time_since($comment['timestamp']) . '</td>'; if (current_user_can('wppa_comments') || current_user_can('wppa_moderate') || wppa_get_user() == $photo['owner'] && wppa_switch('owner_moderate_comment')) { $p = $comment['status'] == 'pending' ? 'selected="selected" ' : ''; $a = $comment['status'] == 'approved' ? 'selected="selected" ' : ''; $s = $comment['status'] == 'spam' ? 'selected="selected" ' : ''; $t = $comment['status'] == 'trash' ? 'selected="selected" ' : ''; echo '<td style="padding:0 4px;" >' . '<select' . ' id="com-stat-' . $comment['id'] . '"' . ' style=""' . ' onchange="wppaAjaxUpdateCommentStatus( ' . $id . ', ' . $comment['id'] . ', this.value );wppaSetComBgCol(' . $comment['id'] . ');"' . ' >' . '<option value="pending" ' . $p . '>' . __('Pending', 'wp-photo-album-plus') . '</option>' . '<option value="approved" ' . $a . '>' . __('Approved', 'wp-photo-album-plus') . '</option>' . '<option value="spam" ' . $s . '>' . __('Spam', 'wp-photo-album-plus') . '</option>' . '<option value="trash" ' . $t . '>' . __('Trash', 'wp-photo-album-plus') . '</option>' . '</select >' . '</td>'; } else { echo '<td style="padding:0 4px;" >'; if ($comment['status'] == 'pending') { _e('Pending', 'wp-photo-album-plus'); } elseif ($comment['status'] == 'approved') { _e('Approved', 'wp-photo-album-plus'); } elseif ($comment['status'] == 'spam') { _e('Spam', 'wp-photo-album-plus'); } elseif ($comment['status'] == 'trash') { _e('Trash', 'wp-photo-album-plus'); } echo '</td>'; } echo '<td style="padding:0 4px;" >' . $comment['comment'] . '</td> </tr>' . '<script>wppaSetComBgCol(' . $comment['id'] . ')</script>'; } echo '</tbody>' . '</table>'; } echo '<script>wppaPhotoStatusChange( ' . $id . ' )</script>' . '<div style="clear:both;"></div>' . '</div>' . '<div style="clear:both;margin-top:7px;"></div>'; } /* foreach photo */ wppa_admin_page_links($page, $pagesize, $count, $link); } /* photos not empty */ }
function wppa_do_maintenance_proc($slug) { global $wpdb; global $wppa_session; global $wppa_supported_video_extensions; global $wppa_supported_audio_extensions; // Check for multiple maintenance procs if (!wppa_switch('maint_ignore_concurrency_error') && !wppa_is_cron()) { $all_slugs = array('wppa_remake_index_albums', 'wppa_remove_empty_albums', 'wppa_remake_index_photos', 'wppa_apply_new_photodesc_all', 'wppa_append_to_photodesc', 'wppa_remove_from_photodesc', 'wppa_remove_file_extensions', 'wppa_readd_file_extensions', 'wppa_all_ext_to_lower', 'wppa_regen_thumbs', 'wppa_rerate', 'wppa_recup', 'wppa_file_system', 'wppa_cleanup', 'wppa_remake', 'wppa_list_index', 'wppa_blacklist_user', 'wppa_un_blacklist_user', 'wppa_rating_clear', 'wppa_viewcount_clear', 'wppa_iptc_clear', 'wppa_exif_clear', 'wppa_watermark_all', 'wppa_create_all_autopages', 'wppa_delete_all_autopages', 'wppa_leading_zeros', 'wppa_add_gpx_tag', 'wppa_optimize_ewww', 'wppa_comp_sizes', 'wppa_edit_tag', 'wppa_sync_cloud', 'wppa_sanitize_tags', 'wppa_sanitize_cats', 'wppa_test_proc', 'wppa_crypt_photos', 'wppa_crypt_albums', 'wppa_create_o1_files', 'wppa_owner_to_name_proc', 'wppa_move_all_photos'); foreach (array_keys($all_slugs) as $key) { if ($all_slugs[$key] != $slug) { if (get_option($all_slugs[$key] . '_togo', '0')) { // Process running return __('You can run only one maintenance procedure at a time', 'wp-photo-album-plus') . '||' . $slug . '||' . __('Error', 'wp-photo-album-plus') . '||' . '' . '||' . ''; } } } } // Lock this proc if (wppa_is_cron()) { update_option($slug . '_user', 'cron-job'); update_option($slug . '_lasttimestamp', time()); } else { update_option($slug . '_user', wppa_get_user()); } // Extend session wppa_extend_session(); // Initialize // Cron job: 30 sec, realtime: 5 sec $endtime = wppa_is_cron() ? time() + '30' : time() + '5'; $chunksize = '1000'; $lastid = strval(intval(get_option($slug . '_last', '0'))); $errtxt = ''; $id = '0'; $topid = '0'; $reload = ''; $to_delete_from_cloudinary = array(); if (!isset($wppa_session)) { $wppa_session = array(); } if (!isset($wppa_session[$slug . '_fixed'])) { $wppa_session[$slug . '_fixed'] = '0'; } if (!isset($wppa_session[$slug . '_added'])) { $wppa_session[$slug . '_added'] = '0'; } if (!isset($wppa_session[$slug . '_deleted'])) { $wppa_session[$slug . '_deleted'] = '0'; } if (!isset($wppa_session[$slug . '_skipped'])) { $wppa_session[$slug . '_skipped'] = '0'; } if ($lastid == '0') { $wppa_session[$slug . '_fixed'] = '0'; $wppa_session[$slug . '_deleted'] = '0'; $wppa_session[$slug . '_skipped'] = '0'; } wppa_save_session(); // Pre-processing needed? if ($lastid == '0') { if (wppa_is_cron()) { wppa_log('Obs', 'Cron job ' . $slug . ' started.'); } else { wppa_log('Obs', 'Maintenance proc ' . $slug . ' started.'); } switch ($slug) { case 'wppa_remake_index_albums': // Pre-Clear album index only if not cron if (!wppa_is_cron()) { $wpdb->query("UPDATE `" . WPPA_INDEX . "` SET `albums` = ''"); } break; case 'wppa_remake_index_photos': // Pre-Clear photo index only if not cron if (!wppa_is_cron()) { $wpdb->query("UPDATE `" . WPPA_INDEX . "` SET `photos` = ''"); } wppa_index_compute_skips(); break; case 'wppa_recup': // Pre-Clear exif and iptc tables only if not cron if (!wppa_is_cron()) { $wpdb->query("DELETE FROM `" . WPPA_IPTC . "` WHERE `photo` <> '0'"); $wpdb->query("DELETE FROM `" . WPPA_EXIF . "` WHERE `photo` <> '0'"); } break; case 'wppa_file_system': if (get_option('wppa_file_system') == 'flat') { update_option('wppa_file_system', 'to-tree'); } if (get_option('wppa_file_system') == 'tree') { update_option('wppa_file_system', 'to-flat'); } break; case 'wppa_cleanup': $orphan_album = get_option('wppa_orphan_album', '0'); $album_exists = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM`" . WPPA_ALBUMS . "` WHERE `id` = %s", $orphan_album)); if (!$album_exists) { $orphan_album = false; } if (!$orphan_album) { $orphan_album = wppa_create_album_entry(array('name' => __('Orphan photos', 'wp-photo-album-plus'), 'a_parent' => '-1', 'description' => __('This album contains refound lost photos', 'wp-photo-album-plus'))); update_option('wppa_orphan_album', $orphan_album); } break; case 'wppa_sync_cloud': if (!wppa_get_present_at_cloudinary_a()) { // Still Initializing $status = 'Initializing'; if (!isset($wppa_session['fun-count'])) { $wppa_session['fun-count'] = 0; } $wppa_session['fun-count'] = ($wppa_session['fun-count'] + 1) % 3; for ($i = 0; $i < $wppa_session['fun-count']; $i++) { $status .= '.'; } $togo = 'all'; $reload = false; echo '||' . $slug . '||' . $status . '||' . $togo . '||' . $reload; wppa_exit(); } break; case 'wppa_crypt_albums': update_option('wppa_album_crypt_0', wppa_get_unique_album_crypt()); update_option('wppa_album_crypt_1', wppa_get_unique_album_crypt()); update_option('wppa_album_crypt_2', wppa_get_unique_album_crypt()); update_option('wppa_album_crypt_3', wppa_get_unique_album_crypt()); update_option('wppa_album_crypt_9', wppa_get_unique_album_crypt()); break; case 'wppa_owner_to_name_proc': if (!wppa_switch('owner_to_name')) { echo __('Feature must be enabled in Table IV-A28 first', 'wp-photo-album-plus') . '||' . $slug . '||||||'; wppa_exit(); } break; case 'wppa_move_all_photos': $fromalb = get_option('wppa_move_all_photos_from'); if (!wppa_album_exists($fromalb)) { echo sprintf(__('From album %d does not exist', 'wp-photo-album-plus'), $fromalb); wppa_exit(); } $toalb = get_option('wppa_move_all_photos_to'); if (!wppa_album_exists($toalb)) { echo sprintf(__('To album %d does not exist', 'wp-photo-album-plus'), $toalb); wppa_exit(); } if ($fromalb == $toalb) { echo __('From and To albums are identical', 'wp-photo-album-plus'); wppa_exit(); } break; } wppa_save_session(); } // Dispatch on albums / photos / single actions switch ($slug) { case 'wppa_remake_index_albums': case 'wppa_remove_empty_albums': case 'wppa_sanitize_cats': case 'wppa_crypt_albums': // Process albums $table = WPPA_ALBUMS; $topid = $wpdb->get_var("SELECT `id` FROM `" . WPPA_ALBUMS . "` ORDER BY `id` DESC LIMIT 1"); $albums = $wpdb->get_results("SELECT * FROM `" . WPPA_ALBUMS . "` WHERE `id` > " . $lastid . " ORDER BY `id` LIMIT 100", ARRAY_A); wppa_cache_album('add', $albums); if ($albums) { foreach ($albums as $album) { $id = $album['id']; switch ($slug) { case 'wppa_remake_index_albums': // If done as cron job, no initial clear has been done if (wppa_is_cron()) { wppa_index_remove('album', $id); } wppa_index_add('album', $id); break; case 'wppa_remove_empty_albums': $p = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM `" . WPPA_PHOTOS . "` WHERE `album` = %s", $id)); $a = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM `" . WPPA_ALBUMS . "` WHERE `a_parent` = %s", $id)); if (!$a && !$p) { $wpdb->query($wpdb->prepare("DELETE FROM `" . WPPA_ALBUMS . "` WHERE `id` = %s", $id)); wppa_delete_album_source($id); wppa_flush_treecounts($id); wppa_index_remove('album', $id); } break; case 'wppa_sanitize_cats': $cats = $album['cats']; if ($cats) { wppa_update_album(array('id' => $album['id'], 'cats' => wppa_sanitize_tags($cats))); } break; case 'wppa_crypt_albums': wppa_update_album(array('id' => $album['id'], 'crypt' => wppa_get_unique_album_crypt())); break; } // Test for timeout / ready $lastid = $id; update_option($slug . '_last', $lastid); if (time() > $endtime) { break; } // Time out } } else { // Nothing to do, Done anyway $lastid = $topid; } break; // End process albums // End process albums case 'wppa_remake_index_photos': case 'wppa_apply_new_photodesc_all': case 'wppa_append_to_photodesc': case 'wppa_remove_from_photodesc': case 'wppa_remove_file_extensions': case 'wppa_readd_file_extensions': case 'wppa_all_ext_to_lower': case 'wppa_regen_thumbs': case 'wppa_rerate': case 'wppa_recup': case 'wppa_file_system': case 'wppa_cleanup': case 'wppa_remake': case 'wppa_watermark_all': case 'wppa_create_all_autopages': case 'wppa_delete_all_autopages': case 'wppa_leading_zeros': case 'wppa_add_gpx_tag': case 'wppa_optimize_ewww': case 'wppa_comp_sizes': case 'wppa_edit_tag': case 'wppa_sync_cloud': case 'wppa_sanitize_tags': case 'wppa_crypt_photos': case 'wppa_test_proc': case 'wppa_create_o1_files': case 'wppa_owner_to_name_proc': case 'wppa_move_all_photos': // Process photos $table = WPPA_PHOTOS; if ($slug == 'wppa_cleanup') { $topid = get_option('wppa_' . WPPA_PHOTOS . '_lastkey', '1') * 10; $photos = array(); for ($i = $lastid + '1'; $i <= $topid; $i++) { $photos[]['id'] = $i; } } else { $topid = $wpdb->get_var("SELECT `id` FROM `" . WPPA_PHOTOS . "` ORDER BY `id` DESC LIMIT 1"); $photos = $wpdb->get_results("SELECT * FROM `" . WPPA_PHOTOS . "` WHERE `id` > " . $lastid . " ORDER BY `id` LIMIT " . $chunksize, ARRAY_A); } if ($slug == 'wppa_edit_tag') { $edit_tag = get_option('wppa_tag_to_edit'); $new_tag = get_option('wppa_new_tag_value'); } if (!$photos && $slug == 'wppa_file_system') { $fs = get_option('wppa_file_system'); if ($fs == 'to-tree') { $to = 'tree'; } elseif ($fs == 'to-flat') { $to = 'flat'; } else { $to = $fs; } } if ($photos) { foreach ($photos as $photo) { $thumb = $photo; // Make globally known $id = $photo['id']; switch ($slug) { case 'wppa_remake_index_photos': // If done as cron job, no initial clear has been done if (wppa_is_cron()) { wppa_index_remove('photo', $id); } wppa_index_add('photo', $id); break; case 'wppa_apply_new_photodesc_all': $value = wppa_opt('newphoto_description'); $description = trim($value); if ($description != $photo['description']) { // Modified photo description $wpdb->query($wpdb->prepare("UPDATE `" . WPPA_PHOTOS . "` SET `description` = %s WHERE `id` = %s", $description, $id)); } break; case 'wppa_append_to_photodesc': $value = trim(wppa_opt('append_text')); if (!$value) { return 'Unexpected error: missing text to append||' . $slug . '||Error||0'; } $description = rtrim($photo['description'] . ' ' . $value); if ($description != $photo['description']) { // Modified photo description $wpdb->query($wpdb->prepare("UPDATE `" . WPPA_PHOTOS . "` SET `description` = %s WHERE `id` = %s", $description, $id)); } break; case 'wppa_remove_from_photodesc': $value = trim(wppa_opt('remove_text')); if (!$value) { return 'Unexpected error: missing text to remove||' . $slug . '||Error||0'; } $description = rtrim(str_replace($value, '', $photo['description'])); if ($description != $photo['description']) { // Modified photo description $wpdb->query($wpdb->prepare("UPDATE `" . WPPA_PHOTOS . "` SET `description` = %s WHERE `id` = %s", $description, $id)); } break; case 'wppa_remove_file_extensions': if (!wppa_is_video($id)) { $name = str_replace(array('.jpg', '.png', '.gif', '.JPG', '.PNG', '.GIF'), '', $photo['name']); if ($name != $photo['name']) { // Modified photo name $wpdb->query($wpdb->prepare("UPDATE `" . WPPA_PHOTOS . "` SET `name` = %s WHERE `id` = %s", $name, $id)); } } break; case 'wppa_readd_file_extensions': if (!wppa_is_video($id)) { $name = str_replace(array('.jpg', '.png', 'gif', '.JPG', '.PNG', '.GIF'), '', $photo['name']); if ($name == $photo['name']) { // Name had no fileextension $wpdb->query($wpdb->prepare("UPDATE `" . WPPA_PHOTOS . "` SET `name` = %s WHERE `id` = %s", $name . '.' . $photo['ext'], $id)); } } break; case 'wppa_all_ext_to_lower': $EXT = wppa_get_photo_item($id, 'ext'); $ext = strtolower($EXT); if ($EXT != $ext) { wppa_update_photo(array('id' => $id, 'ext' => $ext)); $fixed_this = true; } $EXT = strtoupper($ext); $rawpath = wppa_strip_ext(wppa_get_photo_path($id)); $rawthumb = wppa_strip_ext(wppa_get_thumb_path($id)); $fixed_this = false; if (wppa_is_multi($id)) { } else { if (is_file($rawpath . '.' . $EXT)) { if (is_file($rawpath . '.' . $ext)) { unlink($rawpath . '.' . $EXT); } else { rename($rawpath . '.' . $EXT, $rawpath . '.' . $ext); } $fixed_this = true; } if (is_file($rawthumb . '.' . $EXT)) { if (is_file($rawthumb . '.' . $ext)) { unlink($rawthumb . '.' . $EXT); } else { rename($rawthumb . '.' . $EXT, $rawthumb . '.' . $ext); } $fixed_this = true; } } if ($fixed_this) { $wppa_session[$slug . '_fixed']++; } else { $wppa_session[$slug . '_skipped']++; } break; case 'wppa_regen_thumbs': if (!wppa_is_video($id) || file_exists(str_replace('xxx', 'jpg', wppa_get_photo_path($id)))) { wppa_create_thumbnail($id); } break; case 'wppa_rerate': wppa_rate_photo($id); break; case 'wppa_recup': $a_ret = wppa_recuperate($id); if ($a_ret['iptcfix']) { $wppa_session[$slug . '_fixed']++; } if ($a_ret['exiffix']) { $wppa_session[$slug . '_fixed']++; } break; case 'wppa_file_system': $fs = get_option('wppa_file_system'); if ($fs == 'to-tree' || $fs == 'to-flat') { if ($fs == 'to-tree') { $from = 'flat'; $to = 'tree'; } else { $from = 'tree'; $to = 'flat'; } // Media files if (wppa_is_multi($id)) { // Can NOT use wppa_has_audio() or wppa_is_video(), they use wppa_get_photo_path() without fs switch!! $exts = array_merge($wppa_supported_video_extensions, $wppa_supported_audio_extensions); $pathfrom = wppa_get_photo_path($id, $from); $pathto = wppa_get_photo_path($id, $to); // wppa_log( 'dbg', 'Trying: '.$pathfrom ); foreach ($exts as $ext) { if (is_file(str_replace('.xxx', '.' . $ext, $pathfrom))) { // wppa_log( 'dbg', str_replace( '.xxx', '.'.$ext, $pathfrom ).' -> '.str_replace( '.xxx', '.'.$ext, $pathto )); @rename(str_replace('.xxx', '.' . $ext, $pathfrom), str_replace('.xxx', '.' . $ext, $pathto)); } } } // Poster / photo if (file_exists(wppa_fix_poster_ext(wppa_get_photo_path($id, $from), $id))) { @rename(wppa_fix_poster_ext(wppa_get_photo_path($id, $from), $id), wppa_fix_poster_ext(wppa_get_photo_path($id, $to), $id)); } // Thumbnail if (file_exists(wppa_fix_poster_ext(wppa_get_thumb_path($id, $from), $id))) { @rename(wppa_fix_poster_ext(wppa_get_thumb_path($id, $from), $id), wppa_fix_poster_ext(wppa_get_thumb_path($id, $to), $id)); } } break; case 'wppa_cleanup': $photo_files = glob(WPPA_UPLOAD_PATH . '/' . $id . '.*'); // Remove dirs if ($photo_files) { foreach (array_keys($photo_files) as $key) { if (is_dir($photo_files[$key])) { unset($photo_files[$key]); } } } // files left? process if ($photo_files) { foreach ($photo_files as $photo_file) { $basename = basename($photo_file); $ext = substr($basename, strpos($basename, '.') + '1'); if (!$wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM `" . WPPA_PHOTOS . "` WHERE `id` = %s", $id))) { // no db entry for this photo if (wppa_is_id_free(WPPA_PHOTOS, $id)) { if (wppa_create_photo_entry(array('id' => $id, 'album' => $orphan_album, 'ext' => $ext, 'filename' => $basename))) { // Can create entry $wppa_session[$slug . '_fixed']++; // Bump counter wppa_log('Debug', 'Lost photo file ' . $photo_file . ' recovered'); } else { wppa_log('Debug', 'Unable to recover lost photo file ' . $photo_file . ' Create photo entry failed'); } } else { wppa_log('Debug', 'Could not recover lost photo file ' . $photo_file . ' The id is not free'); } } } } break; case 'wppa_remake': $doit = true; if (wppa_switch('remake_orientation_only')) { $ori = wppa_get_exif_orientation(wppa_get_source_path($id)); if ($ori < '2') { $doit = false; } } if (wppa_switch('remake_missing_only')) { if (is_file(wppa_get_thumb_path($id)) && is_file(wppa_get_photo_path($id))) { $doit = false; } } if ($doit && wppa_remake_files('', $id)) { $wppa_session[$slug . '_fixed']++; } else { $wppa_session[$slug . '_skipped']++; } break; case 'wppa_watermark_all': if (!wppa_is_video($id)) { if (wppa_add_watermark($id)) { wppa_create_thumbnail($id); // create new thumb $wppa_session[$slug . '_fixed']++; } else { $wppa_session[$slug . '_skipped']++; } } else { $wppa_session[$slug . '_skipped']++; } break; case 'wppa_create_all_autopages': wppa_get_the_auto_page($id); break; case 'wppa_delete_all_autopages': wppa_remove_the_auto_page($id); break; case 'wppa_leading_zeros': $name = $photo['name']; if (wppa_is_int($name)) { $target_len = wppa_opt('zero_numbers'); $name = strval(intval($name)); while (strlen($name) < $target_len) { $name = '0' . $name; } } if ($name !== $photo['name']) { $wpdb->query($wpdb->prepare("UPDATE `" . WPPA_PHOTOS . "` SET `name` = %s WHERE `id` = %s", $name, $id)); } break; case 'wppa_add_gpx_tag': $tags = $photo['tags']; $temp = explode('/', $photo['location']); if (!isset($temp['2'])) { $temp['2'] = false; } if (!isset($temp['3'])) { $temp['3'] = false; } $lat = $temp['2']; $lon = $temp['3']; if ($lat < 0.01 && $lat > -0.01 && $lon < 0.01 && $lon > -0.01) { $lat = false; $lon = false; } if ($photo['location'] && strpos($tags, 'Gpx') === false && $lat && $lon) { // Add it $tags = wppa_sanitize_tags($tags . ',Gpx'); wppa_update_photo(array('id' => $photo['id'], 'tags' => $tags)); wppa_index_update('photo', $photo['id']); wppa_clear_taglist(); } elseif (strpos($tags, 'Gpx') !== false && !$lat && !$lon) { // Remove it $tags = wppa_sanitize_tags(str_replace('Gpx', '', $tags)); wppa_update_photo(array('id' => $photo['id'], 'tags' => $tags)); wppa_index_update('photo', $photo['id']); wppa_clear_taglist(); } break; case 'wppa_optimize_ewww': $file = wppa_get_photo_path($photo['id']); if (is_file($file)) { ewww_image_optimizer($file, 4, false, false, false); } $file = wppa_get_thumb_path($photo['id']); if (is_file($file)) { ewww_image_optimizer($file, 4, false, false, false); } break; case 'wppa_comp_sizes': $tx = 0; $ty = 0; $px = 0; $py = 0; $file = wppa_get_photo_path($photo['id']); if (is_file($file)) { $temp = getimagesize($file); if (is_array($temp)) { $px = $temp[0]; $py = $temp[1]; } } $file = wppa_get_thumb_path($photo['id']); if (is_file($file)) { $temp = getimagesize($file); if (is_array($temp)) { $tx = $temp[0]; $ty = $temp[1]; } } wppa_update_photo(array('id' => $photo['id'], 'thumbx' => $tx, 'thumby' => $ty, 'photox' => $px, 'photoy' => $py)); break; case 'wppa_edit_tag': $phototags = explode(',', wppa_get_photo_item($photo['id'], 'tags')); if (in_array($edit_tag, $phototags)) { foreach (array_keys($phototags) as $key) { if ($phototags[$key] == $edit_tag) { $phototags[$key] = $new_tag; } } $tags = wppa_sanitize_tags(implode(',', $phototags)); wppa_update_photo(array('id' => $photo['id'], 'tags' => $tags)); $wppa_session[$slug . '_fixed']++; } else { $wppa_session[$slug . '_skipped']++; } break; case 'wppa_sync_cloud': $is_old = wppa_opt('max_cloud_life') && time() > $photo['timestamp'] + wppa_opt('max_cloud_life'); // $is_in_cloud = @ getimagesize( wppa_get_cloudinary_url( $photo['id'], 'test_only' ) ); $is_in_cloud = isset($wppa_session['cloudinary_ids'][$photo['id']]); // wppa_log('Obs', 'Id='.$photo['id'].', is old='.$is_old.', in cloud='.$is_in_cloud); if ($is_old && $is_in_cloud) { $to_delete_from_cloudinary[] = strval($photo['id']); if (count($to_delete_from_cloudinary) == 10) { wppa_delete_from_cloudinary($to_delete_from_cloudinary); $to_delete_from_cloudinary = array(); } $wppa_session[$slug . '_deleted']++; } if (!$is_old && !$is_in_cloud) { wppa_upload_to_cloudinary($photo['id']); $wppa_session[$slug . '_added']++; } if ($is_old && !$is_in_cloud) { $wppa_session[$slug . '_skipped']++; } if (!$is_old && $is_in_cloud) { $wppa_session[$slug . '_skipped']++; } break; case 'wppa_sanitize_tags': $tags = $photo['tags']; if ($tags) { wppa_update_photo(array('id' => $photo['id'], 'tags' => wppa_sanitize_tags($tags))); } break; case 'wppa_crypt_photos': wppa_update_photo(array('id' => $photo['id'], 'crypt' => wppa_get_unique_photo_crypt())); break; case 'wppa_create_o1_files': wppa_make_o1_source($photo['id']); break; case 'wppa_owner_to_name_proc': $iret = wppa_set_owner_to_name($id); if ($iret === true) { $wppa_session[$slug . '_fixed']++; } if ($iret === '0') { $wppa_session[$slug . '_skipped']++; } break; case 'wppa_move_all_photos': $fromalb = get_option('wppa_move_all_photos_from'); $toalb = get_option('wppa_move_all_photos_to'); $alb = wppa_get_photo_item($id, 'album'); if ($alb == $fromalb) { wppa_update_photo(array('id' => $id, 'album' => $toalb)); wppa_move_source(wppa_get_photo_item($id, 'filename'), $fromalb, $toalb); wppa_flush_treecounts($fromalb); wppa_flush_treecounts($toalb); $wppa_session[$slug . '_fixed']++; } break; case 'wppa_test_proc': $tags = ''; $albid = $photo['album']; $albnam = wppa_get_album_item($albid, 'name'); $tags .= $albnam; while ($albid > '0') { $albid = wppa_get_album_item($albid, 'a_parent'); if ($albid > '0') { $tags .= ',' . wppa_get_album_item($albid, 'name'); } } wppa_update_photo(array('id' => $photo['id'], 'tags' => wppa_sanitize_tags($tags))); break; } // Test for timeout / ready $lastid = $id; update_option($slug . '_last', $lastid); if (time() > $endtime) { break; } // Time out } } else { // Nothing to do, Done anyway $lastid = $topid; wppa_log('Debug', 'Maintenance proc ' . $slug . ': Done!'); } break; // End process photos // Single action maintenance modules // case 'wppa_list_index': // break; // case 'wppa_blacklist_user': // break; // case 'wppa_un_blacklist_user': // break; // case 'wppa_rating_clear': // break; // case 'wppa_viewcount_clear': // break; // case 'wppa_iptc_clear': // break; // case 'wppa_exif_clear': // break; // End process photos // Single action maintenance modules // case 'wppa_list_index': // break; // case 'wppa_blacklist_user': // break; // case 'wppa_un_blacklist_user': // break; // case 'wppa_rating_clear': // break; // case 'wppa_viewcount_clear': // break; // case 'wppa_iptc_clear': // break; // case 'wppa_exif_clear': // break; default: $errtxt = 'Unimplemented maintenance slug: ' . strip_tags($slug); } // either $albums / $photos has been exhousted ( for this try ) or time is up // Post proc this try: switch ($slug) { case 'wppa_sync_cloud': if (count($to_delete_from_cloudinary) > 0) { wppa_delete_from_cloudinary($to_delete_from_cloudinary); } break; } // Find togo if ($slug == 'wppa_cleanup') { $togo = $topid - $lastid; } else { $togo = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM `" . $table . "` WHERE `id` > %s ", $lastid)); } // Find status if (!$errtxt) { $status = $togo ? 'Working' : 'Ready'; } else { $status = 'Error'; } // Not done yet? if ($togo) { // If a cron job, reschedule next chunk if (wppa_is_cron()) { update_option($slug . '_togo', $togo); update_option($slug . '_status', 'Running cron'); wppa_schedule_maintenance_proc($slug); } else { update_option($slug . '_togo', $togo); update_option($slug . '_status', 'Pending'); } } else { // Report fixed/skipped/deleted if ($wppa_session[$slug . '_fixed']) { $status .= ' fixed:' . $wppa_session[$slug . '_fixed']; unset($wppa_session[$slug . '_fixed']); } if ($wppa_session[$slug . '_added']) { $status .= ' added:' . $wppa_session[$slug . '_added']; unset($wppa_session[$slug . '_added']); } if ($wppa_session[$slug . '_deleted']) { $status .= ' deleted:' . $wppa_session[$slug . '_deleted']; unset($wppa_session[$slug . '_deleted']); } if ($wppa_session[$slug . '_skipped']) { $status .= ' skipped:' . $wppa_session[$slug . '_skipped']; unset($wppa_session[$slug . '_skipped']); } // Re-Init options update_option($slug . '_togo', ''); update_option($slug . '_status', ''); update_option($slug . '_last', '0'); update_option($slug . '_user', ''); update_option($slug . '_lasttimestamp', '0'); // Post-processing needed? switch ($slug) { case 'wppa_remake_index_albums': case 'wppa_remake_index_photos': $wpdb->query("DELETE FROM `" . WPPA_INDEX . "` WHERE `albums` = '' AND `photos` = ''"); // Remove empty entries delete_option('wppa_index_need_remake'); break; case 'wppa_apply_new_photodesc_all': case 'wppa_append_to_photodesc': case 'wppa_remove_from_photodesc': update_option('wppa_remake_index_photos_status', __('Required', 'wp-photo-album-plus')); break; case 'wppa_regen_thumbs': wppa_bump_thumb_rev(); break; case 'wppa_file_system': wppa_update_option('wppa_file_system', $to); $reload = 'reload'; break; case 'wppa_remake': wppa_bump_photo_rev(); wppa_bump_thumb_rev(); break; case 'wppa_edit_tag': wppa_clear_taglist(); if (wppa_switch('search_tags')) { update_option('wppa_remake_index_photos_status', __('Required', 'wp-photo-album-plus')); } $reload = 'reload'; break; case 'wppa_sanitize_tags': wppa_clear_taglist(); break; case 'wppa_sanitize_cats': wppa_clear_catlist(); break; case 'wppa_test_proc': wppa_clear_taglist(); break; case 'wppa_sync_cloud': unset($wppa_session['cloudinary_ids']); break; } wppa_log('Obs', 'Maintenance proc ' . $slug . ' completed'); } wppa_save_session(); if (wppa_is_cron()) { wppa_log('obs', $errtxt . '||' . $slug . '||' . $status . '||' . $togo . '||' . $reload); } return $errtxt . '||' . $slug . '||' . $status . '||' . $togo . '||' . $reload; }