[Linpha-cvs] SF.net SVN: linpha: [4561] trunk/linpha2
Status: Inactive
Brought to you by:
bzrudi
From: <fan...@us...> - 2006-08-27 22:16:53
|
Revision: 4561 Author: fangehrn Date: 2006-08-27 15:16:12 -0700 (Sun, 27 Aug 2006) ViewCVS: http://svn.sourceforge.net/linpha/?rev=4561&view=rev Log Message: ----------- 2006-08-27 flo * fixed image rotate with gdlib * implemented user settings - change username, display name, email, password - the table linpha_config contains now two more columns: override and user_id all settings with override == 1 apear in the user settings and the user will be able to change themself the config array $linpha->sql->config->value[] will contain the real settings (system config + the configs the user made) Modified Paths: -------------- trunk/linpha2/ChangeLog trunk/linpha2/admin/image_fields.php trunk/linpha2/admin/image_fields_define.php trunk/linpha2/admin/image_fields_select.php trunk/linpha2/admin/index.php trunk/linpha2/admin/permissions.php trunk/linpha2/admin/permissions_groups.php trunk/linpha2/admin/permissions_others.php trunk/linpha2/admin/permissions_readwrite.php trunk/linpha2/admin/permissions_users.php trunk/linpha2/admin/settings.php trunk/linpha2/admin/settings_all.php trunk/linpha2/admin/settings_features.php trunk/linpha2/admin/settings_layout.php trunk/linpha2/docs/dev/TODO.txt trunk/linpha2/docs/dev/important stuff.txt trunk/linpha2/index.php trunk/linpha2/install/sql/sql.data.php trunk/linpha2/lib/classes/linpha.sql.class.php trunk/linpha2/lib/modules/module.filemanager.php trunk/linpha2/linpha2.specs.txt trunk/linpha2/templates/default/global.html.php Added Paths: ----------- trunk/linpha2/lib/classes/linpha.admin.class.php trunk/linpha2/lib/modules/module.settings.php trunk/linpha2/templates/default/settings.html.php Modified: trunk/linpha2/ChangeLog =================================================================== --- trunk/linpha2/ChangeLog 2006-08-27 13:44:17 UTC (rev 4560) +++ trunk/linpha2/ChangeLog 2006-08-27 22:16:12 UTC (rev 4561) @@ -1,5 +1,10 @@ -2006-08-25 flo +2006-08-27 flo * fixed image rotate with gdlib + * implemented user settings + - change username, display name, email, password + - the table linpha_config contains now two more columns: override and user_id + all settings with override == 1 apear in the user settings and the user will be able to change themself + the config array $linpha->sql->config->value[] will contain the real settings (system config + the configs the user made) 2006-08-26 bzrudi * fixed broken installation for postgres Modified: trunk/linpha2/admin/image_fields.php =================================================================== --- trunk/linpha2/admin/image_fields.php 2006-08-27 13:44:17 UTC (rev 4560) +++ trunk/linpha2/admin/image_fields.php 2006-08-27 22:16:12 UTC (rev 4561) @@ -11,7 +11,7 @@ 'define' => Array('name' => 'Define image fields', 'link' => 'imagefields_define') ); -print_admin_menu($array_menu,$cat2); +LinAdmin::printAdminMenu($array_menu,$cat2); switch($cat2) { Modified: trunk/linpha2/admin/image_fields_define.php =================================================================== --- trunk/linpha2/admin/image_fields_define.php 2006-08-27 13:44:17 UTC (rev 4560) +++ trunk/linpha2/admin/image_fields_define.php 2006-08-27 22:16:12 UTC (rev 4561) @@ -24,7 +24,7 @@ 'iptc' => Array('name' => 'Iptc fields', 'link' => 'imagefields_define_iptc') ); - print_admin_menu($array_menu,$cat3); + LinAdmin::printAdminMenu($array_menu,$cat3); /** * parse POST data Modified: trunk/linpha2/admin/image_fields_select.php =================================================================== --- trunk/linpha2/admin/image_fields_select.php 2006-08-27 13:44:17 UTC (rev 4560) +++ trunk/linpha2/admin/image_fields_select.php 2006-08-27 22:16:12 UTC (rev 4561) @@ -13,7 +13,7 @@ 'album' => Array('name' => 'Album', 'link' => 'imagefields_select_album') ); -print_admin_menu($array_menu,$cat3); +LinAdmin::printAdminMenu($array_menu,$cat3); switch($cat3) { Modified: trunk/linpha2/admin/index.php =================================================================== --- trunk/linpha2/admin/index.php 2006-08-27 13:44:17 UTC (rev 4560) +++ trunk/linpha2/admin/index.php 2006-08-27 22:16:12 UTC (rev 4561) @@ -6,6 +6,8 @@ */ include_once(LINPHA_DIR.'/lib/include/common.php'); include_once(LINPHA_DIR.'/lib/classes/linpha.class.php'); + include_once(LINPHA_DIR.'/lib/classes/linpha.admin.class.php'); + $linpha = new linpha(); $linpha->sql->startSession(); @@ -14,6 +16,7 @@ echo i18n("Only Admin Has Access To This Area"); exit(1); } + /** * @todo admin permission check */ @@ -61,7 +64,7 @@ 'imagefields' => Array('name' => 'Image fields', 'link' => 'imagefields'), ); -print_admin_menu($array_menu,$cat1); +LinAdmin::printAdminMenu($array_menu,$cat1); switch($cat1) { @@ -94,114 +97,4 @@ <?php } ?> </body> -</html> - -<?php - -function print_admin_menu($array_menu,$active) -{ - ?> - <ul class="navlist"> - <?php - foreach($array_menu AS $key=>$value) - { - if($value['link']=='linpha_home') - { - echo '<li><a href="../">'.i18n($value['name']).'</a></li>'; - } - else - { - if($active==$key) - { - echo '<li class="active"><a href="./?cat='.$value['link'].'" class="current">'.i18n($value['name']).'</a></li>'; - } - else - { - echo '<li><a href="./?cat='.$value['link'].'">'.i18n($value['name']).'</a></li>'; - } - } - } - ?> - </ul> - <?php -} - -function printAdminConfig($type,$text,$id,$options=array()) -{ - ?> - <div style="width: 600px; border: 1px solid black; padding: 5px; margin-bottom: 5px;"> - <div align="left" style="float: left;"> - <?php - switch($type) - { - case 'radio': - if($GLOBALS['linpha']->sql->config->value[$id]) - { - $str_enabled = ' checked="checked"'; - $str_disabled = ''; - } - else - { - $str_enabled = ''; - $str_disabled = ' checked="checked"'; - } - echo $text; - ?> - </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> - <?php - break; - case 'text': - echo $text; - ?> - </div> - <div align="right"> - <input type="text" name="<?php echo $id; ?>" value="<?php echo $GLOBALS['linpha']->sql->config->value[$id]; ?>" maxlength="255"/> - <?php - - break; - case 'select': - echo $text; - ?> - </div> - <div align="right"> - <select name="<?php echo $id; ?>" size="1"> - <?php - foreach($options AS $key=>$value) - { - if($key == $GLOBALS['linpha']->sql->config->value[$id]) - { - $selected = ' selected="selected"'; - } - else - { - $selected = ''; - } - echo '<option value="'.$key.'"'.$selected.'>'.$value.'</option>'; - } - ?> - </select> - <?php - break; - } - ?> - </div> - </div> - <?php -} - -function saveConfig($array) -{ - foreach($array AS $value) - { - if(isset($GLOBALS['linpha']->sql->config->value[$value]) && - isset($_POST[$value])) - { - $GLOBALS['linpha']->sql->config->updateConfig($value,$_POST[$value]); - } - } - $GLOBALS['linpha']->sql->config->reloadConfig(); -} -?> \ No newline at end of file +</html> \ No newline at end of file Modified: trunk/linpha2/admin/permissions.php =================================================================== --- trunk/linpha2/admin/permissions.php 2006-08-27 13:44:17 UTC (rev 4560) +++ trunk/linpha2/admin/permissions.php 2006-08-27 22:16:12 UTC (rev 4561) @@ -17,7 +17,7 @@ 'others' => Array('name' => 'Others', 'link' => 'permissions_others'), ); -print_admin_menu($array_menu,$cat2); +LinAdmin::printAdminMenu($array_menu,$cat2); switch($cat2) { Modified: trunk/linpha2/admin/permissions_groups.php =================================================================== --- trunk/linpha2/admin/permissions_groups.php 2006-08-27 13:44:17 UTC (rev 4560) +++ trunk/linpha2/admin/permissions_groups.php 2006-08-27 22:16:12 UTC (rev 4561) @@ -6,11 +6,10 @@ */ if(isset($_POST['cmd'])) { + try + { + /** - * @todo use something like htmlspecialchars() ? - */ - - /** * prevent changes on admin group */ switch($_POST['cmd']) @@ -21,51 +20,62 @@ $admingroup_id = $data['id']; if($_POST['id'] == $admingroup_id) { - linSysLog(i18n("Error").' trying to edit admin, something went wrong!'); - $error = 1; + throw new Exception(i18n("Trying to edit the admin group, something went wrong!")); } break; } - /** - * check if group already exists - */ switch($_POST['cmd']) { case 'ren_group': case 'new_group': + /** + * check if group is empty + */ + if(empty($_POST['group_name'])) + { + throw new Exception(i18n("The group name may not be empty.")); + } + + /** + * check if group already exists + */ $data = $GLOBALS['linpha']->db->GetRow("SELECT id FROM ".PREFIX."groups " . "WHERE group_name = '".LinSql::linAddslashes($_POST['group_name'])."'"); if(isset($data['id'])) { - linSysLog(i18n("Error: Group Already Exists")); - $error = 2; + throw new Exception(i18n("A group with the same name already exists.")); } break; } - if(!isset($error)) - { + /** + * update data + */ switch($_POST['cmd']) { case 'ren_group': $GLOBALS['linpha']->db->Execute("UPDATE ".PREFIX."groups " . "SET group_name='".LinSql::linAddslashes($_POST['group_name'])."' " . "WHERE id='".LinSql::linAddslashes($_POST['id'])."'"); - linSysLog("Group Renamed"); + linSysLog(i18n("Group Renamed")); break; case 'del_group': $GLOBALS['linpha']->db->Execute("DELETE FROM ".PREFIX."groups ". "WHERE id='".LinSql::linAddslashes($_POST['id'])."'"); - linSysLog("Group Deleted"); + linSysLog(i18n("Group Deleted")); break; case 'new_group': $GLOBALS['linpha']->db->Execute("INSERT INTO ".PREFIX."groups (group_name) ". "VALUES ('".LinSql::linAddslashes($_POST['group_name'])."')"); - linSysLog("Group Created"); + linSysLog(i18n("Group Created")); break; } } + catch(Exception $error) + { + linSysLog("Error: ".$error -> getMessage()); + } } ?> <table border="1"> @@ -81,7 +91,7 @@ <tr> <form method="POST" action="<?php echo LINPHA_DIR.'/admin/?cat=permissions_groups'; ?>"> <td> - <input style="width: 200;" type="text" name="group_name" value="<?php echo $data['group_name']; ?>" maxsize="255"> + <input style="width: 200;" type="text" name="group_name" value="<?php echo htmlspecialchars($data['group_name'],ENT_QUOTES); ?>" maxsize="255"> </td> <td> Modified: trunk/linpha2/admin/permissions_others.php =================================================================== --- trunk/linpha2/admin/permissions_others.php 2006-08-27 13:44:17 UTC (rev 4560) +++ trunk/linpha2/admin/permissions_others.php 2006-08-27 22:16:12 UTC (rev 4561) @@ -31,7 +31,7 @@ break; } -print_admin_menu($array_menu,$cat3); +LinAdmin::printAdminMenu($array_menu,$cat3); if(!empty($cat3)) { Modified: trunk/linpha2/admin/permissions_readwrite.php =================================================================== --- trunk/linpha2/admin/permissions_readwrite.php 2006-08-27 13:44:17 UTC (rev 4560) +++ trunk/linpha2/admin/permissions_readwrite.php 2006-08-27 22:16:12 UTC (rev 4561) @@ -15,7 +15,7 @@ <?php if(isset($_POST['cmd']) && $_POST['cmd']=='saveconfig') { - saveConfig( + LinAdmin::saveConfig( Array( 'plugins_filemanager_enable' ) @@ -23,7 +23,7 @@ } - printAdminConfig('radio',i18n("Enable Filemanager For Non-Admin Users"),'plugins_filemanager_enable'); + LinAdmin::printAdminConfig('radio',i18n("Enable Filemanager For Non-Admin Users"),'plugins_filemanager_enable'); ?> <input type="hidden" name="cmd" value="saveconfig" /> Modified: trunk/linpha2/admin/permissions_users.php =================================================================== --- trunk/linpha2/admin/permissions_users.php 2006-08-27 13:44:17 UTC (rev 4560) +++ trunk/linpha2/admin/permissions_users.php 2006-08-27 22:16:12 UTC (rev 4561) @@ -3,36 +3,63 @@ /** * save data - * @todo create new user: check if name does not already exists - * @todo rename user: check if name does not already exists - * -> will not be easy - * @todo check if username and password not empty */ if(isset($_POST['cmd'])) { - /** - * @todo use something like htmlspecialchars() ? - */ + try + { + switch($_POST['cmd']) { case 'mod_user': + /** + * check if username is empty + */ + if( empty($_POST['mod_user_name']) ) + { + throw new Exception(i18n("The username may not be empty.")); + } + + /** + * check if username already exists + * (only if it will be changed) + */ + if( $_POST['old_user_name'] != $_POST['mod_user_name'] ) + { + $query = $GLOBALS['linpha']->db->Execute("SELECT username FROM ".PREFIX."users " . + "WHERE username = '".LinSql::linAddslashes($_POST['mod_user_name'])."'"); + if( ! $query->EOF ) + { + throw new Exception(i18n("A user with the same username already exists.")); + } + } + + /** + * check length of new password + * (if strlen() == 0, the password isn't updated at all) + */ + if( strlen($_POST['mod_user_pass'])>0 && strlen($_POST['mod_user_pass'])<3 ) + { + throw new Exception(i18n("Password To Short")); + } + /** * update password * only if it is not empty */ if(empty($_POST['mod_user_pass'])) { - $new_password = ""; + $sql_str_new_password = ""; } else { $md5_pass = md5($_POST['mod_user_pass']); - $new_password = "password='".$md5_pass."', "; + $sql_str_new_password = "password='".$md5_pass."', "; } $GLOBALS['linpha']->db->Execute("UPDATE ".PREFIX."users SET ". "username='".LinSql::linAddslashes($_POST['mod_user_name'])."', ". "display_name='".LinSql::linAddslashes($_POST['mod_user_fullname'])."', ". - $new_password. + $sql_str_new_password. "user_email='".LinSql::linAddslashes($_POST['mod_user_mail'])."' ". "WHERE id='".LinSql::linAddslashes($_POST['id'])."'"); @@ -60,6 +87,33 @@ $GLOBALS['linpha']->db->Execute("DELETE FROM ".PREFIX."users WHERE id='".LinSql::linAddslashes($_POST['id'])."'"); break; case 'new_user': + + /** + * check if username is empty + */ + if( empty($_POST['new_user_name']) ) + { + throw new Exception(i18n("The username may not be empty.")); + } + + /** + * check if username already exists + */ + $query = $GLOBALS['linpha']->db->Execute("SELECT username FROM ".PREFIX."users " . + "WHERE username = '".LinSql::linAddslashes($_POST['new_user_name'])."'"); + if( ! $query->EOF ) + { + throw new Exception(i18n("A user with the same username already exists.")); + } + + /** + * check length of new password + */ + if( strlen($_POST['new_user_pass'])<3 ) + { + throw new Exception(i18n("Password To Short")); + } + $GLOBALS['linpha']->db->Execute("INSERT INTO ".PREFIX."users " . "(username, password, user_email, display_name) ". "VALUES " . @@ -67,16 +121,12 @@ "'".LinSql::linAddslashes($_POST['new_user_mail'])."', '".LinSql::linAddslashes($_POST['new_user_fullname'])."')"); break; } + } + catch(Exception $error) + { + linSysLog("Error: ".$error -> getMessage()); + } } - -/** - * @todo !! - */ -function smart_htmlspecialchars($str) -{ - return $str; -} - ?> <table border="1"> <tr> @@ -97,10 +147,10 @@ <tr> <form name="mod_user" method="POST" action="<?php echo LINPHA_DIR.'/admin/?cat=permissions_users'; ?>"> <td> - <input type="text" name="mod_user_name" size="20" maxlength="255" value="<?php echo smart_htmlspecialchars($data['username'], ENT_QUOTES); ?>"> + <input type="text" name="mod_user_name" size="20" maxlength="255" value="<?php echo htmlspecialchars($data['username'], ENT_QUOTES); ?>"> </td> <td> - <input type="text" name="mod_user_fullname" size="20" maxlength="255" value="<?php echo smart_htmlspecialchars($data['display_name'], ENT_QUOTES); ?>"> + <input type="text" name="mod_user_fullname" size="20" maxlength="255" value="<?php echo htmlspecialchars($data['display_name'], ENT_QUOTES); ?>"> </td> <td> <input type="password" name="mod_user_pass" size="20" maxlength="255"> @@ -110,7 +160,7 @@ </td> <td> <input type="hidden" name="id" value="<?php echo $data['id']; ?>"> - <input type="hidden" name="old_user_name" value="<?php echo smart_htmlspecialchars($data['username'], ENT_QUOTES); ?>"> + <input type="hidden" name="old_user_name" value="<?php echo htmlspecialchars($data['username'], ENT_QUOTES); ?>"> <input type="hidden" name="cmd" value="mod_user"> <input type="submit" value="<?php echo i18n("Modify User"); ?>" style="float: left;"> </form> Modified: trunk/linpha2/admin/settings.php =================================================================== --- trunk/linpha2/admin/settings.php 2006-08-27 13:44:17 UTC (rev 4560) +++ trunk/linpha2/admin/settings.php 2006-08-27 22:16:12 UTC (rev 4561) @@ -13,8 +13,18 @@ 'all' => Array('name' => 'All', 'link' => 'settings_all') ); -print_admin_menu($array_menu,$cat2); +LinAdmin::printAdminMenu($array_menu,$cat2); +/** + * get system option names and values + */ +$query = $GLOBALS['linpha']->db->Execute("SELECT option_name, option_value FROM ".PREFIX."config WHERE user_id = '0' ORDER by option_name"); +while($data = $query->FetchRow()) +{ + $options[] = $data['option_name']; + $option_value_system[$data['option_name']] = $data['option_value']; +} + switch($cat2) { case 'layout': Modified: trunk/linpha2/admin/settings_all.php =================================================================== --- trunk/linpha2/admin/settings_all.php 2006-08-27 13:44:17 UTC (rev 4560) +++ trunk/linpha2/admin/settings_all.php 2006-08-27 22:16:12 UTC (rev 4561) @@ -1,96 +1,31 @@ <?php if(!defined('LINPHA_DIR')) { exit(1); } -$options = array( - 'sys_db_version', - 'sys_im_bracket_support', - 'sys_im_imagemagick_path', - 'sys_im_use_imagemagick', - 'sys_im_video_thumbnail', - - 'sys_import_autoimport', - 'sys_import_exif', - 'sys_import_exif_autorot', - - 'sys_image_exif', - 'sys_image_iptc', - 'sys_image_xmp', - 'sys_lang', - 'sys_lang_autolang', - 'sys_path_album_dir', - 'sys_path_cache_dir', - 'sys_path_tmp_dir', - - 'sys_basket_mail_max_size', - 'sys_basket_download_limit', - - 'sys_style_sortorder', - 'sys_style_template', - 'sys_style_home_showbrowsebydate', - 'sys_style_home_nrrandomimages', - 'sys_style_home_showalbums', - 'sys_style_home_usedefaultwelcometext', - 'sys_style_home_firstsortorder', - 'sys_style_thumb_size_max', - 'sys_style_thumb_size_display', - 'sys_style_thumb_showsubfoldersseparate', - 'sys_style_thumb_selectsizes', - 'sys_style_thumb_selectnrimages', - 'sys_style_thumb_nojsnrrows', - 'sys_style_thumb_nojsnrcols', - 'sys_style_image_quality', - 'sys_style_image_size', - 'sys_style_image_nrprevnextthumbs', - - 'sys_user_autologin' -); - -$radio_options = array( - 'sys_im_bracket_support', - 'sys_im_use_imagemagick', - 'sys_im_video_thumbnail', - 'sys_import_autoimport', - 'sys_import_exif', - 'sys_import_exif_autorot', - 'sys_image_exif', - 'sys_image_iptc', - 'sys_image_xmp', - 'sys_lang_autolang', - 'sys_style_home_showbrowsebydate', - 'sys_style_home_showalbums', - 'sys_style_home_usedefaultwelcometext', - 'sys_style_thumb_showsubfoldersseparate', - 'sys_user_autologin' -); - - echo '<b>'.i18n("This Stuff here is only for advanced Users, don't play around...").'</b>'; ?> <br /><br /> <form method="POST" action="<?php echo LINPHA_DIR.'/admin/?cat=settings_all'; ?>"> <?php +$radio_options = LinAdmin::getRadioOptions(); - - - /** - * save settings - */ - if(isset($_POST['cmd']) && $_POST['cmd']=='saveconfig') - { - saveConfig($options); - } - - foreach($options AS $value) +/** + * save settings + */ + if(isset($_POST['cmd']) && $_POST['cmd']=='saveconfig') { - if(in_array($value,$radio_options)) - { - $type = 'radio'; - } - else - { - $type = 'text'; - } - printAdminConfig($type,$value,$value); + LinAdmin::saveConfig($options); } +foreach($options AS $option_name) +{ + if(in_array($option_name,$radio_options)) + { + $type = 'radio'; + } + else + { + $type = 'text'; + } + LinAdmin::printAdminConfig($type,$option_name,$option_name,$option_value_system[$option_name]); +} ?> \ No newline at end of file Modified: trunk/linpha2/admin/settings_features.php =================================================================== --- trunk/linpha2/admin/settings_features.php 2006-08-27 13:44:17 UTC (rev 4560) +++ trunk/linpha2/admin/settings_features.php 2006-08-27 22:16:12 UTC (rev 4561) @@ -10,7 +10,7 @@ 'others' => Array('name' => 'Others', 'link' => 'settings_features_others') ); -print_admin_menu($array_menu,$cat3); +LinAdmin::printAdminMenu($array_menu,$cat3); ?> <form method="POST" action="<?php echo LINPHA_DIR.'/admin/?cat=settings_features_'.$cat3; ?>"> @@ -24,7 +24,7 @@ */ if(isset($_POST['cmd']) && $_POST['cmd']=='saveconfig') { - saveConfig(Array( + LinAdmin::saveConfig(Array( 'sys_image_exif', 'sys_image_iptc', 'sys_image_xmp' @@ -32,9 +32,9 @@ } - printAdminConfig('radio',i18n("Use EXIF"),'sys_image_exif'); - printAdminConfig('radio',i18n("Use IPTC"),'sys_image_iptc'); - printAdminConfig('radio',i18n("Use XMP"),'sys_image_xmp'); + LinAdmin::printAdminConfig('radio',i18n("Use EXIF"),'sys_image_exif',$option_value_system['sys_image_exif']); + LinAdmin::printAdminConfig('radio',i18n("Use IPTC"),'sys_image_iptc',$option_value_system['sys_image_iptc']); + LinAdmin::printAdminConfig('radio',i18n("Use XMP"),'sys_image_xmp',$option_value_system['sys_image_xmp']); break; } ?> \ No newline at end of file Modified: trunk/linpha2/admin/settings_layout.php =================================================================== --- trunk/linpha2/admin/settings_layout.php 2006-08-27 13:44:17 UTC (rev 4560) +++ trunk/linpha2/admin/settings_layout.php 2006-08-27 22:16:12 UTC (rev 4561) @@ -12,7 +12,7 @@ 'others' => Array('name' => 'Others', 'link' => 'settings_layout_others') ); -print_admin_menu($array_menu,$cat3); +LinAdmin::printAdminMenu($array_menu,$cat3); ?> <form method="POST" action="<?php echo LINPHA_DIR.'/admin/?cat=settings_layout_'.$cat3; ?>"> @@ -34,7 +34,7 @@ */ if(isset($_POST['cmd']) && $_POST['cmd']=='saveconfig') { - saveConfig(Array('sys_style_home_usedefaultwelcometext', + LinAdmin::saveConfig(Array('sys_style_home_usedefaultwelcometext', 'sys_style_home_nrrandomimages', 'sys_style_home_showalbums', 'sys_style_home_firstsortorder', @@ -62,23 +62,23 @@ echo '<b>'.i18n("Welcome Text").'</b><br />'; - printAdminConfig('radio',i18n("Use Default Welcome Text"),'sys_style_home_usedefaultwelcometext'); + LinAdmin::printAdminConfig('radio',i18n("Use Default Welcome Text"),'sys_style_home_usedefaultwelcometext',$option_value_system['sys_style_home_usedefaultwelcometext']); ?> <textarea name="welcometext" rows="10" cols="50"><?php echo htmlspecialchars($welcometxt,ENT_QUOTES); ?></textarea> <br /><br /><br /> <?php - printAdminConfig('text',i18n("Nr Of Random Images (0 to disable)"),'sys_style_home_nrrandomimages'); - printAdminConfig('radio',i18n("Show Browse By Date"),'sys_style_home_showbrowsebydate'); - printAdminConfig('radio',i18n("Show Albums On Home Site"),'sys_style_home_showalbums'); - printAdminConfig('select',i18n("Sort Order Of First Level Albums"),'sys_style_home_firstsortorder',getSortOrders()); + LinAdmin::printAdminConfig('text',i18n("Nr Of Random Images (0 to disable)"),'sys_style_home_nrrandomimages',$option_value_system['sys_style_home_nrrandomimages']); + LinAdmin::printAdminConfig('radio',i18n("Show Browse By Date"),'sys_style_home_showbrowsebydate',$option_value_system['sys_style_home_showbrowsebydate']); + LinAdmin::printAdminConfig('radio',i18n("Show Albums On Home Site"),'sys_style_home_showalbums',$option_value_system['sys_style_home_showalbums']); + LinAdmin::printAdminConfig('select',i18n("Sort Order Of First Level Albums"),'sys_style_home_firstsortorder',$option_value_system['sys_style_home_firstsortorder'],getSortOrders()); break; case 'thumb': - printAdminConfig('radio',i18n("Show Subfolders Separate"),'sys_style_thumb_showsubfoldersseparate'); + LinAdmin::printAdminConfig('radio',i18n("Show Subfolders Separate"),'sys_style_thumb_showsubfoldersseparate',$option_value_system['sys_style_thumb_showsubfoldersseparate']); break; case 'image': - printAdminConfig('text',i18n("Nr Of Previous/Next Thumbnails"),'sys_style_image_nrprevnextthumbs'); + LinAdmin::printAdminConfig('text',i18n("Nr Of Previous/Next Thumbnails"),'sys_style_image_nrprevnextthumbs',$option_value_system['sys_style_image_nrprevnextthumbs']); break; case 'others': Modified: trunk/linpha2/docs/dev/TODO.txt =================================================================== --- trunk/linpha2/docs/dev/TODO.txt 2006-08-27 13:44:17 UTC (rev 4560) +++ trunk/linpha2/docs/dev/TODO.txt 2006-08-27 22:16:12 UTC (rev 4561) @@ -32,9 +32,6 @@ - Plugins (copy from linpha1) -- Admin - - User Settings - - ImageMagick - Bracket Support, enable by default, only if old version found, disable it, or require imagemagick > "6.1.4" Modified: trunk/linpha2/docs/dev/important stuff.txt =================================================================== --- trunk/linpha2/docs/dev/important stuff.txt 2006-08-27 13:44:17 UTC (rev 4560) +++ trunk/linpha2/docs/dev/important stuff.txt 2006-08-27 22:16:12 UTC (rev 4561) @@ -12,4 +12,27 @@ clearstatcache(); $handle = fopen($tmp_file, "rb"); - $file_data = fread($handle, filesize($tmp_file)); \ No newline at end of file + $file_data = fread($handle, filesize($tmp_file)); + +- adodb eof + $query = $GLOBALS['linpha']->db->Execute("SELECT id FROM meta_fields WHERE flags = '7'"); + if( ! $query->EOF ) -> on or more results + if( $query->EOF ) -> no results + +- trycatch + try + { + if(!isset( $_GET['id'] ) ) + { + throw new Exception("no id supplied!"); + } + } + catch(Exception $error) + { + echo "Error: ".$error -> getMessage(); + } + +- some common language strings + "Successfully updated data." + "Submit" + ?? \ No newline at end of file Modified: trunk/linpha2/index.php =================================================================== --- trunk/linpha2/index.php 2006-08-27 13:44:17 UTC (rev 4560) +++ trunk/linpha2/index.php 2006-08-27 22:16:12 UTC (rev 4561) @@ -38,6 +38,9 @@ case 'filemanager': include_once(LINPHA_DIR.'/lib/modules/module.filemanager.php'); break; +case 'settings': + include_once(LINPHA_DIR.'/lib/modules/module.settings.php'); + break; } ?> \ No newline at end of file Modified: trunk/linpha2/install/sql/sql.data.php =================================================================== --- trunk/linpha2/install/sql/sql.data.php 2006-08-27 13:44:17 UTC (rev 4560) +++ trunk/linpha2/install/sql/sql.data.php 2006-08-27 22:16:12 UTC (rev 4561) @@ -72,13 +72,35 @@ 'plugins_filemanager_nruploads' => '5' ); +$options_user_overridable = Array( + 'sys_lang', + 'sys_lang_autolang', + 'sys_style_sortorder', + 'sys_style_template', + 'sys_style_home_showbrowsebydate', + 'sys_style_home_nrrandomimages', + 'sys_style_home_showalbums', + 'sys_style_home_firstsortorder', + 'sys_style_thumb_size_display', + 'sys_style_thumb_showsubfoldersseparate', + 'sys_style_thumb_nojsnrrows', + 'sys_style_thumb_nojsnrcols', + 'sys_style_image_size', + 'sys_style_image_nrprevnextthumbs' +); + /** * create sql executes */ while( list($name, $value) = each($options) ) { - $sql_queries[] = "INSERT INTO ".PREFIX."config (option_name, option_value, user_id) " . - "VALUES ('".$name."', '".$value."', '0')"; + if(in_array($name,$options_user_overridable)) { + $override = 1; + } else { + $override = 0; + } + $sql_queries[] = "INSERT INTO ".PREFIX."config (option_name, option_value, override, user_id) " . + "VALUES ('".$name."', '".$value."', '".$override."', '0')"; } /** Added: trunk/linpha2/lib/classes/linpha.admin.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.admin.class.php (rev 0) +++ trunk/linpha2/lib/classes/linpha.admin.class.php 2006-08-27 22:16:12 UTC (rev 4561) @@ -0,0 +1,262 @@ +<?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. +*/ + +/** + * This class provides functions for edit configs etc. + * @package Admin + */ +class LinAdmin +{ + +function printAdminMenu($array_menu,$active) +{ + ?> + <ul class="navlist"> + <?php + foreach($array_menu AS $key=>$value) + { + if($value['link']=='linpha_home') + { + echo '<li><a href="../">'.i18n($value['name']).'</a></li>'; + } + else + { + if($active==$key) + { + echo '<li class="active"><a href="./?cat='.$value['link'].'" class="current">'.i18n($value['name']).'</a></li>'; + } + else + { + echo '<li><a href="./?cat='.$value['link'].'">'.i18n($value['name']).'</a></li>'; + } + } + } + ?> + </ul> + <?php +} + +function printAdminConfig($type,$text,$id,$value,$options=array()) +{ + ?> + <div style="width: 600px; border: 1px solid black; padding: 5px; margin-bottom: 5px;"> + <div align="left" style="float: left;"> + <?php + switch($type) + { + case 'radio': + if($value) + { + $str_enabled = ' checked="checked"'; + $str_disabled = ''; + } + else + { + $str_enabled = ''; + $str_disabled = ' checked="checked"'; + } + echo $text; + ?> + </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> + <?php + break; + case 'text': + case 'password': + echo $text; + ?> + </div> + <div align="right"> + <input type="<?php echo $type; ?>" name="<?php echo $id; ?>" value="<?php echo htmlspecialchars($value, ENT_QUOTES); ?>" maxlength="255" style="width: 200px;" /> + <?php + + break; + case 'select': + echo $text; + ?> + </div> + <div align="right"> + <select name="<?php echo $id; ?>" size="1"> + <?php + foreach($options AS $key=>$value) + { + if($key == $value) + { + $selected = ' selected="selected"'; + } + else + { + $selected = ''; + } + echo '<option value="'.$key.'"'.$selected.'>'.$value.'</option>'; + } + ?> + </select> + <?php + break; + } + ?> + </div> + </div> + <?php +} + +function saveConfig($array,$userid=0) +{ + foreach($array AS $value) + { + /** + * does this config name exists? + */ + if(isset($GLOBALS['linpha']->sql->config->value[$value]) && + isset($_POST[$value])) + { + $GLOBALS['linpha']->sql->config->updateConfig($value,$_POST[$value],$userid); + } + } + + /** + * update config array + */ + $GLOBALS['linpha']->sql->config->reloadConfig(); + + /** + * update system config array, used in admin/settings*.php + */ + if(isset($GLOBALS['option_value_system'])) + { + + $query = $GLOBALS['linpha']->db->Execute("SELECT option_name, option_value FROM ".PREFIX."config WHERE user_id = '0' ORDER by option_name"); + while($data = $query->FetchRow()) + { + $GLOBALS['option_value_system'][$data['option_name']] = $data['option_value']; + } + } +} + +/** + * thanks to http://www.ilovejackdaniels.com/php/email-address-validation/ + */ +function checkValidEmailAddress($email) +{ + // First, we check that there's one @ symbol, and that the lengths are right + if (!ereg("^[^@]{1,64}@[^@]{1,255}$", $email)) { + // Email invalid because wrong number of characters in one section, or wrong number of @ symbols. + return false; + } + // Split it into sections to make life easier + $email_array = explode("@", $email); + $local_array = explode(".", $email_array[0]); + for ($i = 0; $i < sizeof($local_array); $i++) { + if (!ereg("^(([A-Za-z0-9!#$%&'*+/=?^_`{|}~-][A-Za-z0-9!#$%&'*+/=?^_`{|}~\.-]{0,63})|(\"[^(\\|\")]{0,62}\"))$", $local_array[$i])) { + return false; + } + } + if (!ereg("^\[?[0-9\.]+\]?$", $email_array[1])) { // Check if domain is IP. If not, it should be valid domain name + $domain_array = explode(".", $email_array[1]); + if (sizeof($domain_array) < 2) { + return false; // Not enough parts to domain + } + for ($i = 0; $i < sizeof($domain_array); $i++) { + if (!ereg("^(([A-Za-z0-9][A-Za-z0-9-]{0,61}[A-Za-z0-9])|([A-Za-z0-9]+))$", $domain_array[$i])) { + return false; + } + } + } + return true; +} + +/*function getOptions() +{ + return array( + 'sys_db_version', + 'sys_im_bracket_support', + 'sys_im_imagemagick_path', + 'sys_im_use_imagemagick', + 'sys_im_video_thumbnail', + + 'sys_import_autoimport', + 'sys_import_exif', + 'sys_import_exif_autorot', + + 'sys_image_exif', + 'sys_image_iptc', + 'sys_image_xmp', + 'sys_lang', + 'sys_lang_autolang', + 'sys_path_album_dir', + 'sys_path_cache_dir', + 'sys_path_tmp_dir', + + 'sys_basket_mail_max_size', + 'sys_basket_download_limit', + + 'sys_style_sortorder', + 'sys_style_template', + 'sys_style_home_showbrowsebydate', + 'sys_style_home_nrrandomimages', + 'sys_style_home_showalbums', + 'sys_style_home_usedefaultwelcometext', + 'sys_style_home_firstsortorder', + 'sys_style_thumb_size_max', + 'sys_style_thumb_size_display', + 'sys_style_thumb_showsubfoldersseparate', + 'sys_style_thumb_selectsizes', + 'sys_style_thumb_selectnrimages', + 'sys_style_thumb_nojsnrrows', + 'sys_style_thumb_nojsnrcols', + 'sys_style_image_quality', + 'sys_style_image_size', + 'sys_style_image_nrprevnextthumbs', + + 'sys_user_autologin' + ); +}*/ + +/** + * a list of all settings which are enable/disable + * to show radio buttons instead of text field + */ +function getRadioOptions() +{ + return array( + 'sys_im_bracket_support', + 'sys_im_use_imagemagick', + 'sys_im_video_thumbnail', + 'sys_import_autoimport', + 'sys_import_exif', + 'sys_import_exif_autorot', + 'sys_image_exif', + 'sys_image_iptc', + 'sys_image_xmp', + 'sys_lang_autolang', + 'sys_style_home_showbrowsebydate', + 'sys_style_home_showalbums', + 'sys_style_home_usedefaultwelcometext', + 'sys_style_thumb_showsubfoldersseparate', + 'sys_user_autologin' + ); +} + +} // end class LinAdmin + +?> \ No newline at end of file Modified: trunk/linpha2/lib/classes/linpha.sql.class.php =================================================================== --- trunk/linpha2/lib/classes/linpha.sql.class.php 2006-08-27 13:44:17 UTC (rev 4560) +++ trunk/linpha2/lib/classes/linpha.sql.class.php 2006-08-27 22:16:12 UTC (rev 4561) @@ -337,6 +337,19 @@ { $_SESSION['basket_ids'] = Array(); } + + /** + * apply user overridden config values + * this has also to be here because the session isn't started yet in reloadConfig() + * but also has to be in reloadConfig() if it will be called during the script + */ + $query = $GLOBALS['linpha']->db->Execute("SELECT option_name, option_value " . + "FROM ".PREFIX."config WHERE user_id = '".$_SESSION['user_id']."'"); + + while($data = $query->FetchRow(ADODB_FETCH_NUM)) + { + $GLOBALS['linpha']->sql->config->value[$data['0']] = $data['1']; + } } // end function startSession /** @@ -364,6 +377,7 @@ { $_SESSION['user_groups'][] = $data['group_id']; } + } @@ -698,17 +712,39 @@ $this->reloadConfig(); } +/** + * (re-)load config from db to array + * the overriden user configs will be load in startSession() + */ function reloadConfig() { unset($this->value); + /** + * load system values + */ $query = $GLOBALS['linpha']->db->Execute("SELECT option_name, option_value " . - "FROM ".PREFIX."config"); - + "FROM ".PREFIX."config WHERE user_id = '0'"); while($data = $query->FetchRow(ADODB_FETCH_NUM)) { $this->value[$data['0']] = $data['1']; - } + } + + /** + * apply user overridden config values + * this has also to be in startSession() because the session isn't started yet in reloadConfig() + * but also has to be in reloadConfig() if it will be called during the script + */ + if(isset($_SESSION['user_id']) && !empty($_SESSION['user_id'])) + { + $query = $GLOBALS['linpha']->db->Execute("SELECT option_name, option_value " . + "FROM ".PREFIX."config WHERE user_id = '".$_SESSION['user_id']."'"); + + while($data = $query->FetchRow(ADODB_FETCH_NUM)) + { + $GLOBALS['linpha']->sql->config->value[$data['0']] = $data['1']; + } + } } function writeConfig($option_name,$option_value) @@ -719,12 +755,53 @@ ")"); } -function updateConfig($option_name,$option_value) +function updateConfig($option_name,$option_value,$user_id=0) { - $GLOBALS['linpha']->db->Execute("UPDATE ".PREFIX."config SET option_value = ". - "'".linSql::linAddslashes($option_value)."'". - "WHERE option_name = ". - "'".linSql::linAddslashes($option_name)."'"); + if($user_id == 0) + { + $GLOBALS['linpha']->db->Execute("UPDATE ".PREFIX."config SET option_value = ". + "'".LinSql::linAddslashes($option_value)."'". + "WHERE option_name = '".LinSql::linAddslashes($option_name)."' " . + "AND user_id = '0'"); + } + else + { + /** + * if the value is the same like the system value, delete it + */ + $data = $GLOBALS['linpha']->db->GetRow("SELECT option_value FROM ".PREFIX."config " . + "WHERE option_name = '".LinSql::linAddslashes($option_name)."' AND user_id = '0'"); + if($option_value == $data['option_value']) + { + $GLOBALS['linpha']->db->Execute("DELETE FROM ".PREFIX."config " . + "WHERE option_name = '".LinSql::linAddslashes($option_name)."' " . + "AND user_id = '".$user_id."'"); + } + else + { + /** + * insert or update? + */ + $query = $GLOBALS['linpha']->db->Execute("SELECT id FROM ".PREFIX."config " . + "WHERE option_name = '".$option_name."' AND user_id = '".$user_id."'"); + if( ! $query->EOF ) // update + { + $GLOBALS['linpha']->db->Execute("UPDATE ".PREFIX."config SET option_value = ". + "'".LinSql::linAddslashes($option_value)."'". + "WHERE option_name = '".LinSql::linAddslashes($option_name)."' " . + "AND user_id = '".$user_id."'"); + } + else // insert + { + $GLOBALS['linpha']->db->Execute("INSERT into ".PREFIX."config " . + "(option_name, option_value, user_id) " . + "VALUES ('".LinSql::linAddslashes($option_name)."', " . + "'".LinSql::linAddslashes($option_value)."', " . + "'".$user_id."')"); + + } + } + } } } // end sub-class linSqlConfig Modified: trunk/linpha2/lib/modules/module.filemanager.php =================================================================== --- trunk/linpha2/lib/modules/module.filemanager.php 2006-08-27 13:44:17 UTC (rev 4560) +++ trunk/linpha2/lib/modules/module.filemanager.php 2006-08-27 22:16:12 UTC (rev 4561) @@ -937,7 +937,6 @@ $linpha->template->URL_full = LINPHA_DIR.'/?cat=filemanager&id='.$parent_id; $linpha->template->output['title'] = i18n("Filemanager"); include_once(LINPHA_DIR.'/templates/'.$linpha->template->template_name.'/global.html.php'); -exit(); ?> Added: trunk/linpha2/lib/modules/module.settings.php =================================================================== --- trunk/linpha2/lib/modules/module.settings.php (rev 0) +++ trunk/linpha2/lib/modules/module.settings.php 2006-08-27 22:16:12 UTC (rev 4561) @@ -0,0 +1,254 @@ +<?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. + */ + +/** + * Settings + * @package Modules + */ + +if(!defined('LINPHA_DIR')) { exit(1); } + +include_once(LINPHA_DIR.'/lib/classes/linpha.admin.class.php'); + +/** + * check permissions + */ + if( ! $GLOBALS['linpha']->sql->isLoggedIn()) + { + echo i18n("No Access!"); + exit(); + } + +/** + * get user data + */ + $data = $GLOBALS['linpha']->db->GetRow("SELECT username, password, display_name, user_email ". + "FROM ".PREFIX."users ". + "WHERE id = '".$_SESSION['user_id']."'"); + +/** + * get user settings + */ + $options = Array(); + $query = $GLOBALS['linpha']->db->Execute("SELECT option_name FROM ".PREFIX."config WHERE override = 1 ORDER by option_name"); + while($data = $query->FetchRow()) + { + $options[] = $data['option_name']; + } + $radio_options = LinAdmin::getRadioOptions(); + +/** + * output buffering, to use in template + */ +ob_start(); + +/** + * parse POST data + */ +if(isset($_POST['cmd'])) +{ + try + { + switch($_POST['cmd']) + { + case 'saveuserinfos': + + /** + * check if username is empty + */ + if( empty($_POST['username']) ) + { + throw new Exception(i18n("The username may not be empty.")); + } + + /** + * check if username already exists + * (only if it will be changed) + */ + if( $data['username'] != $_POST['username'] ) + { + $query = $GLOBALS['linpha']->db->Execute("SELECT username FROM ".PREFIX."users " . + "WHERE username = '".LinSql::linAddslashes($_POST['username'])."'"); + if( ! $query->EOF ) + { + throw new Exception(i18n("A user with the same username already exists.")); + } + } + + /** + * check if it is a valid email + */ + if( ! LinAdmin::checkValidEmailAddress($_POST['user_email']) ) + { + throw new Exception(i18n("This is not a valid email address.")); + } + + /** + * update data in db + */ + $GLOBALS['linpha']->db->Execute("UPDATE ".PREFIX."users SET " . + "username = '".LinSql::linAddslashes($_POST['username'])."', " . + "user_email = '".LinSql::linAddslashes($_POST['user_email'])."', " . + "display_name = '".LinSql::linAddslashes($_POST['display_name'])."' " . + "WHERE id = '".$_SESSION['user_id']."'"); + + /** + * update data also for show in html form + */ + $data['username'] = $_POST['username']; + $data['user_email'] = $_POST['user_email']; + $data['display_name'] = $_POST['display_name']; + + /** + * update session variables + */ + $_SESSION['user_name'] = $_POST['username']; + $_SESSION['user_displayname'] = (empty($_POST['display_name'])) ? $_POST['username'] : $_POST['display_name']; //Store user fullname. If fullname is blank - store username. + + + linSysLog(i18n("Successfully updated data.")); + + break; + case 'changepw': + /** + * check if old password is correct + */ + if( md5($_POST['old_password']) != $data['password'] ) + { + throw new Exception(i18n("Old password is not correct.")); + } + + /** + * check length of new password + */ + if( strlen($_POST['new_password'])<3 ) + { + throw new Exception(i18n("Password To Short")); + } + + /** + * check correct repeating passwords + */ + if( $_POST['new_password'] != $_POST['new_password2'] ) + { + throw new Exception(i18n("New password doesn't match with retyped password")); + } + + /** + * update password + */ + $GLOBALS['linpha']->db->Execute("UPDATE ".PREFIX."users SET " . + "password = '".md5($_POST['new_password'])."' WHERE id = '".$_SESSION['user_id']."'"); + + linSysLog(i18n("Password successfully updated.")); + + break; + case 'saveconfig': + /** + * save and reload config + */ + LinAdmin::saveConfig($options,$_SESSION['user_id']); + linSysLog(i18n("Successfully updated data.")); + break; + case 'loaddefault': + $GLOBALS['linpha']->db->Execute("DELETE FROM ".PREFIX."config " . + "WHERE user_id = '".$_SESSION['user_id']."'"); + $GLOBALS['linpha']->sql->config->reloadConfig(); + linSysLog(i18n("Successfully updated data.")); + break; + } + + } + catch(Exception $error) + { + linSysLog("Error: ".$error -> getMessage()); + } +} + +?> +<h2><?php echo i18n("Change User Information"); ?></h2> +<form method="POST" action="./?cat=settings"> +<?php +LinAdmin::printAdminConfig('text',i18n("Username"),'username',$data['username']); +LinAdmin::printAdminConfig('text',i18n("Display Name"),'display_name',$data['display_name']); +LinAdmin::printAdminConfig('text',i18n("Email"),'user_email',$data['user_email']); +?> +<input type="hidden" name="cmd" value="saveuserinfos" /> +<input type="submit" name="submit" value="<?php echo i18n("Submit"); ?>" class="button" /> +</form> +<hr /> + +<h2><?php echo i18n("Change Password"); ?></h2> +<form method="POST" name="change_password" action="./?cat=settings"> +<?php +LinAdmin::printAdminConfig('password',i18n("Old Password"),'old_password',''); +LinAdmin::printAdminConfig('password',i18n("New Password"),'new_password',''); +LinAdmin::printAdminConfig('password',i18n("Repeat New Password"),'new_password2',''); +?> +<input type="hidden" name="cmd" value="changepw" /> +<input type="submit" name="submit" value="<?php echo i18n("Submit"); ?>" class="button" onclick="return checkPassLength();" /> +</form> +<script language="JavaScript" type="text/javascript"> +function checkPassLength() +{ + if(document.change_password.new_password.value.length <3 ) + { + alert ('<?php echo i18n("Password To Short"); ?>'); + document.change_password.new_password.focus(); + return false; + } +} +</script> +<hr /> + +<h2><?php echo i18n("Change User Settings"); ?></h2> +<form method="POST" action="./?cat=settings"> +<?php +foreach($options AS $value) +{ + if(in_array($value,$radio_options)) + { + $type = 'radio'; + } + else + { + $type = 'text'; + } + LinAdmin::printAdminConfig($type,$value,$value,$GLOBALS['linpha']->sql->config->value[$value]); +} +?> +<input type="hidden" name="cmd" value="saveconfig" /> +<input type="submit" name="submit" value="<?php echo i18n("Submit"); ?>" class="button" /> +</form> + +<form method="POST" action="./?cat=settings"> +<input type="hidden" name="cmd" value="loaddefault" /> +<input type="submit" name="submit" value="<?php echo i18n("Load default values"); ?>" class="button" /> +</form> +<hr /> + +<?php +$linpha->template->output['settings'] = ob_get_clean(); + +$linpha->template->setModuleName('settings'); +$linpha->template->URL_full = LINPHA_DIR.'/?cat=settings'; +$linpha->template->output['title'] = i18n("Settings"); +include_once(LINPHA_DIR.'/templates/'.$linpha->template->template_name.'/global.html.php'); +?> \ No newline at end of file Modified: trunk/linpha2/linpha2.specs.txt =================================================================== --- trunk/linpha2/linpha2.specs.txt 2006-08-27 13:44:17 UTC (rev 4560) +++ trunk/linpha2/linpha2.specs.txt 2006-08-27 22:16:12 UTC (rev 4561) @@ -43,13 +43,13 @@ - all own methods get a "lin" prefix, class names start Uppercase - would be nice if we can define some coding format - wether to use single or doulbe quotes in html attributes (maybe..) - - which function to use to eoncode html data + - which function to use to encode html data all php output where quotes and other signs may break the html design (except ids and md5sums) needs to be encoded which function to use? - urlencode() -> doesn't work in <a href="" title="<?php echo $title; ?>"> - rawurlencode() - - htmlspecialchars() + - htmlspecialchars() -> will use this: htmlspecialchars($str, ENT_QUOTES) - htmlentities() - smart_htmlspecialchars() from phpmeta used several times in forms in linpha1 ? Modified: trunk/linpha2/templates/default/global.html.php =================================================================== --- trunk/linpha2/templates/default/global.html.php 2006-08-27 13:44:17 UTC (rev 4560) +++ trunk/linpha2/templates/default/global.html.php 2006-08-27 22:16:12 UTC (rev 4561) @@ -129,7 +129,7 @@ <a href="<?php echo $GLOBALS['linpha']->template->URL_full; ?>&slideshow=play"><img src="<?php echo LINPHA_DIR.'/templates/'.$GLOBALS['linpha']->template->template_name.'/images/slideshow.png'; ?>" border="0" title="<?php echo i18n("Play Slideshow"); ?>" /></a> </div> <ul> - <li><a href="./admin/"><?php echo i18n("My Settings"); ?></a></li> + <li><a href="./?cat=settings"><?php echo i18n("My Settings"); ?></a></li> </ul> <?php $GLOBALS['linpha']->template->printMenu("Admin","./admin/"); ?> </div> Added: trunk/linpha2/templates/default/settings.html.php =================================================================== --- trunk/linpha2/templates/default/settings.html.php (rev 0) +++ trunk/linpha2/templates/default/settings.html.php 2006-08-27 22:16:12 UTC (rev 4561) @@ -0,0 +1,19 @@ +<div id="divmain"> + <div class="roundtop"> + <img src="<?php echo LINPHA_DIR.'/templates/'.$GLOBALS['linpha']->template->template_name.'/images/tl.gif'; ?>" alt="" width="15" height="15" class="corner" style="display: none" /> + </div> + + <div id="main"> + + +<?php +echo $GLOBALS['linpha']->template->output['settings']; +?> + + + </div> + + <div class="roundbottom"> + <img src="<?php echo LINPHA_DIR.'/templates/'.$GLOBALS['linpha']->template->template_name.'/images/bl.gif'; ?>" alt="" width="15" height="15" class="corner" style="display: none" /> + </div> +</div> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |