[Linpha-cvs] SF.net SVN: linpha: [4804] trunk/linpha2
Status: Inactive
Brought to you by:
bzrudi
From: <fan...@us...> - 2007-12-02 21:47:05
|
Revision: 4804 http://linpha.svn.sourceforge.net/linpha/?rev=4804&view=rev Author: fangehrn Date: 2007-12-02 13:46:57 -0800 (Sun, 02 Dec 2007) Log Message: ----------- 2007-12-02 flo * created settings and permissions section for plugins they are dynamically loaded with the files /lib/plugins/*/settings.*.php and /lib/plugins/*/permissions.*.php * decided to have for each plugin own sql files -> plugins are now nearly separated from the main linpha files -> if someone adds a new plugin, you don't have to update linpha itself, just copy the plugin folder to the plugin directory and it will automatically appear in the admin section where it can be enabled and the tables and config entries are automatically created -> this solves also the sequences and triggers problem with oracle * changed back the style of the form buttons i think buttons should still be buttons * filemanager - disallow change of the file extension a user could upload anEvilPhpScriptMaskedAsAnImage.jpg and rename it later to anEvilPhpScriptMaskedAsAnImage.php Modified Paths: -------------- trunk/linpha2/ChangeLog trunk/linpha2/admin/permissions.php trunk/linpha2/admin/permissions_others.php trunk/linpha2/admin/permissions_readwrite.php trunk/linpha2/admin/settings_plugins.php trunk/linpha2/index.php trunk/linpha2/install/step9_createtables.php trunk/linpha2/lib/classes/linpha.admin.class.php trunk/linpha2/lib/classes/linpha.filesys.class.php trunk/linpha2/lib/include/sql/sql.data.php trunk/linpha2/lib/include/sql/sql.mysql.php trunk/linpha2/lib/include/sql/sql.tables.php trunk/linpha2/lib/modules/module.settings.php trunk/linpha2/lib/plugins/filemanager/settings.filemanager.php trunk/linpha2/reset_database.php trunk/linpha2/templates/default/global.html.php trunk/linpha2/templates/default/themes/default/colorsettings.php trunk/linpha2/templates/default/themes/default/css/global.css Added Paths: ----------- trunk/linpha2/lib/plugins/example/ trunk/linpha2/lib/plugins/example/module.example.php trunk/linpha2/lib/plugins/example/permissions.example.php trunk/linpha2/lib/plugins/example/settings.example.php trunk/linpha2/lib/plugins/example/sql/ trunk/linpha2/lib/plugins/example/sql/sql.data.php trunk/linpha2/lib/plugins/example/sql/sql.mysql.php trunk/linpha2/lib/plugins/example/sql/sql.oci8po.php trunk/linpha2/lib/plugins/example/sql/sql.postgres.php trunk/linpha2/lib/plugins/example/sql/sql.sqlite.php trunk/linpha2/lib/plugins/filemanager/module.filemanager.php trunk/linpha2/lib/plugins/filemanager/sql/ trunk/linpha2/lib/plugins/filemanager/sql/sql.data.php trunk/linpha2/lib/plugins/guestbook/permissions.guestbook.php trunk/linpha2/lib/plugins/guestbook/sql/ trunk/linpha2/lib/plugins/guestbook/sql/sql.data.php trunk/linpha2/lib/plugins/log/sql/ trunk/linpha2/lib/plugins/log/sql/sql.data.php trunk/linpha2/lib/plugins/maillist/sql/ trunk/linpha2/lib/plugins/maillist/sql/sql.data.php trunk/linpha2/lib/plugins/maps/permissions.maps.php trunk/linpha2/lib/plugins/maps/settings.maps.php trunk/linpha2/lib/plugins/maps/sql/ trunk/linpha2/lib/plugins/maps/sql/sql.data.php trunk/linpha2/lib/plugins/maps/sql/sql.mysql.php trunk/linpha2/lib/plugins/maps/sql/sql.oci8po.php trunk/linpha2/lib/plugins/maps/sql/sql.postgres.php trunk/linpha2/lib/plugins/maps/sql/sql.sqlite.php trunk/linpha2/lib/plugins/rss/sql/ trunk/linpha2/lib/plugins/rss/sql/sql.data.php trunk/linpha2/lib/plugins/stats/sql/ trunk/linpha2/lib/plugins/stats/sql/sql.data.php trunk/linpha2/lib/plugins/watermark/permissions.watermark.php trunk/linpha2/lib/plugins/watermark/sql/ trunk/linpha2/lib/plugins/watermark/sql/sql.data.php Removed Paths: ------------- trunk/linpha2/lib/modules/module.filemanager.php Modified: trunk/linpha2/ChangeLog =================================================================== --- trunk/linpha2/ChangeLog 2007-12-01 17:14:09 UTC (rev 4803) +++ trunk/linpha2/ChangeLog 2007-12-02 21:46:57 UTC (rev 4804) @@ -1,4 +1,26 @@ +2007-12-02 flo + * created settings and permissions section for plugins + they are dynamically loaded with the files /lib/plugins/*/settings.*.php + and /lib/plugins/*/permissions.*.php + + * decided to have for each plugin own sql files + -> plugins are now nearly separated from the main linpha files + -> if someone adds a new plugin, you don't have to update linpha itself, + just copy the plugin folder to the plugin directory and it will + automatically appear in the admin section where it can be enabled + and the tables and config entries are automatically created + -> this solves also the sequences and triggers problem with oracle + + + * changed back the style of the form buttons + i think buttons should still be buttons + + * filemanager + - disallow change of the file extension + a user could upload anEvilPhpScriptMaskedAsAnImage.jpg and rename it later + to anEvilPhpScriptMaskedAsAnImage.php + 2007-12-01 flo * creating plugin interface - moved whole install/sql folder to lib/include/sql Modified: trunk/linpha2/admin/permissions.php =================================================================== --- trunk/linpha2/admin/permissions.php 2007-12-01 17:14:09 UTC (rev 4803) +++ trunk/linpha2/admin/permissions.php 2007-12-02 21:46:57 UTC (rev 4804) @@ -10,10 +10,11 @@ 'users' => array('name' => i18n("Users"), 'link' => 'permissions_users'), 'groups' => array('name' => i18n("Groups"), 'link' => 'permissions_groups'), 'usergroup' => array('name' => i18n("Group Memberships"), 'link' => 'permissions_usergroup'), - 'view' => array('name' => i18n("View"), 'link' => 'permissions_view'), - 'write' => array('name' => i18n("Write"), 'link' => 'permissions_write'), + 'view' => array('name' => i18n("Image View"), 'link' => 'permissions_view'), + 'write' => array('name' => i18n("Image Upload"), 'link' => 'permissions_write'), 'basket' => array('name' => i18n("Basket"), 'link' => 'permissions_basket'), 'metadata' => array('name' => i18n("MetaData"), 'link' => 'permissions_metadata'), + 'plugins' => array('name' => i18n("Plugins"), 'link' => 'permissions_plugins'), 'others' => array('name' => i18n("Others"), 'link' => 'permissions_others'), ); @@ -40,9 +41,14 @@ case 'basket': case 'metadata': +case 'plugins': case 'others': include_once('./permissions_others.php'); break; + +/*case 'plugins': + include_once(LINPHA_DIR.'/admin/permissions_plugins.php'); + break;*/ } ?> Modified: trunk/linpha2/admin/permissions_others.php =================================================================== --- trunk/linpha2/admin/permissions_others.php 2007-12-01 17:14:09 UTC (rev 4803) +++ trunk/linpha2/admin/permissions_others.php 2007-12-02 21:46:57 UTC (rev 4804) @@ -1,59 +1,16 @@ <?php if(!defined('LINPHA_DIR')) { exit(1); } -if(!isset($cat3)) -{ - $cat3 = ''; -} - -switch($cat2) -{ -case 'basket': - $array_menu = array( - 'print' => array('name' => i18n("Print"), 'link' => 'permissions_basket_print'), - 'mail' => array('name' => i18n("Mail"), 'link' => 'permissions_basket_mail'), - 'download' => array('name' => i18n("Download"), 'link' => 'permissions_basket_download'), - ); - break; -case 'metadata': - $array_menu = array( - 'comments' => array('name' => i18n("Write Comments"), 'link' => 'permissions_metadata_comments'), - 'deletecomments' => array('name' => i18n("Delete Comments"), 'link' => 'permissions_metadata_deletecomments'), - 'edit' => array('name' => i18n("Edit Image Informations"), 'link' => 'permissions_metadata_edit'), - ); - break; -case 'others': - $array_menu = array( - 'watermark' => array('name' => i18n("Watermark"), 'link' => 'permissions_others_watermark'), - 'stats' => array('name' => i18n("Statistics"), 'link' => 'permissions_others_stats'), - 'download' => array('name' => i18n("Download"), 'link' => 'permissions_others_download'), - ); - break; -} - -LinAdmin::printAdminMenu($array_menu,$cat3); - -if(!empty($cat3)) -{ - if($cat2 == 'basket' OR $cat2 == 'metadata') - { - $key = $cat2.'_'.$cat3; - } - elseif($cat2 == 'others') - { - $key = $cat3; - } - - /** - * save data - */ +/** + * save data + */ if(isset($_POST['cmd']) && $_POST['cmd'] == 'edit') { if($_POST['allowall'] == 'allowall') { $GLOBALS['linpha']->db->Execute("UPDATE ".LIN_PREFIX."permissions " . "SET permission = ';public;' " . - "WHERE perm_type = '".LinSql::linAddslashes($key)."'"); + "WHERE perm_type = '".LinSql::linAddslashes($_POST['perm_type'])."'"); } else { @@ -68,38 +25,120 @@ $GLOBALS['linpha']->db->Execute("UPDATE ".LIN_PREFIX."permissions " . "SET permission = '".LinSql::linAddslashes($str)."' " . - "WHERE perm_type = '".LinSql::linAddslashes($key)."'"); + "WHERE perm_type = '".LinSql::linAddslashes($_POST['perm_type'])."'"); } } + +switch($cat2) +{ +case 'basket': + printPermissions('basket_print',i18n("Basket Print")); + printPermissions('basket_mail',i18n("Basket Mail")); + printPermissions('basket_download',i18n("Basket Download")); + break; +case 'metadata': + printPermissions('metadata_comments',i18n("Write Comments")); + printPermissions('metadata_deletecomments',i18n("Delete Comments")); + printPermissions('metadata_edit',i18n("Edit Image Informations")); + break; +case 'others': + printPermissions('download',i18n("Download Single Images")); + break; +case 'plugins': + + $array_menu = array(); + $arrPlugins = LinAdmin::getPlugins(); + foreach( $arrPlugins as $key=>$value) + { + $includeFile = LINPHA_DIR.'/lib/plugins/'.$value.'/permissions.'.$value.'.php'; + if( isset($LinAdmin->option_value_system['plugins_'.$value.'_enable']) + && $LinAdmin->option_value_system['plugins_'.$value.'_enable']=='1' + && file_exists($includeFile) + ) + { + $array_menu[$value] = array( + 'name' => $LinAdmin->description_array['plugins_'.$value], + 'link' => 'permissions_plugins_'.$value + ); + } + } + if(!isset($cat3)) { + LinAdmin::printAdminMenu($array_menu,''); + } else { + LinAdmin::printAdminMenu($array_menu,$cat3); + } - echo '<b>'.i18n("Edit").': '.$array_menu[$cat3]['name'].'</b><br />'; + + if( isset($cat3) && in_array($cat3,$arrPlugins) + && $LinAdmin->option_value_system['plugins_'.$cat3.'_enable']=='1' ) + { + $includeFile = LINPHA_DIR.'/lib/plugins/'.$cat3.'/permissions.'.$cat3.'.php'; + if( file_exists($includeFile) ) + { + include_once($includeFile); + } + } + + break; +} + +?> + <script language="JavaScript" type="text/javascript"> + + function update_forms(formId) + { + if(formId.allowall[0].checked) + { + // use elements[2] for select name because it does not work with the name groups[] + formId.elements[2].disabled = true; + formId.elements[2].selectedIndex = -1; + } + + if(formId.allowall[1].checked) + { + formId.elements[2].disabled = false; + } + } + //update_forms(); + + </script> +<?php + +function printPermissions($key,$description) +{ + echo '<b>'.$description.'</b><br />'; + $data = $GLOBALS['linpha']->db->GetRow("SELECT permission FROM ".LIN_PREFIX."permissions " . "WHERE perm_type = '".LinSql::linAddslashes($key)."'"); + if( !$data ) { + echo "Warning: This permission does not exists: ".$key."<br />"; + return; + } + $array_permissions = linExplodeAndSlice(';',$data['permission']); if(in_array('public',$array_permissions)) { $allowall_checked = ' checked="checked"'; $allowgroups_checked = ''; + $groups_disabled = ' disabled="disabled"'; } else { $allowall_checked = ''; $allowgroups_checked = ' checked="checked"'; + $groups_disabled = ''; } -?> - <form method="POST" action="<?php echo LINPHA_DIR.'/admin/?cat=permissions_'.$cat2.'_'.$cat3; ?>"> - <br /> - <input type="radio" id="allowall" name="allowall" value="allowall"<?php echo $allowall_checked; ?>onClick="update_forms()" /> - <label for="allowall"><?php echo i18n("Allow All"); ?></label> - <br /><br /> - <input type="radio" id="allowgroups" name="allowall" value="allowgroups"<?php echo $allowgroups_checked; ?>onClick="update_forms()" /> - <label for="allowgroups"><?php echo i18n("Allow Only This Groups:"); ?></label> - <br /> + ?> + <form method="POST" action="<?php echo LINPHA_DIR.'/admin/?cat=permissions_'.$key; ?>"> + <label for="allowall<?php echo $key; ?>"><input type="radio" id="allowall<?php echo $key; ?>" name="allowall" value="allowall"<?php + echo $allowall_checked; ?> onclick="update_forms(this.form)" /> <?php echo i18n("Allow All"); ?></label><br /> + <label for="allowgroups<?php echo $key; ?>"><input type="radio" id="allowgroups<?php echo $key; ?>" name="allowall" value="allowgroups"<?php + echo $allowgroups_checked; ?>onclick="update_forms(this.form)" /> <?php echo i18n("Allow Only These Groups:"); ?></label><br /> - <select id="selectgroups" name="groups[]" size="5" style="width: 200;" multiple="multiple"> + <select id="selectgroups" name="groups[]" size="5" style="width: 200;" multiple="multiple"<?php echo $groups_disabled; ?>> <?php $query = $GLOBALS['linpha']->db->Execute("SELECT id, group_name FROM ".LIN_PREFIX."groups ORDER by group_name"); while($data = $query->FetchRow()) @@ -116,35 +155,15 @@ echo '<option value="'.$data['id'].'"'.$checked.'>'.$data['group_name'].'</option>'; } ?> + + <input type="hidden" name="perm_type" value="<?php echo $key; ?>" /> <input type="hidden" name="cmd" value="edit" /> <br /> <input type="submit" name="submit" value="<?php echo i18n("Submit"); ?>" /> </select> </form> + <br /> + <?php +} - <script language="JavaScript" type="text/javascript"> - - function update_forms() - { - var allowall = document.getElementById('allowall'); - var allowgroups = document.getElementById('allowgroups'); - var selectgroups = document.getElementById('selectgroups'); - - if(allowall.checked) - { - selectgroups.disabled = true; - selectgroups.selectedIndex = -1; - } - - if(allowgroups.checked) - { - selectgroups.disabled = false; - } - } - update_forms(); - - </script> - -<?php -} ?> \ No newline at end of file Modified: trunk/linpha2/admin/permissions_readwrite.php =================================================================== --- trunk/linpha2/admin/permissions_readwrite.php 2007-12-01 17:14:09 UTC (rev 4803) +++ trunk/linpha2/admin/permissions_readwrite.php 2007-12-02 21:46:57 UTC (rev 4804) @@ -17,12 +17,12 @@ { $LinAdmin->saveConfig( Array( - 'plugins_filemanager_enable' + 'plugins_filemanager_userEnable' ) ); } - $LinAdmin->printAdminConfig('radio',$LinAdmin->getDescriptionByOptionName('plugins_filemanager_enable'),'plugins_filemanager_enable',$LinAdmin->option_value_system['plugins_filemanager_enable']); + $LinAdmin->printAdminConfig('radio',$LinAdmin->getDescriptionByOptionName('plugins_filemanager_userEnable'),'plugins_filemanager_userEnable',$LinAdmin->option_value_system['plugins_filemanager_userEnable']); ?> <input type="hidden" name="cmd" value="saveconfig" /> @@ -32,7 +32,7 @@ <?php } -if($cat2 == 'view' OR ($cat2 == 'write' AND $GLOBALS['linpha']->sql->config->value['plugins_filemanager_enable'] )) +if($cat2 == 'view' OR ($cat2 == 'write' AND $GLOBALS['linpha']->sql->config->value['plugins_filemanager_userEnable'] )) { /** Modified: trunk/linpha2/admin/settings_plugins.php =================================================================== --- trunk/linpha2/admin/settings_plugins.php 2007-12-01 17:14:09 UTC (rev 4803) +++ trunk/linpha2/admin/settings_plugins.php 2007-12-02 21:46:57 UTC (rev 4804) @@ -6,7 +6,7 @@ $cat3 = 'enable'; } -$arrPlugins = explode(',',$LinAdmin->option_value_system['plugins_available']); +$arrPlugins = LinAdmin::getPlugins(); /** * save settings before showing menu @@ -19,30 +19,29 @@ } /** - * create database tables if necessary - * !!! WARNING: SAME CODE ALSO IN install/step9_createtables.php !!! + * create database tables and insert config data if necessary */ - include(LINPHA_DIR.'/lib/include/sql/sql.tables.php'); - foreach($linpha_tables AS $key=>$value) + foreach($arrPlugins as $value) // go through all plugins { - $linpha_tables[$key] = LIN_PREFIX.$value; - } - include(LINPHA_DIR.'/lib/include/sql/sql.'.LIN_DB_TYPE.'.php'); - - // go through all plugins - foreach($arrPlugins as $value) - { - // if now enabled and before it was disabled + // only if we enabled the plugin now and it didn't existed before if( isset($_POST['plugins_'.$value.'_enable']) && $_POST['plugins_'.$value.'_enable']=='1' - && $LinAdmin->option_value_system['plugins_'.$value.'_enable']=='0') + && !isset($LinAdmin->option_value_system['plugins_'.$value.'_enable']) ) { - linSysLog(i18n("Creating tables for plugin: ").' '.$LinAdmin->description_array['plugins_'.$value]); - foreach($sql_tables as $sqlStr) + $str1 = i18n("Enabling plugin \"%s\""); + linSysLog( sprintf($str1,$LinAdmin->description_array['plugins_'.$value]) ); + + /** + * create database tables + */ + $includeFile = LINPHA_DIR.'/lib/plugins/'.$value.'/sql/sql.'.LIN_DB_TYPE.'.php'; + if( file_exists($includeFile) ) { - // if table starts with "CREATE TABLE linpha_plugins_$value" - $sqlStrSearch = "CREATE TABLE ".LIN_PREFIX."plugins_".$value; - if(substr($sqlStr,0,strlen($sqlStrSearch)) == $sqlStrSearch) + $sql_tables = array(); + include($includeFile); + + linSysLog(i18n("Creating tables")); + foreach($sql_tables as $sqlStr) { $result = $linpha->db->Execute($sqlStr); @@ -51,10 +50,35 @@ if(!$result) { linSysLog($linpha->db->ErrorMsg()); } - } + } } + + /** + * insert config data + */ + $includeFile = LINPHA_DIR.'/lib/plugins/'.$value.'/sql/sql.data.php'; + if( file_exists($includeFile) ) // this file always exists (it wouldnt be a plugin otherwise) + { + $sql_queries = array(); + include($includeFile); + + linSysLog(i18n("Insert config data")); + foreach($sql_queries as $sqlStr) + { + $result = $linpha->db->Execute($sqlStr); + + // it the table already exists, we get automatically a nice message like + // "Table 'linpha2_plugins_maps_markers' already exists" + if(!$result) { + linSysLog($linpha->db->ErrorMsg()); + } + } + } + } - } + } + + // set plugins_*_enable to '1' $LinAdmin->saveConfig($arrPluginsFullName); } @@ -66,7 +90,9 @@ ); foreach( $arrPlugins as $key=>$value) { - if($LinAdmin->option_value_system['plugins_'.$value.'_enable'] == '1') + if(isset($LinAdmin->option_value_system['plugins_'.$value.'_enable']) + && $LinAdmin->option_value_system['plugins_'.$value.'_enable'] == '1' + ) { $array_menu[$value] = array( 'name' => $LinAdmin->description_array['plugins_'.$value], @@ -84,11 +110,17 @@ { foreach( $arrPlugins as $key=>$value) { + if(isset($LinAdmin->option_value_system['plugins_'.$value.'_enable'])) { + $optionValue = $LinAdmin->option_value_system['plugins_'.$value.'_enable']; + } else { + $optionValue = '0'; + } + $LinAdmin->printAdminConfig( 'radio', $LinAdmin->getDescriptionByOptionName('plugins_'.$value), 'plugins_'.$value.'_enable', - $LinAdmin->option_value_system['plugins_'.$value.'_enable'] + $optionValue ); } } Modified: trunk/linpha2/index.php =================================================================== --- trunk/linpha2/index.php 2007-12-01 17:14:09 UTC (rev 4803) +++ trunk/linpha2/index.php 2007-12-02 21:46:57 UTC (rev 4804) @@ -43,9 +43,9 @@ case 'browse': require_once(LINPHA_DIR.'/lib/modules/module.browse.php'); break; -case 'filemanager': +/*case 'filemanager': require_once(LINPHA_DIR.'/lib/modules/module.filemanager.php'); - break; + break;*/ case 'settings': require_once(LINPHA_DIR.'/lib/modules/module.settings.php'); break; @@ -72,17 +72,22 @@ break; -// plugins -case 'maps': - /** - * @todo check if plugin enabled - */ - require_once(LINPHA_DIR.'/lib/plugins/maps/module.maps.php'); - break; +default: + // include plugins + $plugindDir = LINPHA_DIR.'/lib/plugins'; + $includeFile = $plugindDir.'/'.$_GET['linCat'].'/module.'.$_GET['linCat'].'.php'; - -default: - require_once(LINPHA_DIR.'/lib/modules/module.empty.php'); + if( is_dir($pluginDir) + && isset($GLOBALS['linpha']->sql->config->value['plugins_'.$_GET['linCat'].'_enable']) + && $GLOBALS['linpha']->sql->config->value['plugins_'.$_GET['linCat'].'_enable']=='1' + && file_exists($includeFile)) + { + require_once($includeFile); + } + else + { + require_once(LINPHA_DIR.'/lib/modules/module.empty.php'); + } break; } Modified: trunk/linpha2/install/step9_createtables.php =================================================================== --- trunk/linpha2/install/step9_createtables.php 2007-12-01 17:14:09 UTC (rev 4803) +++ trunk/linpha2/install/step9_createtables.php 2007-12-02 21:46:57 UTC (rev 4804) @@ -39,13 +39,15 @@ /** * create tables - * !!! WARNING: SAME CODE ALSO IN admin/settings_plugins.php !!! */ /** * get table names and add prefix */ include_once(LINPHA_DIR.'/lib/include/sql/sql.tables.php'); - foreach($linpha_tables AS $key=>$value) + + // append LIN_PREFIX before each table + // but we also could do this directly in the sql.mysql.php file!? + foreach($linpha_tables as $key=>$value) { $linpha_tables[$key] = LIN_PREFIX.$value; } @@ -63,20 +65,13 @@ $translation_array = array_keys($linpha_tables); // only used in error case while( list($key,$query) = each($sql_tables) ) { - /** - * ignore plugins_ tables - */ - $sqlStrSearch = "CREATE TABLE ".LIN_PREFIX."plugins_"; - if(substr($query,0,strlen($sqlStrSearch)) != $sqlStrSearch) + $result = $linpha->db->Execute($query); + if(!$result) { - $result = $linpha->db->Execute($query); - if(!$result) - { - echo LIN_PREFIX.$translation_array[$key].' '; - echo failed_msg(); - echo ' '.$linpha->db->ErrorMsg().'<br />'; - $error_nr = 1; - } + echo LIN_PREFIX.$translation_array[$key].' '; + echo failed_msg(); + echo ' '.$linpha->db->ErrorMsg().'<br />'; + $error_nr = 1; } } /** Modified: trunk/linpha2/lib/classes/linpha.admin.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.admin.class.php 2007-12-01 17:14:09 UTC (rev 4803) +++ trunk/linpha2/lib/classes/linpha.admin.class.php 2007-12-02 21:46:57 UTC (rev 4804) @@ -97,8 +97,6 @@ 'plugins_log_email_to' => i18n("Recipient"), 'plugins_log_email_headers' => i18n("Extra headers"), 'plugins_log_email_subject' => i18n("Subject"), - - 'plugins_filemanager_enable' => i18n("Enable Filemanager For Non-Admin Users"), ); } @@ -153,8 +151,10 @@ ?> </div> <div align="right"> - <input type="radio" id="<?php echo $id; ?>01" name="<?php echo $id; ?>" value="1"<?php echo $str_enabled; ?> /><label for="<?php echo $id; ?>01"><?php echo i18n("Enable"); ?></label> - <input type="radio" id="<?php echo $id; ?>02" name="<?php echo $id; ?>" value="0"<?php echo $str_disabled; ?>/><label for="<?php echo $id; ?>02"><?php echo i18n("Disable"); ?></label> + <label for="<?php echo $id; ?>01"><input type="radio" id="<?php echo $id; ?>01" name="<?php + echo $id; ?>" value="1"<?php echo $str_enabled; ?> /> <?php echo i18n("Enable"); ?></label> + <label for="<?php echo $id; ?>02"><input type="radio" id="<?php echo $id; ?>02" name="<?php + echo $id; ?>" value="0"<?php echo $str_disabled; ?> /> <?php echo i18n("Disable"); ?></label> <?php break; case 'text': @@ -174,7 +174,7 @@ <div align="right"> <select name="<?php echo $id; ?>" size="1"<?php echo (isset($settings['input_settings']) ? $settings['input_settings'] : '' ); ?> class="linForms"> <?php - foreach($settings['options'] AS $option_key=>$option_value) + foreach($settings['options'] as $option_key=>$option_value) { if($option_key == $value) { @@ -199,7 +199,14 @@ function saveConfig($array,$userid=0) { - foreach($array AS $value) + /** + * update config array once before + * need this for the plugins, the configs are not yet in array, only in the database + */ + $GLOBALS['linpha']->sql->config->reloadConfig(); + + + foreach($array as $value) { /** * does this config name exists? @@ -214,7 +221,7 @@ linSysLog(i18n("Settings saved.")); /** - * update config array + * update config array once after */ $GLOBALS['linpha']->sql->config->reloadConfig(); @@ -311,6 +318,10 @@ /** * a list of all settings which are enable/disable * to show radio buttons instead of text field + * not that bad if not uptodate + * + * @uses /admin/settings_all.php + * @uses /modules/module.settings.php */ function getRadioOptions() { @@ -358,24 +369,20 @@ function getTemplates() { $templatesdir = LINPHA_DIR."/templates"; - - $file_handle = opendir($templatesdir); - $all_themes = array(); - - while( ($file = readdir($file_handle)) !== false ) - { - if($file != "." && $file != ".." && $file != ".svn" && - is_dir($templatesdir.'/'.$file) && - file_exists($templatesdir.'/'.$file.'/global.html.php') && // do at least this check - file_exists($templatesdir.'/'.$file.'/themes') // do at least this check + $d = dir($templatesdir); + while ( ($entry = $d->read()) !== false ) { + if($entry != "." && $entry != ".." && $entry != ".svn" + && is_dir($templatesdir.'/'.$entry) + && file_exists($templatesdir.'/'.$entry.'/global.html.php') // do at least this check + && file_exists($templatesdir.'/'.$entry.'/themes') // do at least this check + ) { - $all_themes[$file] = $file; + $all_themes[$entry] = $entry; } } + $d->close(); - closedir($file_handle); - /* Sort theme files aphabetically */ asort($all_themes); @@ -385,26 +392,40 @@ function getThemes($template) { $templatesdir = LINPHA_DIR."/templates/".$template."/themes"; - - $file_handle = opendir($templatesdir); - $all_themes = array(); - - while( ($file = readdir($file_handle)) !== false ) - { - if($file != "." && $file != ".." && $file != ".svn" && is_dir($templatesdir.'/'.$file)) + $d = dir($templatesdir); + while ( ($entry = $d->read()) !== false ) { + if($entry != "." && $entry != ".." && $entry != ".svn" + && is_dir($templatesdir.'/'.$entry) ) { - $all_themes[$file] = $file; + $all_themes[$entry] = $entry; } } + $d->close(); - closedir($file_handle); - /* Sort theme files aphabetically */ asort($all_themes); return $all_themes; } +function getPlugins() +{ + $plugin_dir = LINPHA_DIR.'/lib/plugins'; + $d = dir($plugin_dir); + while ( ($entry = $d->read()) !== false ) { + if($entry != "." && $entry != ".." && $entry != ".svn" && $entry != "example" + && is_dir($plugin_dir.'/'.$entry) + && file_exists($plugin_dir.'/'.$entry.'/sql/sql.data.php') + ) + { + $arrPlugins[] = $entry; + } + } + $d->close(); + + return $arrPlugins; +} + } // end class LinAdmin ?> \ No newline at end of file Modified: trunk/linpha2/lib/classes/linpha.filesys.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.filesys.class.php 2007-12-01 17:14:09 UTC (rev 4803) +++ trunk/linpha2/lib/classes/linpha.filesys.class.php 2007-12-02 21:46:57 UTC (rev 4804) @@ -140,6 +140,7 @@ /** * create a unique tmp folder + * not really thread safe, but it should be enough for us */ public static function createTmpFolder($prefix) { Modified: trunk/linpha2/lib/include/sql/sql.data.php =================================================================== --- trunk/linpha2/lib/include/sql/sql.data.php 2007-12-01 17:14:09 UTC (rev 4803) +++ trunk/linpha2/lib/include/sql/sql.data.php 2007-12-02 21:46:57 UTC (rev 4804) @@ -97,36 +97,6 @@ 'sys_style_others_sortorder' => 'nameasc', 'sys_user_autologin' => '1', - - - 'plugins_available' => 'filemanager,guestbook,log,maps,maillist,rss,stats,watermark', - - 'plugins_filemanager_enable' => '0', - 'plugins_filemanager_nruploads' => '5', - - 'plugins_guestbook_enable' => '0', - - 'plugins_log_enable' => '0', - 'plugins_log_filename' => 'var/linpha-'.random_string(6).'.log', - 'plugins_log_syslog_enable' => '0', - 'plugins_log_syslog_add_events' => '', - 'plugins_log_email_enable' => '0', - 'plugins_log_email_add_events' => '', - 'plugins_log_email_to' => 'LinPHA Logger<log@'.$_SERVER["HTTP_HOST"].'>', - 'plugins_log_email_headers' => 'From:LinPHA Logger<noreply@'.$_SERVER["HTTP_HOST"].'>', - 'plugins_log_email_subject' => 'Linpha Log', - - 'plugins_maps_enable' => '0', - 'plugins_maps_defaultMarkerZoom' => '10', - 'plugins_maps_mapType' => 'google', - 'plugins_maps_google_key' => 'ABQIAAAAAXCMfho4_sqSSh0VqMB80xT2yXp_ZAY8_ufC3CFXhHIE1NvwkxSfO_6bbb_ScfT_zPgcnJMKyGltOg', // key for http://localhost - 'plugins_maps_markerThumbSize' => '350', - - 'plugins_maillist_enable' => '0', - 'plugins_rss_enable' => '0', - 'plugins_stats_enable' => '0', - 'plugins_watermark_enable' => '0', - ); $options_user_overrideable = Array( @@ -200,13 +170,7 @@ $sql_queries[] = "INSERT INTO ".LIN_PREFIX."permissions (perm_type, permission) " . "VALUES ('metadata_edit', '')"; $sql_queries[] = "INSERT INTO ".LIN_PREFIX."permissions (perm_type, permission) " . - "VALUES ('watermark', '')"; -$sql_queries[] = "INSERT INTO ".LIN_PREFIX."permissions (perm_type, permission) " . - "VALUES ('stats', '')"; -$sql_queries[] = "INSERT INTO ".LIN_PREFIX."permissions (perm_type, permission) " . "VALUES ('download', '')"; -$sql_queries[] = "INSERT INTO ".LIN_PREFIX."permissions (perm_type, permission) " . - "VALUES ('plugins_maps_setMarkers', '')"; /** Modified: trunk/linpha2/lib/include/sql/sql.mysql.php =================================================================== --- trunk/linpha2/lib/include/sql/sql.mysql.php 2007-12-01 17:14:09 UTC (rev 4803) +++ trunk/linpha2/lib/include/sql/sql.mysql.php 2007-12-02 21:46:57 UTC (rev 4804) @@ -145,15 +145,5 @@ "meta_data VARCHAR(255) NOT NULL default '', " . "PRIMARY KEY (id) " . ")", - "CREATE TABLE ".$linpha_tables['plugins_maps_markers']." ( ". - "id INT NOT NULL AUTO_INCREMENT, " . - "albId INT NOT NULL default '0', " . - "albPath VARCHAR(255) NOT NULL default '', " . - "markerName VARCHAR(255) NOT NULL default '', " . - "markerLat VARCHAR(255) NOT NULL default '', " . - "markerLon VARCHAR(255) NOT NULL default '', " . - "markerZoom INT NOT NULL default '0', " . - "PRIMARY KEY (id) " . - ")" ); ?> Modified: trunk/linpha2/lib/include/sql/sql.tables.php =================================================================== --- trunk/linpha2/lib/include/sql/sql.tables.php 2007-12-01 17:14:09 UTC (rev 4803) +++ trunk/linpha2/lib/include/sql/sql.tables.php 2007-12-02 21:46:57 UTC (rev 4804) @@ -36,6 +36,6 @@ "meta_xmp" => "meta_xmp", "meta_comments" => "meta_comments", "meta_data" => "meta_data", - "plugins_maps_markers" => "plugins_maps_markers" + "plugins_maps_setMarkers" => "plugins_maps_markers", // still need the plugin entries; workaround for reset_database.php ); ?> Deleted: trunk/linpha2/lib/modules/module.filemanager.php =================================================================== --- trunk/linpha2/lib/modules/module.filemanager.php 2007-12-01 17:14:09 UTC (rev 4803) +++ trunk/linpha2/lib/modules/module.filemanager.php 2007-12-02 21:46:57 UTC (rev 4804) @@ -1,1216 +0,0 @@ -<?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. - */ - -/** - * Filemanager - * @package Modules - */ - -/** - * Short Permission Description - * If a user has write permission to folder A, it means that - * he can upload images to this folder, rename content, delete content - * But he cannot rename or delete the folder itself - * - * - * it doesnt make sense to give write permissions to the files itself - * - * - * @todo make an option with allowed filetypes to upload: images, images and videos, all - * default setting: images - * its very dangerous if users may upload php files etc.!! or even video files may be - * prepared with malicious code (there are known security holes in some video players!) - */ - -/** - * @todo update md5sum while renaming or moving a folder - * on a folder, the md5sum is based on $md5sum = md5($dirname.'/'.$filename); - */ - -if(!defined('LINPHA_DIR')) { exit(1); } - -/** - * some double used i18n entries - */ - $str_checkpermissions = i18n("Check the permissions in the linpha albums folder. (This means NOT the write permissions page in the admin section)"); - $str_autoimportdisabled = i18n("Autoimport is disabled, you need now to start the manual import to make your changes appear, but you maybe don't have permissions to do that..."); - $str_nopermission = i18n("You don't have permissions to this folder!"); - $str_filealreadyexists = i18n("A File/Folder with the same name already exists!"); - -/** - * init stuff - */ - $parent_id = $linpha->template->idCurrent; - - /** - * check global permission - */ - if(! $linpha->sql->config->value['plugins_filemanager_enable'] - && !$linpha->sql->isAdmin()) - { - echo i18n("No Access!"); - exit(); - } - - if( ! $linpha->sql->photoIsAllowed( $parent_id, 'read' ) ) - { - echo i18n("No Access!"); - exit(); - } - - /** - * use this for child objects - */ - if( $linpha->sql->photoIsAllowed( $parent_id, 'write' ) ) - { - $isWriteAble = true; - } - else - { - $isWriteAble = false; - } - - - $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; - } - - /** - * upload stuff - */ - include_once(LINPHA_DIR.'/lib/classes/archiver.class.php'); - $apps = new Archive_Applications(); - $apps->searchApps(); - - $appselect = '<option value="-">'. i18n("Extract Archive With"). '</option>'; - foreach($apps->found_apps AS $key=>$value) - { - $value = $key.' (.'.$apps->apps[$key]['file_ext'].')'; - $appselect .= '<option value="'.$key.'">'.$value.'</option>'; - } - -/** - * output buffering, to use in template - */ -ob_start(); - -/** - * parsing POST data - * - * cmd = file_action -> show forms - * cmd = do_file_action -> do actions - */ -if(isset($_REQUEST['cmd'])) -{ - try - { - switch($_REQUEST['cmd']) - { - case 'file_action': - if(!isset($_REQUEST['checkedfiles'])) - { - throw new Exception(i18n("No Files Selected")); - } - if(!isset($_REQUEST['file_action'])) - { - throw new Exception(i18n("No Action Selected")); - } - - ?> - <form method="POST" action="<?php echo LINPHA_LINK.'&linCat=filemanager&linId='.$parent_id; ?>"> - <?php - switch($_REQUEST['file_action']) - { - case 'rename': - $data = $linpha->db->GetRow("SELECT name, parent_id FROM ".LIN_PREFIX."photos " . - "WHERE id = '".LinSql::linAddslashes($_REQUEST['checkedfiles'][0])."'"); - - echo '<b>'.i18n("Rename File/Folder").':</b><br />'; - ?> - <input type="text" name="new_name" value="<?php echo htmlspecialchars($data['name'],ENT_QUOTES); ?>" class="linForms" style="width: 300px;" /> - <input type="hidden" name="file_id" value="<?php echo $_REQUEST['checkedfiles'][0]; ?>" /> - <?php - break; - - case 'move': - case 'copy': - if( $_REQUEST['file_action'] == 'move') - { - echo i18n("Move These Files/Folders"); - } - elseif( $_REQUEST['file_action'] == 'copy') - { - echo i18n("Copy These Files/Folders"); - } - echo ':<br />'; - - foreach($_REQUEST['checkedfiles'] AS $value) - { - $data = $linpha->db->GetRow("SELECT name FROM ".LIN_PREFIX."photos " . - "WHERE id = '".LinSql::linAddslashes($value)."'"); - echo htmlspecialchars($data['name'],ENT_QUOTES).', '; - } - echo '<br /><br />'; - echo i18n("To").':'; - echo '<br />'; - ?> - <select name="movecopy_to" class="linForms"> - <option value="0">/</option> - <?php - linBuildAlbumSelect( $with_all_albs_entry=false,$with_linebreaks=true ); - ?> - </selet> - <input type="hidden" name="checkedfiles" value="<?php echo implode(';',$_REQUEST['checkedfiles']); ?>" /> - <?php - break; - case 'delete': - echo i18n("Delete all the following files/folders including contents:").'<br />'; - foreach($_REQUEST['checkedfiles'] AS $value) - { - $data = $linpha->db->GetRow("SELECT name FROM ".LIN_PREFIX."photos " . - "WHERE id = '".LinSql::linAddslashes($value)."'"); - echo htmlspecialchars($data['name'],ENT_QUOTES).', '; - } - echo '<br /><br />'; - echo i18n("Really Sure?"); - ?> - <input type="hidden" name="checkedfiles" value="<?php echo implode(';',$_REQUEST['checkedfiles']); ?>" /> - <?php - break; - case 'changeperm': - $full_filename = LinSql::getFullImagePath( $_REQUEST['checkedfiles'][0]); - - if( $full_filename == false ) - { - throw new Exception(i18n("This file doesn't exists anymore!").' '.$full_filename); - } - - $perm = getReadableFileperms($full_filename); - - (substr($perm, 1, 1)!="-" ? $ur = 1 : ''); - (substr($perm, 2, 1)!="-" ? $uw = 1 : ''); - (substr($perm, 3, 1)!="-" ? $ux = 1 : ''); - (substr($perm, 4, 1)!="-" ? $gr = 1 : ''); - (substr($perm, 5, 1)!="-" ? $gw = 1 : ''); - (substr($perm, 6, 1)!="-" ? $gx = 1 : ''); - (substr($perm, 7, 1)!="-" ? $or = 1 : ''); - (substr($perm, 8, 1)!="-" ? $ow = 1 : ''); - (substr($perm, 9, 1)!="-" ? $ox = 1 : ''); - - echo i18n("Change Permission Of:").' '.htmlspecialchars($full_filename,ENT_QUOTES); - ?> - <br /> - <table border="1" cellpadding="0" cellspacing="0"> - <tr> - <td width="100"> </td> - <td class='admintable' width="75"><?php echo i18n("Read"); ?></td> - <td class='admintable' width="75"><?php echo i18n("Write"); ?></td> - <td class='admintable' width="75"><?php echo i18n("Execute"); ?></td> - </tr> - <tr> - <td class='admintable'><?php echo i18n("Owner"); ?></td> - <td><input name="ur" type="checkbox" value="4"<?=(isset($ur) ? ' checked' : '')?>></td> - <td><input name="uw" type="checkbox" value="2"<?=(isset($uw) ? ' checked' : '')?>></td> - <td><input name="ux" type="checkbox" value="1"<?=(isset($ux) ? ' checked' : '')?>></td> - </tr> - <tr> - <td class='admintable'><?php echo i18n("Group"); ?></td> - <td><input name="gr" type="checkbox" value="4"<?=(isset($gr) ? ' checked' : '')?>></td> - <td><input name="gw" type="checkbox" value="2"<?=(isset($gw) ? ' checked' : '')?>></td> - <td><input name="gx" type="checkbox" value="1"<?=(isset($gx) ? ' checked' : '')?>></td> - </tr> - <tr> - <td class='admintable'><?php echo i18n("All Others"); ?></td> - <td><input name="or" type="checkbox" value="4"<?=(isset($or) ? ' checked' : '')?>></td> - <td><input name="ow" type="checkbox" value="2"<?=(isset($ow) ? ' checked' : '')?>></td> - <td><input name="ox" type="checkbox" value="1"<?=(isset($ox) ? ' checked' : '')?>></td> - </tr> - </table> - <input type="hidden" name="file_id" value="<?php echo $_REQUEST['checkedfiles'][0]; ?>" /> - <?php - break; - } - ?> - <input type="hidden" name="cmd" value="do_file_action" /> - <input type="hidden" name="file_action" value="<?php echo $_REQUEST['file_action']; ?>" /> - <input type="submit" name="submit" value="<?php echo i18n("Submit"); ?>" class="linButton" /> - </form> - <hr /><br /> - <?php - break; - - case 'do_file_action': - - switch($_POST['file_action']) - { - case 'rename': - $new_name = removeUnWantedChars( $_POST['new_name'] ); - - $full_filename = LinSql::getFullImagePath( $_POST['file_id'] ); - - if( $full_filename == false ) - { - throw new Exception(i18n("This file doesn't exists anymore!").' '.$full_filename); - } - - $parent_dirname = dirname($full_filename); - - /** - * check write permission of parent folder - */ - $data = $linpha->db->GetRow("SELECT parent_id FROM ".LIN_PREFIX."photos " . - "WHERE id = '".LinSql::linAddslashes($_POST['file_id'])."'"); - if( ! $linpha->sql->photoIsAllowed( $data['parent_id'], 'write') ) - { - throw new Exception($str_nopermission); - } - - if( nameAlreadyExists( $new_name, $data['parent_id'] )) - { - throw new Exception($str_filealreadyexists); - } - - if( ! @rename( $full_filename , $parent_dirname."/".$new_name ) ) - { - throw new Exception(i18n("Rename File/Folder Failed!"). - htmlspecialchars($full_filename,ENT_QUOTES).' '.i18n("to").' '.htmlspecialchars($parent_dirname.'/'.$new_name,ENT_QUOTES). - LIN_NL.$str_checkpermissions - ); - } - - /** - * rename on filesys was successful - * -> rename also in db - */ - $linpha->db->Execute("UPDATE ".LIN_PREFIX."photos SET name = '".LinSql::linAddslashes($new_name)."' " . - "WHERE id = '".LinSql::linAddslashes($_POST['file_id'])."'"); - - linSysLog(i18n("Successfully Renamed!")); - linLog(LOG_TYPE_FILEMANAGER,LOG_NOTICE,'fm_rename',"renamed file (".$full_filename." to ".$parent_dirname."/".$new_name.")"); - break; - - case 'move': - case 'copy': - /** - * check write permission of target folder - * AND it will also check if it is a valid id (?) - */ - if( ! $linpha->sql->photoIsAllowed( $_POST['movecopy_to'], 'write') ) - { - throw new Exception($str_nopermission); - } - - /** - * get target name - */ - $full_destparentname = LinSql::getFullImagePath( $_POST['movecopy_to'] ); - - if( $full_destparentname == false ) - { - throw new Exception(i18n("This file doesn't exists anymore!").' '.$full_destparentname); - } - - /** - * check write permission of destination parent folder - */ - if( ! is_writable($full_destparentname) ) - { - throw new Exception( - sprintf( - i18n("Cannot Copy/Move to Folder \"%s\" because its not writable!"), - htmlspecialchars($full_destparentname,ENT_QUOTES) - ). - LIN_NL.$str_checkpermissions - ); - } - - - /** - * go through each folder - */ - $checkedfiles = explode(';',$_POST['checkedfiles']); - foreach($checkedfiles AS $value) - { - /** - * get full source name - */ - $full_sourcename = LinSql::getFullImagePath( $value ); - - if( $full_sourcename == false ) - { - throw new Exception(i18n("This file doesn't exists anymore!").' '.$full_filename); - } - - /** - * check read permission of source folder (not parent! ...) and content - */ - if( ! $linpha->sql->photoIsAllowed( $value, 'read') ) - { - throw new Exception($str_nopermission); - } - - /** - * check if destination is empty - */ - if( nameAlreadyExists( basename($full_sourcename), $_POST['movecopy_to'] )) - { - throw new Exception($str_filealreadyexists); - } - - /** - * move - */ - if( $_POST['file_action'] == 'move') - { - /** - * check write permission of parent source folder - */ - $data = $linpha->db->GetRow("SELECT parent_id FROM ".LIN_PREFIX."photos " . - "WHERE id = '".LinSql::linAddslashes($value)."'"); - if($_POST['file_action'] == 'move') - { - if( ! $linpha->sql->photoIsAllowed( $data['parent_id'], 'write') ) - { - throw new Exception($str_nopermission); - } - } - - if( ! rename($full_sourcename, $full_destparentname.'/'.basename($full_sourcename) ) ) - { - linSysLog( - sprintf( - i18n("Error While Moving Files/Folders \"%s\" to \"%s\"!"), - htmlspecialchars($full_sourcename,ENT_QUOTES), - htmlspecialchars($full_destparentname.'/'.basename($full_sourcename),ENT_QUOTES) - ) - ); - linSysLog($str_checkpermissions); - - linLog(LOG_TYPE_FILEMANAGER,LOG_ERR,'fm_move',"cannot moved file/folder (".$full_sourcename." to ".$full_destparentname.'/'.basename($full_sourcename).")"); - } - else - { - $linpha->db->Execute("UPDATE ".LIN_PREFIX."photos " . - "SET parent_id = '".LinSql::linAddslashes($_POST['movecopy_to'])."' " . - "WHERE id = '".LinSql::linAddslashes($value)."'"); - - linSysLog( - sprintf( - i18n("Successfully Moved \"%s\" to \"%s\"!"), - htmlspecialchars($full_sourcename,ENT_QUOTES), - htmlspecialchars($full_destparentname.'/'.basename($full_sourcename),ENT_QUOTES) - ) - ); - - linLog(LOG_TYPE_FILEMANAGER,LOG_NOTICE,'fm_move',"moved file/folder (".$full_sourcename." to ".$full_destparentname.'/'.basename($full_sourcename).")"); - } - } - /** - * copy - */ - elseif( $_POST['file_action'] == 'copy') - { - /** - * copy files/folders (only which we have read permission) - */ - copy_r( $value, $full_sourcename, $full_destparentname); - - if( ! file_exists( $full_destparentname.'/'.basename($full_sourcename) )) - { - linSysLog( - sprintf( - i18n("Error While Copying Files/Folders \"%s\" to \"%s\"!"), - htmlspecialchars($full_sourcename,ENT_QUOTES), - htmlspecialchars($full_destparentname.'/'.basename($full_sourcename),ENT_QUOTES) - ) - ); - linSysLog($str_checkpermissions); - - linLog(LOG_TYPE_FILEMANAGER,LOG_ERR,'fm_copy',"Cannot copy file/folder (".$full_sourcename." to ".$full_destparentname.'/'.basename($full_sourcename).")"); - } - else - { - linSysLog( - sprintf( - i18n("Successfully Copied \"%s\" to \"%s\"!"), - $full_sourcename, - $full_destparentname.'/'.basename($full_sourcename) - ) - ); - - linLog(LOG_TYPE_FILEMANAGER,LOG_NOTICE,'fm_copy',"Copied file/folder (".$full_sourcename." to ".$full_destparentname.'/'.basename($full_sourcename).")"); - } - } - } - - break; - - case 'delete': - $checkedfiles = explode(';',$_POST['checkedfiles']); - foreach($checkedfiles AS $value) - { - if( $value == 0 ) - { - throw new Exception(i18n("For security reasons, its not possible to delete the whole albums folder!")); - } - - $data = $linpha->db->GetRow("SELECT parent_id FROM ".LIN_PREFIX."photos " . - "WHERE id = '".LinSql::linAddslashes($value)."'"); - - if( !isset($data['parent_id']) ) - { - throw new Exception(i18n("This file doesn't exists anymore!").' file id: '.$value); - } - - /** - * check write permission of parent folder - */ - if( ! $linpha->sql->photoIsAllowed( $data['parent_id'], 'write') ) - { - throw new Exception($str_nopermission); - } - - $full_filename = LinSql::getFullImagePath( $value ); - - if( $full_filename == false ) - { - throw new Exception(i18n("This file doesn't exists anymore!").' '.$full_filename); - } - - LinFilesys::rm_rf($full_filename); - - if(file_exists($full_filename)) - { - throw new Exception(i18n("Deleting Files/Folders Failed").": \"".htmlspecialchars($full_filename,ENT_QUOTES)."\"".LIN_NL.$str_checkpermissions); - } - - linSysLog(i18n("File/Folder deleted successfully!")); - LinImport::deleteEntry( $value, $full_filename); - - linLog(LOG_TYPE_FILEMANAGER,LOG_NOTICE,'fm_delete',"Deleted file/folder (".$full_filename.")"); - } - break; - - case 'create_folder': - /** - * check write permission of parent folder - */ - if( ! $linpha->sql->photoIsAllowed( $linpha->template->idCurrent, 'write') ) - { - throw new Exception($str_nopermission); - } - - $new_name = removeUnWantedChars( $_POST['folder_name'] ); - - if( nameAlreadyExists( $new_name, $linpha->template->idCurrent )) - { - throw new Exception($str_filealreadyexists); - } - - $full_filename = LinSql::getFullImagePath( $linpha->template->idCurrent ); - - if( $full_filename == false ) - { - throw new Exception(i18n("This file doesn't exists anymore!").' '.$full_filename); - } - - if( empty( $new_name ) ) //catch empty folder create submit - { - throw new Exception(i18n("Create Folder Failed, No Folder Name given")); - } - elseif(! @mkdir( $full_filename .'/'. $new_name ) ) - { - throw new Exception(i18n("Create Folder Failed").": \"".htmlspecialchars($new_name,ENT_QUOTES)."\"".LIN_NL.$str_checkpermissions); - } - - linLog(LOG_TYPE_FILEMANAGER,LOG_NOTICE,'fm_create_folder',"Created folder (".$full_filename.'/'.$new_name.")"); - linSysLog(i18n("Folder Created Successfully!")); - - if( ! $linpha->sql->config->value['sys_import_autoimport'] ) - { - linSysLog($str_autoimportdisabled); - } - - break; - case 'changeperm': - $full_filename = LinSql::getFullImagePath( $_POST['file_id'] ); - - if( $full_filename == false ) - { - throw new Exception(i18n("This file doesn't exists anymore!").' '.$full_filename); - } - - isset($_POST['ur']) ? $ur = $_POST['ur'] : $ur = 0; - isset($_POST['uw']) ? $uw = $_POST['uw'] : $uw = 0; - isset($_POST['ux']) ? $ux = $_POST['ux'] : $ux = 0; - isset($_POST['gr']) ? $gr = $_POST['gr'] : $gr = 0; - isset($_POST['gw']) ? $gw = $_POST['gw'] : $gw = 0; - isset($_POST['gx']) ? $gx = $_POST['gx'] : $gx = 0; - isset($_POST['or']) ? $or = $_POST['or'] : $or = 0; - isset($_POST['ow']) ? $ow = $_POST['ow'] : $ow = 0; - isset($_POST['ox']) ? $ox = $_POST['ox'] : $ox = 0; - - $u = $ur+$uw+$ux; - $g = $gr+$gw+$gx; - $o = $or+$ow+$ox; - - $mode = $u.$g.$o; - - if(! @chmod($full_filename,intval($mode,8))) - { - throw new Exception(i18n("Change Permissions Failed").": \"".htmlspecialchars($full_filename,ENT_QUOTES)."\" to ".$mode.LIN_NL.$str_checkpermissions); - } - - linSysLog(i18n("Permissions Changed Successfully!")); - linLog(LOG_TYPE_FILEMANAGER,LOG_NOTICE,'fm_perm',"changed permission of ".$full_filename." to ".$mode); - - break; - case 'upload': - $targetdir = LinSql::getFullImagePath( $linpha->template->idCurrent ); - - $full_filename = LinSql::getFullImagePath( $linpha->template->idCurrent ); - if( $full_filename == false ) - { - throw new Exception(i18n("This file doesn't exists anymore!").' '.$full_filename); - } - - for($i = 0; $i < $linpha->sql->config->value['plugins_filemanager_nruploads']; $i++ ) - { - if( isset( $_FILES[ 'file' . $i ] ) && $_FILES[ 'file' . $i]['name'] ) // break loop as sson as 'name' is not set, to prevent a couple of warnings - { - $thisfile = $_FILES[ 'file' . $i ]; - - /** - * check errors - */ - if (isset($thisfile['error']) && $thisfile['error'] != 0 ) // ['error'] was added in PHP 4.2.0 - { - switch ( $thisfile['error'] ) - { - case 1: - throw new Exception( sprintf(i18n("Error: The uploaded file %s exceeds the upload_max_filesize directive in php.ini - %s"), - htmlspecialchars($thisfile['name'],ENT_QUOTES), ini_get('upload_max_filesize') ) ); - break; - case 2: - throw new Exception( sprintf(i18n("Error: Size of uploaded file %s exceeds the HTML FORM settings"), htmlspecialchars($thisfile['name'],ENT_QUOTES) ) ); - break; - case 3: - throw new Exception( sprintf(i18n("The uploaded file %s was only partially uploaded"), htmlspecialchars($thisfile['name'],ENT_QUOTES) ) ); - break; - } - } - - if ( $_POST[ 'app' . $i ] == '-' ) - { - list($org_width, $org_height, $org_type) = LinIdentify::linGetImageSize( $thisfile['tmp_name'] ); - if( !LinIdentify::isSupportedImage( $org_type ) && !LinIdentify::isVideo( $org_type ) ) - { - throw new Exception( i18n("This File Is Wether An Image Nor A Video").' ('.htmlspecialchars($thisfile['name'],ENT_QUOTES).')' ); - } - - if ( !move_uploaded_file( $thisfile['tmp_name'], "".$targetdir.'/'.$thisfile['name']."" ) ) - { - throw new Exception( sprintf(i18n("Unable To Move File (%s) To Directory (%s)"),htmlspecialchars($thisfile['name'],ENT_QUOTES),htmlspecialchars($targetdir,ENT_QUOTES ) ) ); - } - - $somethingUploaded = true; - } - /** - * extract archives - */ - else // $_POST[ 'app' . $i ] != '-' - { - $tmpfolder = LinFilesys::createTmpFolder('filemanager'); - - if ( !move_uploaded_file( $thisfile['tmp_name'], $tmpfolder . '/' . $thisfile['name'] ) ) - { - throw new Exception(sprintf( i18n("Unable To Move File (%s) To Directory (%s)"), htmlspecialchars($thisfile[ 'name' ],ENT_QUOTES), htmlspecialchars($targetdir,ENT_QUOTES) ) ); - } - - - $command = $apps->apps[$_POST['app'.$i]]['command_extract']; - $apps->searchApp($_POST['app'.$i]); - - $executable = $apps->found_apps[$_POST['app'.$i]].$apps->apps[$_POST['app'.$i]]['executable_extract']; - - $command = str_replace('{executable}',$executable,$command); - $command = str_replace('{archive_name}',linEscapeString($thisfile['name']),$command); - - $oldpwd = getcwd(); - if ( !chdir( $tmpfolder ) ) - { - throw new Exception( sprintf( i18n("Unable to switch (chdir) to %s directory. File being processed: %s"), $tmpfolder, $thisfile[ 'name' ] ) ); - } - - $output=array(); $return_value=''; // do not this directly in exec() ! - exec( $command, $output, $return_value ); - chdir( $oldpwd ); - - - echo '<textarea cols="80" rows="4"">' . - htmlspecialchars( $command . "\n". implode( "\n", $output ), ENT_QUOTES ) . - '</textarea><br />'; - - unset($output); - - /** - * move valid images and videos to target dir - * this will delete the archive file automatically... - * and also delete the tmpfolder - */ - moveValidEntries( $tmpfolder, $targetdir ); - - $somethingUploaded = true; - } - - linSysLog(i18n("File uploaded").": ".$thisfile['tmp_name']." ".$targetdir.'/'.$thisfile['name']); - linLog(LOG_TYPE_FILEMANAGER,LOG_NOTICE,'fm_upload',"Uploaded file (".$thisfile['tmp_name']." ".$targetdir.'/'.$thisfile['name'].")"); - } - } - - if(isset($somethingUploaded)) - { - if( ! $linpha->sql->config->value['sys_import_autoimport'] ) - { - linSysLog($str_autoimportdisabled); - } - } - break; - } // end switch($_POST['file_action']) - break; // end case 'do_file_action': - - } // end switch($_REQUEST['cmd']) - } // end try() - catch(Exception $error) - { - linSysLog("Error: ".str_replace(LIN_NL,"<br />",$error -> getMessage())); - linLog(LOG_TYPE_FILEMANAGER,LOG_ERR,'fm_'.$_REQUEST['file_action'],$error->getMessage()); - } - - /** - * print Syslog - */ - /*if( isset($linpha->template->output['sys_log']) ) - { - echo $linpha->template->output['sys_log']; - echo '<hr />'; - unset($linpha->template->output['sys_log']); - }*/ -} - -/** - * do import - */ - if( $linpha->sql->config->value['sys_import_autoimport'] ) - { - /** - * empty syslog - */ - //unset($linpha->template->output['sys_log']); - - LinImport::updateDir( $parent_id, $recursive = false, $dryrun = false ); - - /** - * print Syslog - */ - /*if( isset($linpha->template->output['sys_log']) ) - { - echo i18n("LinPHA Import:").'<br />'; - echo $linpha->template->output['sys_log']; - echo '<hr />'; - unset($linpha->template->output['sys_log']); - }*/ - } - -echo i18n("Current Folder:").' '.linSetNavigationLine( $parent_id, LINPHA_LINK.'&linCat=filemanager&linId=').'<br />'; -?> - -<form method="POST" action="<?php echo LINPHA_LINK.'&linCat=filemanager&linId='.$parent_id; ?>"> -<div id="linDivFilemanager"> -<table> - <tr> - <td width="20"> </td> - <td width="500"> - <?php - if($parent_id == 0) - { - echo ' '; - } - else - { - $data = $linpha->db->GetRow("SELECT name, parent_id FROM ".LIN_PREFIX."photos WHERE id = '".LinSql::linAddslashes($parent_id)."'"); - ?> - <a href="<?php echo LINPHA_LINK.'&linCat=filemanager&linId='.$data['parent_id']; ?>">..</a> - <?php - } - ?> - </td> - <td width="100"> </td> - <td width="150"> </td> - <td width="100"> </td> - </tr> - -<?php - -$query = $linpha->db->Execute("SELECT id, name, img_type FROM ".LIN_PREFIX."photos WHERE parent_id = '".LinSql::linAddslashes($parent_id)."' ORDER by name"); -while($data = $query->FetchRow()) -{ - $full_filename = LinSql::getFullImagePath( $data['id'] ); - - /** - * show only if file exists and we have READ permissions - */ - if( file_exists( $full_filename ) && $linpha->sql->photoIsAllowed( $data['id'], 'read' ) ) - { - /** - * set file informations - */ - $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( LIN_OS == '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_LINK.'&linCat=filemanager&cmd=file_action&file_action=changeperm&checkedfiles[]='.$data['id'].'">'. $perm . '</a>'; - } - else - { - $file_permissions = $perm; - } - } - - ?> - <tr> - <td> - <?php - if($isWriteAble) - { - if( isset($_REQUEST['checkedfiles']) - && is_array($_REQUEST['checkedfiles']) - && in_array($data['id'], $_REQUEST['checkedfiles']) ) - { - $str_checked = ' checked="checked"'; - } - else - { - $str_checked = ''; - } - ?> - <input type="checkbox" name="checkedfiles[]" value="<?php echo $data['id']; ?>"<?php echo $str_checked; ?> /> - <?php } else { ?> - - <?php } ?> - </td> - <td> - <?php - if($data['img_type']==0) - { - echo '<a href="'.LINPHA_LINK.'&linCat=filemanager&linId='.$data['id'].'">'.htmlspecialchars($data['name'],ENT_QUOTES).'</a>'; - } - else - { - echo htmlspecialchars($data['name'],ENT_QUOTES); - } - ?> - </td> - <td align="right"><?php echo $data['img_type']==0 ? ' ' : LinFilesys::niceFilesize($filestat['size'],1); ?></td> - <td align="center"><?php echo strftime(... [truncated message content] |