[Linpha-cvs] SF.net SVN: linpha: [4547] trunk/linpha2
Status: Inactive
Brought to you by:
bzrudi
From: <fan...@us...> - 2006-04-24 21:02:30
|
Revision: 4547 Author: fangehrn Date: 2006-04-24 14:02:12 -0700 (Mon, 24 Apr 2006) ViewCVS: http://svn.sourceforge.net/linpha/?rev=4547&view=rev Log Message: ----------- * created a filemanager layout Modified Paths: -------------- trunk/linpha2/ChangeLog trunk/linpha2/index.php trunk/linpha2/lib/classes/linpha.sql.class.php trunk/linpha2/lib/modules/module.albums.php trunk/linpha2/lib/modules/module.basket.php trunk/linpha2/lib/modules/module.browse.php trunk/linpha2/lib/modules/module.search.php Added Paths: ----------- trunk/linpha2/lib/modules/module.filemanager.php Modified: trunk/linpha2/ChangeLog =================================================================== --- trunk/linpha2/ChangeLog 2006-04-24 20:08:47 UTC (rev 4546) +++ trunk/linpha2/ChangeLog 2006-04-24 21:02:12 UTC (rev 4547) @@ -1,5 +1,6 @@ 2006-04-24 flo * created import/index/create thumbnail/re-create-scripts in admin-import section + * created a filemanager layout 2006-04-18 flo * calendar: apply previous update from linpha1 Modified: trunk/linpha2/index.php =================================================================== --- trunk/linpha2/index.php 2006-04-24 20:08:47 UTC (rev 4546) +++ trunk/linpha2/index.php 2006-04-24 21:02:12 UTC (rev 4547) @@ -35,6 +35,9 @@ case 'browse': include_once(LINPHA_DIR.'/lib/modules/module.browse.php'); break; +case 'filemanager': + include_once(LINPHA_DIR.'/lib/modules/module.filemanager.php'); + break; } ?> \ No newline at end of file Modified: trunk/linpha2/lib/classes/linpha.sql.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.sql.class.php 2006-04-24 20:08:47 UTC (rev 4546) +++ trunk/linpha2/lib/classes/linpha.sql.class.php 2006-04-24 21:02:12 UTC (rev 4547) @@ -562,7 +562,7 @@ /** * really need this hard limit - * because if we try to infos from an id which doesn't exist anymore + * because if we try to get infos from an id which doesn't exist anymore * we would run in an endless loop */ @@ -595,8 +595,8 @@ */ function getFullImagePath( $photo_id ) { - $array_path = $GLOBALS['linpha']->sql->getFullFilenameFromId( $photo_id ); - $album_dir = $GLOBALS['linpha']->sql->getPath('album'); + $array_path = LinSql::getFullFilenameFromId( $photo_id ); + $album_dir = LinSql::getPath('album'); return $album_dir .'/'. implode('/',$array_path); } Modified: trunk/linpha2/lib/modules/module.albums.php =================================================================== --- trunk/linpha2/lib/modules/module.albums.php 2006-04-24 20:08:47 UTC (rev 4546) +++ trunk/linpha2/lib/modules/module.albums.php 2006-04-24 21:02:12 UTC (rev 4547) @@ -20,7 +20,7 @@ /** * Albums view related methods and functions - * @package Template + * @package Modules */ if(!defined('LINPHA_DIR')) { exit(1); } Modified: trunk/linpha2/lib/modules/module.basket.php =================================================================== --- trunk/linpha2/lib/modules/module.basket.php 2006-04-24 20:08:47 UTC (rev 4546) +++ trunk/linpha2/lib/modules/module.basket.php 2006-04-24 21:02:12 UTC (rev 4547) @@ -20,7 +20,7 @@ /** * Basket view related methods and functions - * @package Template + * @package Modules */ if(!defined('LINPHA_DIR')) { exit(1); } Modified: trunk/linpha2/lib/modules/module.browse.php =================================================================== --- trunk/linpha2/lib/modules/module.browse.php 2006-04-24 20:08:47 UTC (rev 4546) +++ trunk/linpha2/lib/modules/module.browse.php 2006-04-24 21:02:12 UTC (rev 4547) @@ -20,7 +20,7 @@ /** * Navigation view related methods and functions - * @package Template + * @package Modules */ if(!defined('LINPHA_DIR')) { exit(1); } Added: trunk/linpha2/lib/modules/module.filemanager.php =================================================================== --- trunk/linpha2/lib/modules/module.filemanager.php (rev 0) +++ trunk/linpha2/lib/modules/module.filemanager.php 2006-04-24 21:02:12 UTC (rev 4547) @@ -0,0 +1,288 @@ +<?php +/* + * Copyright (c) 2005 Heiko Rutenbeck <bz...@tu...> + * Florian Angehrn + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +/** + * Albums view related methods and functions + * @package Modules + */ +if(!defined('LINPHA_DIR')) { exit(1); } + +if(!isset($_GET['id'])) +{ + $parent_id = 0; +} +else +{ + $parent_id = $_GET['id']; +} + + +$i = 0; +$sum['size'] = 0; +$sum['files'] = 0; + +$use_posix = checkPosix(); + +if($use_posix) { + $uid = @posix_getuid(); // get user id of current process +} else { + $uid = 0; +} + + +?> + +<table border="1"> + + +<?php +if($parent_id != 0) +{ + $data = $GLOBALS['linpha']->db->GetRow("SELECT name, parent_id FROM ".PREFIX."photos WHERE id = '".LinSql::linAddslashes($parent_id)."'"); + + echo i18n("Current Folder:").' '.$data['name'].'<br />'; + ?> + <tr> + <td> </td> + <td><a href="<?php echo LINPHA_DIR.'/?cat=filemanager&id='.$data['parent_id']; ?>">..</a></td> + <td> </td> + <td> </td> + <td> </td> + </tr> + <?php +} + +$query = $GLOBALS['linpha']->db->Execute("SELECT id, name, img_type FROM ".PREFIX."photos WHERE parent_id = '".LinSql::linAddslashes($parent_id)."' ORDER by name"); +while($data = $query->FetchRow()) +{ + /** + * set file informations + */ + $full_filename = LinSql::getFullImagePath( $data['id'] ); + $filestat = stat($full_filename); + + /** + * size and nr files + */ + if( $data['img_type'] != 0 && $data['img_type'] != 9999999 ) + { + $sum['size'] += $filestat['size']; + $sum['files']++; + } + + /** + * owner and group name + */ + if($use_posix) { + $owner_info = @posix_getpwuid($filestat['uid']); // use @ because check_posix() can return true even if it fails... + $group_info = @posix_getgrgid($filestat['gid']); + } else { + $owner_info['name'] = ''; + $group_info['name'] = ''; + } + + /** + * file permissions + */ + if(getOS() == 'win') + { + $file_permissions = + '[' . + (is_readable($full_filename) ? '<font color="green">r</font>' : ' ') . + (is_writable($full_filename) ? '<font color="red">w</font>' : ' ') . + (function_exists('is_executable') ? + (is_executable($full_filename) ? '<font color="blue">x</font>' : ' ') + : + ' ' + ) . + ']'; + } else { + $perm = '['.getReadableFileperms($full_filename).']'; + + $perm = str_replace('r','<font color="green">r</font>',$perm); + $perm = str_replace('w','<font color="red">w</font>',$perm); + $perm = str_replace('x','<font color="blue">x</font>',$perm); + + if($uid == $filestat['uid']) + { + $file_permissions = '<a href="'.LINPHA_DIR.'/?cat=filemanager&cmd=change_perm_form">'. $perm . '</a>'; + } + else + { + $file_permissions = $perm; + } + } + + + + + + + + + ?> + <tr> + <td><input type="checkbox" name="checkedfiles[<?php echo $data['id']; ?>]" value="value" /></td> + <td width="500"> + <?php + if($data['img_type']==0) + { + echo '<a href="'.LINPHA_DIR.'/?cat=filemanager&id='.$data['id'].'">'.$data['name'].'</a>'; + } + else + { + echo $data['name']; + } + ?> + </td> + <td width="100" align="right"><?php echo ($data['img_type']==0 OR $data['img_type']==9999999) ? ' ' : niceFilesize($filestat['size'],1); ?></td> + <td width="150" align="center"><?php echo strftime("%x %X",$filestat['mtime']); ?></td> + <td width="100" align="center" title="<?php echo $owner_info['name'].' '.$group_info['name']; ?>"><?php echo $file_permissions; ?></td> + </tr> + <?php +} +?> +</table> +<input type="radio" name="file_action" value="rename" /><label for=""><?php echo ' '.i18n("Rename"); ?></label> +<input type="radio" name="file_action" value="rename" /><label for=""><?php echo ' '.i18n("Move"); ?></label> +<input type="radio" name="file_action" value="rename" /><label for=""><?php echo ' '.i18n("Copy"); ?></label> +<input type="radio" name="file_action" value="rename" /><label for=""><?php echo ' '.i18n("Delete"); ?></label> +<input type="submit" name="submit" value="<?php echo i18n("Submit"); ?>"/> +</form> + + +<br /><br /> +<form action="<?php echo LINPHA_DIR.'/?cat=filemanager&id='.$parent_id; ?>"> +<input type="text" name="createfolder" value="" /> +<input type="hidden" name="cmd" value="createfolder" /> +<input type="submit" name="submit" value="<?php echo i18n("Create Folder"); ?>"/> +</form> + +<br /><br /> +<form action="<?php echo LINPHA_DIR.'/?cat=filemanager&id='.$parent_id; ?>"> +<input type="file" name="uploadfile0" value="" /><br /> +<input type="file" name="uploadfile1" value="" /><br /> +<input type="file" name="uploadfile2" value="" /><br /> +<input type="file" name="uploadfile3" value="" /><br /> +<input type="file" name="uploadfile4" value="" /><br /> + +<input type="hidden" name="cmd" value="upload" /> +<input type="submit" name="submit" value="<?php echo i18n("Upload Files"); ?>"/> +</form> + +<?php + +/** +* found on http://ch.php.net/manual/en/function.fileperms.php +*/ +function getReadableFileperms($file) +{ + $perms = fileperms($file); + + $info = ''; + + if (($perms & 0xC000) == 0xC000) { + // Socket + $info .= 's'; + } elseif (($perms & 0xA000) == 0xA000) { + // Symbolic Link + $info .= 'l'; + } elseif (($perms & 0x8000) == 0x8000) { + // Regular + $info .= '-'; + } elseif (($perms & 0x6000) == 0x6000) { + // Block special + $info .= 'b'; + } elseif (($perms & 0x4000) == 0x4000) { + // Directory + $info .= 'd'; + } elseif (($perms & 0x2000) == 0x2000) { + // Character special + $info .= 'c'; + } elseif (($perms & 0x1000) == 0x1000) { + // FIFO pipe + $info .= 'p'; + } else { + // Unknown + $info .= 'u'; + } + + // Owner + $info .= (($perms & 0x0100) ? 'r' : '-'); + $info .= (($perms & 0x0080) ? 'w' : '-'); + $info .= (($perms & 0x0040) ? + (($perms & 0x0800) ? 's' : 'x' ) : + (($perms & 0x0800) ? 'S' : '-')); + + // Group + $info .= (($perms & 0x0020) ? 'r' : '-'); + $info .= (($perms & 0x0010) ? 'w' : '-'); + $info .= (($perms & 0x0008) ? + (($perms & 0x0400) ? 's' : 'x' ) : + (($perms & 0x0400) ? 'S' : '-')); + + // World + $info .= (($perms & 0x0004) ? 'r' : '-'); + $info .= (($perms & 0x0002) ? 'w' : '-'); + $info .= (($perms & 0x0001) ? + (($perms & 0x0200) ? 't' : 'x' ) : + (($perms & 0x0200) ? 'T' : '-')); + + + return $info; +} + +/** +* this function checks if the posix functions are available +* +* @author flo +* @return bool true if posix enabled, false if not +* @package requirements +*/ +function checkPosix() +{ + $array_needed_functions = Array( + 'posix_getuid', + 'posix_getpwuid', + 'posix_getgrgid' + ); + + foreach($array_needed_functions AS $value) + { + if( !function_exists($value) ) + { + return false; + } + } + + /** + * can return true even if it fails...!!! seen on sf.net + */ + if($uid = @posix_getuid()) + { + if(@posix_getpwuid($uid)) + { + return true; + } + } + + return false; +} +?> \ No newline at end of file Modified: trunk/linpha2/lib/modules/module.search.php =================================================================== --- trunk/linpha2/lib/modules/module.search.php 2006-04-24 20:08:47 UTC (rev 4546) +++ trunk/linpha2/lib/modules/module.search.php 2006-04-24 21:02:12 UTC (rev 4547) @@ -1,32 +1,30 @@ <?php /* -* Copyright (c) 2005 Heiko Rutenbeck <bz...@tu...> -* Florian Angehrn -* -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ + * Copyright (c) 2005 Heiko Rutenbeck <bz...@tu...> + * Florian Angehrn + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ /** * Albums view related methods and functions - * @package Template + * @package Modules */ +if(!defined('LINPHA_DIR')) { exit(1); } - - - /** * call from exif href in img_view */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |