function cleanup() { global $serendipity; // Purge DB cache serendipity_db_query("DELETE FROM {$serendipity['dbPrefix']}pluginlist"); serendipity_db_query("DELETE FROM {$serendipity['dbPrefix']}plugincategories"); // Purge cached XML files. $files = serendipity_traversePath($serendipity['serendipityPath'] . PATH_SMARTY_COMPILE, '', false, '/package_.+\\.xml$/'); if (!is_array($files)) { return false; } foreach ($files as $file) { $this->outputMSG('notice', sprintf(DELETING_FILE . '<br />', $file['name'])); @unlink($serendipity['serendipityPath'] . PATH_SMARTY_COMPILE . '/' . $file['name']); } }
/** * Gets all available media directories * * @return array * */ function &serendipity_getMediaPaths() { global $serendipity; $aExclude = array("CVS" => true, ".svn" => true); serendipity_plugin_api::hook_event('backend_media_path_exclude_directories', $aExclude); $paths = array(); $aResultSet = serendipity_traversePath($serendipity['serendipityPath'] . $serendipity['uploadPath'], '', false, NULL, 1, NULL, FALSE, $aExclude); foreach ($aResultSet as $sKey => $sFile) { if ($sFile['directory']) { array_push($paths, $sFile); } unset($aResultSet[$sKey]); } serendipity_directoryACL($paths, 'read'); usort($paths, 'serendipity_sortPath'); return $paths; }
break; case 'directorySelect': if (!serendipity_checkPermission('adminImagesDirectories')) { return; } $folders = serendipity_traversePath($serendipity['serendipityPath'] . $serendipity['uploadPath'], '', true, NULL, 1, NULL, 'write'); usort($folders, 'serendipity_sortPath'); $data['case_directorySelect'] = true; $data['folders'] = $folders; break; case 'addSelect': if (!serendipity_checkPermission('adminImagesAdd')) { return; } serendipity_restoreVar($serendipity['COOKIE']['addmedia_directory'], $serendipity['GET']['only_path']); $folders = serendipity_traversePath($serendipity['serendipityPath'] . $serendipity['uploadPath'], '', true, NULL, 1, NULL, 'write'); usort($folders, 'serendipity_sortPath'); $form_hidden = ''; if (isset($image_selector_addvars) && is_array($image_selector_addvars)) { // These variables may come from serendipity_admin_image_selector.php to show embedded upload form foreach ($image_selector_addvars as $imgsel_key => $imgsel_val) { $form_hidden .= ' <input type="hidden" name="serendipity[' . serendipity_specialchars($imgsel_key) . ']" value="' . serendipity_specialchars($imgsel_val) . '" />' . "\n"; } } $mediaFiles = array('token' => serendipity_setFormToken(), 'form_hidden' => $form_hidden, 'folders' => $folders, 'only_path' => $serendipity['GET']['only_path'], 'max_file_size' => $serendipity['maxFileSize'], 'maxImgHeight' => $serendipity['maxImgHeight'], 'maxImgWidth' => $serendipity['maxImgWidth'], 'extraParems' => serendipity_generateImageSelectorParems(), 'manage' => isset($serendipity['GET']['showMediaToolbar']) ? serendipity_db_bool($serendipity['GET']['showMediaToolbar']) : true); // ToDo later: merge $data and $media $serendipity['smarty']->assign('media', $mediaFiles); $serendipity['smarty']->display(serendipity_getTemplateFile('admin/media_upload.tpl', 'serendipityPath')); return; case 'rotateCW': $file = serendipity_fetchImageFromDatabase($serendipity['GET']['fid']);
function introspect_config_item_custom($name, &$propbag) { global $serendipity; switch ($name) { case 'media_base_directory': if ($this->get_config('media_hotlinks_only', 'no') == 'no') { $select['gallery'] = ALL_DIRECTORIES; $paths = serendipity_traversePath($serendipity['serendipityPath'] . $serendipity['uploadPath']); foreach ($paths as $folder) { $select[$folder['relpath']] = str_repeat('-', $folder['depth']) . ' ' . $folder['name']; } $propbag->add('type', 'select'); $propbag->add('name', PLUGIN_SIDEBAR_MEDIASIDEBAR_DIRECTORY_NAME); $propbag->add('description', PLUGIN_SIDEBAR_MEDIASIDEBAR_DIRECTORY_DESC); $propbag->add('select_values', $select); } break; case 'media_image_strict': if ($this->get_config('media_hotlinks_only', 'no') == 'no') { $propbag->add('type', 'radio'); $propbag->add('name', PLUGIN_SIDEBAR_MEDIASIDEBAR_IMAGESTRICT_NAME); $propbag->add('description', PLUGIN_SIDEBAR_MEDIASIDEBAR_IMAGESTRICT_DESC); $propbag->add('radio', array('value' => array('yes', 'no'), 'desc' => array(YES, NO))); $propbag->add('radio_per_row', '2'); $propbag->add('default', 'yes'); } break; case 'media_number_images': $propbag->add('type', 'string'); $propbag->add('name', PLUGIN_SIDEBAR_MEDIASIDEBAR_NUMIMAGES_NAME); $propbag->add('description', PLUGIN_SIDEBAR_MEDIASIDEBAR_NUMIMAGES_DESC); $propbag->add('default', '1'); break; case 'media_rotate_time': $propbag->add('type', 'string'); $propbag->add('name', PLUGIN_SIDEBAR_MEDIASIDEBAR_ROTATETIME_NAME); $propbag->add('description', PLUGIN_SIDEBAR_MEDIASIDEBAR_ROTATETIME_DESC); $propbag->add('default', '60'); break; case 'media_linkbehavior': $select["inpage"] = PLUGIN_SIDEBAR_MEDIASIDEBAR_LINKBEHAVIOR_INPAGE; $select["popup"] = PLUGIN_SIDEBAR_MEDIASIDEBAR_LINKBEHAVIOR_POPUP; $select["url"] = PLUGIN_SIDEBAR_MEDIASIDEBAR_LINKBEHAVIOR_URL; $select["entry"] = PLUGIN_SIDEBAR_MEDIASIDEBAR_LINKBEHAVIOR_ENTRY; if (class_exists('serendipity_event_usergallery')) { $select["gallery"] = PLUGIN_SIDEBAR_MEDIASIDEBAR_LINKBEHAVIOR_GALLERY; } $propbag->add('type', 'select'); $propbag->add('name', PLUGIN_SIDEBAR_MEDIASIDEBAR_LINKBEHAVIOR_NAME); $propbag->add('description', PLUGIN_SIDEBAR_MEDIASIDEBAR_LINKBEHAVIOR_DESC); $propbag->add('select_values', $select); $propbag->add('default', 'inpage'); break; case 'media_lightbox': $propbag->add('type', 'string'); $propbag->add('name', PLUGIN_SIDEBAR_MEDIASIDEBAR_LIGHTBOX_NAME); $propbag->add('description', PLUGIN_SIDEBAR_MEDIASIDEBAR_LIGHTBOX_DESC); $propbag->add('default', ''); break; case 'media_fixed_width': $propbag->add('type', 'string'); $propbag->add('name', PLUGIN_SIDEBAR_MEDIASIDEBAR_WIDTH_NAME); $propbag->add('description', PLUGIN_SIDEBAR_MEDIASIDEBAR_WIDTH_DESC); $propbag->add('default', '162'); break; case 'media_url': if ($this->get_config('media_linkbehavior') == 'url') { $propbag->add('type', 'string'); $propbag->add('name', PLUGIN_SIDEBAR_MEDIASIDEBAR_URL_NAME); $propbag->add('description', PLUGIN_SIDEBAR_MEDIASIDEBAR_URL_DESC); $propbag->add('default', $serendipity['baseURL']); } break; case 'media_gal_permalink': if ($this->get_config('media_linkbehavior') == 'gallery') { $propbag->add('type', 'string'); $propbag->add('name', PLUGIN_SIDEBAR_MEDIASIDEBAR_GALPERM_NAME); $propbag->add('description', PLUGIN_SIDEBAR_MEDIASIDEBAR_GALPERM_DESC); $propbag->add('default', $serendipity['rewrite'] != 'none' ? $serendipity['serendipityHTTPPath'] . 'pages/gallery.html' : $serendipity['serendipityHTTPPath'] . $serendipity['indexFile'] . '?serendipity[subpage]=gallery'); } break; case 'media_intro': $propbag->add('type', 'html'); $propbag->add('name', PLUGIN_SIDEBAR_MEDIASIDEBAR_INTRO); $propbag->add('description', ''); $propbag->add('default', ''); break; case 'media_summery': $propbag->add('type', 'html'); $propbag->add('name', PLUGIN_SIDEBAR_MEDIASIDEBAR_SUMMERY); $propbag->add('description', ''); $propbag->add('default', ''); break; case 'media_hotlinks_only': $propbag->add('type', 'radio'); $propbag->add('name', PLUGIN_SIDEBAR_MEDIASIDEBAR_HOTLINKS_NAME); $propbag->add('description', PLUGIN_SIDEBAR_MEDIASIDEBAR_HOTLINKS_DESC); $propbag->add('radio', array('value' => array('yes', 'no'), 'desc' => array(YES, NO))); $propbag->add('radio_per_row', '2'); $propbag->add('default', 'no'); break; case 'media_hotlink_base': if ($this->get_config('media_hotlinks_only', 'no') == 'yes') { $propbag->add('type', 'string'); $propbag->add('name', PLUGIN_SIDEBAR_MEDIASIDEBAR_HOTLINKBASE_NAME); $propbag->add('description', PLUGIN_SIDEBAR_MEDIASIDEBAR_HOTLINKBASE_DESC); $propbag->add('default', ''); } break; default: return false; break; } return true; }
# All rights reserved. See LICENSE file for licensing details // Call this file from the base directory with // echo "true" | 'php -B "define('IN_serendipity', true);" -F bundled-libs/serendipity_generateFTPChecksums.php' if (IN_serendipity !== true) { die("Don't hack!\n"); } echo "Creating checksums.\n"; $basedir = realpath(dirname(__FILE__) . '/../') . '/'; require_once $basedir . 'include/functions_installer.inc.php'; require_once $basedir . 'include/functions_images.inc.php'; $conf = file_get_contents($basedir . 'serendipity_config.inc.php'); preg_match('@\\$serendipity\\[\'version\'\\]\\s*=\\s*\'(.+)\'@imsU', $conf, $vmatch); // Find all the files in the serendipity directory and calculate their md5 sums $sums = array(); $excludes = array('CHANGELOG', 'checksums.inc.php'); $files = serendipity_traversePath($basedir, '', false); foreach ($files as $fdata) { echo $fdata['relpath'] . "\n"; // Don't take checksums of directories if ($fdata['directory']) { continue; } $fname = $fdata['name']; $prel = $fdata['relpath']; $path = $basedir . $prel; if ($fname[0] == '.' || !is_readable($path)) { // serendipity_traversePath already excludes CVS and svn directories continue; } // Are we SURE we should checksum this file? if (is_file($path) && !in_array($fname, $excludes)) {
/** * Purge compiled Smarty Templates * * @access public * @return null */ function serendipity_smarty_purge() { global $serendipity; /* Attempt to init Smarty, brrr */ serendipity_smarty_init(); $files = serendipity_traversePath($serendipity['smarty']->getCompileDir() . DIRECTORY_SEPARATOR, '', false, '/.+\\.tpl\\.php$/'); if (!is_array($files)) { return false; } foreach ($files as $file) { @unlink($serendipity['smarty']->getCompileDir() . DIRECTORY_SEPARATOR . $file['name']); } }
function picasa_pre_upload() { global $serendipity; if (!serendipity_userLoggedIn()) { if (!serendipity_login()) { // save off the rss data because it won't be posted again if ($_POST['rss']) { $_SESSION['picasa_rss'] = $_POST['rss']; } echo "<html>\n"; echo "<head>\n"; echo "<script language=javascript> function sf() { document.getElementById('serendipity[user]').focus(); }</script>\n"; echo "</head>\n"; echo "<body onload='javscript:sf()'>\n"; echo "<form name='f' method='post' action='index.php?/plugin/picasa_pre_upload'>\n"; echo "<h2>" . PLUGIN_EVENT_PICASA_UPLOAD_HEADER . $serendipity['baseURL'] . "</h2>\n"; echo PLUGIN_EVENT_PICASA_UPLOAD_USERNAME . "<br />\n"; echo "<input type='text' name='serendipity[user]' /><br />\n"; echo PLUGIN_EVENT_PICASA_UPLOAD_PASSWORD . "<br />\n"; echo "<input type='password' name='serendipity[pass]' /><br />\n"; echo "<input id='autologin' type='checkbox' name='serendipity[auto]' /><label for='autologin'>" . PLUGIN_EVENT_PICASA_UPLOAD_REMEMBER_LOGIN . "</label><br />\n"; echo "<input type='submit' name='submit' value='" . PLUGIN_EVENT_PICASA_UPLOAD_LOGIN . "' />"; echo "<input type='button' value='" . PLUGIN_EVENT_PICASA_UPLOAD_DISCARD . "' onclick=\"location.href='minibrowser:close'\">\n"; echo "</form>\n"; echo "</body>\n"; echo "</html>\n"; return; } } if (!$_POST['rss']) { if (!$_SESSION['picasa_rss']) { echo PLUGIN_EVENT_PICASA_ERR_MISSING_RSS; return; } else { $rss = $_SESSION['picasa_rss']; } } else { $rss = $_POST['rss']; } $imgSize = $this->get_config('upload_image_size'); $thumbSize = $serendipity['thumbSize']; $xh = new xmlHandler(); $nodeNames = array("PHOTO:THUMBNAIL", "PHOTO:IMGSRC", "TITLE", "DESCRIPTION"); $xh->setElementNames($nodeNames); $xh->setStartTag("ITEM"); $xh->setXmlData($rss); $pData = $xh->xmlParse(); // save this since we need to access the descriptions during upload $_SESSION['picasa_rss_parsed'] = $pData; echo "<html>\n"; echo "<head>\n"; echo "<script language=javascript> function sf() { document.getElementById('albumName').focus(); }</script>\n"; echo "</head>\n"; echo "<body onload='javscript:sf()'>\n"; echo "<form name='f' method='post' action='index.php?/plugin/picasa_upload'>\n"; echo "<h2>" . PLUGIN_EVENT_PICASA_UPLOAD_HEADER . $serendipity['baseURL'] . "</h2>\n"; echo "<div>" . PLUGIN_EVENT_PICASA_UPLOAD_ALBUMNAME . "</div>\n"; echo "<div><input type='text' name='albumName' tabindex='1'></div>\n"; echo "<div>" . PLUGIN_EVENT_PICASA_UPLOAD_DESCRIPTION . "</div>\n"; echo "<div><textarea name='albumDescription' rows='5' cols='50'></textarea></div>\n"; echo "<div>" . PLUGIN_EVENT_PICASA_UPLOAD_PARENTDIR . "</div>\n"; echo "<select name='parentDir' id='parentDir'>\n"; echo "<option value=''>" . PLUGIN_EVENT_PICASA_UPLOAD_PARENTDIR_BASEDIR . "</option>\n"; $picasapath = $this->get_config('picasapath'); $paths = serendipity_traversePath($picasapath); $prunedPaths = array(); foreach ($paths as $path) { $name = $path['name']; $relpath = $path['relpath']; // check if this is a subdirectory of an already pruned directory $subdirOfPruned = false; foreach ($prunedPaths as $prunedPath) { if (0 == strncmp($prunedPath, $relpath, strlen($prunedPath))) { $subdirOfPruned = true; break; } } // don't allow nesting of albums; if the album has any subdirectories, collisions could happen if (!file_exists($picasapath . '/' . $relpath . '/index.xml')) { if (!$subdirOfPruned) { $splitPath = explode('/', $relpath); $encodedRelpath = htmlentities($relpath, ENT_QUOTES, LANG_CHARSET); $prefix = str_repeat(' ', count($splitPath)); echo "<option value='{$encodedRelpath}'>{$prefix} {$name}</option>\n"; } } else { $prunedPaths[] = $relpath; } } echo "</select>\n"; // Image request queue: add image requests for base image & clickthrough foreach ($pData as $e) { // use a thumbnail if you don't want exif (saves space) // thumbnail requests are clamped at 144 pixels // (negative values give square-cropped images) $small = $e['photo:thumbnail'] . "?size={$thumbSize}"; $large = $e['photo:imgsrc'] . "?size={$imgSize}"; echo "<input type='hidden' name='{$large}'>\n"; echo "<input type='hidden' name='{$small}'>\n"; } echo "<br />\n"; echo "<input type=submit value='" . PLUGIN_EVENT_PICASA_UPLOAD_UPLOAD . "'>\n"; echo "<input type=button value='" . PLUGIN_EVENT_PICASA_UPLOAD_DISCARD . "' onclick=\"location.href='minibrowser:close'\">\n"; echo "</form><br />\n"; // Preview "tray": draw thumbnails of each image that will be uploaded foreach ($pData as $e) { $thumb = $e['photo:thumbnail']; echo "<img src='{$thumb}?size={$thumbSize}'>\n"; } echo "</body>\n"; echo "</html>\n"; }
function show() { global $serendipity; if (!headers_sent()) { header('HTTP/1.0 200'); header('Status: 200'); } if (!is_object($serendipity['smarty'])) { serendipity_smarty_init(); } $_ENV['staticpage_pagetitle'] = preg_replace('@[^a-z0-9]@i', '_', $this->get_config('base_directory')); $serendipity['smarty']->assign('staticpage_pagetitle', $_ENV['staticpage_pagetitle']); $serendipity['smarty']->assign('const', array('filesize' => PLUGIN_EVENT_USERGALLERY_FILESIZE, 'filename' => PLUGIN_EVENT_USERGALLERY_FILENAME, 'dimension' => PLUGIN_EVENT_USERGALLERY_DIMENSION, 'uponelevel' => PLUGIN_EVENT_USERGALLERY_UPONELEVEL, 'back' => PLUGIN_EVENT_USERGALLERY_BACK, 'previous' => PLUGIN_EVENT_USERGALLERY_PREVIOUS, 'next' => PLUGIN_EVENT_USERGALLERY_NEXT, 'PREVIOUS_PAGE' => PREVIOUS_PAGE, 'NEXT_PAGE' => NEXT_PAGE)); $sub_page = $this->get_config('subpage'); $permalink = $this->get_config('permalink'); $serendipity['smarty']->assign('plugin_usergallery_httppath', $serendipity['rewrite'] != 'none' ? $permalink : $serendipity['indexFile'] . '?serendipity[subpage]=' . $sub_page); $serendipity['smarty']->assign('plugin_usergallery_httppath_extend', $serendipity['rewrite'] != 'none' ? $permalink . '?' : $serendipity['indexFile'] . '?serendipity[subpage]=' . $sub_page . '&'); //Can't trust $serendipity['GET'] on all servers.... so we build it ourselves from subpage if ($serendipity['rewrite'] != 'none') { $uri_parts = explode('?', str_replace('&', '&', $serendipity['GET']['subpage'])); $parts = explode('&', $uri_parts[1]); if (count($parts) > 1) { foreach ($parts as $key => $value) { $val = explode('=', $value); $val0 = str_replace('serendipity[', '', $val[0]); if ($val[0] == $val0) { $_GET[$val[0]] = $val[1]; } else { $val0 = str_replace(']', '', $val0); $serendipity['GET'][$val0] = $val[1]; } } } else { $val = explode('=', $parts[0]); $val0 = str_replace('serendipity[', '', $val[0]); if ($val[0] == $val0) { $_GET[$val[0]] = $val[1]; } else { $val0 = str_replace(']', '', $val0); $serendipity['GET'][$val0] = $val[1]; } } } switch ($this->get_config("image_order")) { case 'nameacs': $orderby = 'i.name'; $order = 'ASC'; break; case 'namedesc': $orderby = 'i.name'; $order = 'DESC'; break; case 'dateacs': $orderby = 'i.date'; $order = 'ASC'; break; case 'datedesc': $orderby = 'i.date'; $order = 'DESC'; break; } if (isset($serendipity['GET']['image'])) { $this->displayImage($serendipity['GET']['image'], $orderby, $order); } else { $num_cols = $this->get_config('num_cols'); $base_directory = $this->get_config('base_directory'); $show_objects = serendipity_db_bool($this->get_config('show_objects', false)); if ($this->get_config('style') == "thumbpage") { $images_per_page = $this->get_config('images_per_page'); $display_dir_tree = $this->get_config('display_dir_tree', 'no'); $show_1lvl_sub = $this->get_config('show_1lvl_sub', 'no'); $dir_list = $this->get_config('dir_list'); $num_cols = $this->get_config('num_cols'); $permitted_gallery = false; if ($base_directory == 'gallery') { $limit_directory = ''; } else { $limit_directory = $base_directory; } $limit_images_directory = $limit_directory; $limit_output = $limit_directory; $serendipity['smarty']->assign('plugin_usergallery_currentgal', ''); $serendipity['smarty']->assign('plugin_usergallery_uppath', ''); $serendipity['smarty']->assign('plugin_usergallery_toplevel', 'yes'); //Let's get a directory listing that has all our ACLs applied already! $directories_temp = serendipity_traversePath($serendipity['serendipityPath'] . $serendipity['uploadPath'], $limit_directory, NULL, $pattern, 1, NULL, "read", NULL); //Check to see if we are calling a gallery directly if (isset($_GET['gallery']) && $_GET['gallery'] != '') { //replace weird characters. Was more important before we used the database. $getpathtemp = str_replace("//", "/", str_replace("..", "", urldecode($_GET['gallery']))); //Ok, let's check the out directory is actually in the returned directories. if (is_array($directories_temp)) { foreach ($directories_temp as $f => $dir) { if ($getpathtemp == $dir['relpath']) { //yay! We have access to the directory. $permitted_gallery = true; break; } } } //If we have a matching directory, let's set the gallery up. if ($permitted_gallery) { $limit_images_directory = $getpathtemp; $temp_array = explode('/', $getpathtemp); array_pop($temp_array); $limit_output = array_pop($temp_array); if ($display_dir_tree == 'no') { $up_path = implode('/', $temp_array); if ($up_path != "") { $up_path = $up_path . "/"; } } $serendipity['smarty']->assign('plugin_usergallery_currentgal', $getpathtemp); $serendipity['smarty']->assign('plugin_usergallery_uppath', $up_path); $serendipity['smarty']->assign('plugin_usergallery_toplevel', 'no'); } } else { //We weren't calling a gallery directory, so it is set up in the configuration. If it is the base 'uploads' directory there are never any permissions on it. if ($limit_images_directory != '') { $perm_test_array = array(array('name' => str_replace("/", "", $limit_images_directory), 'depth' => 1, 'relpath' => $limit_images_directory, 'directory' => 1)); if (serendipity_directoryACL($perm_test_array, 'read')) { $permitted_gallery = true; } } else { $permitted_gallery = true; } } $where = $show_objects ? '' : "WHERE mime LIKE 'image/%'"; $query = "SELECT path, count(id) FROM {$serendipity['dbPrefix']}images " . $where . " GROUP BY path"; $rs = serendipity_db_query($query, false, 'assoc'); if (is_array($rs)) { foreach ($rs as $f => $record) { if ($limit_directory != '') { $temp_count = strlen($limit_directory); if (strcmp(substr($record['path'], 0, $temp_count), $limit_directory) == 0) { $temp_filecount[$record['path']] = $record['count(id)']; } } else { $temp_filecount[$record['path']] = $record['count(id)']; } } } if ($dir_list == 'yes') { if ($display_dir_tree == 'yes') { if (!isset($temp_filecount[$limit_directory])) { $temp_filecount[$limit_directory] = '0'; } $serendipity['smarty']->assign('plugin_usergallery_maindir_filecount', $temp_filecount[$limit_directory]); } else { if ($up_path == '') { $temp_filecount[$up_path] = $temp_filecount[$limit_directory]; } if (!isset($temp_filecount[$up_path])) { $temp_filecount[$up_path] = '0'; } $serendipity['smarty']->assign('plugin_usergallery_maindir_filecount', $temp_filecount[$up_path]); } } if (is_array($directories_temp)) { usort($directories_temp, 'serendipity_sortPath'); foreach ($directories_temp as $f => $dir) { $directory = $dir['relpath']; $dir['filecount'] = $temp_filecount[$directory]; if (isset($dir['depth'])) { $dir['pxdepth'] = $dir['depth'] * $this->get_config('dir_tab', 10); } if ($dir['filecount'] == '') { $dir['filecount'] = 0; } if ($display_dir_tree == 'yes') { $directories[$dir['relpath']] = $dir; } else { if ($show_1lvl_sub == 'yes') { $temp_count = strlen($limit_images_directory); if (strcmp(substr($directory, 0, $temp_count), $limit_images_directory) == 0 && $directory != $limit_images_directory) { $full_length = strlen($directory); if (substr_count(substr($directory, $temp_count, $full_length), '/') == 1) { $directories[$dir['relpath']] = $dir; } else { $temp_count = $temp_count + 1 + strpos(substr($directory, $temp_count, $full_length), '/'); $directories[substr($directory, 0, $temp_count)]['filecount'] = $directories[substr($directory, 0, $temp_count)]['filecount'] + $dir['filecount']; } } } else { $temp_count = strlen($limit_images_directory); if (strcmp(substr($directory, 0, $temp_count), $limit_images_directory) == 0 && $directory != $limit_images_directory) { $directories[$directory] = $dir; } } } } } $serendipity['smarty']->assign('plugin_usergallery_subdirectories', $directories); $lower_limit = 0; $showpage = false; if ($images_per_page != 0 && $permitted_gallery) { $showpage = true; $total_count = $temp_filecount[$limit_images_directory]; if ($total_count <= $images_per_page) { $showpage = false; } if ($showpage) { if (isset($_GET['page']) && $_GET['page'] != '') { $current_page = intval($_GET['page']); } else { $current_page = 1; } $total_pages = ceil($total_count / $images_per_page); $previous_page = $current_page - 1; if ($previous_page == 0) { $lower_limit = 0; } else { $lower_limit = $previous_page * $images_per_page; } } } $serendipity['smarty']->assign(array('plugin_usergallery_pagination' => $showpage, 'plugin_usergallery_total_count' => $total_count, 'plugin_usergallery_total_pages' => $total_pages, 'plugin_usergallery_current_page' => $current_page, 'plugin_usergallery_next_page' => $current_page + 1, 'plugin_usergallery_previous_page' => $current_page - 1)); if ($this->get_config('image_strict') == 'yes') { $images = serendipity_fetchImagesFromDatabase($lower_limit, $images_per_page, $total, $orderby, $order, $limit_images_directory, '', '', array(), true); } else { $images = serendipity_fetchImagesFromDatabase($lower_limit, $images_per_page, $total, $orderby, $order, $limit_images_directory); } if (is_array($images)) { foreach ($images as $f => $image) { $is_image = serendipity_isImage($image); if (!$is_image && !$show_objects) { continue; } // do not include Non-Image objects to array if ($is_image) { $image['link'] = $serendipity['serendipityHTTPPath'] . $serendipity['uploadHTTPPath'] . $image['path'] . $image['name'] . '.' . $image['thumbnail_name'] . '.' . $image['extension']; $image['dimension'] = $image['dimensions_width'] . 'x' . $image['dimensions_height']; $image['isimage'] = true; } else { $image['isimage'] = false; $image['link'] = serendipity_getTemplateFile('admin/img/mime_unknown.png'); } $image['fullimage'] = $serendipity['serendipityHTTPPath'] . $serendipity['uploadHTTPPath'] . $image['path'] . $image['name'] . '.' . $image['extension']; $image['filesize'] = round($image['size'] / 1024); $image['popupwidth'] = $is_image ? $image['dimensions_width'] + 20 : 600; $image['popupheight'] = $is_image ? $image['dimensions_height'] + 20 : 500; $process_images[$image['name']] = $image; } } $gallery_array = explode('/', $up_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; } } unset($path_array['']); if ($limit_output == $base_directory) { $limit_output = ''; } // this needs the latest >= v. 2.0 lightbox plugin installed! $lightbox_type = $this->get_config('lightbox_type'); $lbtype = 'rel="lightbox[]"'; if ($lightbox_type == 'prettyphoto') { $lbtype = 'rel="prettyPhoto[]"'; } elseif ($lightbox_type == 'colorbox') { $lbtype = 'rel="colorbox[]"'; } elseif ($lightbox_type == 'magnific') { $lbtype = 'rel="magnificPopup[]"'; } $serendipity['smarty']->assign(array('plugin_usergallery_title' => $this->get_config('title'), 'plugin_usergallery_cols' => $num_cols, 'plugin_usergallery_preface' => $this->get_config('intro'), 'plugin_usergallery_fixed_width' => $this->get_config('fixed_width'), 'plugin_usergallery_image_display' => $this->get_config('image_display'), 'plugin_usergallery_gallery_breadcrumb' => $path_array, 'plugin_usergallery_dir_list' => $dir_list, 'plugin_usergallery_display_dir_tree' => $display_dir_tree, 'plugin_usergallery_colwidth' => round(10 / $num_cols * 10 - 6, 2), 'plugin_usergallery_limit_directory' => preg_replace('@[^a-z0-9]@i', ' ', $limit_output), 'plugin_usergallery_uselightbox' => serendipity_db_bool($this->get_config('show_lightbox', false)), 'plugin_usergallery_lightbox_script' => $lightbox_type, 'plugin_usergallery_lightbox_dir' => $this->get_config('lightbox_path'), 'plugin_usergallery_lightbox_jquery' => !class_exists('serendipity_event_jquery') && !$serendipity['capabilities']['jquery'] ? true : false, 'plugin_usergallery_lightbox_type' => $lbtype, 'plugin_usergallery_images' => $process_images)); $content = $this->parseTemplate('plugin_usergallery.tpl'); echo $content; } else { $add_url = '?serendipity[subpage]=' . $this->get_config('subpage'); if ($base_directory == 'gallery') { $limit_directory = ''; } else { $limit_directory = $base_directory; } serendipity_displayImageList(isset($serendipity['GET']['page']) ? $serendipity['GET']['page'] : 1, $num_cols, false, $add_url, false, $limit_directory); } } }
function scanUploadDir() { global $serendipity; if (!serendipity_checkPermission('adminImagesDirectories')) { return; } $folders = serendipity_traversePath($serendipity['serendipityPath'] . $serendipity['uploadPath'], '', true, NULL, 1, NULL, 'write'); usort($folders, 'serendipity_sortPath'); $result = array('' => PARENT_DIRECTORY); foreach ($folders as $dirmeta) { $result[$dirmeta['relpath']] = $dirmeta['relpath']; } return $result; }
function getTemplates($dir = '/home/garvin/cvs/serendipity/additional_themes/') { $this->i18n = false; $ret = serendipity_traversePath($dir, '', true, null, 1, 1); $this->xmlData['template'] = array(); $x =& $this->xmlData['template']; $x[] = '<?xml version="1.0" encoding="UTF-8" ?>'; $x[] = '<!-- -->' . "\n"; $x[] = '<packages>'; $_blacklist = explode("\n", file_get_contents($dir . '/blacklist.txt')); $blacklist = array(); foreach ($_blacklist as $idx => $blackline) { $blackline = trim($blackline); if (empty($blackline)) { continue; } if ($blackline[0] == '#') { continue; } $blacklist[$blackline] = true; } $t = array(); $nametofile = array(); foreach ($ret as $idx => $path) { $info = array(); if (file_exists($dir . $path['name'] . '/info.txt')) { $info = serendipity_fetchTemplateInfo($path['name'], $dir); } if (empty($info['name'])) { continue; } $olddir = getcwd(); chdir($dir); $info['files'] = $this->get_files($path['name']); chdir($olddir); $td = ''; $td .= '<div class="template_summary">' . $this->encode($info['name']) . '<br />' . $this->encode($info['summary']) . '</div>'; $td .= '<div class="template_name">' . $this->encode($path['name']) . '</template>'; if (empty($info['version'])) { $info['version'] = '1.0'; } if (empty($info['license'])) { $info['license'] = 'N/A (=GPL)'; } $td .= '<div class="template_version">' . $this->encode(VERSION . ' ' . $info['version']) . '(' . $this->encode($info['license']) . ', ' . $this->encode($info['date']) . ')</div>'; $td .= '<div class="template_maintainers">' . $this->encode($info['author']) . '</div>'; if (!empty($info['require serendipity'])) { $td .= '<div class="template_requirements">Serendipity >= ' . $this->encode($info['require serendipity']) . '</div>'; } if (!isset($blacklist[$path['name']])) { $td .= '<a style="font-weight: bold; margin: 0px auto" href="http://blog.s9y.org/index.php?user_template=additional_themes/' . $path['name'] . '">See demo on blog.s9y.org</a>' . "\n"; } $td .= '<div class="template_description"><span class="template_download"><a href="cvs/additional_themes/' . $path['name'] . '.zip"><img alt="Download" src="cvs/additional_themes/' . $path['name'] . '/preview_fullsize.jpg" width="100%" /></a></div>' . $this->encode($info['description']) . '</div>'; $x[] = '<package version="1.0">'; $x[] = '<name>' . $this->encode($info['name'], true) . '</name>'; $x[] = '<template>' . $this->encode($path['name'], true) . '</template>'; $x[] = '<license>' . $this->encode($info['license'], true) . '</license>'; $x[] = '<summary>' . $this->encode($info['summary']) . '</summary>'; $x[] = '<description>' . $this->encode($info['description']) . '</description>'; $x[] = '<maintainers><maintainer><name>' . $this->encode($info['author'], true) . '</name><role>lead</role></maintainer></maintainers>'; $x[] = '<release>'; $x[] = ' <version>' . $this->encode($info['version'], true) . '</version>'; $x[] = ' <requirements:s9yVersion>' . $this->encode($info['require serendipity'], true) . '</requirements:s9yVersion>'; $x[] = ' <date>' . $this->encode($info['date'], true) . '</date>'; $x[] = ' <filelist>'; $x[] = $info['files']['xml']; $x[] = ' </filelist>'; $x[] = ' <serendipityFilelist>'; foreach ($info['files']['full'] as $file) { $x[] = ' <file>' . $file . '</file>'; } $x[] = ' </serendipityFilelist>'; $x[] = '</release>'; $x[] = '</package>'; $t[$info['name']] .= '<div class="template">' . $td . '</div>' . "\n"; $nametofile[$info['name']] = $path['name']; } $x[] = '</packages>'; ksort($t); $theme_li = ''; foreach ($t as $theme => $html) { $theme_li .= '<li><a href="index.php?mode=template_' . $nametofile[$theme] . '">' . $theme . '</a></li>' . "\n"; $fp = fopen('homepage/template_' . $nametofile[$theme] . '.htm', 'w'); fwrite($fp, $html); fclose($fp); } $fp = fopen('homepage/template_all.htm', 'w'); fwrite($fp, implode("\n", $t)); fclose($fp); $fp = fopen('homepage/box_groups_template.htm', 'w'); fwrite($fp, $theme_li); fclose($fp); }