function generate_content(&$title) { global $serendipity; $title = THUMBPAGE_TITLE; if ($serendipity['GET']['page'] != 'thumbs') { return true; } if (!headers_sent()) { header('HTTP/1.0 200'); header('Status: 200 OK'); } $entries = serendipity_db_query("SELECT id,\n title,\n timestamp\n FROM {$serendipity['dbPrefix']}entries\n WHERE isdraft = 'false'\n ORDER BY timestamp DESC"); if (isset($entries) && is_array($entries)) { $count = 0; echo '<table><tr>'; foreach ($entries as $k => $entry) { echo '<td align="center">'; $entryLink = serendipity_archiveURL($entry['id'], $entry['title'], 'serendipityHTTPPath', true, array('timestamp' => $entry['timestamp'])); $photo = $this->getPhoto($entry['id']); if (isset($photo)) { $file = serendipity_fetchImageFromDatabase($photo['photoid']); $imgsrc = $serendipity['serendipityHTTPPath'] . $serendipity['uploadHTTPPath'] . $file['path'] . $file['name'] . '.' . $file['thumbnail_name'] . '.' . $file['extension']; $thumbbasename = $file['path'] . $file['name'] . '.' . $file['thumbnail_name'] . '.' . $file['extension']; $thumbName = $serendipity['serendipityHTTPPath'] . $serendipity['uploadHTTPPath'] . $thumbbasename; $thumbsize = @getimagesize($serendipity['serendipityPath'] . $serendipity['uploadPath'] . $thumbbasename); } echo '<a href="' . $entryLink . '" title="' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($entry['title']) : htmlspecialchars($entry['title'], ENT_COMPAT, LANG_CHARSET)) . '">'; if (isset($photo)) { echo '<img style="margin:5px;" src="' . $imgsrc . '" width=' . $thumbsize[0] . ' height=' . $thumbsize[1]; if (isset($id) && $id == $entry['id']) { echo ' border=4'; } echo ' />'; } else { if (isset($id) && $id == $entry['id']) { echo '<b>'; } echo $entry['title']; if (isset($id) && $id == $entry['id']) { echo '</b>'; } } echo '</a></td>'; if ($count++ >= $this->get_config('number') - 1) { $count = 0; echo "</tr><tr>"; } } echo "</tr></table>"; } }
/** * Checks if properties to a specific image are allowed to be fetched * * @param array Array of image metadata * @param array Array of additional image metadata * @param string ACL toggle type ('read', 'write') * @return array Stripped Array of image metadata * */ function serendipity_checkPropertyAccess(&$new_media, &$additional, $mode = 'read') { global $serendipity; // Strip out images we don't have access to $ids = array(); foreach ($new_media as $id => $item) { $ids[] = $item['image_id']; } $valid_images = serendipity_fetchImageFromDatabase($ids, $mode); foreach ($new_media as $id => $media) { if (!isset($valid_images[$media['image_id']])) { unset($new_media[$id]); unset($additional[$id]); } else { $new_media[$id]['internal'] = $valid_images[$media['image_id']]; } } return true; }
$file = serendipity_fetchImageFromDatabase($serendipity['GET']['fid']); if (!is_array($file) || !serendipity_checkPermission('adminImagesDelete') || !serendipity_checkPermission('adminImagesMaintainOthers') && $file['authorid'] != '0' && $file['authorid'] != $serendipity['authorid']) { return; } $data['extraParems'] = serendipity_generateImageSelectorParems("form"); $data['case_scaleSelect'] = true; $s = getimagesize($serendipity['serendipityPath'] . $serendipity['uploadPath'] . $file['path'] . $file['name'] . ($file['extension'] ? '.' . $file['extension'] : "")); $data['img_width'] = $s[0]; $data['img_height'] = $s[1]; $data['print_RESIZE_BLAHBLAH'] = sprintf(RESIZE_BLAHBLAH, serendipity_specialchars($serendipity['GET']['fname'])); $data['print_ORIGINAL_SIZE'] = sprintf(ORIGINAL_SIZE, $s[0], $s[1]); $data['formtoken'] = serendipity_setFormToken(); $data['file'] = $serendipity['uploadHTTPPath'] . $file['path'] . $file['name'] . ($file['extension'] ? '.' . $file['extension'] : ""); break; case 'choose': $file = serendipity_fetchImageFromDatabase($serendipity['GET']['fid']); $media['file'] =& $file; if (!is_array($file)) { $media['perm_denied'] = true; break; } serendipity_prepareMedia($file); $media['file']['props'] =& serendipity_fetchMediaProperties((int) $serendipity['GET']['fid']); serendipity_plugin_api::hook_event('media_getproperties_cached', $media['file']['props']['base_metadata'], $media['file']['realfile']); if ($file['is_image']) { $file['finishJSFunction'] = $file['origfinishJSFunction'] = 'serendipity.serendipity_imageSelector_done(\'' . serendipity_specialchars($serendipity['GET']['textarea']) . '\')'; if (!empty($serendipity['GET']['filename_only']) && $serendipity['GET']['filename_only'] !== 'true') { $file['fast_select'] = true; } } $media = array_merge($serendipity['GET'], $media);
function generate_content(&$title) { global $serendipity; $number = $this->get_config('number'); $showpicsonly = $this->get_config('showpicsonly'); if (!$number || !is_numeric($number) || $number < 1) { $number = 5; } $title = PLUGIN_PHOTOBLOG_TITLE; if (!isset($serendipity['GET']['id']) || !is_numeric($serendipity['GET']['id'])) { $number = $number * $number + 1; $entries = serendipity_db_query("SELECT id,\n title,\n timestamp\n FROM {$serendipity['dbPrefix']}entries\n WHERE isdraft = 'false'\n ORDER BY timestamp DESC\n LIMIT {$number}"); } else { $id = serendipity_db_escape_string($serendipity['GET']['id']); $entries1 = serendipity_db_query("SELECT id,\n title,\n timestamp\n FROM {$serendipity['dbPrefix']}entries\n WHERE isdraft = 'false'\n AND id > {$id}\n ORDER BY timestamp ASC\n LIMIT {$number}"); $number++; $entries2 = serendipity_db_query("SELECT id,\n title,\n timestamp\n FROM {$serendipity['dbPrefix']}entries\n WHERE isdraft = 'false'\n AND id <= {$id}\n ORDER BY timestamp DESC\n LIMIT {$number}"); if (isset($entries1) && is_array($entries1) && isset($entries2) && is_array($entries2)) { $entries = array_merge(array_reverse($entries1), $entries2); } elseif (isset($entries1) && is_array($entries1)) { $entries = array_reverse($entries1); } elseif (isset($entries2) && is_array($entries2)) { $entries = $entries2; } } if (isset($entries) && is_array($entries)) { foreach ($entries as $k => $entry) { $entryLink = serendipity_archiveURL($entry['id'], $entry['title'], 'serendipityHTTPPath', true, array('timestamp' => $entry['timestamp'])); $photo = $this->getPhoto($entry['id']); if ($showpicsonly == 'true' && isset($photo) || $showpicsonly != 'true') { if (isset($photo)) { $file = serendipity_fetchImageFromDatabase($photo['photoid']); $imgsrc = $serendipity['serendipityHTTPPath'] . $serendipity['uploadHTTPPath'] . $file['path'] . $file['name'] . '.' . $file['thumbnail_name'] . '.' . $file['extension']; $thumbbasename = $file['path'] . $file['name'] . '.' . $file['thumbnail_name'] . '.' . $file['extension']; $thumbName = $serendipity['serendipityHTTPPath'] . $serendipity['uploadHTTPPath'] . $thumbbasename; $thumbsize = @getimagesize($serendipity['serendipityPath'] . $serendipity['uploadPath'] . $thumbbasename); } echo '<a href="' . $entryLink . '" title="' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($entry['title']) : htmlspecialchars($entry['title'], ENT_COMPAT, LANG_CHARSET)) . '">'; if (isset($photo)) { echo '<img style="margin:5px;" src="' . $imgsrc . '" width=' . $thumbsize[0] . ' height=' . $thumbsize[1]; if (isset($id) && $id == $entry['id']) { echo ' border=4'; } echo ' />'; } else { if (isset($id) && $id == $entry['id']) { echo '<b>'; } echo $entry['title']; if (isset($id) && $id == $entry['id']) { echo '</b>'; } } echo '</a><br />'; } } } }
$media['is_deleted'] = $is_deleted; $media['new_dir'] = $new_dir; } $media['external'] = ob_get_contents(); ob_end_clean(); break; case 'tree': $media['case'] = 'tree'; break; case 'showItem': serendipity_plugin_api::hook_event('frontend_media_showitem_init', $media); if ($media['perm_denied']) { break; } $media['case'] = 'showitem'; $file = serendipity_fetchImageFromDatabase((int) $serendipity['GET']['image']); $media['file'] =& $file; $keywords = $dprops = ''; if (!is_array($file)) { $media['perm_denied'] = true; break; } serendipity_prepareMedia($file); $showfile = null; if (($serendipity['GET']['resizeWidth'] || $serendipity['GET']['resizeHeight']) && $serendipity['dynamicResize'] && $media['file']['is_image']) { $width = (int) $serendipity['GET']['resizeWidth']; $height = (int) $serendipity['GET']['resizeHeight']; if (empty($width)) { $width = NULL; } if (empty($height)) {
function displayImage($id, $orderby, $order) { global $serendipity; $extended_data = array(); $base_directory = $this->get_config('base_directory'); $file = serendipity_fetchImageFromDatabase($id); $file['link'] = $serendipity['serendipityHTTPPath'] . $serendipity['uploadHTTPPath'] . $file['path'] . $file['name'] . '.' . $file['extension']; $test_string = $serendipity['serendipityPath'] . $serendipity['uploadHTTPPath'] . $base_directory; $path_len = strlen($test_string); $pic_string = substr($serendipity['serendipityPath'] . $serendipity['uploadHTTPPath'] . $file['path'], 0, $path_len); if (isset($file['id'])) { $file['size_txt'] = round($file['size'] / 1024); $file['is_image'] = serendipity_isImage($file); $max_width = $this->get_config('image_width', 480); if ($file['dimensions_width'] > $max_width && $max_width != 0) { $file['alt_width'] = $max_width; $file['alt_height'] = round($max_width / $file['dimensions_width'] * $file['dimensions_height']); } else { $file['alt_width'] = $file['dimensions_width']; $file['alt_height'] = $file['dimensions_height']; } if ($this->get_config('image_strict') == 'yes') { $images = serendipity_fetchImagesFromDatabase($lower_limit, $images_per_page, $total, $orderby, $order, $file['path'], '', '', array(), true); } else { $images = serendipity_fetchImagesFromDatabase($lower_limit, $images_per_page, $total, $orderby, $order, $file['path']); } $extended_data = serendipity_fetchMediaProperties($id); $base_directory = str_replace('gallery', '', $base_directory); $previous_attempt = -1; $previous_id = -1; $next_id = -1; if (is_array($images)) { $stop = false; $onecount = false; while ((list($f, $image) = each($images)) && !$stop) { if ($image['id'] == $file['id']) { $path = $image['path']; $previous_id = $previous_attempt; $onecount = true; } else { if ($onecount == true) { $next_id = $image['id']; $stop = true; } else { $previous_attempt = $image['id']; } } } } $gallery_array = explode('/', $path); foreach ($gallery_array as $f => $gallery) { $gallery_path = $gallery_path . $gallery . "/"; if ($gallery_path != $base_directory) { $path_array[$gallery]['path'] = $gallery_path; $path_array[$gallery]['name'] = $gallery; } } // EXIF DATA if ($this->get_config('exif_show_data') == 'yes') { // If any exif tags that are available. $filepath = $serendipity['serendipityPath'] . $serendipity['uploadHTTPPath'] . $file['path']; $exif_data = $this->getExifTags($filepath, $file['name'], $file['extension']); $exifsettings_one = $this->get_config('exif_data', $this->makeExifSelector()); // Create array of exif display settings for main information table. $exif_arr = explode(',', $exifsettings_one); foreach ($exif_arr as $key => $value) { $display = explode('-', $exif_arr[$key]); $exif_display_one[$display[0]] = $display[1]; } $data_written = false; $exif_output .= '<div class="all_img_info">'; $exif_output .= '<div class="exif_info_row"><div class="exif_info_head"><strong>' . PLUGIN_EVENT_USERGALLERY_EXIFDATA_ADDITIONALDATA . '</strong></div></div>'; foreach ($exif_data as $tag => $value) { if ($value != 'Unknown' && $exif_display_one[$tag] == 'yes') { $data_written = true; $exif_output .= '<div class="exif_info_row"><span class="exif_info_tag">' . $tag . '</span><span class="exif_info">' . $value . '</span></div>'; } } if (!$data_written) { $exif_output .= '<div class="exif_info_row"><strong>' . PLUGIN_EVENT_USERGALLERY_EXIFDATA_NOADDITIONALDATA . '</strong></div>'; } $exif_output .= '</div>'; } // END EXIF DATA //Show Media Library Properties if ($this->get_config('show_media_properties', 'no') == 'yes') { if (is_array($extended_data) && isset($extended_data['base_property'])) { $extended_data = array_merge($extended_data['base_property'], (array) $extended_data['base_metadata']); } else { $extended_data = array(); } $extended_data_out = array(); $extended_output = explode(';', $this->get_config('media_properties', 'COPYRIGHT:Copyright;TITLE:Title;COMMENT2:Comment')); foreach ($extended_output as $option) { $option = explode(':', $option); foreach ($extended_data as $ex_name => $ex_data) { if ($ex_name == $option[0] && isset($option[1]) && $ex_data != '') { $extended_data_out[] = array('name' => $option[1], 'value' => $ex_data); if ($ex_name == 'TITLE' && $ex_data != '') { $file['title'] = $ex_data; } } } } } if (!isset($file['title'])) { $file['title'] = $file['name']; } if (serendipity_db_bool($this->get_config('linked_entries'))) { $_filename = $file['name'] . '.' . $file['extension']; $_thumbname = $file['name'] . '.' . $file['thumbnail_name'] . '.' . $file['extension']; $e = $this->fetchLinkedEntries($file['id'], $file['path'] . $_filename, $file['path'] . $_thumbname); if (is_array($e)) { $file['entries'] = array(); foreach ($e as $_item) { $file['entries'][] = array('href' => serendipity_archiveURL($_item['id'], $_item['title'], 'serendipityHTTPPath', true, array('timestamp' => $_item['timestamp'])), 'title' => $_item['title']); } } if (class_exists('serendipity_event_staticpage')) { $s = $this->fetchStaticPages($file['id'], $file['path'] . $_filename, $file['path'] . $_thumbname); if (is_array($s)) { $file['staticpage_results'] = array(); foreach ($s as $_item) { $staticpage_title = $_item['headline']; if ($staticpage_title == '') { $staticpage_title = $_item['pagetitle']; } if ($serendipity['rewrite'] == 'none') { $staticpage_link = $serendipity['serendipityHTTPPath'] . $serendipity['indexFile'] . '?serendipity[subpage]=' . $_item['subpage']; } else { $staticpage_link = $_item['permalink']; } $file['staticpage_results'][] = array('href' => $staticpage_link, 'title' => $staticpage_title); } } } } unset($path_array['']); $serendipity['smarty']->assign(array('plugin_usergallery_title' => $this->get_config('title'), 'plugin_usergallery_nextid' => $next_id, 'plugin_usergallery_gallery_breadcrumb' => $path_array, 'plugin_usergallery_previousid' => $previous_id, 'plugin_usergallery_xtra_info' => $exif_output, 'plugin_usergallery_extended_info' => $extended_data_out, 'plugin_usergallery_file' => $file)); $content = $this->parseTemplate('plugin_usergallery_imagedisplay.tpl'); echo $content; return true; } else { echo "Invalid file."; return false; } }
function pb_entry_display(&$eventData) { global $serendipity; if (is_array($eventData[0]['properties'])) { unset($eventData[0]['properties']['ep_cache_body']); unset($eventData[0]['properties']['ep_cache_extended']); } if ($serendipity['POST']['preview'] == 'true') { $prop_val = $serendipity['POST']['properties']['photoname']; if (!empty($prop_val)) { $file = $this->parsePhotoname($prop_val); $thumbstring = $this->return_thumbstr($file); $imgsrc = $serendipity['serendipityHTTPPath'] . $serendipity['uploadHTTPPath'] . $file['path'] . $file['name'] . $thumbstring . '.' . $file['extension']; $img = '<div align=center><img src="' . $imgsrc . '" /></div>'; $eventData[0]['body'] = $img . $eventData[0]['body']; } } else { $elements = count($eventData); for ($i = 0; $i < $elements; $i++) { $row = $this->getPhoto($eventData[$i]['id']); if (isset($row)) { $file = serendipity_fetchImageFromDatabase($row['photoid']); $thumbstring = $this->return_thumbstr($row); $imgsrc = $serendipity['serendipityHTTPPath'] . $serendipity['uploadHTTPPath'] . $file['path'] . $file['name'] . $thumbstring . '.' . $file['extension']; $img = '<div align=center><img src="' . $imgsrc . '" /></div>'; $eventData[$i]['body'] = $img . $eventData[$i]['body']; } } } }