Update of /cvsroot/php-blog/serendipity/include
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23780/include
Modified Files:
functions.inc.php functions_images.inc.php
Log Message:
- Rewrite directories in terms of layout and a few core functions, fixed a few possible bugs
- Don't run imagick command after using gdlib to resize an image
- Replace old fake buttons with new and pretty fake buttons
Layout of directory overview is pending change
Index: functions_images.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/include/functions_images.inc.php,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- functions_images.inc.php 26 Jan 2005 14:14:02 -0000 1.25
+++ functions_images.inc.php 3 Feb 2005 18:04:40 -0000 1.26
@@ -253,11 +253,11 @@
if ($serendipity['magick'] !== true) {
serendipity_resize_image_gd($infile, $outfile, $width, $height);
+ } else {
+ $cmd = $serendipity['convert'] . ' -scale ' . $width . 'x' . $height . ' ' . $infile . ' ' . $outfile;
+ $res = `$cmd`;
}
- $cmd = $serendipity['convert'] . ' -scale ' . $width . 'x' . $height . ' ' . $infile . ' ' . $outfile;
- $res = `$cmd`;
-
serendipity_updateImageInDatabase(array('dimensions_width' => $width, 'dimensions_height' => $height), $id);
return;
}
@@ -775,7 +775,7 @@
if (isset($serendipity['GET']['only_path']) && !empty($serendipity['GET']['only_path']) ) {
$extraParems .= 'serendipity[only_path]='. $serendipity['GET']['only_path'] .'&';
- serendipity_uploadSecure($serendipity['GET']['only_path'], true);
+ $serendipity['GET']['only_path'] = serendipity_uploadSecure($serendipity['GET']['only_path'], true);
}
foreach ( (array)$serendipity['GET']['sortorder'] as $k => $v ) {
@@ -788,17 +788,7 @@
$sort_order = serendipity_getImageFields();
- serendipity_traversePath(
- $paths,
- $serendipity['serendipityPath'] . $serendipity['uploadPath'],
- '',
- '',
- false,
- '',
- 2,
- 0,
- (isset($serendipity['GET']['only_path']) ? $serendipity['GET']['only_path'] : '')
- );
+ $paths = serendipity_traversePath($serendipity['serendipityPath'] . $serendipity['uploadPath']);
if (is_null($lineBreak)) {
@@ -821,7 +811,9 @@
<td><?php echo FILTER_DIRECTORY ?></td>
<td colspan="5"><select name="serendipity[only_path]">
<option value=""><?php echo ALL_DIRECTORIES ?></option>
- <?php echo $paths ?>
+ <?php foreach ( $paths as $folder ) { ?>
+ <option <?php echo ($serendipity['GET']['only_path'] == $folder['relpath']) ? 'selected="selected"' : '' ?> value="<?php echo $folder['relpath'] ?>"><?php echo str_repeat(' ', $folder['depth']*2) . ' '. $folder['name'] ?></option>
+ <?php } ?>
</select>
</td>
</tr>
@@ -979,8 +971,8 @@
}
function serendipity_killPath($basedir, $directory = '', $forceDelete = false) {
-static $n = "<br />\n";
-static $serious = true;
+ static $n = "<br />\n";
+ static $serious = true;
if ($handle = @opendir($basedir . $directory)) {
while (false !== ($file = @readdir($handle))) {
@@ -1048,47 +1040,34 @@
return true;
}
-function serendipity_traversePath(&$out, $basedir, $jscode = '', $directory = '', $show_files = false, $pattern = '', $output_mode = 1, $level = 0, $selected = '') {
- if (empty($pattern)) {
- $pattern = '@.*@';
- }
- if ($handle = @opendir($basedir . DIRECTORY_SEPARATOR . $directory)) {
- if ($output_mode == 1) {
- $out .= '<ul>';
- }
+function serendipity_traversePath($basedir, $dir='', $onlyDirs=true, $pattern = NULL, $depth = 1) {
- while (false !== ($file = @readdir($handle))) {
- if ($file != '.' && $file != '..' && preg_match($pattern, $file)) {
- if (is_dir($basedir . $directory . DIRECTORY_SEPARATOR . $file)) {
- $cdir = (!empty($directory) ? $directory . DIRECTORY_SEPARATOR : '');
- switch($output_mode) {
- default:
- case 1:
- $out .= '<li><a href="#" onclick="' . $jscode . '" title="' . $cdir . $file . DIRECTORY_SEPARATOR . '">' . $file . DIRECTORY_SEPARATOR . '</a></li>' . "\n";
- break;
- case 2:
- $value = $cdir . $file . DIRECTORY_SEPARATOR;
- $out .= '<option ' . ($selected == $value ? 'selected="selected"' : '') . ' value="' . $value . '">' . str_repeat(' ', $level * 2) . $file . '</option>' . "\n";
- break;
- }
+ $dh = @opendir($basedir . DIRECTORY_SEPARATOR . $dir);
+ if ( !$dh ) {
+ return false;
+ }
- serendipity_traversePath($out, $basedir, $jscode, $cdir . $file, $show_files, $pattern, $output_mode, $level + 1, $selected);
- } elseif ($show_files) {
- $out .= '<li>' . $file . '</li>' . "\n";
+ $files = array();
+ while (($file = @readdir($dh)) !== false) {
+ if ( $file != '.' && $file != '..' ) {
+ if ( $onlyDirs === true && is_dir($basedir . DIRECTORY_SEPARATOR . $dir . DIRECTORY_SEPARATOR . $file) ) {
+ if ( is_null($pattern) || preg_match($pattern, $file) ) {
+ $files[] = array('name' => $file, 'depth' => $depth, 'relpath' => ltrim($dir, DIRECTORY_SEPARATOR) . basename($file) . DIRECTORY_SEPARATOR);
}
+ }
+ if ( is_dir($basedir . DIRECTORY_SEPARATOR . $dir . DIRECTORY_SEPARATOR . $file) ) {
+ $files = array_merge($files, serendipity_traversePath($basedir, $dir . DIRECTORY_SEPARATOR . basename($file) . DIRECTORY_SEPARATOR, $onlyDirs, $pattern, ($depth+1)));
}
- }
-
- if ($output_mode == 1) {
- $out .= '</ul>';
- }
+ }
+ }
- closedir($handle);
- }
+ fclose($dh);
+ return $files;
}
+
function serendipity_deletePath($dir) {
$d = dir($dir);
if ($d) {
@@ -1109,7 +1088,7 @@
}
}
-function serendipity_uploadSecure(&$var, $strip_paths = true) {
+function serendipity_uploadSecure($var, $strip_paths = true) {
$var = preg_replace('@[^0-9a-z\._/-]@i', '', $var);
if ($strip_paths) {
$var = preg_replace('@(\.+[/\\\\]+)@', '/', $var);
@@ -1117,7 +1096,7 @@
$var = preg_replace('@^(/+)@', '', $var);
- return true;
+ return $var;
}
function serendipity_getimagesize($file, $ft_mime = '', $suf = '') {
Index: functions.inc.php
===================================================================
RCS file: /cvsroot/php-blog/serendipity/include/functions.inc.php,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- functions.inc.php 26 Jan 2005 14:14:01 -0000 1.20
+++ functions.inc.php 3 Feb 2005 18:04:40 -0000 1.21
@@ -82,8 +82,11 @@
function serendipity_fetchTemplateInfo($theme) {
global $serendipity;
- /* Blame jannis */
- $lines = file($serendipity['serendipityPath'] . $serendipity['templatePath'] . $theme . '/info.txt');
+
+ $lines = @file($serendipity['serendipityPath'] . $serendipity['templatePath'] . $theme . '/info.txt');
+ if ( !$lines ) {
+ return array();
+ }
for($x=0; $x<count($lines); $x++) {
$j = preg_split('/([^\:]+)\:/', $lines[$x], -1, PREG_SPLIT_DELIM_CAPTURE);
|